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

Commit 9b790553 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
Merged-In: I206e0308a4e43f65e537c1f247ba3ce8f036b6d2
(cherry picked from commit 272addb1)
parent daf27a86
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -2513,9 +2513,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;
                            scheduleLikeTopApp = true;
                        }
+7 −0
Original line number Diff line number Diff line
@@ -1862,6 +1862,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")