Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a6dd714a authored by Felipe Leme's avatar Felipe Leme Committed by Android (Google) Code Review
Browse files

Merge "Added new options (--eial, --elal, --efal, and --esal) to pass multiple...

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_array_list  Changes to be committed: 	modified:   src/com/android/commands/am/Am.java" into mnc-dev
parents 7cbe9f03 f36a0f5d
Loading
Loading
Loading
Loading
+56 −2
Original line number Diff line number Diff line
@@ -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();