diff options
| author | Marco Nelissen <marcone@google.com> | 2011-11-15 11:19:53 -0800 |
|---|---|---|
| committer | Marco Nelissen <marcone@google.com> | 2011-12-15 12:13:59 -0800 |
| commit | 18cb28756caf02bf2b2f5e67c68451edaf719b47 (patch) | |
| tree | 14de3eb7cea27a7928b5dbc78f6e73780859fddc /core/java/android/app/ActivityThread.java | |
| parent | 8a0a72c7c18d1143983cea1c49b666f534262fa1 (diff) | |
Add ContentProvider.dump()
This is similar to the existing dump() facility for services.
ContentProviders can now implement dump() and that info will be shown
when running "dumpsys activity provider" and when taking a bugreport.
Change-Id: I33b3b132e3c4f920153355cc368eda2f725a715f
Diffstat (limited to 'core/java/android/app/ActivityThread.java')
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 0c761fc4b7e3..9e88bc6e8442 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -813,6 +813,19 @@ public final class ActivityThread { } } + public void dumpProvider(FileDescriptor fd, IBinder providertoken, + String[] args) { + DumpComponentInfo data = new DumpComponentInfo(); + try { + data.fd = ParcelFileDescriptor.dup(fd); + data.token = providertoken; + data.args = args; + queueOrSendMessage(H.DUMP_PROVIDER, data); + } catch (IOException e) { + Slog.w(TAG, "dumpProvider failed", e); + } + } + @Override public Debug.MemoryInfo dumpMemInfo(FileDescriptor fd, boolean checkin, boolean all, String[] args) { @@ -1044,6 +1057,7 @@ public final class ActivityThread { public void scheduleTrimMemory(int level) { queueOrSendMessage(H.TRIM_MEMORY, null, level); } + } private class H extends Handler { @@ -1088,6 +1102,7 @@ public final class ActivityThread { public static final int SET_CORE_SETTINGS = 138; public static final int UPDATE_PACKAGE_COMPATIBILITY_INFO = 139; public static final int TRIM_MEMORY = 140; + public static final int DUMP_PROVIDER = 141; String codeToString(int code) { if (DEBUG_MESSAGES) { switch (code) { @@ -1132,6 +1147,7 @@ public final class ActivityThread { case SET_CORE_SETTINGS: return "SET_CORE_SETTINGS"; case UPDATE_PACKAGE_COMPATIBILITY_INFO: return "UPDATE_PACKAGE_COMPATIBILITY_INFO"; case TRIM_MEMORY: return "TRIM_MEMORY"; + case DUMP_PROVIDER: return "DUMP_PROVIDER"; } } return "(unknown)"; @@ -1264,6 +1280,9 @@ public final class ActivityThread { case DUMP_ACTIVITY: handleDumpActivity((DumpComponentInfo)msg.obj); break; + case DUMP_PROVIDER: + handleDumpProvider((DumpComponentInfo)msg.obj); + break; case SLEEPING: handleSleeping((IBinder)msg.obj, msg.arg1 != 0); break; @@ -2347,6 +2366,19 @@ public final class ActivityThread { } } + private void handleDumpProvider(DumpComponentInfo info) { + ProviderClientRecord r = mLocalProviders.get(info.token); + if (r != null && r.mLocalProvider != null) { + PrintWriter pw = new PrintWriter(new FileOutputStream(info.fd.getFileDescriptor())); + r.mLocalProvider.dump(info.fd.getFileDescriptor(), pw, info.args); + pw.flush(); + try { + info.fd.close(); + } catch (IOException e) { + } + } + } + private void handleServiceArgs(ServiceArgsData data) { Service s = mServices.get(data.token); if (s != null) { |
