Loading core/java/android/net/ConnectivityDiagnosticsManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -136,7 +136,7 @@ public class ConnectivityDiagnosticsManager { * {@link #NETWORK_VALIDATION_RESULT_PARTIALLY_VALID}, * {@link #NETWORK_VALIDATION_RESULT_SKIPPED}. * * @see android.net.NetworkCapabilities#CAPABILITY_VALIDATED * @see android.net.NetworkCapabilities#NET_CAPABILITY_VALIDATED */ @NetworkValidationResult public static final String KEY_NETWORK_VALIDATION_RESULT = "networkValidationResult"; Loading core/java/android/net/ITestNetworkManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ interface ITestNetworkManager TestNetworkInterface createTapInterface(); void setupTestNetwork(in String iface, in LinkProperties lp, in boolean isMetered, in IBinder binder); in int[] administratorUids, in IBinder binder); void teardownTestNetwork(int netId); } core/java/android/net/TestNetworkManager.java +30 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.net; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.TestApi; import android.os.IBinder; import android.os.RemoteException; Loading Loading @@ -53,6 +54,19 @@ public class TestNetworkManager { } } private void setupTestNetwork( @NonNull String iface, @Nullable LinkProperties lp, boolean isMetered, @NonNull int[] administratorUids, @NonNull IBinder binder) { try { mService.setupTestNetwork(iface, lp, isMetered, administratorUids, binder); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Sets up a capability-limited, testing-only network for a given interface * Loading @@ -66,11 +80,7 @@ public class TestNetworkManager { public void setupTestNetwork( @NonNull LinkProperties lp, boolean isMetered, @NonNull IBinder binder) { Preconditions.checkNotNull(lp, "Invalid LinkProperties"); try { mService.setupTestNetwork(lp.getInterfaceName(), lp, isMetered, binder); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } setupTestNetwork(lp.getInterfaceName(), lp, isMetered, new int[0], binder); } /** Loading @@ -82,11 +92,21 @@ public class TestNetworkManager { */ @TestApi public void setupTestNetwork(@NonNull String iface, @NonNull IBinder binder) { try { mService.setupTestNetwork(iface, null, true, binder); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); setupTestNetwork(iface, null, true, new int[0], binder); } /** * Sets up a capability-limited, testing-only network for a given interface with the given * administrator UIDs. * * @param iface the name of the interface to be used for the Network LinkProperties. * @param administratorUids The administrator UIDs to be used for the test-only network * @param binder A binder object guarding the lifecycle of this test network. * @hide */ public void setupTestNetwork( @NonNull String iface, @NonNull int[] administratorUids, @NonNull IBinder binder) { setupTestNetwork(iface, null, true, administratorUids, binder); } /** Loading services/core/java/com/android/server/TestNetworkService.java +13 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import java.net.InterfaceAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; Loading Loading @@ -230,6 +231,7 @@ class TestNetworkService extends ITestNetworkManager.Stub { @Nullable LinkProperties lp, boolean isMetered, int callingUid, @NonNull int[] administratorUids, @NonNull IBinder binder) throws RemoteException, SocketException { Objects.requireNonNull(looper, "missing Looper"); Loading @@ -248,6 +250,7 @@ class TestNetworkService extends ITestNetworkManager.Stub { nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED); nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED); nc.setNetworkSpecifier(new StringNetworkSpecifier(iface)); nc.setAdministratorUids(intArrayToList(administratorUids)); if (!isMetered) { nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED); } Loading Loading @@ -290,6 +293,14 @@ class TestNetworkService extends ITestNetworkManager.Stub { return new TestNetworkAgent(looper, context, ni, nc, lp, callingUid, binder); } private List<Integer> intArrayToList(@NonNull int[] array) { final List<Integer> list = new ArrayList<>(array.length); for (final int i : array) { list.add(i); } return list; } /** * Sets up a Network with extremely limited privileges, guarded by the MANAGE_TEST_NETWORKS * permission. Loading @@ -301,6 +312,7 @@ class TestNetworkService extends ITestNetworkManager.Stub { @NonNull String iface, @Nullable LinkProperties lp, boolean isMetered, @NonNull int[] administratorUids, @NonNull IBinder binder) { enforceTestNetworkPermissions(mContext); Loading Loading @@ -335,6 +347,7 @@ class TestNetworkService extends ITestNetworkManager.Stub { lp, isMetered, callingUid, administratorUids, binder); mTestNetworkTracker.put(agent.getNetwork().netId, agent); Loading Loading
core/java/android/net/ConnectivityDiagnosticsManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -136,7 +136,7 @@ public class ConnectivityDiagnosticsManager { * {@link #NETWORK_VALIDATION_RESULT_PARTIALLY_VALID}, * {@link #NETWORK_VALIDATION_RESULT_SKIPPED}. * * @see android.net.NetworkCapabilities#CAPABILITY_VALIDATED * @see android.net.NetworkCapabilities#NET_CAPABILITY_VALIDATED */ @NetworkValidationResult public static final String KEY_NETWORK_VALIDATION_RESULT = "networkValidationResult"; Loading
core/java/android/net/ITestNetworkManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ interface ITestNetworkManager TestNetworkInterface createTapInterface(); void setupTestNetwork(in String iface, in LinkProperties lp, in boolean isMetered, in IBinder binder); in int[] administratorUids, in IBinder binder); void teardownTestNetwork(int netId); }
core/java/android/net/TestNetworkManager.java +30 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.net; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.TestApi; import android.os.IBinder; import android.os.RemoteException; Loading Loading @@ -53,6 +54,19 @@ public class TestNetworkManager { } } private void setupTestNetwork( @NonNull String iface, @Nullable LinkProperties lp, boolean isMetered, @NonNull int[] administratorUids, @NonNull IBinder binder) { try { mService.setupTestNetwork(iface, lp, isMetered, administratorUids, binder); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Sets up a capability-limited, testing-only network for a given interface * Loading @@ -66,11 +80,7 @@ public class TestNetworkManager { public void setupTestNetwork( @NonNull LinkProperties lp, boolean isMetered, @NonNull IBinder binder) { Preconditions.checkNotNull(lp, "Invalid LinkProperties"); try { mService.setupTestNetwork(lp.getInterfaceName(), lp, isMetered, binder); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } setupTestNetwork(lp.getInterfaceName(), lp, isMetered, new int[0], binder); } /** Loading @@ -82,11 +92,21 @@ public class TestNetworkManager { */ @TestApi public void setupTestNetwork(@NonNull String iface, @NonNull IBinder binder) { try { mService.setupTestNetwork(iface, null, true, binder); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); setupTestNetwork(iface, null, true, new int[0], binder); } /** * Sets up a capability-limited, testing-only network for a given interface with the given * administrator UIDs. * * @param iface the name of the interface to be used for the Network LinkProperties. * @param administratorUids The administrator UIDs to be used for the test-only network * @param binder A binder object guarding the lifecycle of this test network. * @hide */ public void setupTestNetwork( @NonNull String iface, @NonNull int[] administratorUids, @NonNull IBinder binder) { setupTestNetwork(iface, null, true, administratorUids, binder); } /** Loading
services/core/java/com/android/server/TestNetworkService.java +13 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import java.net.InterfaceAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; Loading Loading @@ -230,6 +231,7 @@ class TestNetworkService extends ITestNetworkManager.Stub { @Nullable LinkProperties lp, boolean isMetered, int callingUid, @NonNull int[] administratorUids, @NonNull IBinder binder) throws RemoteException, SocketException { Objects.requireNonNull(looper, "missing Looper"); Loading @@ -248,6 +250,7 @@ class TestNetworkService extends ITestNetworkManager.Stub { nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED); nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED); nc.setNetworkSpecifier(new StringNetworkSpecifier(iface)); nc.setAdministratorUids(intArrayToList(administratorUids)); if (!isMetered) { nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED); } Loading Loading @@ -290,6 +293,14 @@ class TestNetworkService extends ITestNetworkManager.Stub { return new TestNetworkAgent(looper, context, ni, nc, lp, callingUid, binder); } private List<Integer> intArrayToList(@NonNull int[] array) { final List<Integer> list = new ArrayList<>(array.length); for (final int i : array) { list.add(i); } return list; } /** * Sets up a Network with extremely limited privileges, guarded by the MANAGE_TEST_NETWORKS * permission. Loading @@ -301,6 +312,7 @@ class TestNetworkService extends ITestNetworkManager.Stub { @NonNull String iface, @Nullable LinkProperties lp, boolean isMetered, @NonNull int[] administratorUids, @NonNull IBinder binder) { enforceTestNetworkPermissions(mContext); Loading Loading @@ -335,6 +347,7 @@ class TestNetworkService extends ITestNetworkManager.Stub { lp, isMetered, callingUid, administratorUids, binder); mTestNetworkTracker.put(agent.getNetwork().netId, agent); Loading