Loading core/java/android/view/ViewRootImpl.java +28 −1 Original line number Diff line number Diff line Loading @@ -3216,6 +3216,12 @@ public final class ViewRootImpl implements ViewParent, endDragResizing(); destroyHardwareResources(); } if (sToolkitSetFrameRateReadOnlyFlagValue && viewVisibility == View.VISIBLE) { // Boost frame rate when the viewVisibility becomes true. // This is mainly for lanuchers that lanuch new windows. boostFrameRate(FRAME_RATE_TOUCH_BOOST_TIME); } } // Non-visible windows can't hold accessibility focus. Loading Loading @@ -3925,6 +3931,11 @@ public final class ViewRootImpl implements ViewParent, focused.restoreDefaultFocus(); } } if (sToolkitSetFrameRateReadOnlyFlagValue) { // Boost the frame rate when the ViewRootImpl first becomes available. boostFrameRate(FRAME_RATE_TOUCH_BOOST_TIME); } } final boolean changedVisibility = (viewVisibilityChanged || mFirst) && isViewVisible; Loading Loading @@ -12159,6 +12170,22 @@ public final class ViewRootImpl implements ViewParent, return mPreferredFrameRate; } /** * Get the value of mIsFrameRateBoosting */ @VisibleForTesting public boolean getIsFrameRateBoosting() { return mIsFrameRateBoosting; } private void boostFrameRate(int boostTimeOut) { mIsFrameRateBoosting = true; setPreferredFrameRateCategory(mPreferredFrameRateCategory); mHandler.removeMessages(MSG_TOUCH_BOOST_TIMEOUT); mHandler.sendEmptyMessageDelayed(MSG_TOUCH_BOOST_TIMEOUT, boostTimeOut); } @Override public boolean transferHostTouchGestureToEmbedded( @NonNull SurfaceControlViewHost.SurfacePackage surfacePackage) { Loading core/tests/coretests/src/android/view/ViewRootImplTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -472,6 +472,7 @@ public class ViewRootImplTest { * Test the value of the frame rate cateogry based on the visibility of a view * Invsible: FRAME_RATE_CATEGORY_NO_PREFERENCE * Visible: FRAME_RATE_CATEGORY_NORMAL * Also, mIsFrameRateBoosting should be true when the visibility becomes visible */ @Test @RequiresFlagsEnabled(FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY) Loading @@ -485,6 +486,7 @@ public class ViewRootImplTest { assertEquals(viewRootImpl.getPreferredFrameRateCategory(), FRAME_RATE_CATEGORY_NO_PREFERENCE); }); sInstrumentation.waitForIdleSync(); sInstrumentation.runOnMainSync(() -> { view.setVisibility(View.VISIBLE); Loading @@ -492,6 +494,11 @@ public class ViewRootImplTest { assertEquals(viewRootImpl.getPreferredFrameRateCategory(), FRAME_RATE_CATEGORY_NORMAL); }); sInstrumentation.waitForIdleSync(); sInstrumentation.runOnMainSync(() -> { assertEquals(viewRootImpl.getIsFrameRateBoosting(), true); }); } /** Loading Loading
core/java/android/view/ViewRootImpl.java +28 −1 Original line number Diff line number Diff line Loading @@ -3216,6 +3216,12 @@ public final class ViewRootImpl implements ViewParent, endDragResizing(); destroyHardwareResources(); } if (sToolkitSetFrameRateReadOnlyFlagValue && viewVisibility == View.VISIBLE) { // Boost frame rate when the viewVisibility becomes true. // This is mainly for lanuchers that lanuch new windows. boostFrameRate(FRAME_RATE_TOUCH_BOOST_TIME); } } // Non-visible windows can't hold accessibility focus. Loading Loading @@ -3925,6 +3931,11 @@ public final class ViewRootImpl implements ViewParent, focused.restoreDefaultFocus(); } } if (sToolkitSetFrameRateReadOnlyFlagValue) { // Boost the frame rate when the ViewRootImpl first becomes available. boostFrameRate(FRAME_RATE_TOUCH_BOOST_TIME); } } final boolean changedVisibility = (viewVisibilityChanged || mFirst) && isViewVisible; Loading Loading @@ -12159,6 +12170,22 @@ public final class ViewRootImpl implements ViewParent, return mPreferredFrameRate; } /** * Get the value of mIsFrameRateBoosting */ @VisibleForTesting public boolean getIsFrameRateBoosting() { return mIsFrameRateBoosting; } private void boostFrameRate(int boostTimeOut) { mIsFrameRateBoosting = true; setPreferredFrameRateCategory(mPreferredFrameRateCategory); mHandler.removeMessages(MSG_TOUCH_BOOST_TIMEOUT); mHandler.sendEmptyMessageDelayed(MSG_TOUCH_BOOST_TIMEOUT, boostTimeOut); } @Override public boolean transferHostTouchGestureToEmbedded( @NonNull SurfaceControlViewHost.SurfacePackage surfacePackage) { Loading
core/tests/coretests/src/android/view/ViewRootImplTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -472,6 +472,7 @@ public class ViewRootImplTest { * Test the value of the frame rate cateogry based on the visibility of a view * Invsible: FRAME_RATE_CATEGORY_NO_PREFERENCE * Visible: FRAME_RATE_CATEGORY_NORMAL * Also, mIsFrameRateBoosting should be true when the visibility becomes visible */ @Test @RequiresFlagsEnabled(FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY) Loading @@ -485,6 +486,7 @@ public class ViewRootImplTest { assertEquals(viewRootImpl.getPreferredFrameRateCategory(), FRAME_RATE_CATEGORY_NO_PREFERENCE); }); sInstrumentation.waitForIdleSync(); sInstrumentation.runOnMainSync(() -> { view.setVisibility(View.VISIBLE); Loading @@ -492,6 +494,11 @@ public class ViewRootImplTest { assertEquals(viewRootImpl.getPreferredFrameRateCategory(), FRAME_RATE_CATEGORY_NORMAL); }); sInstrumentation.waitForIdleSync(); sInstrumentation.runOnMainSync(() -> { assertEquals(viewRootImpl.getIsFrameRateBoosting(), true); }); } /** Loading