From e17aeb31030cfeed339a39a107912ad5e9178390 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Thu, 7 Apr 2011 15:11:57 -0700 Subject: Improve activity manager debug dumps. Activity manager now does all dump requests into apps asynchronously, so it can nicely timeout if there is an app problem. Also lots of general cleanup of the am dump output. Change-Id: Id0dbccffb217315aeb85c964e379833e6aa3f5af --- core/java/android/os/Binder.java | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'core/java/android/os/Binder.java') diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java index 7dc36f9..ae1e1c2 100644 --- a/core/java/android/os/Binder.java +++ b/core/java/android/os/Binder.java @@ -256,6 +256,25 @@ public class Binder implements IBinder { } /** + * Like {@link #dump(FileDescriptor, String[])}, but ensures the target + * executes asynchronously. + */ + public void dumpAsync(final FileDescriptor fd, final String[] args) { + final FileOutputStream fout = new FileOutputStream(fd); + final PrintWriter pw = new PrintWriter(fout); + Thread thr = new Thread("Binder.dumpAsync") { + public void run() { + try { + dump(fd, pw, args); + } finally { + pw.flush(); + } + } + }; + thr.start(); + } + + /** * Print the object's state into the given stream. * * @param fd The raw file descriptor that the dump is being sent to. @@ -364,6 +383,20 @@ final class BinderProxy implements IBinder { } } + public void dumpAsync(FileDescriptor fd, String[] args) throws RemoteException { + Parcel data = Parcel.obtain(); + Parcel reply = Parcel.obtain(); + data.writeFileDescriptor(fd); + data.writeStringArray(args); + try { + transact(DUMP_TRANSACTION, data, reply, FLAG_ONEWAY); + reply.readException(); + } finally { + data.recycle(); + reply.recycle(); + } + } + BinderProxy() { mSelf = new WeakReference(this); } -- cgit v1.1