Loading services/core/java/com/android/server/wm/RefreshRatePolicy.java +27 −11 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.view.Display; 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; Loading Loading @@ -191,26 +192,35 @@ class RefreshRatePolicy { 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 Loading @@ -221,17 +231,20 @@ class RefreshRatePolicy { 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) { Loading Loading @@ -265,7 +278,8 @@ class RefreshRatePolicy { 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); } } } Loading @@ -273,7 +287,8 @@ class RefreshRatePolicy { 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 Loading @@ -282,7 +297,8 @@ class RefreshRatePolicy { 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); } } Loading services/core/java/com/android/server/wm/WindowState.java +8 −3 Original line number Diff line number Diff line Loading @@ -178,6 +178,7 @@ import static com.android.server.wm.WindowStateProto.UNRESTRICTED_KEEP_CLEAR_ARE 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; Loading Loading @@ -5207,9 +5208,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP boolean voteChanged = refreshRatePolicy.updateFrameRateVote(this); if (voteChanged) { getPendingTransaction().setFrameRate( mSurfaceControl, mFrameRateVote.mRefreshRate, getPendingTransaction() .setFrameRate(mSurfaceControl, mFrameRateVote.mRefreshRate, mFrameRateVote.mCompatibility, Surface.CHANGE_FRAME_RATE_ALWAYS); if (explicitRefreshRateHints()) { getPendingTransaction().setFrameRateSelectionStrategy(mSurfaceControl, mFrameRateVote.mSelectionStrategy); } } } Loading services/tests/wmtests/src/com/android/server/wm/FrameRateSelectionPriorityTests.java +53 −6 Original line number Diff line number Diff line Loading @@ -19,10 +19,13 @@ package com.android.server.wm; 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; Loading Loading @@ -62,9 +65,11 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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); Loading Loading @@ -110,6 +115,8 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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 Loading Loading @@ -140,6 +147,8 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { appWindow.getSurfaceControl(), 1); verify(appWindow.getPendingTransaction(), never()).setFrameRate( any(SurfaceControl.class), anyInt(), anyInt(), anyInt()); verify(appWindow.getPendingTransaction(), never()).setFrameRateSelectionStrategy( any(SurfaceControl.class), anyInt()); } @Test Loading Loading @@ -175,8 +184,17 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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 Loading @@ -202,8 +220,17 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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 Loading @@ -229,6 +256,8 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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 Loading Loading @@ -256,6 +285,14 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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 Loading Loading @@ -283,6 +320,8 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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 Loading Loading @@ -310,5 +349,13 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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()); } } } services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java +11 −5 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -69,15 +70,20 @@ public class RefreshRatePolicyTest extends WindowTestsBase { 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 Loading Loading
services/core/java/com/android/server/wm/RefreshRatePolicy.java +27 −11 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.view.Display; 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; Loading Loading @@ -191,26 +192,35 @@ class RefreshRatePolicy { 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 Loading @@ -221,17 +231,20 @@ class RefreshRatePolicy { 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) { Loading Loading @@ -265,7 +278,8 @@ class RefreshRatePolicy { 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); } } } Loading @@ -273,7 +287,8 @@ class RefreshRatePolicy { 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 Loading @@ -282,7 +297,8 @@ class RefreshRatePolicy { 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); } } Loading
services/core/java/com/android/server/wm/WindowState.java +8 −3 Original line number Diff line number Diff line Loading @@ -178,6 +178,7 @@ import static com.android.server.wm.WindowStateProto.UNRESTRICTED_KEEP_CLEAR_ARE 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; Loading Loading @@ -5207,9 +5208,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP boolean voteChanged = refreshRatePolicy.updateFrameRateVote(this); if (voteChanged) { getPendingTransaction().setFrameRate( mSurfaceControl, mFrameRateVote.mRefreshRate, getPendingTransaction() .setFrameRate(mSurfaceControl, mFrameRateVote.mRefreshRate, mFrameRateVote.mCompatibility, Surface.CHANGE_FRAME_RATE_ALWAYS); if (explicitRefreshRateHints()) { getPendingTransaction().setFrameRateSelectionStrategy(mSurfaceControl, mFrameRateVote.mSelectionStrategy); } } } Loading
services/tests/wmtests/src/com/android/server/wm/FrameRateSelectionPriorityTests.java +53 −6 Original line number Diff line number Diff line Loading @@ -19,10 +19,13 @@ package com.android.server.wm; 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; Loading Loading @@ -62,9 +65,11 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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); Loading Loading @@ -110,6 +115,8 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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 Loading Loading @@ -140,6 +147,8 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { appWindow.getSurfaceControl(), 1); verify(appWindow.getPendingTransaction(), never()).setFrameRate( any(SurfaceControl.class), anyInt(), anyInt(), anyInt()); verify(appWindow.getPendingTransaction(), never()).setFrameRateSelectionStrategy( any(SurfaceControl.class), anyInt()); } @Test Loading Loading @@ -175,8 +184,17 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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 Loading @@ -202,8 +220,17 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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 Loading @@ -229,6 +256,8 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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 Loading Loading @@ -256,6 +285,14 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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 Loading Loading @@ -283,6 +320,8 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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 Loading Loading @@ -310,5 +349,13 @@ public class FrameRateSelectionPriorityTests extends WindowTestsBase { 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()); } } }
services/tests/wmtests/src/com/android/server/wm/RefreshRatePolicyTest.java +11 −5 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -69,15 +70,20 @@ public class RefreshRatePolicyTest extends WindowTestsBase { 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 Loading