Merge "Correctly rollback failed system app installs." into lmp-dev

This commit is contained in:
Jeff Sharkey
2014-10-05 01:06:26 +00:00
committed by Android (Google) Code Review

View File

@@ -9990,6 +9990,7 @@ public class PackageManagerService extends IPackageManager.Stub {
String installerPackageName, PackageInstalledInfo res) {
if (DEBUG_INSTALL) Slog.d(TAG, "replaceSystemPackageLI: new=" + pkg
+ ", old=" + deletedPackage);
boolean disabledSystem = false;
boolean updatedSettings = false;
parseFlags |= PackageParser.PARSE_IS_SYSTEM;
if ((deletedPackage.applicationInfo.flags&ApplicationInfo.FLAG_PRIVILEGED) != 0) {
@@ -10023,7 +10024,8 @@ public class PackageManagerService extends IPackageManager.Stub {
removePackageLI(oldPkgSetting, true);
// writer
synchronized (mPackages) {
if (!mSettings.disableSystemPackageLPw(packageName) && deletedPackage != null) {
disabledSystem = mSettings.disableSystemPackageLPw(packageName);
if (!disabledSystem && deletedPackage != null) {
// We didn't need to disable the .apk as a current system package,
// which means we are replacing another update that is already
// installed. We need to make sure to delete the older one's .apk.
@@ -10082,9 +10084,11 @@ public class PackageManagerService extends IPackageManager.Stub {
Slog.e(TAG, "Failed to restore original package: " + e.getMessage());
}
// Restore the old system information in Settings
synchronized(mPackages) {
if (updatedSettings) {
synchronized (mPackages) {
if (disabledSystem) {
mSettings.enableSystemPackageLPw(packageName);
}
if (updatedSettings) {
mSettings.setInstallerPackageName(packageName,
oldPkgSetting.installerPackageName);
}