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

Commit 69acb6b7 authored by Jean-Baptiste Queru's avatar Jean-Baptiste Queru
Browse files

Unify am startservice commands.

This replaces the implementation with an equivalent one.

Change-Id: I1343ddee9414a67906cd426b8381ddbace873894
parent d4dd85d5
Loading
Loading
Loading
Loading
+12 −14
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ public class Am {

        if (op.equals("start")) {
            runStart();
        } else if (op.equals("start-service")) {
        } else if (op.equals("startservice")) {
            runStartService();
        } else if (op.equals("instrument")) {
            runInstrument();
@@ -181,6 +181,15 @@ public class Am {
        return intent;
    }

    private void runStartService() throws Exception {
        Intent intent = makeIntent();
        System.out.println("Starting service: " + intent);
        ComponentName cn = mAm.startService(null, intent, intent.getType());
        if (cn == null) {
            System.err.println("Error: Not found; no service started.");
        }
    }

    private void runStart() throws Exception {
        Intent intent = makeIntent();
        System.out.println("Starting: " + intent);
@@ -240,19 +249,6 @@ public class Am {
        }
    }

    private void runStartService() throws Exception {
        Intent intent = makeIntent();

        if (intent != null) {
            System.out.println("Starting: " + intent);
            try {
                mAm.startService(null, intent, intent.getType());
            } catch (Exception e) {
                System.err.println("Error: " + e);
            }
        }
    }

    private void sendBroadcast() throws Exception {
        Intent intent = makeIntent();
        IntentReceiver receiver = new IntentReceiver();
@@ -507,6 +503,8 @@ public class Am {
                "    start an Activity: am start [-D] <INTENT>\n" +
                "        -D: enable debugging\n" +
                "\n" +
                "    start a Service: am startservice <INTENT>\n" +
                "\n" +
                "    send a broadcast Intent: am broadcast <INTENT>\n" +
                "\n" +
                "    start an Instrumentation: am instrument [flags] <COMPONENT>\n" +