Loading core/tests/coretests/src/android/os/EnvironmentTest.java +0 −36 Original line number Diff line number Diff line Loading @@ -47,29 +47,6 @@ public class EnvironmentTest { return InstrumentationRegistry.getContext(); } /** * Sets {@code mode} for the given {@code ops} and the given {@code uid}. * * <p>This method drops shell permission identity. */ private static void setAppOpsModeForUid(int uid, int mode, String... ops) { if (ops == null) { return; } InstrumentationRegistry.getInstrumentation() .getUiAutomation() .adoptShellPermissionIdentity(); try { for (String op : ops) { getContext().getSystemService(AppOpsManager.class).setUidMode(op, uid, mode); } } finally { InstrumentationRegistry.getInstrumentation() .getUiAutomation() .dropShellPermissionIdentity(); } } @Before public void setUp() throws Exception { dir = getContext().getDir("testing", Context.MODE_PRIVATE); Loading Loading @@ -127,17 +104,4 @@ public class EnvironmentTest { Environment.buildPath(dir, "Taxes.pdf").createNewFile(); assertEquals(HAS_OTHER, classifyExternalStorageDirectory(dir)); } @Test public void testIsExternalStorageManager() throws Exception { assertFalse(Environment.isExternalStorageManager()); try { setAppOpsModeForUid(Process.myUid(), AppOpsManager.MODE_ALLOWED, AppOpsManager.OPSTR_MANAGE_EXTERNAL_STORAGE); assertTrue(Environment.isExternalStorageManager()); } finally { setAppOpsModeForUid(Process.myUid(), AppOpsManager.MODE_DEFAULT, AppOpsManager.OPSTR_MANAGE_EXTERNAL_STORAGE); } } } Loading
core/tests/coretests/src/android/os/EnvironmentTest.java +0 −36 Original line number Diff line number Diff line Loading @@ -47,29 +47,6 @@ public class EnvironmentTest { return InstrumentationRegistry.getContext(); } /** * Sets {@code mode} for the given {@code ops} and the given {@code uid}. * * <p>This method drops shell permission identity. */ private static void setAppOpsModeForUid(int uid, int mode, String... ops) { if (ops == null) { return; } InstrumentationRegistry.getInstrumentation() .getUiAutomation() .adoptShellPermissionIdentity(); try { for (String op : ops) { getContext().getSystemService(AppOpsManager.class).setUidMode(op, uid, mode); } } finally { InstrumentationRegistry.getInstrumentation() .getUiAutomation() .dropShellPermissionIdentity(); } } @Before public void setUp() throws Exception { dir = getContext().getDir("testing", Context.MODE_PRIVATE); Loading Loading @@ -127,17 +104,4 @@ public class EnvironmentTest { Environment.buildPath(dir, "Taxes.pdf").createNewFile(); assertEquals(HAS_OTHER, classifyExternalStorageDirectory(dir)); } @Test public void testIsExternalStorageManager() throws Exception { assertFalse(Environment.isExternalStorageManager()); try { setAppOpsModeForUid(Process.myUid(), AppOpsManager.MODE_ALLOWED, AppOpsManager.OPSTR_MANAGE_EXTERNAL_STORAGE); assertTrue(Environment.isExternalStorageManager()); } finally { setAppOpsModeForUid(Process.myUid(), AppOpsManager.MODE_DEFAULT, AppOpsManager.OPSTR_MANAGE_EXTERNAL_STORAGE); } } }