Preserve flags for non-runtime permissions upon package update. am: 0e1ebd84e2
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23331796 Change-Id: Id0395f08f2cbba1d5dd88b6b07e7a03534bb2fb0 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -2882,29 +2882,55 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
||||
+ pkg.getPackageName());
|
||||
}
|
||||
|
||||
if ((bp.isNormal() && shouldGrantNormalPermission)
|
||||
|| (bp.isSignature()
|
||||
&& (!bp.isPrivileged() || CollectionUtils.contains(
|
||||
isPrivilegedPermissionAllowlisted, permName))
|
||||
&& (CollectionUtils.contains(shouldGrantSignaturePermission,
|
||||
permName)
|
||||
|| (((bp.isPrivileged() && CollectionUtils.contains(
|
||||
shouldGrantPrivilegedPermissionIfWasGranted,
|
||||
permName)) || bp.isDevelopment() || bp.isRole())
|
||||
&& origState.isPermissionGranted(permName))))
|
||||
|| (bp.isInternal()
|
||||
&& (!bp.isPrivileged() || CollectionUtils.contains(
|
||||
isPrivilegedPermissionAllowlisted, permName))
|
||||
&& (CollectionUtils.contains(shouldGrantInternalPermission,
|
||||
permName)
|
||||
|| (((bp.isPrivileged() && CollectionUtils.contains(
|
||||
shouldGrantPrivilegedPermissionIfWasGranted,
|
||||
permName)) || bp.isDevelopment() || bp.isRole())
|
||||
&& origState.isPermissionGranted(permName))))) {
|
||||
// Grant an install permission.
|
||||
if (uidState.grantPermission(bp)) {
|
||||
changedInstallPermission = true;
|
||||
if (bp.isNormal() || bp.isSignature() || bp.isInternal()) {
|
||||
if ((bp.isNormal() && shouldGrantNormalPermission)
|
||||
|| (bp.isSignature()
|
||||
&& (!bp.isPrivileged() || CollectionUtils.contains(
|
||||
isPrivilegedPermissionAllowlisted, permName))
|
||||
&& (CollectionUtils.contains(shouldGrantSignaturePermission,
|
||||
permName)
|
||||
|| (((bp.isPrivileged() && CollectionUtils.contains(
|
||||
shouldGrantPrivilegedPermissionIfWasGranted,
|
||||
permName)) || bp.isDevelopment()
|
||||
|| bp.isRole())
|
||||
&& origState.isPermissionGranted(
|
||||
permName))))
|
||||
|| (bp.isInternal()
|
||||
&& (!bp.isPrivileged() || CollectionUtils.contains(
|
||||
isPrivilegedPermissionAllowlisted, permName))
|
||||
&& (CollectionUtils.contains(shouldGrantInternalPermission,
|
||||
permName)
|
||||
|| (((bp.isPrivileged() && CollectionUtils.contains(
|
||||
shouldGrantPrivilegedPermissionIfWasGranted,
|
||||
permName)) || bp.isDevelopment()
|
||||
|| bp.isRole())
|
||||
&& origState.isPermissionGranted(
|
||||
permName))))) {
|
||||
// Grant an install permission.
|
||||
if (uidState.grantPermission(bp)) {
|
||||
changedInstallPermission = true;
|
||||
}
|
||||
} else {
|
||||
if (DEBUG_PERMISSIONS) {
|
||||
boolean wasGranted = uidState.isPermissionGranted(bp.getName());
|
||||
if (wasGranted || bp.isAppOp()) {
|
||||
Slog.i(TAG, (wasGranted ? "Un-granting" : "Not granting")
|
||||
+ " permission " + perm
|
||||
+ " from package " + friendlyName
|
||||
+ " (protectionLevel=" + bp.getProtectionLevel()
|
||||
+ " flags=0x"
|
||||
+ Integer.toHexString(PackageInfoUtils.appInfoFlags(pkg,
|
||||
ps))
|
||||
+ ")");
|
||||
}
|
||||
}
|
||||
if (uidState.revokePermission(bp)) {
|
||||
changedInstallPermission = true;
|
||||
}
|
||||
}
|
||||
PermissionState origPermState = origState.getPermissionState(perm);
|
||||
int flags = origPermState != null ? origPermState.getFlags() : 0;
|
||||
uidState.updatePermissionFlags(bp, MASK_PERMISSION_FLAGS_ALL, flags);
|
||||
} else if (bp.isRuntime()) {
|
||||
boolean hardRestricted = bp.isHardRestricted();
|
||||
boolean softRestricted = bp.isSoftRestricted();
|
||||
@@ -3018,22 +3044,8 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
||||
uidState.updatePermissionFlags(bp, MASK_PERMISSION_FLAGS_ALL,
|
||||
flags);
|
||||
} else {
|
||||
if (DEBUG_PERMISSIONS) {
|
||||
boolean wasGranted = uidState.isPermissionGranted(bp.getName());
|
||||
if (wasGranted || bp.isAppOp()) {
|
||||
Slog.i(TAG, (wasGranted ? "Un-granting" : "Not granting")
|
||||
+ " permission " + perm
|
||||
+ " from package " + friendlyName
|
||||
+ " (protectionLevel=" + bp.getProtectionLevel()
|
||||
+ " flags=0x"
|
||||
+ Integer.toHexString(PackageInfoUtils.appInfoFlags(pkg,
|
||||
ps))
|
||||
+ ")");
|
||||
}
|
||||
}
|
||||
if (uidState.removePermissionState(bp.getName())) {
|
||||
changedInstallPermission = true;
|
||||
}
|
||||
Slog.wtf(LOG_TAG, "Unknown permission protection " + bp.getProtection()
|
||||
+ " for permission " + bp.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user