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

Commit ca97e212 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Fix foreground service evaluation

Ensure we evaluate all foreground services (removed a break).

Undo and fix in a better way a recent CL that affected reporting
foreground state changes immediately.

Bug: 129167628
Bug: 70812877
Test: atest CtsAppTestCases:ActivityManagerProcessStateTest
Change-Id: I7cc18b8ff3f80d103851645ff5a3064e80b98343
parent 493080e8
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -1478,7 +1478,6 @@ public final class ActiveServices {
            if (sr.isForeground || sr.fgRequired) {
                anyForeground = true;
                fgServiceTypes |= sr.foregroundServiceType;
                break;
            }
        }
        mAm.updateProcessForegroundLocked(proc, anyForeground, fgServiceTypes, oomAdj);
+6 −9
Original line number Diff line number Diff line
@@ -16331,12 +16331,10 @@ public class ActivityManagerService extends IActivityManager.Stub
    @GuardedBy("this")
    final void updateProcessForegroundLocked(ProcessRecord proc, boolean isForeground,
            int fgServiceTypes, boolean oomAdj) {
        proc.setHasForegroundServices(isForeground, fgServiceTypes);
        final boolean hasFgServiceLocationType =
                (fgServiceTypes & ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION) != 0;
        if (isForeground != proc.hasForegroundServices()
                || proc.hasLocationForegroundServices() != hasFgServiceLocationType) {
                || proc.getForegroundServiceTypes() != fgServiceTypes) {
            proc.setHasForegroundServices(isForeground, fgServiceTypes);
            ArrayList<ProcessRecord> curProcs = mForegroundPackages.get(proc.info.packageName,
                    proc.info.uid);
            if (isForeground) {
@@ -16361,16 +16359,15 @@ public class ActivityManagerService extends IActivityManager.Stub
                    }
                }
            }
            if (oomAdj) {
                updateOomAdjLocked();
            }
        }
        if (proc.getForegroundServiceTypes() != fgServiceTypes) {
            proc.setReportedForegroundServiceTypes(fgServiceTypes);
            ProcessChangeItem item = enqueueProcessChangeItemLocked(proc.info.uid, proc.pid);
            item.changes = ProcessChangeItem.CHANGE_FOREGROUND_SERVICES;
            item.foregroundServiceTypes = fgServiceTypes;
            if (oomAdj) {
                updateOomAdjLocked();
            }
        }
    }