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
This commit is contained in:
Nikita Ioffe
2022-01-14 00:59:43 +00:00
committed by Mohammad Samiul Islam
parent c9bf2574b4
commit e20cef5908

View File

@@ -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();