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

Commit d652c3a9 authored by Hui Yu's avatar Hui Yu
Browse files

updateOomAdjLocked() need to be called regardless outer block.

For detail reason, see b/151999776.

Bug: 151999776, 151883680
Test: atest cts/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java
atest cts/tests/app/src/android/app/cts/ActivityManagerApi29Test.java
atest cts/tests/app/src/android/app/cts/ActivityManagerFgsBgStartTest.java

Change-Id: I8d88c8fb2d7451e8e983bba82f185b5ed046fa46
parent d3de0b9f
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -17633,7 +17633,6 @@ public class ActivityManagerService extends IActivityManager.Stub
    @GuardedBy("this")
    final void updateProcessForegroundLocked(ProcessRecord proc, boolean isForeground,
            int fgServiceTypes, boolean oomAdj) {
        if (isForeground != proc.hasForegroundServices()
                || proc.getForegroundServiceTypes() != fgServiceTypes) {
            proc.setHasForegroundServices(isForeground, fgServiceTypes);
@@ -17666,12 +17665,11 @@ public class ActivityManagerService extends IActivityManager.Stub
            ProcessChangeItem item = enqueueProcessChangeItemLocked(proc.pid, proc.info.uid);
            item.changes = ProcessChangeItem.CHANGE_FOREGROUND_SERVICES;
            item.foregroundServiceTypes = fgServiceTypes;
        }
        if (oomAdj) {
            updateOomAdjLocked(proc, OomAdjuster.OOM_ADJ_REASON_UI_VISIBILITY);
        }
    }
    }
    // TODO(b/111541062): This method is only used for updating OOM adjustments. We need to update
    // the logic there and in mBatteryStatsService to make them aware of multiple resumed activities