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

Commit 9d56bc12 authored by Hyunyoung Song's avatar Hyunyoung Song
Browse files

Do not add unnecessary prefix to dumpsys activity provider [NAME] --proto

Bug: 36904684
Test: builds, and tests succeed in the same topic branch

The test executes following
"dumpsys activity provider [launcher package name]/[provider name that implements workspace dump logging]
--proto"

In order to extract the proto binary from this stream, there cannot
be extra prefix added to each line. Hence, when "--proto" flag
is on, simply call the sub provider record's dump method.

This is following same pattern on other system service dump.
Having --proto flag also doesn't do any pretty printing.
e.g., dumpsys appwidget --proto.

Change-Id: I13712a45ce5b584123b3bd73c023df349fb86809
parent 54ddf4a4
Loading
Loading
Loading
Loading
+41 −21
Original line number Diff line number Diff line
@@ -382,18 +382,29 @@ public final class ProviderMap {
    }

    /**
     * Invokes IApplicationThread.dumpProvider() on the thread of the specified provider if
     * there is a thread associated with the provider.
     * Before invoking IApplicationThread.dumpProvider(), print meta information to the print
     * writer and handle passed flags.
     */
    private void dumpProvider(String prefix, FileDescriptor fd, PrintWriter pw,
            final ContentProviderRecord r, String[] args, boolean dumpAll) {
        for (String s: args) {
            if (!dumpAll && s.contains("--proto")) {
                if (r.proc != null && r.proc.thread != null) {
                    dumpToTransferPipe(null , fd, pw, r, args);
                }
                return;
            }
        }
        String innerPrefix = prefix + "  ";
        synchronized (mAm) {
            pw.print(prefix); pw.print("PROVIDER ");
            pw.print(r);
            pw.print(" pid=");
                    if (r.proc != null) pw.println(r.proc.pid);
                    else pw.println("(not running)");
            if (r.proc != null) {
                pw.println(r.proc.pid);
            } else {
                pw.println("(not running)");
            }
            if (dumpAll) {
                r.dump(pw, innerPrefix, true);
            }
@@ -401,12 +412,22 @@ public final class ProviderMap {
        if (r.proc != null && r.proc.thread != null) {
            pw.println("    Client:");
            pw.flush();
            dumpToTransferPipe("      ", fd, pw, r, args);
        }
    }

    /**
     * Invokes IApplicationThread.dumpProvider() on the thread of the specified provider without
     * any meta string (e.g., provider info, indentation) written to the file descriptor.
     */
    private void dumpToTransferPipe(String prefix, FileDescriptor fd, PrintWriter pw,
            final ContentProviderRecord r, String[] args) {
        try {
            TransferPipe tp = new TransferPipe();
            try {
                r.proc.thread.dumpProvider(
                    tp.getWriteFd(), r.provider.asBinder(), args);
                    tp.setBufferPrefix("      ");
                tp.setBufferPrefix(prefix);
                // Short timeout, since blocking here can
                // deadlock with the application.
                tp.go(fd, 2000);
@@ -420,4 +441,3 @@ public final class ProviderMap {
        }
    }
}
}