diff options
author | Dan Egnor <egnor@google.com> | 2010-03-05 13:28:36 -0800 |
---|---|---|
committer | Dan Egnor <egnor@google.com> | 2010-03-08 12:13:11 -0800 |
commit | 3eda9799a162765dd49f481cc303fc5702a9c5fe (patch) | |
tree | 4f5cd7c7b4468dbc5a2f70a8a4747a2084fc7791 /core/java | |
parent | e879e4b9145fb05a7a7a478cbef681b0436bc49a (diff) | |
download | frameworks_base-3eda9799a162765dd49f481cc303fc5702a9c5fe.zip frameworks_base-3eda9799a162765dd49f481cc303fc5702a9c5fe.tar.gz frameworks_base-3eda9799a162765dd49f481cc303fc5702a9c5fe.tar.bz2 |
Add Debug.dumpService(), a public method for "dumpsys" functionality
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/os/Debug.java | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java index a4c595d..2e14667 100644 --- a/core/java/android/os/Debug.java +++ b/core/java/android/os/Debug.java @@ -57,6 +57,8 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo */ public final class Debug { + private static final String TAG = "Debug"; + /** * Flags for startMethodTracing(). These can be ORed together. * @@ -1111,7 +1113,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo } } } else { - Log.w("android.os.Debug", + Log.wtf(TAG, "setFieldsOn(" + (cl == null ? "null" : cl.getName()) + ") called in non-DEBUG build"); } @@ -1127,4 +1129,31 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo @Retention(RetentionPolicy.RUNTIME) public @interface DebugProperty { } + + /** + * Get a debugging dump of a system service by name. + * + * <p>Most services require the caller to hold android.permission.DUMP. + * + * @param name of the service to dump + * @param fd to write dump output to (usually an output log file) + * @param args to pass to the service's dump method, may be null + * @return true if the service was dumped successfully, false if + * the service could not be found or had an error while dumping + */ + public static boolean dumpService(String name, FileDescriptor fd, String[] args) { + IBinder service = ServiceManager.getService(name); + if (service == null) { + Log.e(TAG, "Can't find service to dump: " + name); + return false; + } + + try { + service.dump(fd, args); + return true; + } catch (RemoteException e) { + Log.e(TAG, "Can't dump service: " + name, e); + return false; + } + } } |