summaryrefslogtreecommitdiffstats
path: root/cmds/pm
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2012-09-07 19:25:16 -0700
committerAmith Yamasani <yamasani@google.com>2012-09-08 19:14:00 -0700
commit151ec4c9f8ca34625733730a4551a23eb97cda23 (patch)
tree9a0ab8bed19904dce51ae3d23f5ff72c0581b7e2 /cmds/pm
parent4aacf93d40b4be82aa35bf164d6fd6536c8b2a50 (diff)
downloadframeworks_base-151ec4c9f8ca34625733730a4551a23eb97cda23.zip
frameworks_base-151ec4c9f8ca34625733730a4551a23eb97cda23.tar.gz
frameworks_base-151ec4c9f8ca34625733730a4551a23eb97cda23.tar.bz2
More multi-user methods in PM
pm can list installed packages by user now. Bug: 6926465 Change-Id: I822311bfd6e7e2d6fb315fc484739fbf953c9bb6
Diffstat (limited to 'cmds/pm')
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index 8570f27..e0f54fb 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -42,6 +42,7 @@ import android.net.Uri;
import android.os.IUserManager;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.UserHandle;
import java.io.File;
import java.lang.reflect.Field;
@@ -241,6 +242,7 @@ public final class Pm {
boolean listDisabled = false, listEnabled = false;
boolean listSystem = false, listThirdParty = false;
boolean listInstaller = false;
+ int userId = UserHandle.USER_OWNER;
try {
String opt;
while ((opt=nextOption()) != null) {
@@ -260,6 +262,8 @@ public final class Pm {
listThirdParty = true;
} else if (opt.equals("-i")) {
listInstaller = true;
+ } else if (opt.equals("--user")) {
+ userId = Integer.parseInt(nextArg());
} else if (opt.equals("-u")) {
getFlags |= PackageManager.GET_UNINSTALLED_PACKAGES;
} else {
@@ -275,7 +279,7 @@ public final class Pm {
String filter = nextArg();
try {
- final List<PackageInfo> packages = getInstalledPackages(mPm, getFlags);
+ final List<PackageInfo> packages = getInstalledPackages(mPm, getFlags, userId);
int count = packages.size();
for (int p = 0 ; p < count ; p++) {
@@ -309,7 +313,7 @@ public final class Pm {
}
@SuppressWarnings("unchecked")
- private List<PackageInfo> getInstalledPackages(IPackageManager pm, int flags)
+ private List<PackageInfo> getInstalledPackages(IPackageManager pm, int flags, int userId)
throws RemoteException {
final List<PackageInfo> packageInfos = new ArrayList<PackageInfo>();
PackageInfo lastItem = null;
@@ -317,7 +321,7 @@ public final class Pm {
do {
final String lastKey = lastItem != null ? lastItem.packageName : null;
- slice = pm.getInstalledPackages(flags, lastKey);
+ slice = pm.getInstalledPackages(flags, lastKey, userId);
lastItem = slice.populateList(packageInfos, PackageInfo.CREATOR);
} while (!slice.isLastSlice());
@@ -1420,7 +1424,7 @@ public final class Pm {
}
private static void showUsage() {
- System.err.println("usage: pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [FILTER]");
+ System.err.println("usage: pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [--user USER_ID] [FILTER]");
System.err.println(" pm list permission-groups");
System.err.println(" pm list permissions [-g] [-f] [-d] [-u] [GROUP]");
System.err.println(" pm list instrumentation [-f] [TARGET-PACKAGE]");