From 0b43aa9cd9361639dceb1b93b8de2f37fcdc2897 Mon Sep 17 00:00:00 2001 From: Hai Zhang Date: Tue, 16 Nov 2021 11:09:24 +0000 Subject: [PATCH] Fix install permission revocation upon source package uninstallation. The revocation should only be done when the source package is completely removed, instead of only being marked as uninstalled for certain users. However, the original code would erroneously take a null pkg parameter as the package is gone instead of its original meaning that all packages need to be updated. So simply drop that parameter and get the pkg from package manager to see if the package is really being completely removed. Bug: 206047992 Test: atest RemovePermissionTest Change-Id: Iabbf045a87cb00b4c27d562ff126570f385f64c1 --- .../pm/permission/PermissionManagerService.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java index 3855e655fb278..a01c358ab3410 100644 --- a/services/core/java/com/android/server/pm/permission/PermissionManagerService.java +++ b/services/core/java/com/android/server/pm/permission/PermissionManagerService.java @@ -4205,7 +4205,7 @@ public class PermissionManagerService extends IPermissionManager.Stub { // Make sure all dynamic permissions have been assigned to a package, // and make sure there are no dangling permissions. boolean permissionSourcePackageChanged = updatePermissionSourcePackage(changingPkgName, - changingPkg, callback); + callback); if (permissionTreesSourcePackageChanged | permissionSourcePackageChanged) { // Permission ownership has changed. This e.g. changes which packages can get signature @@ -4244,22 +4244,12 @@ public class PermissionManagerService extends IPermissionManager.Stub { /** * Update which app declares a permission. * - *

Possible parameter combinations - * - * - * - * - *
packageName != nullpackageName == null
pkg != nullpackage is updatedinvalid
pkg == nullpackage is deletedall packages are updated
- * * @param packageName The package that is updated, or {@code null} if all packages should be * updated - * @param pkg The package that is updated, or {@code null} if all packages should be updated or - * package is deleted * * @return {@code true} if a permission source package might have changed */ private boolean updatePermissionSourcePackage(@Nullable String packageName, - @Nullable AndroidPackage pkg, final @Nullable PermissionCallback callback) { // Always need update if packageName is null if (packageName == null) { @@ -4289,6 +4279,7 @@ public class PermissionManagerService extends IPermissionManager.Stub { } } if (needsUpdate != null) { + final AndroidPackage pkg = mPackageManagerInt.getPackage(packageName); for (final Permission bp : needsUpdate) { // If the target package is being uninstalled, we need to revoke this permission // From all other packages