Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1b29e83 authored by Marco Ballesio's avatar Marco Ballesio
Browse files

freezer: disable on "am dumpheap <pid>"

heapDump() is used to collect process heaps via "am dumpheap <pid>". 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 <frozen process pid>
Bug: 151225245
parent 7d00ba0d
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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;
            }