summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-10-15 16:16:39 -0700
committerJeff Sharkey <jsharkey@android.com>2012-10-15 16:16:39 -0700
commita3e9ff7debde50f6b58ebc3033cbbad650c10ac7 (patch)
treeb94d2caf1fa4029650b6ca3fd57a9d3d1b54f684 /cmds
parent52801aae89196b7ad16ef21b07d2d621e7d0bb61 (diff)
downloadframeworks_base-a3e9ff7debde50f6b58ebc3033cbbad650c10ac7.zip
frameworks_base-a3e9ff7debde50f6b58ebc3033cbbad650c10ac7.tar.gz
frameworks_base-a3e9ff7debde50f6b58ebc3033cbbad650c10ac7.tar.bz2
Support pm clear as --user.
Bug: 7352703 Change-Id: I0e9cc4f2313e5424d234c3cb051004c0321d9dac
Diffstat (limited to 'cmds')
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java20
1 files changed, 16 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 16d4ad6..42c9d34 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -1131,6 +1131,19 @@ public final class Pm {
}
private void runClear() {
+ int userId = 0;
+ String option = nextOption();
+ if (option != null && option.equals("--user")) {
+ String optionData = nextOptionData();
+ if (optionData == null || !isNumber(optionData)) {
+ System.err.println("Error: no USER_ID specified");
+ showUsage();
+ return;
+ } else {
+ userId = Integer.parseInt(optionData);
+ }
+ }
+
String pkg = nextArg();
if (pkg == null) {
System.err.println("Error: no package specified");
@@ -1140,8 +1153,7 @@ public final class Pm {
ClearDataObserver obs = new ClearDataObserver();
try {
- // XXX TO DO: add user arg
- if (!ActivityManagerNative.getDefault().clearApplicationUserData(pkg, obs, 0)) {
+ if (!ActivityManagerNative.getDefault().clearApplicationUserData(pkg, obs, userId)) {
System.err.println("Failed");
}
@@ -1179,7 +1191,7 @@ public final class Pm {
return "unknown";
}
- private boolean isNumber(String s) {
+ private static boolean isNumber(String s) {
try {
Integer.parseInt(s);
} catch (NumberFormatException nfe) {
@@ -1452,7 +1464,7 @@ public final class Pm {
System.err.println(" [--algo <algorithm name> --key <key-in-hex> --iv <IV-in-hex>]");
System.err.println(" [--originating-uri <URI>] [--referrer <URI>] PATH");
System.err.println(" pm uninstall [-k] PACKAGE");
- System.err.println(" pm clear PACKAGE");
+ System.err.println(" pm clear [--user USER_ID] PACKAGE");
System.err.println(" pm enable [--user USER_ID] PACKAGE_OR_COMPONENT");
System.err.println(" pm disable [--user USER_ID] PACKAGE_OR_COMPONENT");
System.err.println(" pm disable-user [--user USER_ID] PACKAGE_OR_COMPONENT");