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

Commit 04c4948b authored by Jing Ji's avatar Jing Ji
Browse files

Kill the process with pending task removal on OomAdjuster updates

Fix the issue where it was checking for the "set" process state,
which means the process will be killed when next time this app
is being background.

Bug: 308029155
Bug: 339697954
Test: Manual

Merged-In: I6bef56445497d2edcb59a44a6d42dcdb027a6126
Change-Id: Ifb77329dfa2fe4a468a6676cb8b08bb5f1943633
parent 13aea129
Loading
Loading
Loading
Loading
+81 −83
Original line number Diff line number Diff line
@@ -3313,7 +3313,13 @@ public class OomAdjuster {
        }

        final int curSchedGroup = state.getCurrentSchedulingGroup();
        if (state.getSetSchedGroup() != curSchedGroup) {
        if (app.getWaitingToKill() != null && app.mReceivers.numberOfCurReceivers() == 0
                && ActivityManager.isProcStateBackground(state.getCurProcState())
                && !state.hasStartedServices()) {
            app.killLocked(app.getWaitingToKill(), ApplicationExitInfo.REASON_USER_REQUESTED,
                    ApplicationExitInfo.SUBREASON_REMOVE_TASK, true);
            success = false;
        } else if (state.getSetSchedGroup() != curSchedGroup) {
            int oldSchedGroup = state.getSetSchedGroup();
            state.setSetSchedGroup(curSchedGroup);
            if (DEBUG_SWITCH || DEBUG_OOM_ADJ || mService.mCurOomAdjUid == app.uid) {
@@ -3321,13 +3327,6 @@ public class OomAdjuster {
                        + " to " + curSchedGroup + ": " + state.getAdjType();
                reportOomAdjMessageLocked(TAG_OOM_ADJ, msg);
            }
            if (app.getWaitingToKill() != null && app.mReceivers.numberOfCurReceivers() == 0
                    && ActivityManager.isProcStateBackground(state.getSetProcState())
                    && !state.hasStartedServices()) {
                app.killLocked(app.getWaitingToKill(), ApplicationExitInfo.REASON_USER_REQUESTED,
                        ApplicationExitInfo.SUBREASON_REMOVE_TASK, true);
                success = false;
            } else {
            int processGroup;
            switch (curSchedGroup) {
                case SCHED_GROUP_BACKGROUND:
@@ -3360,8 +3359,8 @@ public class OomAdjuster {
                                mService.scheduleAsFifoPriority(renderThreadTid,
                                        /* suppressLogs */true);
                                if (DEBUG_OOM_ADJ) {
                                        Slog.d("UI_FIFO", "Set RenderThread (TID " +
                                                renderThreadTid + ") to FIFO");
                                    Slog.d("UI_FIFO", "Set RenderThread (TID "
                                            + renderThreadTid + ") to FIFO");
                                }
                            } else {
                                if (DEBUG_OOM_ADJ) {
@@ -3415,7 +3414,6 @@ public class OomAdjuster {
                }
            }
        }
        }
        if (state.hasRepForegroundActivities() != state.hasForegroundActivities()) {
            state.setRepForegroundActivities(state.hasForegroundActivities());
            changes |= ActivityManagerService.ProcessChangeItem.CHANGE_ACTIVITIES;