diff options
| author | 2019-04-30 18:58:57 +0100 | |
|---|---|---|
| committer | 2019-04-30 19:23:45 +0100 | |
| commit | ac3532f336c8d52cfbfd40ee247e7ec15b83a668 (patch) | |
| tree | abc7eadcb2805aded2e1b3bc8005ba817e20120a | |
| parent | fa2e9939d2f8be32f7ec12117e3b3e510bd27db4 (diff) | |
Enable upgrading persistent APKs on boot.
Bug: 131046856
Test: marked the NetworkStack APK as persistent, verified that
without this patch:
- adb install networkstack.apk fails
- adb install --staged networkstack.apk fails (after reboot)
with this patch:
- adb install networkstack.apk fails
- adb install --staged networkstack.apk succeds (after reboot)
Change-Id: I346d772e1f4aed94f6faead3b6455efc4666b651
| -rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index e08af6f3521f..bad1ca1ee2ee 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -939,6 +939,7 @@ public class PackageManagerService extends IPackageManager.Stub ComponentName mCustomResolverComponentName; boolean mResolverReplaced = false; + boolean mOkToReplacePersistentPackages = false; private final @Nullable ComponentName mIntentFilterVerifierComponent; private final @Nullable IntentFilterVerifier<ActivityIntentInfo> mIntentFilterVerifier; @@ -17324,7 +17325,8 @@ public class PackageManagerService extends IPackageManager.Stub + " target SDK " + oldTargetSdk + " does."); } // Prevent persistent apps from being updated - if ((oldPackage.applicationInfo.flags & ApplicationInfo.FLAG_PERSISTENT) != 0) { + if (((oldPackage.applicationInfo.flags & ApplicationInfo.FLAG_PERSISTENT) != 0) + && !mOkToReplacePersistentPackages) { throw new PrepareFailure(PackageManager.INSTALL_FAILED_INVALID_APK, "Package " + oldPackage.packageName + " is a persistent app. " + "Persistent apps are not updateable."); @@ -21505,10 +21507,12 @@ public class PackageManagerService extends IPackageManager.Stub mModuleInfoProvider.systemReady(); + mOkToReplacePersistentPackages = true; // Installer service might attempt to install some packages that have been staged for // installation on reboot. Make sure this is the last component to be call since the // installation might require other components to be ready. mInstallerService.restoreAndApplyStagedSessionIfNeeded(); + mOkToReplacePersistentPackages = false; } public void waitForAppDataPrepared() { |