From ff9d0bab2c59d979984e5bfe4778f87055e21e5c Mon Sep 17 00:00:00 2001 From: Benedict Wong Date: Tue, 9 Apr 2019 16:29:43 -0700 Subject: [PATCH] Enable checks for MANAGE_TEST_NETWORKS in TestNetworkService This commit re-enables enforcement of the MANAGE_TEST_NETWORK permission, which is only granted to the shell. CTS tests using this permission should use UiAutomation.adoptShellPermissionIdentity() to gain access. Bug: 72950854 Test: IPsec CTS tests using this passing Change-Id: I98573a5c68e45abbbaddef01f6ac74a6a18e26f9 --- .../java/com/android/server/TestNetworkService.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/TestNetworkService.java b/services/core/java/com/android/server/TestNetworkService.java index 8997d8c3e5..bd20a24468 100644 --- a/services/core/java/com/android/server/TestNetworkService.java +++ b/services/core/java/com/android/server/TestNetworkService.java @@ -325,14 +325,10 @@ class TestNetworkService extends ITestNetworkManager.Stub { agent.teardown(); } - // STOPSHIP: Change this back to android.Manifest.permission.MANAGE_TEST_NETWORKS - private static final String PERMISSION_NAME = "dummy"; + private static final String PERMISSION_NAME = + android.Manifest.permission.MANAGE_TEST_NETWORKS; public static void enforceTestNetworkPermissions(@NonNull Context context) { - // STOPSHIP: Re-enable these checks. Disabled until adoptShellPermissionIdentity() can be - // called from CTS test code. - if (false) { - context.enforceCallingOrSelfPermission(PERMISSION_NAME, "TestNetworkService"); - } + context.enforceCallingOrSelfPermission(PERMISSION_NAME, "TestNetworkService"); } }