Merge "Fix two multi-user bugs in package upgrade." into nyc-dev

This commit is contained in:
TreeHugger Robot
2016-04-27 00:39:40 +00:00
committed by Android (Google) Code Review

View File

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