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

Commit 16e029a9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add another level to modifyRawOomAdj for BIND_NOT_PERCEPTIBLE services" into main

parents 1044a34d 4defc008
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -393,6 +393,8 @@ final class ProcessServiceRecord {
                adj = ProcessList.PERCEPTIBLE_APP_ADJ;
            } else if (adj < ProcessList.PERCEPTIBLE_LOW_APP_ADJ) {
                adj = ProcessList.PERCEPTIBLE_LOW_APP_ADJ;
            } else if (Flags.addModifyRawOomAdjServiceLevel() && adj < ProcessList.SERVICE_ADJ) {
                adj = ProcessList.SERVICE_ADJ;
            } else if (adj < ProcessList.CACHED_APP_MIN_ADJ) {
                adj = ProcessList.CACHED_APP_MIN_ADJ;
            } else if (adj < ProcessList.CACHED_APP_MAX_ADJ) {
+10 −0
Original line number Diff line number Diff line
@@ -260,3 +260,13 @@ flag {
    description: "Use PROCESS_CAPABILITY_CPU_TIME to control unfreeze state."
    bug: "370817323"
}

flag {
    name: "add_modify_raw_oom_adj_service_level"
    namespace: "backstage_power"
    description: "Add a SERVICE_ADJ level to the modifyRawOomAdj method"
    bug: "374810368"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+28 −3
Original line number Diff line number Diff line
@@ -1425,6 +1425,31 @@ public class MockingOomAdjusterTests {
        assertEquals(PERCEPTIBLE_LOW_APP_ADJ, app.mState.getSetAdj());
    }

    @SuppressWarnings("GuardedBy")
    @Test
    public void testUpdateOomAdj_DoOne_Service_NotPerceptible_AboveClient() {
        ProcessRecord app = spy(makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID,
                MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
        ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
                MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
        ProcessRecord service = spy(makeDefaultProcessRecord(MOCKAPP3_PID, MOCKAPP3_UID,
                MOCKAPP3_PROCESSNAME, MOCKAPP3_PACKAGENAME, false));
        bindService(app, client, null, null, Context.BIND_NOT_PERCEPTIBLE, mock(IBinder.class));
        bindService(service, app, null, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class));
        mProcessStateController.setRunningRemoteAnimation(client, true);
        mProcessStateController.updateHasAboveClientLocked(app.mServices);
        setWakefulness(PowerManagerInternal.WAKEFULNESS_AWAKE);
        updateOomAdj(client, app, service);

        final int expectedAdj;
        if (Flags.addModifyRawOomAdjServiceLevel()) {
            expectedAdj = SERVICE_ADJ;
        } else {
            expectedAdj = CACHED_APP_MIN_ADJ;
        }
        assertEquals(expectedAdj, app.mState.getSetAdj());
    }

    @SuppressWarnings("GuardedBy")
    @Test
    public void testUpdateOomAdj_DoOne_Service_NotVisible() {
@@ -2906,7 +2931,7 @@ public class MockingOomAdjusterTests {
        // Simulate binding to a service in the same process using BIND_ABOVE_CLIENT and
        // verify that its OOM adjustment level is unaffected.
        bindService(service, app, null, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class));
        app.mServices.updateHasAboveClientLocked();
        mProcessStateController.updateHasAboveClientLocked(app.mServices);
        assertTrue(app.mServices.hasAboveClient());

        updateOomAdj(app);
@@ -2928,7 +2953,7 @@ public class MockingOomAdjusterTests {
        // Simulate binding to a service in the same process using BIND_ABOVE_CLIENT and
        // verify that its OOM adjustment level is unaffected.
        bindService(app, app, null, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class));
        app.mServices.updateHasAboveClientLocked();
        mProcessStateController.updateHasAboveClientLocked(app.mServices);
        assertFalse(app.mServices.hasAboveClient());

        updateOomAdj(app);
@@ -2983,7 +3008,7 @@ public class MockingOomAdjusterTests {

        // Since sr.app is null, this service cannot be in the same process as the
        // client so we expect the BIND_ABOVE_CLIENT adjustment to take effect.
        app.mServices.updateHasAboveClientLocked();
        mProcessStateController.updateHasAboveClientLocked(app.mServices);
        updateOomAdj(app);
        assertTrue(app.mServices.hasAboveClient());
        assertNotEquals(FOREGROUND_APP_ADJ, app.mState.getSetAdj());