Fix a bug about AppProfiler / setMemFactorLocked.

Bug: 278925800
Test: atest ActiveServicesTest
Change-Id: Icf83ac0d561b1d1791c106f7f33d2a84c355d4d4
This commit is contained in:
Yu-Ting Tseng
2023-05-23 11:24:53 -07:00
parent c8196383a2
commit 6c2b9614be

View File

@@ -1202,6 +1202,14 @@ public class AppProfiler {
mCachedAppsWatermarkData.updateCachedAppsHighWatermarkIfNecessaryLocked(
numCached + numEmpty, now);
boolean allChanged;
int trackerMemFactor;
synchronized (mService.mProcessStats.mLock) {
allChanged = mService.mProcessStats.setMemFactorLocked(memFactor,
mService.mAtmInternal == null || !mService.mAtmInternal.isSleeping(),
SystemClock.uptimeMillis() /* re-acquire the time within the lock */);
trackerMemFactor = mService.mProcessStats.getMemFactorLocked();
}
if (mService.mConstants.USE_MODERN_TRIM) {
// Modern trim is not sent based on lowmem state
@@ -1235,14 +1243,6 @@ public class AppProfiler {
mLastMemoryLevel = memFactor;
mLastNumProcesses = mService.mProcessList.getLruSizeLOSP();
boolean allChanged;
int trackerMemFactor;
synchronized (mService.mProcessStats.mLock) {
allChanged = mService.mProcessStats.setMemFactorLocked(memFactor,
mService.mAtmInternal == null || !mService.mAtmInternal.isSleeping(),
SystemClock.uptimeMillis() /* re-acquire the time within the lock */);
trackerMemFactor = mService.mProcessStats.getMemFactorLocked();
}
if (memFactor != ADJ_MEM_FACTOR_NORMAL) {
if (mLowRamStartTime == 0) {
mLowRamStartTime = now;