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());
|
+ pkg.getPackageName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((bp.isNormal() && shouldGrantNormalPermission)
|
if (bp.isNormal() || bp.isSignature() || bp.isInternal()) {
|
||||||
|| (bp.isSignature()
|
if ((bp.isNormal() && shouldGrantNormalPermission)
|
||||||
&& (!bp.isPrivileged() || CollectionUtils.contains(
|
|| (bp.isSignature()
|
||||||
isPrivilegedPermissionAllowlisted, permName))
|
&& (!bp.isPrivileged() || CollectionUtils.contains(
|
||||||
&& (CollectionUtils.contains(shouldGrantSignaturePermission,
|
isPrivilegedPermissionAllowlisted, permName))
|
||||||
permName)
|
&& (CollectionUtils.contains(shouldGrantSignaturePermission,
|
||||||
|| (((bp.isPrivileged() && CollectionUtils.contains(
|
permName)
|
||||||
shouldGrantPrivilegedPermissionIfWasGranted,
|
|| (((bp.isPrivileged() && CollectionUtils.contains(
|
||||||
permName)) || bp.isDevelopment() || bp.isRole())
|
shouldGrantPrivilegedPermissionIfWasGranted,
|
||||||
&& origState.isPermissionGranted(permName))))
|
permName)) || bp.isDevelopment()
|
||||||
|| (bp.isInternal()
|
|| bp.isRole())
|
||||||
&& (!bp.isPrivileged() || CollectionUtils.contains(
|
&& origState.isPermissionGranted(
|
||||||
isPrivilegedPermissionAllowlisted, permName))
|
permName))))
|
||||||
&& (CollectionUtils.contains(shouldGrantInternalPermission,
|
|| (bp.isInternal()
|
||||||
permName)
|
&& (!bp.isPrivileged() || CollectionUtils.contains(
|
||||||
|| (((bp.isPrivileged() && CollectionUtils.contains(
|
isPrivilegedPermissionAllowlisted, permName))
|
||||||
shouldGrantPrivilegedPermissionIfWasGranted,
|
&& (CollectionUtils.contains(shouldGrantInternalPermission,
|
||||||
permName)) || bp.isDevelopment() || bp.isRole())
|
permName)
|
||||||
&& origState.isPermissionGranted(permName))))) {
|
|| (((bp.isPrivileged() && CollectionUtils.contains(
|
||||||
// Grant an install permission.
|
shouldGrantPrivilegedPermissionIfWasGranted,
|
||||||
if (uidState.grantPermission(bp)) {
|
permName)) || bp.isDevelopment()
|
||||||
changedInstallPermission = true;
|
|| 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()) {
|
} else if (bp.isRuntime()) {
|
||||||
boolean hardRestricted = bp.isHardRestricted();
|
boolean hardRestricted = bp.isHardRestricted();
|
||||||
boolean softRestricted = bp.isSoftRestricted();
|
boolean softRestricted = bp.isSoftRestricted();
|
||||||
@@ -3018,22 +3044,8 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
|||||||
uidState.updatePermissionFlags(bp, MASK_PERMISSION_FLAGS_ALL,
|
uidState.updatePermissionFlags(bp, MASK_PERMISSION_FLAGS_ALL,
|
||||||
flags);
|
flags);
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG_PERMISSIONS) {
|
Slog.wtf(LOG_TAG, "Unknown permission protection " + bp.getProtection()
|
||||||
boolean wasGranted = uidState.isPermissionGranted(bp.getName());
|
+ " for permission " + 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user