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

Commit 7db56af8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Do not add unnecessary prefix to dumpsys activity provider [NAME] --proto" into oc-dev

parents f296105e 9d56bc12
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 {
        }
    }
}
}