public static void | dumpAsync(android.os.Handler handler, com.android.internal.util.DumpUtils$Dump dump, java.io.PrintWriter pw, long timeout)Helper for dumping state owned by a handler thread.
Because the caller might be holding an important lock that the handler is
trying to acquire, we use a short timeout to avoid deadlocks. The process
is inelegant but this function is only used for debugging purposes.
final StringWriter sw = new StringWriter();
if (handler.runWithScissors(new Runnable() {
@Override
public void run() {
PrintWriter lpw = new FastPrintWriter(sw);
dump.dump(lpw);
lpw.close();
}
}, timeout)) {
pw.print(sw.toString());
} else {
pw.println("... timed out");
}
|