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

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

Do not kill process on removing task if it has a started service

Upon removing the task, if the app is running in the background
process state, it'll be killed. We've exempted if it's running
a broadcast receiver, and here we're exempting the apps with
started service, so the app will get a chance to run its
Service#onTaskRemoved(). Since the app is running in the background
state, its background service will be stopped automatically after
60s, so the process will be killed eventually.

Bug: 310724715
Test: Manual - Launch the media session demo, swipe it from recents.
Change-Id: Ie6c17a7b77a6189b8eac1d35d49c862ea46c00b9
parent 44da7e6e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -18085,7 +18085,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                            (WindowProcessController) procsToKill.get(i);
                    final ProcessRecord pr = (ProcessRecord) wpc.mOwner;
                    if (ActivityManager.isProcStateBackground(pr.mState.getSetProcState())
                            && pr.mReceivers.numberOfCurReceivers() == 0) {
                            && pr.mReceivers.numberOfCurReceivers() == 0
                            && !pr.mState.hasStartedServices()) {
                        pr.killLocked("remove task", ApplicationExitInfo.REASON_USER_REQUESTED,
                                ApplicationExitInfo.SUBREASON_REMOVE_TASK, true);
                    } else {
+2 −1
Original line number Diff line number Diff line
@@ -3228,7 +3228,8 @@ public class OomAdjuster {
                reportOomAdjMessageLocked(TAG_OOM_ADJ, msg);
            }
            if (app.getWaitingToKill() != null && app.mReceivers.numberOfCurReceivers() == 0
                    && ActivityManager.isProcStateBackground(state.getSetProcState())) {
                    && ActivityManager.isProcStateBackground(state.getSetProcState())
                    && !state.hasStartedServices()) {
                app.killLocked(app.getWaitingToKill(), ApplicationExitInfo.REASON_USER_REQUESTED,
                        ApplicationExitInfo.SUBREASON_REMOVE_TASK, true);
                success = false;