summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff Sharkey <jsharkey@android.com> 2016-04-26 17:01:40 -0600
committer Jeff Sharkey <jsharkey@android.com> 2016-04-26 17:01:42 -0600
commite75c0b9873d56e2569d0c5dff78f8872b8c8e97f (patch)
tree3c5744fe2c5966af7430dab5b55ac96c02a22e95
parentaf8be42b9f6aa17c8d17d999b53227f0a1d6da5b (diff)
Fix two multi-user bugs in package upgrade.
When upgrading a package, we need to fill in the "origUsers" field so that we can clone the installed state correctly. This was done for child package, but never set for the parent package. Also fix a bug where a secondary user requested a package to be moved. Because that move was pushed onto a Handler, the calling userId appeared to be the device owner instead of the user that actually requested the move. (Later in the upgrade flow there is code that force-installs the package for the requesting user.) Bug: 26729822 Change-Id: I2d2a007c73558f29a3f8c1408ec373fce6e87761
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 547379d9cafa..4b57a9e741a4 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -13794,6 +13794,7 @@ public class PackageManagerService extends IPackageManager.Stub {
final PackageParser.Package oldPackage;
final String pkgName = pkg.packageName;
final int[] allUsers;
+ final int[] installedUsers;
// First find the old package info and check signatures
synchronized(mPackages) {
@@ -13836,6 +13837,7 @@ public class PackageManagerService extends IPackageManager.Stub {
// In case of rollback, remember per-user/profile install state
allUsers = sUserManager.getUserIds();
+ installedUsers = ps.queryInstalledUsers(allUsers, true);
}
// Update what is removed
@@ -13843,6 +13845,7 @@ public class PackageManagerService extends IPackageManager.Stub {
res.removedInfo.uid = oldPackage.applicationInfo.uid;
res.removedInfo.removedPackage = oldPackage.packageName;
res.removedInfo.isUpdate = true;
+ res.removedInfo.origUsers = installedUsers;
final int childCount = (oldPackage.childPackages != null)
? oldPackage.childPackages.size() : 0;
for (int i = 0; i < childCount; i++) {
@@ -19397,12 +19400,13 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
public int movePackage(final String packageName, final String volumeUuid) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MOVE_PACKAGE, null);
+ final UserHandle user = new UserHandle(UserHandle.getCallingUserId());
final int moveId = mNextMoveId.getAndIncrement();
mHandler.post(new Runnable() {
@Override
public void run() {
try {
- movePackageInternal(packageName, volumeUuid, moveId);
+ movePackageInternal(packageName, volumeUuid, moveId, user);
} catch (PackageManagerException e) {
Slog.w(TAG, "Failed to move " + packageName, e);
mMoveCallbacks.notifyStatusChanged(moveId,
@@ -19414,8 +19418,7 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
}
private void movePackageInternal(final String packageName, final String volumeUuid,
- final int moveId) throws PackageManagerException {
- final UserHandle user = new UserHandle(UserHandle.getCallingUserId());
+ final int moveId, UserHandle user) throws PackageManagerException {
final StorageManager storage = mContext.getSystemService(StorageManager.class);
final PackageManager pm = mContext.getPackageManager();