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

Commit 272addb1 authored by Jing Ji's avatar Jing Ji
Browse files

Fix the flaky sched group with the BIND_SCHEDULE_LIKE_TOP_APP

If the current sched group is already TOP, we'll actually ignore
the BIND_SCHEDULE_LIKE_TOP_APP, which moves the sched group to
restricted if the screen is OFF.

Bug: 298747034
Test: atest MockingOomAdjusterTests
Change-Id: I206e0308a4e43f65e537c1f247ba3ce8f036b6d2
parent df7bb745
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -2823,9 +2823,7 @@ public class OomAdjuster {
                }
            }

            if (schedGroup < SCHED_GROUP_TOP_APP
                    && cr.hasFlag(Context.BIND_SCHEDULE_LIKE_TOP_APP)
                    && clientIsSystem) {
            if (cr.hasFlag(Context.BIND_SCHEDULE_LIKE_TOP_APP) && clientIsSystem) {
                schedGroup = SCHED_GROUP_TOP_APP;
                state.setScheduleLikeTopApp(true);
            }
+7 −0
Original line number Diff line number Diff line
@@ -1895,6 +1895,13 @@ public class MockingOomAdjusterTests {
        assertProcStates(app2, PROCESS_STATE_FOREGROUND_SERVICE, PERCEPTIBLE_APP_ADJ,
                SCHED_GROUP_DEFAULT);
        assertBfsl(app2);

        bindService(client2, app1, null, 0, mock(IBinder.class));
        bindService(app1, client2, null, 0, mock(IBinder.class));
        client2.mServices.setHasForegroundServices(false, 0, /* hasNoneType=*/false);
        updateOomAdj(app1, client1, client2);
        assertProcStates(app1, PROCESS_STATE_IMPORTANT_FOREGROUND, VISIBLE_APP_ADJ,
                SCHED_GROUP_TOP_APP);
    }

    @SuppressWarnings("GuardedBy")