Preserve flags for non-runtime permissions upon package update. am: 0e1ebd84e2 am: 19281f9b81
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23331796 Change-Id: I3531578799cdeb50118a8f8aa1f69dffeb7464dc Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -2882,6 +2882,7 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
|||||||
+ pkg.getPackageName());
|
+ pkg.getPackageName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bp.isNormal() || bp.isSignature() || bp.isInternal()) {
|
||||||
if ((bp.isNormal() && shouldGrantNormalPermission)
|
if ((bp.isNormal() && shouldGrantNormalPermission)
|
||||||
|| (bp.isSignature()
|
|| (bp.isSignature()
|
||||||
&& (!bp.isPrivileged() || CollectionUtils.contains(
|
&& (!bp.isPrivileged() || CollectionUtils.contains(
|
||||||
@@ -2890,8 +2891,10 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
|||||||
permName)
|
permName)
|
||||||
|| (((bp.isPrivileged() && CollectionUtils.contains(
|
|| (((bp.isPrivileged() && CollectionUtils.contains(
|
||||||
shouldGrantPrivilegedPermissionIfWasGranted,
|
shouldGrantPrivilegedPermissionIfWasGranted,
|
||||||
permName)) || bp.isDevelopment() || bp.isRole())
|
permName)) || bp.isDevelopment()
|
||||||
&& origState.isPermissionGranted(permName))))
|
|| bp.isRole())
|
||||||
|
&& origState.isPermissionGranted(
|
||||||
|
permName))))
|
||||||
|| (bp.isInternal()
|
|| (bp.isInternal()
|
||||||
&& (!bp.isPrivileged() || CollectionUtils.contains(
|
&& (!bp.isPrivileged() || CollectionUtils.contains(
|
||||||
isPrivilegedPermissionAllowlisted, permName))
|
isPrivilegedPermissionAllowlisted, permName))
|
||||||
@@ -2899,12 +2902,35 @@ public class PermissionManagerService extends IPermissionManager.Stub {
|
|||||||
permName)
|
permName)
|
||||||
|| (((bp.isPrivileged() && CollectionUtils.contains(
|
|| (((bp.isPrivileged() && CollectionUtils.contains(
|
||||||
shouldGrantPrivilegedPermissionIfWasGranted,
|
shouldGrantPrivilegedPermissionIfWasGranted,
|
||||||
permName)) || bp.isDevelopment() || bp.isRole())
|
permName)) || bp.isDevelopment()
|
||||||
&& origState.isPermissionGranted(permName))))) {
|
|| bp.isRole())
|
||||||
|
&& origState.isPermissionGranted(
|
||||||
|
permName))))) {
|
||||||
// Grant an install permission.
|
// Grant an install permission.
|
||||||
if (uidState.grantPermission(bp)) {
|
if (uidState.grantPermission(bp)) {
|
||||||
changedInstallPermission = true;
|
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