summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@android.com>2014-11-05 19:06:25 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-05 19:06:25 +0000
commit8d37f7c1b28c4e82b3bc961d183c313db16d8333 (patch)
tree6dd4c7deefb689177134f7d963b97b6f8719dada /cmds
parent5468f292f31383ba1ea9b488e1d0dfc743764f47 (diff)
parent9647bdd97ec7fda804244bde195ca10219726e89 (diff)
downloadframeworks_base-8d37f7c1b28c4e82b3bc961d183c313db16d8333.zip
frameworks_base-8d37f7c1b28c4e82b3bc961d183c313db16d8333.tar.gz
frameworks_base-8d37f7c1b28c4e82b3bc961d183c313db16d8333.tar.bz2
am 9647bdd9: am 70bbbd32: Merge "More flexible intent extra parsing." into lmp-mr1-dev
* commit '9647bdd97ec7fda804244bde195ca10219726e89': More flexible intent extra parsing.
Diffstat (limited to 'cmds')
-rw-r--r--cmds/am/src/com/android/commands/am/Am.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java
index ba11a81..bc57030 100644
--- a/cmds/am/src/com/android/commands/am/Am.java
+++ b/cmds/am/src/com/android/commands/am/Am.java
@@ -417,7 +417,7 @@ public class Am extends BaseCommand {
} else if (opt.equals("--ei")) {
String key = nextArgRequired();
String value = nextArgRequired();
- intent.putExtra(key, Integer.valueOf(value));
+ intent.putExtra(key, Integer.decode(value));
} else if (opt.equals("--eu")) {
String key = nextArgRequired();
String value = nextArgRequired();
@@ -434,7 +434,7 @@ public class Am extends BaseCommand {
String[] strings = value.split(",");
int[] list = new int[strings.length];
for (int i = 0; i < strings.length; i++) {
- list[i] = Integer.valueOf(strings[i]);
+ list[i] = Integer.decode(strings[i]);
}
intent.putExtra(key, list);
} else if (opt.equals("--el")) {
@@ -477,8 +477,23 @@ public class Am extends BaseCommand {
hasIntentInfo = true;
} else if (opt.equals("--ez")) {
String key = nextArgRequired();
- String value = nextArgRequired();
- intent.putExtra(key, Boolean.valueOf(value));
+ String value = nextArgRequired().toLowerCase();
+ // Boolean.valueOf() results in false for anything that is not "true", which is
+ // error-prone in shell commands
+ boolean arg;
+ if ("true".equals(value) || "t".equals(value)) {
+ arg = true;
+ } else if ("false".equals(value) || "f".equals(value)) {
+ arg = false;
+ } else {
+ try {
+ arg = Integer.decode(value) != 0;
+ } catch (NumberFormatException ex) {
+ throw new IllegalArgumentException("Invalid boolean value: " + value);
+ }
+ }
+
+ intent.putExtra(key, arg);
} else if (opt.equals("-n")) {
String str = nextArgRequired();
ComponentName cn = ComponentName.unflattenFromString(str);