diff options
author | Amith Yamasani <yamasani@google.com> | 2014-08-28 18:06:51 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2014-08-29 10:28:38 -0700 |
commit | dda003ffa84f986bfaba4344124eafa533f5039d (patch) | |
tree | 649b390602e2efe8abad283fcdd04f285cfaff40 /cmds/pm | |
parent | 551056ec0fd274f4696c2cf1ec9c62298f7f7226 (diff) | |
download | frameworks_base-dda003ffa84f986bfaba4344124eafa533f5039d.zip frameworks_base-dda003ffa84f986bfaba4344124eafa533f5039d.tar.gz frameworks_base-dda003ffa84f986bfaba4344124eafa533f5039d.tar.bz2 |
Clean up apks installed for a removed user
When a user is removed, enumerate through all installed packages
to see if any of them are not installed for any user. Delete the
package if no user has it "installed".
Added a pm option to install an apk for a specific user.
Fixed a crash in UserManagerService when executing the above
cleanup - dying users generate a null UserInfo.
Bug: 15426024
Change-Id: I571decde1ae1c257d0da6db153b896aad6d6bcb4
Diffstat (limited to 'cmds/pm')
-rw-r--r-- | cmds/pm/src/com/android/commands/pm/Pm.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index d9b40b1..da34094 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -866,6 +866,7 @@ public final class Pm { private void runInstall() { int installFlags = PackageManager.INSTALL_ALL_USERS; + int userId = UserHandle.USER_ALL; String installerPackageName = null; String opt; @@ -909,6 +910,13 @@ public final class Pm { } } else if (opt.equals("--abi")) { abi = checkAbiArgument(nextOptionData()); + } else if (opt.equals("--user")) { + userId = Integer.parseInt(nextOptionData()); + if (userId == UserHandle.USER_ALL) { + installFlags |= PackageManager.INSTALL_ALL_USERS; + } else { + installFlags &= ~PackageManager.INSTALL_ALL_USERS; + } } else { System.err.println("Error: Unknown option: " + opt); return; @@ -953,8 +961,8 @@ public final class Pm { VerificationParams verificationParams = new VerificationParams(verificationURI, originatingURI, referrerURI, VerificationParams.NO_UID, null); - mPm.installPackage(apkFilePath, obs.getBinder(), installFlags, installerPackageName, - verificationParams, abi); + mPm.installPackageAsUser(apkFilePath, obs.getBinder(), installFlags, installerPackageName, + verificationParams, abi, userId); synchronized (obs) { while (!obs.finished) { |