[RESTRICT AUTOMERGE] Fix the inconsistency of protection level

The value may be inconsistent between BasePermission.perm.protection-
Level and BasePermission.getProtectionLevel() within the same object.
Update the perm to fix the inconsistency.

Bug: 209607944
Test: manually using the PoC on the buganizer to ensure the symptom
      no longer exists.
Change-Id: I19d6135f98bee9392d85e56478c42e06cfea8ba5
This commit is contained in:
Jackal Guo
2021-12-24 11:47:47 +08:00
parent b5fa0a6c5e
commit b5efdf7293

View File

@@ -409,6 +409,8 @@ public final class BasePermission {
} }
if (bp.perm != null && Objects.equals(bp.perm.getPackageName(), p.getPackageName()) if (bp.perm != null && Objects.equals(bp.perm.getPackageName(), p.getPackageName())
&& Objects.equals(bp.perm.getName(), p.getName())) { && Objects.equals(bp.perm.getName(), p.getName())) {
bp.perm.setFlags(bp.perm.getFlags() & ~PermissionInfo.FLAG_INSTALLED);
bp.perm = p.setFlags(p.getFlags() | PermissionInfo.FLAG_INSTALLED);
bp.protectionLevel = p.getProtectionLevel(); bp.protectionLevel = p.getProtectionLevel();
} }
if (bp.isRuntime() && (ownerChanged || wasNonRuntime)) { if (bp.isRuntime() && (ownerChanged || wasNonRuntime)) {