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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user