Loading core/java/android/view/ViewRootImpl.java +17 −3 Original line number Diff line number Diff line Loading @@ -2182,9 +2182,15 @@ public final class ViewRootImpl implements ViewParent, } } void notifyInsetsAnimationRunningStateChanged(boolean running) { /** * Notify the when the running state of a insets animation changed. */ @VisibleForTesting public void notifyInsetsAnimationRunningStateChanged(boolean running) { if (sToolkitSetFrameRateReadOnlyFlagValue) { mInsetsAnimationRunning = running; } } @Override public void requestLayout() { Loading Loading @@ -11949,7 +11955,7 @@ public final class ViewRootImpl implements ViewParent, return; } int frameRateCategory = mIsFrameRateBoosting int frameRateCategory = mIsFrameRateBoosting || mInsetsAnimationRunning ? FRAME_RATE_CATEGORY_HIGH : preferredFrameRateCategory; try { Loading Loading @@ -12062,6 +12068,14 @@ public final class ViewRootImpl implements ViewParent, return mPreferredFrameRateCategory; } /** * Get the value of mLastPreferredFrameRateCategory */ @VisibleForTesting public int getLastPreferredFrameRateCategory() { return mLastPreferredFrameRateCategory; } /** * Get the value of mPreferredFrameRate */ Loading core/tests/coretests/src/android/view/ViewRootImplTest.java +36 −0 Original line number Diff line number Diff line Loading @@ -628,6 +628,42 @@ public class ViewRootImplTest { }); } /** * We should boost the frame rate if the value of mInsetsAnimationRunning is true. */ @Test @RequiresFlagsEnabled(FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY) public void votePreferredFrameRate_insetsAnimation() { View view = new View(sContext); WindowManager.LayoutParams wmlp = new WindowManager.LayoutParams(TYPE_APPLICATION_OVERLAY); wmlp.token = new Binder(); // Set a fake token to bypass 'is your activity running' check sInstrumentation.runOnMainSync(() -> { WindowManager wm = sContext.getSystemService(WindowManager.class); Display display = wm.getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics); wmlp.width = (int) (metrics.widthPixels * 0.9); wmlp.height = (int) (metrics.heightPixels * 0.9); wm.addView(view, wmlp); }); sInstrumentation.waitForIdleSync(); ViewRootImpl viewRootImpl = view.getViewRootImpl(); sInstrumentation.runOnMainSync(() -> { view.invalidate(); assertEquals(viewRootImpl.getLastPreferredFrameRateCategory(), FRAME_RATE_CATEGORY_NORMAL); viewRootImpl.notifyInsetsAnimationRunningStateChanged(true); view.invalidate(); }); sInstrumentation.waitForIdleSync(); sInstrumentation.runOnMainSync(() -> { assertEquals(viewRootImpl.getLastPreferredFrameRateCategory(), FRAME_RATE_CATEGORY_HIGH); }); } @Test public void forceInvertOffDarkThemeOff_forceDarkModeDisabled() { Loading Loading
core/java/android/view/ViewRootImpl.java +17 −3 Original line number Diff line number Diff line Loading @@ -2182,9 +2182,15 @@ public final class ViewRootImpl implements ViewParent, } } void notifyInsetsAnimationRunningStateChanged(boolean running) { /** * Notify the when the running state of a insets animation changed. */ @VisibleForTesting public void notifyInsetsAnimationRunningStateChanged(boolean running) { if (sToolkitSetFrameRateReadOnlyFlagValue) { mInsetsAnimationRunning = running; } } @Override public void requestLayout() { Loading Loading @@ -11949,7 +11955,7 @@ public final class ViewRootImpl implements ViewParent, return; } int frameRateCategory = mIsFrameRateBoosting int frameRateCategory = mIsFrameRateBoosting || mInsetsAnimationRunning ? FRAME_RATE_CATEGORY_HIGH : preferredFrameRateCategory; try { Loading Loading @@ -12062,6 +12068,14 @@ public final class ViewRootImpl implements ViewParent, return mPreferredFrameRateCategory; } /** * Get the value of mLastPreferredFrameRateCategory */ @VisibleForTesting public int getLastPreferredFrameRateCategory() { return mLastPreferredFrameRateCategory; } /** * Get the value of mPreferredFrameRate */ Loading
core/tests/coretests/src/android/view/ViewRootImplTest.java +36 −0 Original line number Diff line number Diff line Loading @@ -628,6 +628,42 @@ public class ViewRootImplTest { }); } /** * We should boost the frame rate if the value of mInsetsAnimationRunning is true. */ @Test @RequiresFlagsEnabled(FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY) public void votePreferredFrameRate_insetsAnimation() { View view = new View(sContext); WindowManager.LayoutParams wmlp = new WindowManager.LayoutParams(TYPE_APPLICATION_OVERLAY); wmlp.token = new Binder(); // Set a fake token to bypass 'is your activity running' check sInstrumentation.runOnMainSync(() -> { WindowManager wm = sContext.getSystemService(WindowManager.class); Display display = wm.getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics); wmlp.width = (int) (metrics.widthPixels * 0.9); wmlp.height = (int) (metrics.heightPixels * 0.9); wm.addView(view, wmlp); }); sInstrumentation.waitForIdleSync(); ViewRootImpl viewRootImpl = view.getViewRootImpl(); sInstrumentation.runOnMainSync(() -> { view.invalidate(); assertEquals(viewRootImpl.getLastPreferredFrameRateCategory(), FRAME_RATE_CATEGORY_NORMAL); viewRootImpl.notifyInsetsAnimationRunningStateChanged(true); view.invalidate(); }); sInstrumentation.waitForIdleSync(); sInstrumentation.runOnMainSync(() -> { assertEquals(viewRootImpl.getLastPreferredFrameRateCategory(), FRAME_RATE_CATEGORY_HIGH); }); } @Test public void forceInvertOffDarkThemeOff_forceDarkModeDisabled() { Loading