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

Commit 1ee3db14 authored by Jing Ji's avatar Jing Ji
Browse files

Fix missing lock to the process state tracker

Bug: 163812139
Test: atest ProcStatsValidationTests
Test: atest ProcessStatsDumpsysTest
Test: atest CtsIncidentHostTestCases:ProcStatsProtoTest
Change-Id: I3c8ae0da441b61e3ce46d41629ea7aa195ac3c8e
parent 8423c029
Loading
Loading
Loading
Loading
+24 −19
Original line number Diff line number Diff line
@@ -1528,8 +1528,10 @@ public final class ProcessList {
                && proc.setProcState >= ActivityManager.PROCESS_STATE_CACHED_EMPTY
                && proc.lastCachedPss >= 4000) {
            // Turn this condition on to cause killing to happen regularly, for testing.
            synchronized (mService.mProcessStats.mLock) {
                if (proc.baseProcessTracker != null) {
                proc.baseProcessTracker.reportCachedKill(proc.pkgList.mPkgList, proc.lastCachedPss);
                    proc.baseProcessTracker.reportCachedKill(
                            proc.pkgList.mPkgList, proc.lastCachedPss);
                    for (int ipkg = proc.pkgList.size() - 1; ipkg >= 0; ipkg--) {
                        ProcessStats.ProcessStateHolder holder = proc.pkgList.valueAt(ipkg);
                        FrameworkStatsLog.write(FrameworkStatsLog.CACHED_KILL_REPORTED,
@@ -1539,6 +1541,7 @@ public final class ProcessList {
                                proc.lastCachedPss, holder.appVersion);
                    }
                }
            }
            proc.kill(Long.toString(proc.lastCachedPss) + "k from cached",
                    ApplicationExitInfo.REASON_OTHER,
                    ApplicationExitInfo.SUBREASON_LARGE_CACHED,
@@ -1549,6 +1552,7 @@ public final class ProcessList {
            if (DEBUG_PSS) Slog.d(TAG_PSS, "May not keep " + proc + ": pss=" + proc
                    .lastCachedPss);
            if (proc.lastCachedPss >= getCachedRestoreThresholdKb()) {
                synchronized (mService.mProcessStats.mLock) {
                    if (proc.baseProcessTracker != null) {
                        proc.baseProcessTracker.reportCachedKill(proc.pkgList.mPkgList,
                                proc.lastCachedPss);
@@ -1561,6 +1565,7 @@ public final class ProcessList {
                                    proc.lastCachedPss, holder.appVersion);
                        }
                    }
                }
                proc.kill(Long.toString(proc.lastCachedPss) + "k from cached",
                        ApplicationExitInfo.REASON_OTHER,
                        ApplicationExitInfo.SUBREASON_LARGE_CACHED,