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

Commit eb95b087 authored by Joe Onorato's avatar Joe Onorato
Browse files

Show app services in adb bugreport (dumpstate).

There is a 60s timeout for this command.  I'd rather do it as an individual timeout
for each of the services, but this is easier and will probably cover for busted apps
well enough.  Also, this is running last in dumpstate, so if it's lost... oh well.

Also, clean up the formatting of the service dump so it's more readable in bugreport.

Change-Id: Ibd727f4b3366f7af9e7ef1e231868f5cedc48132
parent 8d008342
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -174,6 +174,14 @@ static void dumpstate() {
       to increase its timeout.  we really need to do the timeouts in
       dumpsys itself... */
    run_command("DUMPSYS", 60, "dumpsys", NULL);

    printf("========================================================\n");
    printf("== Application Services\n");
    printf("========================================================\n");

    /* Instead of a 60s timeout, we should give each service a 5 second timeout */
    run_command("APP SERVICES", 60, "dumpsys", "activity", "service", NULL);

}

static void usage() {
+8 −15
Original line number Diff line number Diff line
@@ -7284,7 +7284,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                }
                return;
            } else if ("service".equals(cmd)) {
                dumpService(fd, pw, args, opti, dumpAll);
                dumpService(fd, pw, args, opti);
                return;
            } else if ("services".equals(cmd) || "s".equals(cmd)) {
                synchronized (this) {
@@ -7643,8 +7643,7 @@ public final class ActivityManagerService extends ActivityManagerNative
     *  - the first arg isn't the flattened component name of an existing service:
     *    dump all services whose component contains the first arg as a substring
     */
    protected void dumpService(FileDescriptor fd, PrintWriter pw, String[] args,
            int opti, boolean dumpAll) {
    protected void dumpService(FileDescriptor fd, PrintWriter pw, String[] args, int opti) {
        String[] newArgs;
        String componentNameString;
        ServiceRecord r;
@@ -7664,7 +7663,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
        if (r != null) {
            dumpService(fd, pw, r, newArgs, dumpAll);
            dumpService(fd, pw, r, newArgs);
        } else {
            ArrayList<ServiceRecord> services = new ArrayList<ServiceRecord>();
            synchronized (this) {
@@ -7676,7 +7675,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                }
            }
            for (int i=0; i<services.size(); i++) {
                dumpService(fd, pw, services.get(i), newArgs, dumpAll);
                dumpService(fd, pw, services.get(i), newArgs);
            }
        }
    }
@@ -7685,16 +7684,10 @@ public final class ActivityManagerService extends ActivityManagerNative
     * Invokes IApplicationThread.dumpService() on the thread of the specified service if
     * there is a thread associated with the service.
     */
    private void dumpService(FileDescriptor fd, PrintWriter pw, ServiceRecord r, String[] args,
            boolean dumpAll) {
        pw.println("  Service " + r.name.flattenToString());
        if (dumpAll) {
            synchronized (this) {
                pw.print("  * "); pw.println(r);
                r.dump(pw, "    ");
            }
            pw.println("");
        }
    private void dumpService(FileDescriptor fd, PrintWriter pw, ServiceRecord r, String[] args) {
        pw.println("------------------------------------------------------------"
                + "-------------------");
        pw.println("APP SERVICE: " + r.name.flattenToString());
        if (r.app != null && r.app.thread != null) {
            try {
                // flush anything that is already in the PrintWriter since the thread is going