Skip TestDropPacketToVpnAddress if the feature is disabled

INGRESS_TO_VPN_ADDRESS_FILTERING is disabled due to b/352424251 and
testDropPacketToVpnAddress fails if the feature is disabled.
So skip testDropPacketToVpnAddress if the feature is disabled.

Bug: 362434644
Test: adb shell device_config put tethering
      ingress_to_vpn_address_filtering -1
Test: atest CtsHostsideNetworkTests

Change-Id: Ib16a7550dcf93dd9ecf29047b1c4f101ff6d610d
This commit is contained in:
Motomu Utsumi 2024-08-27 20:00:24 +09:00
commit 9d5d7d0779

View file

@ -6734,4 +6734,33 @@ public class ConnectivityManager {
throw e.rethrowFromSystemServer();
}
}
/**
* Get the specified ConnectivityService feature status. This method is for test code to check
* whether the feature is enabled or not.
* Note that tests can not just read DeviceConfig since ConnectivityService reads flag at
* startup. For example, it's possible that the current flag value is "disable"(-1) but the
* feature is enabled since the flag value was "enable"(1) when ConnectivityService started up.
* If the ConnectivityManager needs to check the ConnectivityService feature status for non-test
* purpose, define feature in {@link ConnectivityManagerFeature} and use
* {@link #isFeatureEnabled} instead.
*
* @param featureFlag target flag for feature
* @return {@code true} if the feature is enabled, {@code false} if the feature is disabled.
* @throws IllegalArgumentException if the flag is invalid
*
* @hide
*/
@RequiresPermission(anyOf = {
android.Manifest.permission.NETWORK_SETTINGS,
android.Manifest.permission.NETWORK_STACK,
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK
})
public boolean isConnectivityServiceFeatureEnabledForTesting(final String featureFlag) {
try {
return mService.isConnectivityServiceFeatureEnabledForTesting(featureFlag);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
}