RefreshRatePolicy: getPreferredRefreshRate should consider preferredRefreshRate
If an app set the WindowManager.LayoutParams#preferredRefreshRate, refresh rate policy should return it the the preferred refresh rate of the window if all the other signals (preferredDisplayModeId or deny list) doesn't have a vote. Test: atest RefreshRatePolicyTest FrameRateSelectionPriorityTests Bug: 192413241 Change-Id: I55dc5c2acc8b66cfedbd0c0f0fb66c57eeaa36fe
This commit is contained in:
@@ -151,6 +151,10 @@ class RefreshRatePolicy {
|
||||
}
|
||||
}
|
||||
|
||||
if (w.mAttrs.preferredRefreshRate != 0) {
|
||||
return w.mAttrs.preferredRefreshRate;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -228,7 +228,7 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPreferredRefreshRate() {
|
||||
public void testDenyListPreferredRefreshRate() {
|
||||
final WindowState appWindow = createWindow("appWindow");
|
||||
assertNotNull("Window state is created", appWindow);
|
||||
when(appWindow.getDisplayContent().getDisplayPolicy()).thenReturn(mDisplayPolicy);
|
||||
@@ -281,4 +281,32 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase {
|
||||
verify(appWindow.getPendingTransaction(), never()).setFrameRate(
|
||||
any(SurfaceControl.class), anyInt(), anyInt(), anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAppPreferredRefreshRate() {
|
||||
final WindowState appWindow = createWindow("appWindow");
|
||||
assertNotNull("Window state is created", appWindow);
|
||||
when(appWindow.getDisplayContent().getDisplayPolicy()).thenReturn(mDisplayPolicy);
|
||||
|
||||
appWindow.mAttrs.packageName = "com.android.test";
|
||||
appWindow.mAttrs.preferredRefreshRate = 60;
|
||||
|
||||
assertEquals(0, mRefreshRatePolicy.getPreferredModeId(appWindow));
|
||||
assertEquals(60, mRefreshRatePolicy.getPreferredRefreshRate(appWindow), FLOAT_TOLERANCE);
|
||||
|
||||
appWindow.updateFrameRateSelectionPriorityIfNeeded();
|
||||
assertEquals(RefreshRatePolicy.LAYER_PRIORITY_UNSET, appWindow.mFrameRateSelectionPriority);
|
||||
assertEquals(60, appWindow.mAppPreferredFrameRate, FLOAT_TOLERANCE);
|
||||
|
||||
// Call the function a few times.
|
||||
appWindow.updateFrameRateSelectionPriorityIfNeeded();
|
||||
appWindow.updateFrameRateSelectionPriorityIfNeeded();
|
||||
|
||||
// Since nothing changed in the priority state, the transaction should not be updating.
|
||||
verify(appWindow.getPendingTransaction(), never()).setFrameRateSelectionPriority(
|
||||
any(SurfaceControl.class), anyInt());
|
||||
verify(appWindow.getPendingTransaction(), times(1)).setFrameRate(
|
||||
appWindow.getSurfaceControl(), 60,
|
||||
Surface.FRAME_RATE_COMPATIBILITY_EXACT, Surface.CHANGE_FRAME_RATE_ALWAYS);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user