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
This commit is contained in:
Dario Freni
2019-04-30 18:58:57 +01:00
parent fa2e9939d2
commit ac3532f336

View File

@@ -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() {