Skip to content
Snippets Groups Projects
Commit 5e3518da authored by Song Chun Fan's avatar Song Chun Fan Committed by Automerger Merge Worker
Browse files

Merge "PM: Use installed userId while moving apps" into main am: d03e417b...

Merge "PM: Use installed userId while moving apps" into main am: d03e417b am: e24844ce am: 623d171d am: 280b30d1 am: 591e049f

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2764865



Change-Id: I051f21c5bb5c02f3c10f2bb442f17b7a7d6add1f
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 6e676243 591e049f
No related branches found
No related tags found
No related merge requests found
......@@ -89,6 +89,21 @@ public final class MovePackageHelper {
if (packageState == null || packageState.getPkg() == null) {
throw new PackageManagerException(MOVE_FAILED_DOESNT_EXIST, "Missing package");
}
final int[] installedUserIds = PackageStateUtils.queryInstalledUsers(packageState,
mPm.mUserManager.getUserIds(), true);
final UserHandle userForMove;
if (installedUserIds.length > 0) {
userForMove = UserHandle.of(installedUserIds[0]);
} else {
throw new PackageManagerException(MOVE_FAILED_DOESNT_EXIST,
"Package is not installed for any user");
}
for (int userId : installedUserIds) {
if (snapshot.shouldFilterApplicationIncludingUninstalled(packageState, callingUid,
userId)) {
throw new PackageManagerException(MOVE_FAILED_DOESNT_EXIST, "Missing package");
}
}
final AndroidPackage pkg = packageState.getPkg();
if (packageState.isSystem()) {
throw new PackageManagerException(MOVE_FAILED_SYSTEM_PACKAGE,
......@@ -134,8 +149,6 @@ public final class MovePackageHelper {
final String label = String.valueOf(pm.getApplicationLabel(
AndroidPackageUtils.generateAppInfoWithoutState(pkg)));
final int targetSdkVersion = pkg.getTargetSdkVersion();
final int[] installedUserIds = PackageStateUtils.queryInstalledUsers(packageState,
mPm.mUserManager.getUserIds(), true);
final String fromCodePath;
if (codeFile.getParentFile().getName().startsWith(
PackageManagerService.RANDOM_DIR_PREFIX)) {
......@@ -303,8 +316,8 @@ public final class MovePackageHelper {
final PackageLite lite = ret.isSuccess() ? ret.getResult() : null;
final InstallingSession installingSession = new InstallingSession(origin, move,
installObserver, installFlags, /* developmentInstallFlags= */ 0, installSource,
volumeUuid, user, packageAbiOverride, PackageInstaller.PACKAGE_SOURCE_UNSPECIFIED,
lite, mPm);
volumeUuid, userForMove, packageAbiOverride,
PackageInstaller.PACKAGE_SOURCE_UNSPECIFIED, lite, mPm);
installingSession.movePackage();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment