From d1b29e838a7127378c68ec9b7bec224f4043e37c Mon Sep 17 00:00:00 2001 From: Marco Ballesio Date: Fri, 3 Apr 2020 11:41:38 -0700 Subject: [PATCH] freezer: disable on "am dumpheap " heapDump() is used to collect process heaps via "am dumpheap ". It is alternative to "dumpsys meminfo" and would hang if called on a frozen process. In this patch: - disable freezer before the binder transaction to collect heap data - install a man-in-the-middle callback to handle completion of collection. The new callback will invoke the original one from the client and then enable the freezer again. Change-Id: I43f501a88a7325d1bd2b3d1c6eb4a4d03b97a691 Test: am dumpheap Bug: 151225245 --- .../android/server/am/ActivityManagerService.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 85d288317b6ab..62d7eb1d04489 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -18376,7 +18376,18 @@ public class ActivityManagerService extends IActivityManager.Stub } } - proc.thread.dumpHeap(managed, mallocInfo, runGc, path, fd, finishCallback); + Process.enableFreezer(false); + + final RemoteCallback intermediateCallback = new RemoteCallback( + new RemoteCallback.OnResultListener() { + @Override + public void onResult(Bundle result) { + finishCallback.sendResult(result); + Process.enableFreezer(true); + } + }, null); + + proc.thread.dumpHeap(managed, mallocInfo, runGc, path, fd, intermediateCallback); fd = null; return true; }