Revoke permission on non-runtime -> runtime upgrade

Not only on normal -> runtime.

Test: atest android.appsecurity.cts.PermissionsHostTest#testNoPermissionEscalationAfterReboot
Bug: 154505240, 168319670
Change-Id: If3b420067b4d7111dcf67ae6f98e42176158b679
Merged-In: If3b420067b4d7111dcf67ae6f98e42176158b679
This commit is contained in:
Philip P. Moltmann
2020-11-03 15:12:44 -08:00
parent bc71724034
commit dd41b25a83

View File

@@ -365,7 +365,7 @@ public final class BasePermission {
if (bp == null) {
bp = new BasePermission(p.info.name, p.info.packageName, TYPE_NORMAL);
}
boolean wasNormal = bp.isNormal();
boolean wasNonRuntime = !bp.isRuntime();
StringBuilder r = null;
if (bp.perm == null) {
if (bp.sourcePackageName == null
@@ -409,7 +409,7 @@ public final class BasePermission {
if (bp.perm == p) {
bp.protectionLevel = p.info.protectionLevel;
}
if (bp.isRuntime() && (ownerChanged || wasNormal)) {
if (bp.isRuntime() && (ownerChanged || wasNonRuntime)) {
// If this is a runtime permission and the owner has changed, or this was a normal
// permission, then permission state should be cleaned up
bp.mPermissionDefinitionChanged = true;