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

Commit 38842298 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Use top sched group for apps in split screen

Currently only one side has the top sched group. This change makes
both sides of split have top priority. This might reduce frame
drop if the non-top side is running a video conference.

Bug: 200769420
Test: MockingOomAdjusterTests#testUpdateOomAdj_DoOne_VisibleActivities
Flag: com.android.window.flags.process_priority_policy_for_multi_window_mode

Change-Id: I6a842810c023648b206f4c9fdd2db403dce20b91
parent 25de1d2d
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -145,6 +145,13 @@ flag {
  is_fixed_read_only: true
}

flag {
  name: "process_priority_policy_for_multi_window_mode"
  namespace: "windowing_frontend"
  description: "Use higher priority for top-like processes"
  bug: "200769420"
}

flag {
  name: "insets_decoupled_configuration"
  namespace: "windowing_frontend"
+7 −1
Original line number Diff line number Diff line
@@ -1683,7 +1683,7 @@ public class OomAdjuster {
            this.mState = app.mState;
        }

        void onVisibleActivity() {
        void onVisibleActivity(int flags) {
            // App has a visible activity; only upgrade adjustment.
            if (adj > VISIBLE_APP_ADJ) {
                adj = VISIBLE_APP_ADJ;
@@ -1703,6 +1703,12 @@ public class OomAdjuster {
            if (schedGroup < SCHED_GROUP_DEFAULT) {
                schedGroup = SCHED_GROUP_DEFAULT;
            }
            if ((flags & WindowProcessController.ACTIVITY_STATE_FLAG_RESUMED_SPLIT_SCREEN) != 0) {
                // Another side of split should be the current global top. Use the same top
                // priority for this non-top split.
                schedGroup = SCHED_GROUP_TOP_APP;
                mAdjType = "resumed-split-screen-activity";
            }
            foregroundActivities = true;
            mHasVisibleActivities = true;
        }
+2 −1
Original line number Diff line number Diff line
@@ -1113,6 +1113,7 @@ final class ProcessStateRecord {
        return mCachedCompatChanges[cachedCompatChangeId] == VALUE_TRUE;
    }

    /** This is only called if the process contains activities and is not the global top. */
    @GuardedBy("mService")
    void computeOomAdjFromActivitiesIfNecessary(OomAdjuster.ComputeOomAdjWindowCallback callback,
            int adj, boolean foregroundActivities, boolean hasVisibleActivities, int procState,
@@ -1125,7 +1126,7 @@ final class ProcessStateRecord {
        final int flags = mApp.getWindowProcessController().getActivityStateFlags();

        if ((flags & ACTIVITY_STATE_FLAG_IS_VISIBLE) != 0) {
            callback.onVisibleActivity();
            callback.onVisibleActivity(flags);
        } else if ((flags & ACTIVITY_STATE_FLAG_IS_PAUSING_OR_PAUSED) != 0) {
            callback.onPausedActivity();
        } else if ((flags & ACTIVITY_STATE_FLAG_IS_STOPPING) != 0) {
+18 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.wm;
import static android.app.ActivityManager.PROCESS_STATE_CACHED_ACTIVITY;
import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.content.res.Configuration.ASSETS_SEQ_UNDEFINED;
import static android.os.Build.VERSION_CODES.Q;
import static android.os.InputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS;
@@ -316,6 +317,7 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
    public static final int ACTIVITY_STATE_FLAG_IS_WINDOW_VISIBLE = 1 << 20;
    public static final int ACTIVITY_STATE_FLAG_HAS_RESUMED = 1 << 21;
    public static final int ACTIVITY_STATE_FLAG_HAS_ACTIVITY_IN_VISIBLE_TASK = 1 << 22;
    public static final int ACTIVITY_STATE_FLAG_RESUMED_SPLIT_SCREEN = 1 << 23;
    public static final int ACTIVITY_STATE_FLAG_MASK_MIN_TASK_LAYER = 0x0000ffff;

    /**
@@ -1238,14 +1240,25 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
                stateFlags |= ACTIVITY_STATE_FLAG_IS_WINDOW_VISIBLE;
            }
            final Task task = r.getTask();
            if (task != null && task.mLayerRank != Task.LAYER_RANK_INVISIBLE) {
            if (task == null) {
                Slog.e(TAG, "Unexpected detached " + r + " in " + this);
                continue;
            }
            if (task.mLayerRank != Task.LAYER_RANK_INVISIBLE) {
                stateFlags |= ACTIVITY_STATE_FLAG_HAS_ACTIVITY_IN_VISIBLE_TASK;
            }
            if (r.isVisibleRequested()) {
                if (r.isState(RESUMED)) {
                    stateFlags |= ACTIVITY_STATE_FLAG_HAS_RESUMED;
                    final int windowingMode = r.getWindowingMode();
                    if (windowingMode == WINDOWING_MODE_MULTI_WINDOW
                            && com.android.window.flags.Flags
                                    .processPriorityPolicyForMultiWindowMode()
                            && task.getAdjacentTask() != null) {
                        stateFlags |= ACTIVITY_STATE_FLAG_RESUMED_SPLIT_SCREEN;
                    }
                if (task != null && minTaskLayer > 0) {
                }
                if (minTaskLayer > 0) {
                    final int layer = task.mLayerRank;
                    if (layer >= 0 && minTaskLayer > layer) {
                        minTaskLayer = layer;
@@ -2089,6 +2102,9 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
                pw.print("V|");
                if ((stateFlags & ACTIVITY_STATE_FLAG_HAS_RESUMED) != 0) {
                    pw.print("R|");
                    if ((stateFlags & ACTIVITY_STATE_FLAG_RESUMED_SPLIT_SCREEN) != 0) {
                        pw.print("RS|");
                    }
                }
            } else if ((stateFlags & ACTIVITY_STATE_FLAG_IS_PAUSING_OR_PAUSED) != 0) {
                pw.print("P|");
+7 −0
Original line number Diff line number Diff line
@@ -493,6 +493,13 @@ public class MockingOomAdjusterTests {
        assertFalse(app.mState.isCached());
        assertFalse(app.mState.isEmpty());
        assertEquals("vis-activity", app.mState.getAdjType());

        doReturn(WindowProcessController.ACTIVITY_STATE_FLAG_IS_VISIBLE
                | WindowProcessController.ACTIVITY_STATE_FLAG_RESUMED_SPLIT_SCREEN)
                .when(wpc).getActivityStateFlags();
        updateOomAdj(app);
        assertProcStates(app, PROCESS_STATE_TOP, VISIBLE_APP_ADJ, SCHED_GROUP_TOP_APP);
        assertEquals("resumed-split-screen-activity", app.mState.getAdjType());
    }

    @SuppressWarnings("GuardedBy")