Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ec600d3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Delete android.os.EnvironmentTest#testIsExternalStorageManager"

parents 29bc594a b1dfdd2f
Loading
Loading
Loading
Loading
+0 −36
Original line number Diff line number Diff line
@@ -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);
@@ -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);
        }
    }
}