Merge "Don't create external storage dirs for apps with PROPERTY_NO_APP_DATA_STORAGE" into tm-dev

This commit is contained in:
Samiul Islam
2022-04-21 11:59:45 +00:00
committed by Android (Google) Code Review

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