From 96a7326d90ff083c768f2ca7334f6ece9031561b Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Wed, 7 Jun 2017 14:46:02 -0700 Subject: [PATCH] expand who can uninstall an instant app More than just those with the ACCESS_INSTANT_APP permission should be able to uninstall instant apps. Any uid that can see instant apps [that includes the shell and some others] should be able to uninstall them. Change-Id: Iea24e5a1cdb369bdf29e7cf5db7977db63faedfc Fixes: 62406346 Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.EphemeralTest --- .../java/com/android/server/pm/PackageManagerService.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 81c849127fedc..0037f184ffbbb 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -3516,7 +3516,7 @@ public class PackageManagerService extends IPackageManager.Stub * and {@code 0} *
  • The calling application has the permission * {@link android.Manifest.permission#ACCESS_INSTANT_APPS}
  • - *
  • [TODO] The calling application is the default launcher on the + *
  • The calling application is the default launcher on the * system partition.
  • * */ @@ -18430,8 +18430,7 @@ public class PackageManagerService extends IPackageManager.Stub final int callingUid = Binder.getCallingUid(); mContext.enforceCallingOrSelfPermission( android.Manifest.permission.DELETE_PACKAGES, null); - final int hasAccessInstantApps = mContext.checkCallingOrSelfPermission( - android.Manifest.permission.ACCESS_INSTANT_APPS); + final boolean canViewInstantApps = canViewInstantApps(callingUid, userId); Preconditions.checkNotNull(versionedPackage); Preconditions.checkNotNull(observer); Preconditions.checkArgumentInRange(versionedPackage.getVersionCode(), @@ -18502,7 +18501,7 @@ public class PackageManagerService extends IPackageManager.Stub final boolean targetIsInstantApp = ps.getInstantApp(UserHandle.getUserId(callingUid)); doDeletePackage = !targetIsInstantApp - || hasAccessInstantApps == PackageManager.PERMISSION_GRANTED; + || canViewInstantApps; } if (doDeletePackage) { if (!deleteAllUsers) {