Merge "Fix wrong LEGACY_STORAGE appop grant" into sc-dev am: 964a1e0f72

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15272231

Change-Id: I5ec40176569edf6121485e7a44c66d72b36b1a6a
This commit is contained in:
Zimuzo Ezeozue
2021-07-15 20:35:15 +00:00
committed by Automerger Merge Worker

View File

@@ -189,12 +189,16 @@ public abstract class SoftRestrictedPermissionPolicy {
return false; return false;
} }
// 3. The app has WRITE_MEDIA_STORAGE, OR // 3. The app targetSDK should be less than R
// the app already has legacy external storage or requested it, if (targetSDK >= Build.VERSION_CODES.R) {
// and is < R. return false;
return hasWriteMediaStorageGrantedForUid }
|| ((hasLegacyExternalStorage || hasRequestedLegacyExternalStorage)
&& targetSDK < Build.VERSION_CODES.R); // 4. The app has WRITE_MEDIA_STORAGE,
// OR the app already has legacy external storage
// OR the app requested legacy external storage
return hasWriteMediaStorageGrantedForUid || hasLegacyExternalStorage
|| hasRequestedLegacyExternalStorage;
} }
@Override @Override
public boolean mayDenyExtraAppOpIfGranted() { public boolean mayDenyExtraAppOpIfGranted() {
@@ -216,10 +220,8 @@ public abstract class SoftRestrictedPermissionPolicy {
return true; return true;
} }
// The package doesn't have WRITE_MEDIA_STORAGE, // The package doesn't request legacy storage to be preserved
// AND didn't request legacy storage to be preserved if (!hasRequestedPreserveLegacyExternalStorage) {
if (!hasWriteMediaStorageGrantedForUid
&& !hasRequestedPreserveLegacyExternalStorage) {
return true; return true;
} }