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

Commit 9d3e8b6d authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Use background priority for a freeform task which is fully occluded

When a freeform task is logically visible but it is visually occluded
by other freeform tasks, make it use lower priority to reduce the
contention of CPU with tasks which are truly visible to user.

Bug: 325594711
Flag: com.android.window.flags.bg_priority_for_occluded_freeform_tasks
Test: MockingOomAdjusterTests#testUpdateOomAdj_DoOne_VisibleActivities
Change-Id: Ib90b54de5591af3c9b831740cd5b5ca4f828782c
parent 983bc5f9
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -144,6 +144,17 @@ flag {
    is_fixed_read_only: true
}

flag {
  name: "bg_priority_for_occluded_freeform_tasks"
  namespace: "windowing_frontend"
  description: "Background priority for occluded freeform tasks"
  bug: "325594711"
  is_fixed_read_only: true
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
  name: "fifo_priority_for_major_ui_processes"
  namespace: "windowing_frontend"
+4 −0
Original line number Diff line number Diff line
@@ -1582,6 +1582,10 @@ public abstract class OomAdjuster {
                // Currently the only case is from freeform apps which are not close to top.
                schedGroup = SCHED_GROUP_FOREGROUND_WINDOW;
                mAdjType = "vis-multi-window-activity";
            } else if ((flags
                    & WindowProcessController.ACTIVITY_STATE_FLAG_OCCLUDED_FREEFORM) != 0) {
                schedGroup = SCHED_GROUP_BACKGROUND;
                mAdjType = "occluded-freeform-activity";
            }
            foregroundActivities = true;
            mHasVisibleActivities = true;
+5 −1
Original line number Diff line number Diff line
@@ -335,6 +335,7 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
    public static final int ACTIVITY_STATE_FLAG_RESUMED_SPLIT_SCREEN = 1 << 23;
    public static final int ACTIVITY_STATE_FLAG_PERCEPTIBLE_FREEFORM = 1 << 24;
    public static final int ACTIVITY_STATE_FLAG_VISIBLE_MULTI_WINDOW_MODE = 1 << 25;
    public static final int ACTIVITY_STATE_FLAG_OCCLUDED_FREEFORM = 1 << 26;
    public static final int ACTIVITY_STATE_FLAG_MASK_MIN_TASK_LAYER = 0x0000ffff;

    /**
@@ -1332,7 +1333,10 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
        if (hasResumedFreeform
                // Exclude task layer 1 because it is already the top most.
                && minTaskLayer > 1) {
            if (minTaskLayer <= 1 + MAX_NUM_PERCEPTIBLE_FREEFORM
            if (com.android.window.flags.Flags.bgPriorityForOccludedFreeformTasks()
                    && nonOccludedRatio == 0) {
                stateFlags |= ACTIVITY_STATE_FLAG_OCCLUDED_FREEFORM;
            } else if (minTaskLayer <= 1 + MAX_NUM_PERCEPTIBLE_FREEFORM
                    || nonOccludedRatio >= PERCEPTIBLE_FREEFORM_VISIBLE_RATIO) {
                stateFlags |= ACTIVITY_STATE_FLAG_PERCEPTIBLE_FREEFORM;
            } else {
+8 −0
Original line number Diff line number Diff line
@@ -599,6 +599,14 @@ public class MockingOomAdjusterTests {
                SCHED_GROUP_FOREGROUND_WINDOW);
        assertEquals("vis-multi-window-activity", app.mState.getAdjType());
        assertCpuTime(app);

        doReturn(ACTIVITY_STATE_FLAG_IS_VISIBLE
                | WindowProcessController.ACTIVITY_STATE_FLAG_OCCLUDED_FREEFORM)
                .when(wpc).getActivityStateFlags();
        updateOomAdj(app);
        assertProcStates(app, PROCESS_STATE_TOP, VISIBLE_APP_ADJ, SCHED_GROUP_BACKGROUND);
        assertEquals("occluded-freeform-activity", app.mState.getAdjType());
        assertCpuTime(app);
    }
    @SuppressWarnings("GuardedBy")
    @Test