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

Commit 5faf2feb authored by Jeff Sharkey's avatar Jeff Sharkey Committed by android-build-merger
Browse files

Merge "Merge "Fix isExternalStorageSandboxed() bug." into qt-dev am:...

Merge "Merge "Fix isExternalStorageSandboxed() bug." into qt-dev am: 10a222bf" into qt-dev-plus-aosp
am: ffe47c19

Change-Id: I287c8ae02bd20d17a59cfd1a46bb35eed0c013d3
parents 492fa282 ffe47c19
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -1147,9 +1147,16 @@ public class Environment {
    public static boolean isExternalStorageSandboxed(@NonNull File path) {
        final Context context = AppGlobals.getInitialApplication();
        final AppOpsManager appOps = context.getSystemService(AppOpsManager.class);
        return appOps.noteOpNoThrow(AppOpsManager.OP_LEGACY_STORAGE,

        final boolean hasLegacy = appOps.noteOpNoThrow(AppOpsManager.OP_LEGACY_STORAGE,
                context.getApplicationInfo().uid,
                context.getPackageName()) != AppOpsManager.MODE_ALLOWED;
                context.getPackageName()) == AppOpsManager.MODE_ALLOWED;

        // STOPSHIP: only use app-op once permission model has fully landed
        final boolean requestedLegacy = !AppGlobals.getInitialApplication().getApplicationInfo()
                .isExternalStorageSandboxAllowed();

        return !(hasLegacy || requestedLegacy);
    }

    static File getDirectory(String variableName, String defaultPath) {