Make legacy storage appop unsticky on upgrade to R

Newly installed apps that target R are not in legacy storage.
However an app that upgrades from a version that has legacy storage
currently keeps the legacy access. Make it unsticky
if new version targets R.

BUG: 148944140
Test: atest RestrictedPermissionsTest
Test: atest RestrictedStoragePermissionSharedUidTest
Change-Id: If1fb226492bbaa747ed13908e49144c3a4aa4093
This commit is contained in:
Nandana Dutt
2020-02-07 10:52:26 +00:00
parent af5dfc2f51
commit e1c1629dbb

View File

@@ -122,8 +122,9 @@ public abstract class SoftRestrictedPermissionPolicy {
PackageManager pm = context.getPackageManager();
int flags = pm.getPermissionFlags(permission, appInfo.packageName, user);
isWhiteListed = (flags & FLAGS_PERMISSION_RESTRICTION_ANY_EXEMPT) != 0;
shouldApplyRestriction = (flags & FLAG_PERMISSION_APPLY_RESTRICTION) != 0;
targetSDK = getMinimumTargetSDK(context, appInfo, user);
shouldApplyRestriction = (flags & FLAG_PERMISSION_APPLY_RESTRICTION) != 0
|| targetSDK > Build.VERSION_CODES.Q;
hasRequestedLegacyExternalStorage = hasUidRequestedLegacyExternalStorage(
appInfo.uid, context);
hasWriteMediaStorageGrantedForUid = hasWriteMediaStorageGrantedForUid(