diff options
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 11 | ||||
| -rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 30 |
2 files changed, 38 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 8b67d0ee4941..9070849c8092 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -18362,9 +18362,14 @@ public final class ActivityManagerService extends ActivityManagerNative for (int j = 0; j < activitiesSize; j++) { final ActivityRecord r = app.activities.get(j); if (r.app != app) { - Slog.w(TAG, "Wtf, activity " + r + " in proc activity list not using proc " - + app + "?!? Using " + r.app + " instead."); - continue; + Log.wtf(TAG, "Found activity " + r + " in proc activity list using " + r.app + + " instead of expected " + app); + if (r.app == null || (r.app.uid == app.uid)) { + // Only fix things up when they look sane + r.app = app; + } else { + continue; + } } if (r.visible) { // App has a visible activity; only upgrade adjustment. diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 64f8c98a082d..1a80a460897e 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -2899,6 +2899,11 @@ public class PackageManagerService extends IPackageManager.Stub { throw new SecurityException("Package " + packageName + " was not found!"); } + if (!ps.getInstalled(userId)) { + throw new SecurityException( + "Package " + packageName + " was not installed for user " + userId + "!"); + } + if (mSafeMode && !ps.isSystem()) { throw new SecurityException("Package " + packageName + " not a system app!"); } @@ -13130,6 +13135,7 @@ public class PackageManagerService extends IPackageManager.Stub { final PackageParser.Package oldPackage; final String pkgName = pkg.packageName; final int[] allUsers; + final boolean weFroze; // First find the old package info and check signatures synchronized(mPackages) { @@ -13162,8 +13168,32 @@ public class PackageManagerService extends IPackageManager.Stub { // In case of rollback, remember per-user/profile install state allUsers = sUserManager.getUserIds(); + + // Mark the app as frozen to prevent launching during the upgrade + // process, and then kill all running instances + if (!ps.frozen) { + ps.frozen = true; + weFroze = true; + } else { + weFroze = false; + } } + try { + replacePackageDirtyLI(pkg, oldPackage, parseFlags, scanFlags, user, allUsers, + installerPackageName, res); + } finally { + // Regardless of success or failure of upgrade steps above, always + // unfreeze the package if we froze it + if (weFroze) { + unfreezePackage(pkgName); + } + } + } + + private void replacePackageDirtyLI(PackageParser.Package pkg, PackageParser.Package oldPackage, + int parseFlags, int scanFlags, UserHandle user, int[] allUsers, + String installerPackageName, PackageInstalledInfo res) { // Update what is removed res.removedInfo = new PackageRemovedInfo(); res.removedInfo.uid = oldPackage.applicationInfo.uid; |