Loading core/java/android/view/View.java +1 −1 Original line number Diff line number Diff line Loading @@ -33989,7 +33989,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, || mLastFrameTop != mTop) && viewRootImpl.shouldCheckFrameRateCategory() && parent instanceof View && ((View) parent).mFrameContentVelocity <= 0 && ((View) parent).getFrameContentVelocity() <= 0 && !isInputMethodWindowType) { return FRAME_RATE_CATEGORY_HIGH_HINT | FRAME_RATE_CATEGORY_REASON_BOOST; core/java/android/view/ViewOverlay.java +15 −0 Original line number Diff line number Diff line Loading @@ -15,7 +15,10 @@ */ package android.view; import static android.view.flags.Flags.FLAG_VIEW_VELOCITY_API; import android.animation.LayoutTransition; import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; Loading Loading @@ -365,6 +368,18 @@ public class ViewOverlay { } return null; } /** * @hide */ @Override @FlaggedApi(FLAG_VIEW_VELOCITY_API) public float getFrameContentVelocity() { if (mHostView != null) { return mHostView.getFrameContentVelocity(); } return super.getFrameContentVelocity(); } } } core/java/android/view/ViewRootImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -13012,7 +13012,7 @@ public final class ViewRootImpl implements ViewParent, private boolean shouldSetFrameRateCategory() { // use toolkitSetFrameRate flag to gate the change return shouldEnableDvrr() && mSurface.isValid() && shouldEnableDvrr(); return shouldEnableDvrr() && mSurface.isValid(); } private boolean shouldSetFrameRate() { core/tests/coretests/src/android/view/ViewFrameRateTest.java +29 −0 Original line number Diff line number Diff line Loading @@ -994,6 +994,35 @@ public class ViewFrameRateTest { mViewRoot.getLastPreferredFrameRateCategory()); } /** * If a View is an instance of ViewGroupOverlay, * we obtain the velocity from its hostView. */ @Test @RequiresFlagsEnabled(FLAG_VIEW_VELOCITY_API) public void overlayViewGroupVelocity() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } FrameLayout host = new FrameLayout(mActivity); View childView = new View(mActivity); float velocity = 1000; mActivityRule.runOnUiThread(() -> { ViewGroup.LayoutParams fullSize = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mActivity.setContentView(host, fullSize); host.setFrameContentVelocity(velocity); ViewGroupOverlay overlay = host.getOverlay(); overlay.add(childView); assertEquals(velocity, host.getFrameContentVelocity()); assertEquals(host.getFrameContentVelocity(), ((View) childView.getParent()).getFrameContentVelocity()); }); } private void runAfterDraw(@NonNull Runnable runnable) { Handler handler = new Handler(Looper.getMainLooper()); mAfterDrawLatch = new CountDownLatch(1); Loading Loading
core/java/android/view/View.java +1 −1 Original line number Diff line number Diff line Loading @@ -33989,7 +33989,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, || mLastFrameTop != mTop) && viewRootImpl.shouldCheckFrameRateCategory() && parent instanceof View && ((View) parent).mFrameContentVelocity <= 0 && ((View) parent).getFrameContentVelocity() <= 0 && !isInputMethodWindowType) { return FRAME_RATE_CATEGORY_HIGH_HINT | FRAME_RATE_CATEGORY_REASON_BOOST;
core/java/android/view/ViewOverlay.java +15 −0 Original line number Diff line number Diff line Loading @@ -15,7 +15,10 @@ */ package android.view; import static android.view.flags.Flags.FLAG_VIEW_VELOCITY_API; import android.animation.LayoutTransition; import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; Loading Loading @@ -365,6 +368,18 @@ public class ViewOverlay { } return null; } /** * @hide */ @Override @FlaggedApi(FLAG_VIEW_VELOCITY_API) public float getFrameContentVelocity() { if (mHostView != null) { return mHostView.getFrameContentVelocity(); } return super.getFrameContentVelocity(); } } }
core/java/android/view/ViewRootImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -13012,7 +13012,7 @@ public final class ViewRootImpl implements ViewParent, private boolean shouldSetFrameRateCategory() { // use toolkitSetFrameRate flag to gate the change return shouldEnableDvrr() && mSurface.isValid() && shouldEnableDvrr(); return shouldEnableDvrr() && mSurface.isValid(); } private boolean shouldSetFrameRate() {
core/tests/coretests/src/android/view/ViewFrameRateTest.java +29 −0 Original line number Diff line number Diff line Loading @@ -994,6 +994,35 @@ public class ViewFrameRateTest { mViewRoot.getLastPreferredFrameRateCategory()); } /** * If a View is an instance of ViewGroupOverlay, * we obtain the velocity from its hostView. */ @Test @RequiresFlagsEnabled(FLAG_VIEW_VELOCITY_API) public void overlayViewGroupVelocity() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } FrameLayout host = new FrameLayout(mActivity); View childView = new View(mActivity); float velocity = 1000; mActivityRule.runOnUiThread(() -> { ViewGroup.LayoutParams fullSize = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mActivity.setContentView(host, fullSize); host.setFrameContentVelocity(velocity); ViewGroupOverlay overlay = host.getOverlay(); overlay.add(childView); assertEquals(velocity, host.getFrameContentVelocity()); assertEquals(host.getFrameContentVelocity(), ((View) childView.getParent()).getFrameContentVelocity()); }); } private void runAfterDraw(@NonNull Runnable runnable) { Handler handler = new Handler(Looper.getMainLooper()); mAfterDrawLatch = new CountDownLatch(1); Loading