Loading Android.bp +4 −1 Original line number Diff line number Diff line Loading @@ -214,7 +214,10 @@ android_library { defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"], static_libs: ["NetworkStackApiStableLib"], manifest: "AndroidManifestBase.xml", visibility: ["//frameworks/base/tests/net/integration"], visibility: [ "//frameworks/base/tests/net/integration", "//cts/tests/tests/net", ], } cc_library_shared { Loading apishim/30/com/android/networkstack/apishim/api30/ConstantsShim.java +5 −0 Original line number Diff line number Diff line Loading @@ -37,4 +37,9 @@ public class ConstantsShim extends com.android.networkstack.apishim.api29.Consta DataStallReport.DETECTION_METHOD_DNS_EVENTS; public static final int DETECTION_METHOD_TCP_METRICS = DataStallReport.DETECTION_METHOD_TCP_METRICS; /** * @see android.net.NetworkCapabilities */ public static final int TRANSPORT_TEST = 7; } apishim/31/com/android/networkstack/apishim/ConstantsShim.java +4 −0 Original line number Diff line number Diff line Loading @@ -30,4 +30,8 @@ public class ConstantsShim extends com.android.networkstack.apishim.api30.Consta */ @VisibleForTesting public static final int VERSION = 31; // When removing this shim, the version in NetworkMonitorUtils should be removed too. // TODO: add TRANSPORT_TEST to system API in API 31 (it is only a test API as of R) public static final int TRANSPORT_TEST = 7; } common/moduleutils/src/android/net/shared/NetworkMonitorUtils.java +35 −3 Original line number Diff line number Diff line Loading @@ -20,11 +20,21 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VPN; import static android.net.NetworkCapabilities.NET_CAPABILITY_TRUSTED; import static android.net.NetworkCapabilities.TRANSPORT_BLUETOOTH; import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR; import static android.net.NetworkCapabilities.TRANSPORT_ETHERNET; import static android.net.NetworkCapabilities.TRANSPORT_WIFI; import android.net.NetworkCapabilities; /** @hide */ public class NetworkMonitorUtils { // This class is used by both NetworkMonitor and ConnectivityService, so it cannot use // NetworkStack shims, but at the same time cannot use non-system APIs. // TRANSPORT_TEST is test API as of R (so it is enforced to always be 7 and can't be changed), // and it is being added as a system API in S. // TODO: use NetworkCapabilities.TRANSPORT_TEST once NetworkStack builds against API 31. private static final int TRANSPORT_TEST = 7; // Network conditions broadcast constants public static final String ACTION_NETWORK_CONDITIONS_MEASURED = Loading @@ -47,11 +57,33 @@ public class NetworkMonitorUtils { * @param nc Network capabilities of the network to test. */ public static boolean isPrivateDnsValidationRequired(NetworkCapabilities nc) { if (nc == null) return false; // TODO: Consider requiring validation for DUN networks. return nc != null && nc.hasCapability(NET_CAPABILITY_INTERNET) if (nc.hasCapability(NET_CAPABILITY_INTERNET) && nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED) && nc.hasCapability(NET_CAPABILITY_TRUSTED); && nc.hasCapability(NET_CAPABILITY_TRUSTED)) { // Real networks return true; } // TODO: once TRANSPORT_TEST is @SystemApi in S and S SDK is stable (so constant shims can // be replaced with the SDK constant that will be inlined), replace isTestNetwork with // hasTransport(TRANSPORT_TEST) // Test networks that also have one of the major transport types are attempting to replicate // that transport on a test interface (for example, test ethernet networks with // EthernetManager#setIncludeTestInterfaces). Run validation on them for realistic tests. // See also comments on EthernetManager#setIncludeTestInterfaces and on TestNetworkManager. if (nc.hasTransport(TRANSPORT_TEST) && nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED) && ( nc.hasTransport(TRANSPORT_WIFI) || nc.hasTransport(TRANSPORT_CELLULAR) || nc.hasTransport(TRANSPORT_BLUETOOTH) || nc.hasTransport(TRANSPORT_ETHERNET))) { return true; } return false; } /** Loading common/networkstackclient/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ aidl_interface { "4", "5", "6", "7", ], visibility: [ "//system/tools/aidl/build", Loading Loading
Android.bp +4 −1 Original line number Diff line number Diff line Loading @@ -214,7 +214,10 @@ android_library { defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"], static_libs: ["NetworkStackApiStableLib"], manifest: "AndroidManifestBase.xml", visibility: ["//frameworks/base/tests/net/integration"], visibility: [ "//frameworks/base/tests/net/integration", "//cts/tests/tests/net", ], } cc_library_shared { Loading
apishim/30/com/android/networkstack/apishim/api30/ConstantsShim.java +5 −0 Original line number Diff line number Diff line Loading @@ -37,4 +37,9 @@ public class ConstantsShim extends com.android.networkstack.apishim.api29.Consta DataStallReport.DETECTION_METHOD_DNS_EVENTS; public static final int DETECTION_METHOD_TCP_METRICS = DataStallReport.DETECTION_METHOD_TCP_METRICS; /** * @see android.net.NetworkCapabilities */ public static final int TRANSPORT_TEST = 7; }
apishim/31/com/android/networkstack/apishim/ConstantsShim.java +4 −0 Original line number Diff line number Diff line Loading @@ -30,4 +30,8 @@ public class ConstantsShim extends com.android.networkstack.apishim.api30.Consta */ @VisibleForTesting public static final int VERSION = 31; // When removing this shim, the version in NetworkMonitorUtils should be removed too. // TODO: add TRANSPORT_TEST to system API in API 31 (it is only a test API as of R) public static final int TRANSPORT_TEST = 7; }
common/moduleutils/src/android/net/shared/NetworkMonitorUtils.java +35 −3 Original line number Diff line number Diff line Loading @@ -20,11 +20,21 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED; import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VPN; import static android.net.NetworkCapabilities.NET_CAPABILITY_TRUSTED; import static android.net.NetworkCapabilities.TRANSPORT_BLUETOOTH; import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR; import static android.net.NetworkCapabilities.TRANSPORT_ETHERNET; import static android.net.NetworkCapabilities.TRANSPORT_WIFI; import android.net.NetworkCapabilities; /** @hide */ public class NetworkMonitorUtils { // This class is used by both NetworkMonitor and ConnectivityService, so it cannot use // NetworkStack shims, but at the same time cannot use non-system APIs. // TRANSPORT_TEST is test API as of R (so it is enforced to always be 7 and can't be changed), // and it is being added as a system API in S. // TODO: use NetworkCapabilities.TRANSPORT_TEST once NetworkStack builds against API 31. private static final int TRANSPORT_TEST = 7; // Network conditions broadcast constants public static final String ACTION_NETWORK_CONDITIONS_MEASURED = Loading @@ -47,11 +57,33 @@ public class NetworkMonitorUtils { * @param nc Network capabilities of the network to test. */ public static boolean isPrivateDnsValidationRequired(NetworkCapabilities nc) { if (nc == null) return false; // TODO: Consider requiring validation for DUN networks. return nc != null && nc.hasCapability(NET_CAPABILITY_INTERNET) if (nc.hasCapability(NET_CAPABILITY_INTERNET) && nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED) && nc.hasCapability(NET_CAPABILITY_TRUSTED); && nc.hasCapability(NET_CAPABILITY_TRUSTED)) { // Real networks return true; } // TODO: once TRANSPORT_TEST is @SystemApi in S and S SDK is stable (so constant shims can // be replaced with the SDK constant that will be inlined), replace isTestNetwork with // hasTransport(TRANSPORT_TEST) // Test networks that also have one of the major transport types are attempting to replicate // that transport on a test interface (for example, test ethernet networks with // EthernetManager#setIncludeTestInterfaces). Run validation on them for realistic tests. // See also comments on EthernetManager#setIncludeTestInterfaces and on TestNetworkManager. if (nc.hasTransport(TRANSPORT_TEST) && nc.hasCapability(NET_CAPABILITY_NOT_RESTRICTED) && ( nc.hasTransport(TRANSPORT_WIFI) || nc.hasTransport(TRANSPORT_CELLULAR) || nc.hasTransport(TRANSPORT_BLUETOOTH) || nc.hasTransport(TRANSPORT_ETHERNET))) { return true; } return false; } /** Loading
common/networkstackclient/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ aidl_interface { "4", "5", "6", "7", ], visibility: [ "//system/tools/aidl/build", Loading