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

Commit bfc71f61 authored by Jing Ji's avatar Jing Ji
Browse files

Fix: java process gets included in native section of meminfo dump

The window between collecting java processes and cpu stats is too
big, some java processes could get started during that window and
get included into the native section of the meminfo dump.

Bug: 139449460
Test: Manual
      1) Power cycle the device, and right after powering up:
      2) adb shell dumpsys meminfo
Change-Id: I846b0b9d19303f749752637fbcf767de4222a2fe
parent 4969b938
Loading
Loading
Loading
Loading
+18 −10
Original line number Diff line number Diff line
@@ -12506,6 +12506,13 @@ public class ActivityManagerService extends IActivityManager.Stub
        if (!brief && !opts.oomOnly && (procs.size() == 1 || opts.isCheckinRequest || opts.packages)) {
            opts.dumpDetails = true;
        }
        final int numProcs = procs.size();
        final boolean collectNative = !opts.isCheckinRequest && numProcs > 1 && !opts.packages;
        if (collectNative) {
            // If we are showing aggregations, also look for native processes to
            // include so that our aggregations are more accurate.
            updateCpuStatsNow();
        }
        dumpApplicationMemoryUsageHeader(pw, uptime, realtime, opts.isCheckinRequest, opts.isCompact);
@@ -12544,7 +12551,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        boolean hasSwapPss = false;
        Debug.MemoryInfo mi = null;
        for (int i = procs.size() - 1 ; i >= 0 ; i--) {
        for (int i = numProcs - 1; i >= 0; i--) {
            final ProcessRecord r = procs.get(i);
            final IApplicationThread thread;
            final int pid;
@@ -12698,10 +12705,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        long nativeProcTotalPss = 0;
        if (!opts.isCheckinRequest && procs.size() > 1 && !opts.packages) {
            // If we are showing aggregations, also look for native processes to
            // include so that our aggregations are more accurate.
            updateCpuStatsNow();
        if (collectNative) {
            mi = null;
            synchronized (mProcessCpuTracker) {
                final int N = mProcessCpuTracker.countStats();
@@ -13069,6 +13073,13 @@ public class ActivityManagerService extends IActivityManager.Stub
        if (!brief && !opts.oomOnly && (procs.size() == 1 || opts.isCheckinRequest || opts.packages)) {
            opts.dumpDetails = true;
        }
        final int numProcs = procs.size();
        final boolean collectNative = numProcs > 1 && !opts.packages;
        if (collectNative) {
            // If we are showing aggregations, also look for native processes to
            // include so that our aggregations are more accurate.
            updateCpuStatsNow();
        }
        ProtoOutputStream proto = new ProtoOutputStream(fd);
@@ -13110,7 +13121,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        boolean hasSwapPss = false;
        Debug.MemoryInfo mi = null;
        for (int i = procs.size() - 1 ; i >= 0 ; i--) {
        for (int i = numProcs - 1; i >= 0; i--) {
            final ProcessRecord r = procs.get(i);
            final IApplicationThread thread;
            final int pid;
@@ -13257,10 +13268,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        long nativeProcTotalPss = 0;
        if (procs.size() > 1 && !opts.packages) {
            // If we are showing aggregations, also look for native processes to
            // include so that our aggregations are more accurate.
            updateCpuStatsNow();
        if (collectNative) {
            mi = null;
            synchronized (mProcessCpuTracker) {
                final int N = mProcessCpuTracker.countStats();