diff options
| author | 2024-06-20 09:59:22 +0000 | |
|---|---|---|
| committer | 2024-06-20 10:03:19 +0000 | |
| commit | 38842298c0a515308fec1464f7788274b4fc42d7 (patch) | |
| tree | 57fdd3b42efea239cc1734ca20424b4af1c4afd8 | |
| parent | 25de1d2d16f272ce42a2abaf8703284a6daea4be (diff) | |
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
5 files changed, 41 insertions, 4 deletions
diff --git a/core/java/android/window/flags/windowing_frontend.aconfig b/core/java/android/window/flags/windowing_frontend.aconfig index b71468247e37..3c2b9f527341 100644 --- a/core/java/android/window/flags/windowing_frontend.aconfig +++ b/core/java/android/window/flags/windowing_frontend.aconfig @@ -146,6 +146,13 @@ flag { } 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" description: "Configuration decoupled from insets" diff --git a/services/core/java/com/android/server/am/OomAdjuster.java b/services/core/java/com/android/server/am/OomAdjuster.java index 0675401421bd..51202b5b0cf6 100644 --- a/services/core/java/com/android/server/am/OomAdjuster.java +++ b/services/core/java/com/android/server/am/OomAdjuster.java @@ -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; } diff --git a/services/core/java/com/android/server/am/ProcessStateRecord.java b/services/core/java/com/android/server/am/ProcessStateRecord.java index cb8b30d26817..bc990d9c5ef9 100644 --- a/services/core/java/com/android/server/am/ProcessStateRecord.java +++ b/services/core/java/com/android/server/am/ProcessStateRecord.java @@ -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) { diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java index dee771b194fc..b8780726f992 100644 --- a/services/core/java/com/android/server/wm/WindowProcessController.java +++ b/services/core/java/com/android/server/wm/WindowProcessController.java @@ -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|"); diff --git a/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java b/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java index 5cbed33c486d..6366f24a27e1 100644 --- a/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java +++ b/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java @@ -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") |