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

Commit e20cef59 authored by Nikita Ioffe's avatar Nikita Ioffe Committed by Mohammad Samiul Islam
Browse files

Don't create external storage dirs for apps with PROPERTY_NO_APP_DATA_STORAGE

Bug: 228424287
Test: atest android.appsecurity.cts.StorageHostTest
Change-Id: I5baa1faf0284016edb40529615bb3eb4f9bff3f4
parent c9bf2574
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -3742,6 +3742,16 @@ class StorageManagerService extends IStorageManager.Stub
                Context.APP_OPS_SERVICE);
        appOps.checkPackage(callingUid, callingPkg);

        try {
            final PackageManager.Property noAppStorageProp = mContext.getPackageManager()
                    .getProperty(PackageManager.PROPERTY_NO_APP_DATA_STORAGE, callingPkg);
            if (noAppStorageProp != null && noAppStorageProp.getBoolean()) {
                throw new SecurityException(callingPkg + " should not have " + appPath);
            }
        } catch (PackageManager.NameNotFoundException ignore) {
            // Property not found
        }

        File appFile = null;
        try {
            appFile = new File(appPath).getCanonicalFile();