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

Commit 351f3227 authored by Xianzhu Wang's avatar Xianzhu Wang
Browse files

Add force-stop subcommand for 'am'.

It's useful for some testing and debugging, to ensure all processes
are stopped before testing. 'kill' doesn't always work because sometimes the
system will restart the process immediately (e.g. if an app is running in
background).

Change-Id: I2c0caa38f74ee65ad6c35172fbf505227be7e7c3
parent 8eed7ade
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -98,6 +98,8 @@ public class Am {
            runStart();
        } else if (op.equals("startservice")) {
            runStartService();
        } else if (op.equals("force-stop")) {
            runForceStop();
        } else if (op.equals("instrument")) {
            runInstrument();
        } else if (op.equals("broadcast")) {
@@ -365,6 +367,10 @@ public class Am {
        }
    }

    private void runForceStop() throws Exception {
        mAm.forceStopPackage(nextArgRequired());
    }

    private void sendBroadcast() throws Exception {
        Intent intent = makeIntent();
        IntentReceiver receiver = new IntentReceiver();
@@ -1013,6 +1019,8 @@ public class Am {
                "\n" +
                "    start a Service: am startservice <INTENT>\n" +
                "\n" +
                "    force stop everything associated with a package: force-stop <package>\n" +
                "\n" +
                "    send a broadcast Intent: am broadcast <INTENT>\n" +
                "\n" +
                "    start an Instrumentation: am instrument [flags] <COMPONENT>\n" +