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

This commit is contained in:
TreeHugger Robot
2017-05-31 21:07:03 +00:00
committed by Android (Google) Code Review

View File

@@ -382,18 +382,29 @@ public final class ProviderMap {
} }
/** /**
* Invokes IApplicationThread.dumpProvider() on the thread of the specified provider if * Before invoking IApplicationThread.dumpProvider(), print meta information to the print
* there is a thread associated with the provider. * writer and handle passed flags.
*/ */
private void dumpProvider(String prefix, FileDescriptor fd, PrintWriter pw, private void dumpProvider(String prefix, FileDescriptor fd, PrintWriter pw,
final ContentProviderRecord r, String[] args, boolean dumpAll) { 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 + " "; String innerPrefix = prefix + " ";
synchronized (mAm) { synchronized (mAm) {
pw.print(prefix); pw.print("PROVIDER "); pw.print(prefix); pw.print("PROVIDER ");
pw.print(r); pw.print(r);
pw.print(" pid="); pw.print(" pid=");
if (r.proc != null) pw.println(r.proc.pid); if (r.proc != null) {
else pw.println("(not running)"); pw.println(r.proc.pid);
} else {
pw.println("(not running)");
}
if (dumpAll) { if (dumpAll) {
r.dump(pw, innerPrefix, true); r.dump(pw, innerPrefix, true);
} }
@@ -401,23 +412,32 @@ public final class ProviderMap {
if (r.proc != null && r.proc.thread != null) { if (r.proc != null && r.proc.thread != null) {
pw.println(" Client:"); pw.println(" Client:");
pw.flush(); 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 { try {
TransferPipe tp = new TransferPipe(); r.proc.thread.dumpProvider(
try { tp.getWriteFd(), r.provider.asBinder(), args);
r.proc.thread.dumpProvider( tp.setBufferPrefix(prefix);
tp.getWriteFd(), r.provider.asBinder(), args); // Short timeout, since blocking here can
tp.setBufferPrefix(" "); // deadlock with the application.
// Short timeout, since blocking here can tp.go(fd, 2000);
// deadlock with the application. } finally {
tp.go(fd, 2000); tp.kill();
} finally {
tp.kill();
}
} catch (IOException ex) {
pw.println(" Failure while dumping the provider: " + ex);
} catch (RemoteException ex) {
pw.println(" Got a RemoteException while dumping the service");
} }
} catch (IOException ex) {
pw.println(" Failure while dumping the provider: " + ex);
} catch (RemoteException ex) {
pw.println(" Got a RemoteException while dumping the service");
} }
} }
} }