Loading core/java/android/view/View.java +10 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import static android.view.flags.Flags.FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY; import static android.view.flags.Flags.FLAG_VIEW_VELOCITY_API; import static android.view.flags.Flags.enableUseMeasureCacheDuringForceLayout; import static android.view.flags.Flags.sensitiveContentAppProtection; import static android.view.flags.Flags.toolkitFrameRateAnimationBugfix25q1; import static android.view.flags.Flags.toolkitFrameRateBySizeReadOnly; import static android.view.flags.Flags.toolkitFrameRateDefaultNormalReadOnly; import static android.view.flags.Flags.toolkitFrameRateSmallUsesPercentReadOnly; Loading Loading @@ -2458,13 +2459,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, toolkitFrameRateDefaultNormalReadOnly(); private static final boolean sToolkitFrameRateBySizeReadOnlyFlagValue = toolkitFrameRateBySizeReadOnly(); private static final boolean sToolkitFrameRateSmallUsesPercentReadOnlyFlagValue = toolkitFrameRateSmallUsesPercentReadOnly(); private static final boolean sToolkitFrameRateViewEnablingReadOnlyFlagValue = toolkitFrameRateViewEnablingReadOnly(); private static boolean sToolkitFrameRateVelocityMappingReadOnlyFlagValue = toolkitFrameRateVelocityMappingReadOnly(); private static boolean sToolkitFrameRateAnimationBugfix25q1FlagValue = toolkitFrameRateAnimationBugfix25q1(); // Used to set frame rate compatibility. @Surface.FrameRateCompatibility int mFrameRateCompatibility = Loading Loading @@ -24429,6 +24431,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, invalidationTransform = t; } // Increase the frame rate if there is a transformation that applies a matrix. if (sToolkitFrameRateAnimationBugfix25q1FlagValue && ((t.getTransformationType() & Transformation.TYPE_MATRIX) != 0)) { mPrivateFlags4 |= PFLAG4_HAS_VIEW_PROPERTY_INVALIDATION; mPrivateFlags4 |= PFLAG4_HAS_MOVED; } if (more) { if (!a.willChangeBounds()) { if ((flags & (ViewGroup.FLAG_OPTIMIZE_INVALIDATE | ViewGroup.FLAG_ANIMATION_DONE)) == core/java/android/view/flags/refresh_rate_flags.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -112,3 +112,11 @@ flag { bug: "335874198" is_fixed_read_only: true } flag { name: "toolkit_frame_rate_animation_bugfix_25q1" namespace: "toolkit" description: "Feature flag to enable the fix for applyLegacyAnimation for VRR V QPR2" bug: "335874198" is_fixed_read_only: true } No newline at end of file core/tests/coretests/src/android/view/ViewFrameRateTest.java +27 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static android.view.Surface.FRAME_RATE_CATEGORY_LOW; import static android.view.Surface.FRAME_RATE_CATEGORY_NORMAL; import static android.view.Surface.FRAME_RATE_CATEGORY_NO_PREFERENCE; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.flags.Flags.FLAG_TOOLKIT_FRAME_RATE_ANIMATION_BUGFIX_25Q1; import static android.view.flags.Flags.FLAG_TOOLKIT_FRAME_RATE_VELOCITY_MAPPING_READ_ONLY; import static android.view.flags.Flags.FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY; import static android.view.flags.Flags.FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY; Loading @@ -46,6 +47,8 @@ import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.DeviceFlagsValueProvider; import android.sysprop.ViewProperties; import android.util.DisplayMetrics; import android.view.animation.Animation; import android.view.animation.TranslateAnimation; import android.widget.FrameLayout; import android.widget.ProgressBar; Loading Loading @@ -1023,6 +1026,30 @@ public class ViewFrameRateTest { }); } @Test @RequiresFlagsEnabled(FLAG_TOOLKIT_FRAME_RATE_ANIMATION_BUGFIX_25Q1) public void boostWhenApplyLegacyAnimation() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } waitForFrameRateCategoryToSettle(); mActivityRule.runOnUiThread(() -> { TranslateAnimation translateAnimation = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, 0f, // fromXDelta Animation.RELATIVE_TO_PARENT, 0f, // toXDelta Animation.RELATIVE_TO_PARENT, 1f, // fromYDelta (100%p) Animation.RELATIVE_TO_PARENT, 0f // toYDelta ); translateAnimation.setDuration(600); mMovingView.startAnimation(translateAnimation); runAfterDraw(() -> assertEquals(FRAME_RATE_CATEGORY_HIGH_HINT, mViewRoot.getLastPreferredFrameRateCategory())); }); waitForAfterDraw(); } private void runAfterDraw(@NonNull Runnable runnable) { Handler handler = new Handler(Looper.getMainLooper()); mAfterDrawLatch = new CountDownLatch(1); Loading Loading
core/java/android/view/View.java +10 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ import static android.view.flags.Flags.FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY; import static android.view.flags.Flags.FLAG_VIEW_VELOCITY_API; import static android.view.flags.Flags.enableUseMeasureCacheDuringForceLayout; import static android.view.flags.Flags.sensitiveContentAppProtection; import static android.view.flags.Flags.toolkitFrameRateAnimationBugfix25q1; import static android.view.flags.Flags.toolkitFrameRateBySizeReadOnly; import static android.view.flags.Flags.toolkitFrameRateDefaultNormalReadOnly; import static android.view.flags.Flags.toolkitFrameRateSmallUsesPercentReadOnly; Loading Loading @@ -2458,13 +2459,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, toolkitFrameRateDefaultNormalReadOnly(); private static final boolean sToolkitFrameRateBySizeReadOnlyFlagValue = toolkitFrameRateBySizeReadOnly(); private static final boolean sToolkitFrameRateSmallUsesPercentReadOnlyFlagValue = toolkitFrameRateSmallUsesPercentReadOnly(); private static final boolean sToolkitFrameRateViewEnablingReadOnlyFlagValue = toolkitFrameRateViewEnablingReadOnly(); private static boolean sToolkitFrameRateVelocityMappingReadOnlyFlagValue = toolkitFrameRateVelocityMappingReadOnly(); private static boolean sToolkitFrameRateAnimationBugfix25q1FlagValue = toolkitFrameRateAnimationBugfix25q1(); // Used to set frame rate compatibility. @Surface.FrameRateCompatibility int mFrameRateCompatibility = Loading Loading @@ -24429,6 +24431,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, invalidationTransform = t; } // Increase the frame rate if there is a transformation that applies a matrix. if (sToolkitFrameRateAnimationBugfix25q1FlagValue && ((t.getTransformationType() & Transformation.TYPE_MATRIX) != 0)) { mPrivateFlags4 |= PFLAG4_HAS_VIEW_PROPERTY_INVALIDATION; mPrivateFlags4 |= PFLAG4_HAS_MOVED; } if (more) { if (!a.willChangeBounds()) { if ((flags & (ViewGroup.FLAG_OPTIMIZE_INVALIDATE | ViewGroup.FLAG_ANIMATION_DONE)) ==
core/java/android/view/flags/refresh_rate_flags.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -112,3 +112,11 @@ flag { bug: "335874198" is_fixed_read_only: true } flag { name: "toolkit_frame_rate_animation_bugfix_25q1" namespace: "toolkit" description: "Feature flag to enable the fix for applyLegacyAnimation for VRR V QPR2" bug: "335874198" is_fixed_read_only: true } No newline at end of file
core/tests/coretests/src/android/view/ViewFrameRateTest.java +27 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static android.view.Surface.FRAME_RATE_CATEGORY_LOW; import static android.view.Surface.FRAME_RATE_CATEGORY_NORMAL; import static android.view.Surface.FRAME_RATE_CATEGORY_NO_PREFERENCE; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.flags.Flags.FLAG_TOOLKIT_FRAME_RATE_ANIMATION_BUGFIX_25Q1; import static android.view.flags.Flags.FLAG_TOOLKIT_FRAME_RATE_VELOCITY_MAPPING_READ_ONLY; import static android.view.flags.Flags.FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY; import static android.view.flags.Flags.FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY; Loading @@ -46,6 +47,8 @@ import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.DeviceFlagsValueProvider; import android.sysprop.ViewProperties; import android.util.DisplayMetrics; import android.view.animation.Animation; import android.view.animation.TranslateAnimation; import android.widget.FrameLayout; import android.widget.ProgressBar; Loading Loading @@ -1023,6 +1026,30 @@ public class ViewFrameRateTest { }); } @Test @RequiresFlagsEnabled(FLAG_TOOLKIT_FRAME_RATE_ANIMATION_BUGFIX_25Q1) public void boostWhenApplyLegacyAnimation() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } waitForFrameRateCategoryToSettle(); mActivityRule.runOnUiThread(() -> { TranslateAnimation translateAnimation = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, 0f, // fromXDelta Animation.RELATIVE_TO_PARENT, 0f, // toXDelta Animation.RELATIVE_TO_PARENT, 1f, // fromYDelta (100%p) Animation.RELATIVE_TO_PARENT, 0f // toYDelta ); translateAnimation.setDuration(600); mMovingView.startAnimation(translateAnimation); runAfterDraw(() -> assertEquals(FRAME_RATE_CATEGORY_HIGH_HINT, mViewRoot.getLastPreferredFrameRateCategory())); }); waitForAfterDraw(); } private void runAfterDraw(@NonNull Runnable runnable) { Handler handler = new Handler(Looper.getMainLooper()); mAfterDrawLatch = new CountDownLatch(1); Loading