Merge "Fixes for sm and pm usage" am: ffb15da518 am: 671d5965f7

am: f73e78fe1c

* commit 'f73e78fe1cb6803a29f7f85b49792f4e8a7350c8':
  Fixes for sm and pm usage
This commit is contained in:
Brian Carlstrom
2015-11-05 18:55:49 +00:00
committed by android-build-merger
2 changed files with 27 additions and 52 deletions

View File

@@ -324,8 +324,7 @@ public final class Pm {
String optionData = nextOptionData();
if (optionData == null || !isNumber(optionData)) {
System.err.println("Error: no USER_ID specified");
showUsage();
return 1;
return showUsage();
} else {
userId = Integer.parseInt(optionData);
}
@@ -428,8 +427,7 @@ public final class Pm {
}
} else {
System.err.println("Error: unknown option: " + opt);
showUsage();
return 1;
return showUsage();
}
}
@@ -437,16 +435,14 @@ public final class Pm {
final String pkg = nextArg();
if (pkg == null) {
System.err.println("Error: no package specified.");
showUsage();
return 1;
return showUsage();
}
// State to apply; {always|ask|never|undefined}, required
final String modeString = nextArg();
if (modeString == null) {
System.err.println("Error: no app link state specified.");
showUsage();
return 1;
return showUsage();
}
final int newMode;
@@ -515,8 +511,7 @@ public final class Pm {
}
} else {
System.err.println("Error: unknown option: " + opt);
showUsage();
return 1;
return showUsage();
}
}
@@ -524,8 +519,7 @@ public final class Pm {
final String pkg = nextArg();
if (pkg == null) {
System.err.println("Error: no package specified.");
showUsage();
return 1;
return showUsage();
}
try {
@@ -942,8 +936,7 @@ public final class Pm {
String optionData = nextOptionData();
if (optionData == null || !isNumber(optionData)) {
System.err.println("Error: no USER_ID specified");
showUsage();
return 1;
return showUsage();
} else {
userId = Integer.parseInt(optionData);
}
@@ -953,8 +946,7 @@ public final class Pm {
flags |= UserInfo.FLAG_RESTRICTED;
} else {
System.err.println("Error: unknown option " + opt);
showUsage();
return 1;
return showUsage();
}
}
String arg = nextArg();
@@ -1114,8 +1106,7 @@ public final class Pm {
String pkg = nextArg();
if (pkg == null) {
System.err.println("Error: no package specified");
showUsage();
return 1;
return showUsage();
}
userId = translateUserId(userId, "runUninstall");
@@ -1184,8 +1175,7 @@ public final class Pm {
String optionData = nextOptionData();
if (optionData == null || !isNumber(optionData)) {
System.err.println("Error: no USER_ID specified");
showUsage();
return 1;
return showUsage();
} else {
userId = Integer.parseInt(optionData);
}
@@ -1194,8 +1184,7 @@ public final class Pm {
String pkg = nextArg();
if (pkg == null) {
System.err.println("Error: no package specified");
showUsage();
return 1;
return showUsage();
}
ClearDataObserver obs = new ClearDataObserver();
@@ -1256,8 +1245,7 @@ public final class Pm {
String optionData = nextOptionData();
if (optionData == null || !isNumber(optionData)) {
System.err.println("Error: no USER_ID specified");
showUsage();
return 1;
return showUsage();
} else {
userId = Integer.parseInt(optionData);
}
@@ -1266,8 +1254,7 @@ public final class Pm {
String pkg = nextArg();
if (pkg == null) {
System.err.println("Error: no package or component specified");
showUsage();
return 1;
return showUsage();
}
ComponentName cn = ComponentName.unflattenFromString(pkg);
if (cn == null) {
@@ -1305,8 +1292,7 @@ public final class Pm {
String optionData = nextOptionData();
if (optionData == null || !isNumber(optionData)) {
System.err.println("Error: no USER_ID specified");
showUsage();
return 1;
return showUsage();
} else {
userId = Integer.parseInt(optionData);
}
@@ -1315,8 +1301,7 @@ public final class Pm {
String pkg = nextArg();
if (pkg == null) {
System.err.println("Error: no package or component specified");
showUsage();
return 1;
return showUsage();
}
try {
mPm.setApplicationHiddenSettingAsUser(pkg, state, userId);
@@ -1343,14 +1328,12 @@ public final class Pm {
String pkg = nextArg();
if (pkg == null) {
System.err.println("Error: no package specified");
showUsage();
return 1;
return showUsage();
}
String perm = nextArg();
if (perm == null) {
System.err.println("Error: no permission specified");
showUsage();
return 1;
return showUsage();
}
try {
@@ -1366,8 +1349,7 @@ public final class Pm {
return 1;
} catch (IllegalArgumentException e) {
System.err.println("Bad argument: " + e.toString());
showUsage();
return 1;
return showUsage();
} catch (SecurityException e) {
System.err.println("Operation not allowed: " + e.toString());
return 1;
@@ -1384,8 +1366,7 @@ public final class Pm {
return 1;
} catch (IllegalArgumentException e) {
System.err.println("Bad argument: " + e.toString());
showUsage();
return 1;
return showUsage();
} catch (SecurityException e) {
System.err.println("Operation not allowed: " + e.toString());
return 1;
@@ -1396,14 +1377,12 @@ public final class Pm {
final String permission = nextArg();
if (permission == null) {
System.err.println("Error: no permission specified");
showUsage();
return 1;
return showUsage();
}
final String enforcedRaw = nextArg();
if (enforcedRaw == null) {
System.err.println("Error: no enforcement specified");
showUsage();
return 1;
return showUsage();
}
final boolean enforced = Boolean.parseBoolean(enforcedRaw);
try {
@@ -1415,8 +1394,7 @@ public final class Pm {
return 1;
} catch (IllegalArgumentException e) {
System.err.println("Bad argument: " + e.toString());
showUsage();
return 1;
return showUsage();
} catch (SecurityException e) {
System.err.println("Operation not allowed: " + e.toString());
return 1;
@@ -1442,8 +1420,7 @@ public final class Pm {
String size = nextArg();
if (size == null) {
System.err.println("Error: no size specified");
showUsage();
return 1;
return showUsage();
}
int len = size.length();
long multiplier = 1;
@@ -1457,8 +1434,7 @@ public final class Pm {
multiplier = 1024L*1024L*1024L;
} else {
System.err.println("Invalid suffix: " + c);
showUsage();
return 1;
return showUsage();
}
size = size.substring(0, len-1);
}
@@ -1467,8 +1443,7 @@ public final class Pm {
sizeVal = Long.parseLong(size) * multiplier;
} catch (NumberFormatException e) {
System.err.println("Error: expected number at: " + size);
showUsage();
return 1;
return showUsage();
}
String volumeUuid = nextArg();
if ("internal".equals(volumeUuid)) {
@@ -1492,8 +1467,7 @@ public final class Pm {
return 1;
} catch (IllegalArgumentException e) {
System.err.println("Bad argument: " + e.toString());
showUsage();
return 1;
return showUsage();
} catch (SecurityException e) {
System.err.println("Operation not allowed: " + e.toString());
return 1;

View File

@@ -42,6 +42,7 @@ public final class Sm {
} catch (Exception e) {
if (e instanceof IllegalArgumentException) {
showUsage();
System.exit(1);
}
Log.e(TAG, "Error", e);
System.err.println("Error: " + e);