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

Commit 16a009fc authored by Michael Wachenschwanz's avatar Michael Wachenschwanz
Browse files

Automatically trigger OomAdjuster updates for RemoteRunningAnimation

Flag: com.android.server.am.auto_trigger_oomadj_updates
Bug: 399666866
Test: atest MockingOomAdjusterTests
Change-Id: I3ea231dd12203ed7fa209d57cd8063137252fb66
parent 088649ae
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1747,10 +1747,15 @@ class ProcessRecord extends ProcessRecordInternal implements WindowProcessListen
        synchronized (mService) {
            if (mService.mProcessStateController.setRunningRemoteAnimation(this,
                    runningRemoteAnimation)) {
                if (Flags.autoTriggerOomadjUpdates()) {
                    // Do nothing.
                    // ProcessStateController handled the update in setRunningRemoteAnimation.
                } else {
                    mService.mProcessStateController.runUpdate(this, OOM_ADJ_REASON_UI_VISIBILITY);
                }
            }
        }
    }

    public long getInputDispatchingTimeoutMillis() {
        return mWindowProcessController.getInputDispatchingTimeoutMillis();
+6 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.am;
import static android.app.ActivityManagerInternal.OOM_ADJ_REASON_ACTIVITY;
import static android.app.ActivityManagerInternal.OOM_ADJ_REASON_BACKUP;
import static android.app.ActivityManagerInternal.OOM_ADJ_REASON_SERVICE_BINDER_CALL;
import static android.app.ActivityManagerInternal.OOM_ADJ_REASON_UI_VISIBILITY;
import static android.app.ProcessMemoryState.HOSTING_COMPONENT_TYPE_BROADCAST_RECEIVER;

import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_OOM_ADJ;
@@ -464,6 +465,11 @@ public class ProcessStateController {
                    + " for pid=" + proc.getPid());
        }
        proc.setIsRunningRemoteAnimation(runningRemoteAnimation);

        if (Flags.autoTriggerOomadjUpdates()) {
            enqueueUpdateTarget(proc);
            runPendingUpdate(OOM_ADJ_REASON_UI_VISIBILITY);
        }
        return true;
    }

+7 −3
Original line number Diff line number Diff line
@@ -545,10 +545,14 @@ public class MockingOomAdjusterTests {
        ProcessRecord app = makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID, MOCKAPP_PROCESSNAME,
                MOCKAPP_PACKAGENAME, true);
        setTopProcessState(PROCESS_STATE_TOP_SLEEPING);
        mProcessStateController.setRunningRemoteAnimation(app, true);
        setWakefulness(PowerManagerInternal.WAKEFULNESS_AWAKE);
        mProcessStateController.setRunningRemoteAnimation(app, true);

        if (Flags.autoTriggerOomadjUpdates()) {
            // Do not manually run the update.
        } else {
            updateOomAdj(app);
        setTopProcessState(PROCESS_STATE_TOP);
        }

        assertProcStates(app, PROCESS_STATE_TOP_SLEEPING, VISIBLE_APP_ADJ, SCHED_GROUP_TOP_APP);
        assertThatProcess(app).hasImplicitCpuTimeCapability();