am a6dd714a: Merge "Added new options (--eial, --elal, --efal, and --esal) to pass multiple extras as ArrayList instead of Array. BUG: 21757911 Change-Id: I7e2a9c81ad4606a8aba90ea4820ba0732a1c8749 modified: src/com/android/commands/am/Am.java On branch handles_arr

* commit 'a6dd714a5ab620cf5b84c2d1f680ddacf763559d':
  Added new options (--eial, --elal, --efal, and --esal) to pass multiple extras as ArrayList instead of Array. BUG: 21757911 Change-Id: I7e2a9c81ad4606a8aba90ea4820ba0732a1c8749 	modified:   src/com/android/commands/am/Am.java  On branch handles_array_list  Changes to be committed: 	modified:   src/com/android/commands/am/Am.java
This commit is contained in:
Felipe Leme
2015-06-10 21:04:51 +00:00
committed by Android Git Automerger

View File

@@ -305,11 +305,23 @@ public class Am extends BaseCommand {
" [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]\n" +
" [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]\n" +
" [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]\n" +
" (mutiple extras passed as Integer[])\n" +
" [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]\n" +
" (mutiple extras passed as List<Integer>)\n" +
" [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]\n" +
" (mutiple extras passed as Long[])\n" +
" [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]\n" +
" (mutiple extras passed as List<Long>)\n" +
" [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]\n" +
" (mutiple extras passed as Float[])\n" +
" [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]\n" +
" (mutiple extras passed as List<Float>)\n" +
" [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]\n" +
" (to embed a comma into a string escape it using \"\\,\")\n" +
" [-n <COMPONENT>] [-p <PACKAGE>] [-f <FLAGS>]\n" +
" (mutiple extras passed as String[]; to embed a comma into a string,\n" +
" escape it using \"\\,\")\n" +
" [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]\n" +
" (mutiple extras passed as List<String>; to embed a comma into a string,\n" +
" escape it using \"\\,\")\n" +
" [--grant-read-uri-permission] [--grant-write-uri-permission]\n" +
" [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]\n" +
" [--debug-log-resolution] [--exclude-stopped-packages]\n" +
@@ -490,6 +502,15 @@ public class Am extends BaseCommand {
list[i] = Integer.decode(strings[i]);
}
intent.putExtra(key, list);
} else if (opt.equals("--eial")) {
String key = nextArgRequired();
String value = nextArgRequired();
String[] strings = value.split(",");
ArrayList<Integer> list = new ArrayList<>(strings.length);
for (int i = 0; i < strings.length; i++) {
list.add(Integer.decode(strings[i]));
}
intent.putExtra(key, list);
} else if (opt.equals("--el")) {
String key = nextArgRequired();
String value = nextArgRequired();
@@ -504,6 +525,16 @@ public class Am extends BaseCommand {
}
intent.putExtra(key, list);
hasIntentInfo = true;
} else if (opt.equals("--elal")) {
String key = nextArgRequired();
String value = nextArgRequired();
String[] strings = value.split(",");
ArrayList<Long> list = new ArrayList<>(strings.length);
for (int i = 0; i < strings.length; i++) {
list.add(Long.valueOf(strings[i]));
}
intent.putExtra(key, list);
hasIntentInfo = true;
} else if (opt.equals("--ef")) {
String key = nextArgRequired();
String value = nextArgRequired();
@@ -519,6 +550,16 @@ public class Am extends BaseCommand {
}
intent.putExtra(key, list);
hasIntentInfo = true;
} else if (opt.equals("--efal")) {
String key = nextArgRequired();
String value = nextArgRequired();
String[] strings = value.split(",");
ArrayList<Float> list = new ArrayList<>(strings.length);
for (int i = 0; i < strings.length; i++) {
list.add(Float.valueOf(strings[i]));
}
intent.putExtra(key, list);
hasIntentInfo = true;
} else if (opt.equals("--esa")) {
String key = nextArgRequired();
String value = nextArgRequired();
@@ -528,6 +569,19 @@ public class Am extends BaseCommand {
String[] strings = value.split("(?<!\\\\),");
intent.putExtra(key, strings);
hasIntentInfo = true;
} else if (opt.equals("--esal")) {
String key = nextArgRequired();
String value = nextArgRequired();
// Split on commas unless they are preceeded by an escape.
// The escape character must be escaped for the string and
// again for the regex, thus four escape characters become one.
String[] strings = value.split("(?<!\\\\),");
ArrayList<String> list = new ArrayList<>(strings.length);
for (int i = 0; i < strings.length; i++) {
list.add(strings[i]);
}
intent.putExtra(key, list);
hasIntentInfo = true;
} else if (opt.equals("--ez")) {
String key = nextArgRequired();
String value = nextArgRequired().toLowerCase();