Merge "WindowState: set frameRateSelectionStrategy" into main
diff --git a/services/core/java/com/android/server/wm/RefreshRatePolicy.java b/services/core/java/com/android/server/wm/RefreshRatePolicy.java
index 23c135a..03574029 100644
--- a/services/core/java/com/android/server/wm/RefreshRatePolicy.java
+++ b/services/core/java/com/android/server/wm/RefreshRatePolicy.java
@@ -26,6 +26,7 @@
import android.view.Display.Mode;
import android.view.DisplayInfo;
import android.view.Surface;
+import android.view.SurfaceControl;
import android.view.SurfaceControl.RefreshRateRange;
import java.util.HashMap;
@@ -191,26 +192,35 @@
public static class FrameRateVote {
float mRefreshRate;
@Surface.FrameRateCompatibility int mCompatibility;
+ @SurfaceControl.FrameRateSelectionStrategy int mSelectionStrategy;
- FrameRateVote(float refreshRate, @Surface.FrameRateCompatibility int compatibility) {
- update(refreshRate, compatibility);
+
+
+ FrameRateVote(float refreshRate, @Surface.FrameRateCompatibility int compatibility,
+ @SurfaceControl.FrameRateSelectionStrategy int selectionStrategy) {
+ update(refreshRate, compatibility, selectionStrategy);
}
FrameRateVote() {
reset();
}
- boolean update(float refreshRate, @Surface.FrameRateCompatibility int compatibility) {
- if (!refreshRateEquals(refreshRate) || mCompatibility != compatibility) {
+ boolean update(float refreshRate, @Surface.FrameRateCompatibility int compatibility,
+ @SurfaceControl.FrameRateSelectionStrategy int selectionStrategy) {
+ if (!refreshRateEquals(refreshRate)
+ || mCompatibility != compatibility
+ || mSelectionStrategy != selectionStrategy) {
mRefreshRate = refreshRate;
mCompatibility = compatibility;
+ mSelectionStrategy = selectionStrategy;
return true;
}
return false;
}
boolean reset() {
- return update(0, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT);
+ return update(0, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT,
+ SurfaceControl.FRAME_RATE_SELECTION_STRATEGY_PROPAGATE);
}
@Override
@@ -221,17 +231,20 @@
FrameRateVote other = (FrameRateVote) o;
return refreshRateEquals(other.mRefreshRate)
- && mCompatibility == other.mCompatibility;
+ && mCompatibility == other.mCompatibility
+ && mSelectionStrategy == other.mSelectionStrategy;
}
@Override
public int hashCode() {
- return Objects.hash(mRefreshRate, mCompatibility);
+ return Objects.hash(mRefreshRate, mCompatibility, mSelectionStrategy);
+
}
@Override
public String toString() {
- return "mRefreshRate=" + mRefreshRate + ", mCompatibility=" + mCompatibility;
+ return "mRefreshRate=" + mRefreshRate + ", mCompatibility=" + mCompatibility
+ + ", mSelectionStrategy=" + mSelectionStrategy;
}
private boolean refreshRateEquals(float refreshRate) {
@@ -265,7 +278,8 @@
for (Display.Mode mode : mDisplayInfo.supportedModes) {
if (preferredModeId == mode.getModeId()) {
return w.mFrameRateVote.update(mode.getRefreshRate(),
- Surface.FRAME_RATE_COMPATIBILITY_EXACT);
+ Surface.FRAME_RATE_COMPATIBILITY_EXACT,
+ SurfaceControl.FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
}
}
}
@@ -273,7 +287,8 @@
if (w.mAttrs.preferredRefreshRate > 0) {
return w.mFrameRateVote.update(w.mAttrs.preferredRefreshRate,
- Surface.FRAME_RATE_COMPATIBILITY_DEFAULT);
+ Surface.FRAME_RATE_COMPATIBILITY_DEFAULT,
+ SurfaceControl.FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
}
// If the app didn't set a preferred mode id or refresh rate, but it is part of the deny
@@ -282,7 +297,8 @@
final String packageName = w.getOwningPackage();
if (mHighRefreshRateDenylist.isDenylisted(packageName)) {
return w.mFrameRateVote.update(mLowRefreshRateMode.getRefreshRate(),
- Surface.FRAME_RATE_COMPATIBILITY_EXACT);
+ Surface.FRAME_RATE_COMPATIBILITY_EXACT,
+ SurfaceControl.FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
}
}
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 9c4ad5c..4e9d23c 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -178,6 +178,7 @@
import static com.android.server.wm.WindowStateProto.VIEW_VISIBILITY;
import static com.android.server.wm.WindowStateProto.WINDOW_CONTAINER;
import static com.android.server.wm.WindowStateProto.WINDOW_FRAMES;
+import static com.android.window.flags.Flags.explicitRefreshRateHints;
import static com.android.window.flags.Flags.secureWindowState;
import static com.android.window.flags.Flags.surfaceTrustedOverlay;
@@ -5207,9 +5208,13 @@
boolean voteChanged = refreshRatePolicy.updateFrameRateVote(this);
if (voteChanged) {
- getPendingTransaction().setFrameRate(
- mSurfaceControl, mFrameRateVote.mRefreshRate,
- mFrameRateVote.mCompatibility, Surface.CHANGE_FRAME_RATE_ALWAYS);
+ getPendingTransaction()
+ .setFrameRate(mSurfaceControl, mFrameRateVote.mRefreshRate,
+ mFrameRateVote.mCompatibility, Surface.CHANGE_FRAME_RATE_ALWAYS);
+ if (explicitRefreshRateHints()) {
+ getPendingTransaction().setFrameRateSelectionStrategy(mSurfaceControl,
+ mFrameRateVote.mSelectionStrategy);
+ }
}
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/FrameRateSelectionPriorityTests.java b/services/tests/wmtests/src/com/android/server/wm/FrameRateSelectionPriorityTests.java
index c0a90b2..e77c14a 100644
--- a/services/tests/wmtests/src/com/android/server/wm/FrameRateSelectionPriorityTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/FrameRateSelectionPriorityTests.java
@@ -19,10 +19,13 @@
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.any;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyFloat;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyInt;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.eq;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.never;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.times;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
+import static com.android.window.flags.Flags.explicitRefreshRateHints;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -62,9 +65,11 @@
private static final FrameRateVote FRAME_RATE_VOTE_NONE = new FrameRateVote();
private static final FrameRateVote FRAME_RATE_VOTE_60_EXACT =
- new FrameRateVote(60, Surface.FRAME_RATE_COMPATIBILITY_EXACT);
+ new FrameRateVote(60, Surface.FRAME_RATE_COMPATIBILITY_EXACT,
+ SurfaceControl.FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
private static final FrameRateVote FRAME_RATE_VOTE_60_PREFERRED =
- new FrameRateVote(60, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT);
+ new FrameRateVote(60, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT,
+ SurfaceControl.FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
WindowState createWindow(String name) {
WindowState window = createWindow(null, TYPE_APPLICATION, name);
@@ -110,6 +115,8 @@
any(SurfaceControl.class), anyInt());
verify(appWindow.getPendingTransaction(), never()).setFrameRate(
any(SurfaceControl.class), anyInt(), anyInt(), anyInt());
+ verify(appWindow.getPendingTransaction(), never()).setFrameRateSelectionStrategy(
+ any(SurfaceControl.class), anyInt());
}
@Test
@@ -140,6 +147,8 @@
appWindow.getSurfaceControl(), 1);
verify(appWindow.getPendingTransaction(), never()).setFrameRate(
any(SurfaceControl.class), anyInt(), anyInt(), anyInt());
+ verify(appWindow.getPendingTransaction(), never()).setFrameRateSelectionStrategy(
+ any(SurfaceControl.class), anyInt());
}
@Test
@@ -175,8 +184,17 @@
appWindow.getSurfaceControl(), 0);
verify(appWindow.getPendingTransaction(), times(2)).setFrameRateSelectionPriority(
appWindow.getSurfaceControl(), 1);
- verify(appWindow.getPendingTransaction(), never()).setFrameRate(
- any(SurfaceControl.class), anyInt(), anyInt(), anyInt());
+ verify(appWindow.getPendingTransaction(), times(1)).setFrameRate(
+ eq(appWindow.getSurfaceControl()), anyFloat(),
+ eq(Surface.FRAME_RATE_COMPATIBILITY_EXACT), eq(Surface.CHANGE_FRAME_RATE_ALWAYS));
+ if (explicitRefreshRateHints()) {
+ verify(appWindow.getPendingTransaction(), times(1)).setFrameRateSelectionStrategy(
+ appWindow.getSurfaceControl(),
+ SurfaceControl.FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
+ } else {
+ verify(appWindow.getPendingTransaction(), never()).setFrameRateSelectionStrategy(
+ any(SurfaceControl.class), anyInt());
+ }
}
@Test
@@ -202,8 +220,17 @@
appWindow.getSurfaceControl(), RefreshRatePolicy.LAYER_PRIORITY_UNSET);
verify(appWindow.getPendingTransaction()).setFrameRateSelectionPriority(
appWindow.getSurfaceControl(), 2);
- verify(appWindow.getPendingTransaction(), never()).setFrameRate(
- any(SurfaceControl.class), anyInt(), anyInt(), anyInt());
+ verify(appWindow.getPendingTransaction(), times(1)).setFrameRate(
+ eq(appWindow.getSurfaceControl()), anyFloat(),
+ eq(Surface.FRAME_RATE_COMPATIBILITY_EXACT), eq(Surface.CHANGE_FRAME_RATE_ALWAYS));
+ if (explicitRefreshRateHints()) {
+ verify(appWindow.getPendingTransaction(), times(1)).setFrameRateSelectionStrategy(
+ appWindow.getSurfaceControl(),
+ SurfaceControl.FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
+ } else {
+ verify(appWindow.getPendingTransaction(), never()).setFrameRateSelectionStrategy(
+ any(SurfaceControl.class), anyInt());
+ }
}
@Test
@@ -229,6 +256,8 @@
appWindow.getSurfaceControl(), RefreshRatePolicy.LAYER_PRIORITY_UNSET);
verify(appWindow.getPendingTransaction(), never()).setFrameRate(
any(SurfaceControl.class), anyInt(), anyInt(), anyInt());
+ verify(appWindow.getPendingTransaction(), never()).setFrameRateSelectionStrategy(
+ any(SurfaceControl.class), anyInt());
}
@Test
@@ -256,6 +285,14 @@
verify(appWindow.getPendingTransaction(), times(1)).setFrameRate(
appWindow.getSurfaceControl(), 60,
Surface.FRAME_RATE_COMPATIBILITY_EXACT, Surface.CHANGE_FRAME_RATE_ALWAYS);
+ if (explicitRefreshRateHints()) {
+ verify(appWindow.getPendingTransaction(), times(1)).setFrameRateSelectionStrategy(
+ appWindow.getSurfaceControl(),
+ SurfaceControl.FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
+ } else {
+ verify(appWindow.getPendingTransaction(), never()).setFrameRateSelectionStrategy(
+ any(SurfaceControl.class), anyInt());
+ }
}
@Test
@@ -283,6 +320,8 @@
appWindow.getSurfaceControl(), RefreshRatePolicy.LAYER_PRIORITY_UNSET);
verify(appWindow.getPendingTransaction(), never()).setFrameRate(
any(SurfaceControl.class), anyInt(), anyInt(), anyInt());
+ verify(appWindow.getPendingTransaction(), never()).setFrameRateSelectionStrategy(
+ any(SurfaceControl.class), anyInt());
}
@Test
@@ -310,5 +349,13 @@
verify(appWindow.getPendingTransaction(), times(1)).setFrameRate(
appWindow.getSurfaceControl(), 60,
Surface.FRAME_RATE_COMPATIBILITY_DEFAULT, Surface.CHANGE_FRAME_RATE_ALWAYS);
+ if (explicitRefreshRateHints()) {
+ verify(appWindow.getPendingTransaction(), times(1)).setFrameRateSelectionStrategy(
+ appWindow.getSurfaceControl(),
+ SurfaceControl.FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
+ } else {
+ verify(appWindow.getPendingTransaction(), never()).setFrameRateSelectionStrategy(
+ any(SurfaceControl.class), anyInt());
+ }
}
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java b/services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java
index 49a8886..c9a83b0 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java
@@ -16,6 +16,7 @@
package com.android.server.wm;
+import static android.view.SurfaceControl.FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN;
import static android.view.SurfaceControl.RefreshRateRange.FLOAT_TOLERANCE;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
@@ -69,15 +70,20 @@
private static final FrameRateVote FRAME_RATE_VOTE_NONE = new FrameRateVote();
private static final FrameRateVote FRAME_RATE_VOTE_DENY_LIST =
- new FrameRateVote(LOW_REFRESH_RATE, Surface.FRAME_RATE_COMPATIBILITY_EXACT);
+ new FrameRateVote(LOW_REFRESH_RATE, Surface.FRAME_RATE_COMPATIBILITY_EXACT,
+ FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
private static final FrameRateVote FRAME_RATE_VOTE_LOW_EXACT =
- new FrameRateVote(LOW_REFRESH_RATE, Surface.FRAME_RATE_COMPATIBILITY_EXACT);
+ new FrameRateVote(LOW_REFRESH_RATE, Surface.FRAME_RATE_COMPATIBILITY_EXACT,
+ FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
private static final FrameRateVote FRAME_RATE_VOTE_HI_EXACT =
- new FrameRateVote(HI_REFRESH_RATE, Surface.FRAME_RATE_COMPATIBILITY_EXACT);
+ new FrameRateVote(HI_REFRESH_RATE, Surface.FRAME_RATE_COMPATIBILITY_EXACT,
+ FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
private static final FrameRateVote FRAME_RATE_VOTE_LOW_PREFERRED =
- new FrameRateVote(LOW_REFRESH_RATE, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT);
+ new FrameRateVote(LOW_REFRESH_RATE, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT,
+ FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
private static final FrameRateVote FRAME_RATE_VOTE_HI_PREFERRED =
- new FrameRateVote(HI_REFRESH_RATE, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT);
+ new FrameRateVote(HI_REFRESH_RATE, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT,
+ FRAME_RATE_SELECTION_STRATEGY_OVERRIDE_CHILDREN);
// Parcel and Unparcel the LayoutParams in the window state to test the path the object
// travels from the app's process to system server