am 77ce60a5: am 7789c9bb: Merge "Support pm clear as --user." into jb-mr1-dev

* commit '77ce60a59330d6059011d737142bd210db845d85':
  Support pm clear as --user.
This commit is contained in:
Jeff Sharkey
2012-10-15 20:19:04 -07:00
committed by Android Git Automerger

View File

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