diff options
author | Suprabh Shukla <suprabh@google.com> | 2018-06-11 15:11:01 -0700 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-06-13 00:28:32 +0000 |
commit | 958fbb9c86a1bad8f11a7bc5b6198a73d571c472 (patch) | |
tree | 8b3adf0203173f100580c2db72d4ae85001d3c08 | |
parent | 2dafb1bf01f8ccb9fd43f0cd575cf67d8b9c8d63 (diff) | |
download | base-958fbb9c86a1bad8f11a7bc5b6198a73d571c472.tar.gz |
Allow unsuspending critical packages
PackageManager prevents certain packages from being suspended to ensure
device is in a sane state. It should not disallow unsuspening these
packages for the same reason.
Test: Existing tests:
atest FrameworksServicesTests:SuspendPackagesTest
Manually, changed the default dialer, then
adb shell pm suspend com.android.dialer
change the default dialer to com.android.dialer, then
adb shell pm unsuspend com.android.dialer
should succeeed.
Bug: 79846500
Change-Id: Ie198f61bf3b092e497f978e60a27f9d52cdda9c7
(cherry picked from commit 4d74d50f53882560ac20c06de53b40f030e31fec)
-rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 1b8c2cc8793e..9ed2b9c18546 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -14178,7 +14178,7 @@ public class PackageManagerService extends IPackageManager.Stub unactionedPackages.add(packageName); continue; } - if (!canSuspendPackageForUserLocked(packageName, userId)) { + if (suspended && !canSuspendPackageForUserLocked(packageName, userId)) { unactionedPackages.add(packageName); continue; } @@ -14333,44 +14333,44 @@ public class PackageManagerService extends IPackageManager.Stub @GuardedBy("mPackages") private boolean canSuspendPackageForUserLocked(String packageName, int userId) { if (isPackageDeviceAdmin(packageName, userId)) { - Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName + Slog.w(TAG, "Cannot suspend package \"" + packageName + "\": has an active device admin"); return false; } String activeLauncherPackageName = getActiveLauncherPackageName(userId); if (packageName.equals(activeLauncherPackageName)) { - Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName + Slog.w(TAG, "Cannot suspend package \"" + packageName + "\": contains the active launcher"); return false; } if (packageName.equals(mRequiredInstallerPackage)) { - Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName + Slog.w(TAG, "Cannot suspend package \"" + packageName + "\": required for package installation"); return false; } if (packageName.equals(mRequiredUninstallerPackage)) { - Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName + Slog.w(TAG, "Cannot suspend package \"" + packageName + "\": required for package uninstallation"); return false; } if (packageName.equals(mRequiredVerifierPackage)) { - Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName + Slog.w(TAG, "Cannot suspend package \"" + packageName + "\": required for package verification"); return false; } if (packageName.equals(getDefaultDialerPackageName(userId))) { - Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName + Slog.w(TAG, "Cannot suspend package \"" + packageName + "\": is the default dialer"); return false; } if (mProtectedPackages.isPackageStateProtected(userId, packageName)) { - Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName + Slog.w(TAG, "Cannot suspend package \"" + packageName + "\": protected package"); return false; } |