Loading Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -404,6 +404,7 @@ java_defaults { "android.hardware.common.fmq-V1-java", "bouncycastle-repackaged-unbundled", "com.android.sysprop.foldlockbehavior", "com.android.sysprop.view", "framework-internal-utils", // If MimeMap ever becomes its own APEX, then this dependency would need to be removed // in favor of an API stubs dependency in java_library "framework" below. Loading core/java/android/view/ViewRootImpl.java +9 −6 Original line number Diff line number Diff line Loading @@ -203,6 +203,7 @@ import android.os.Trace; import android.os.UserHandle; import android.provider.Settings; import android.sysprop.DisplayProperties; import android.sysprop.ViewProperties; import android.text.TextUtils; import android.util.AndroidRuntimeException; import android.util.DisplayMetrics; Loading Loading @@ -1209,6 +1210,7 @@ public final class ViewRootImpl implements ViewParent, Flags.enableInvalidateCheckThread(); private static boolean sSurfaceFlingerBugfixFlagValue = com.android.graphics.surfaceflinger.flags.Flags.vrrBugfix24q4(); private static final boolean sEnableVrr = ViewProperties.vrr_enabled().orElse(true); static { sToolkitSetFrameRateReadOnlyFlagValue = toolkitSetFrameRateReadOnly(); Loading Loading @@ -12924,13 +12926,13 @@ public final class ViewRootImpl implements ViewParent, private boolean shouldSetFrameRateCategory() { // use toolkitSetFrameRate flag to gate the change return mSurface.isValid() && shouldEnableDvrr(); return shouldEnableDvrr() && mSurface.isValid() && shouldEnableDvrr(); } private boolean shouldSetFrameRate() { // use toolkitSetFrameRate flag to gate the change return mSurface.isValid() && mPreferredFrameRate >= 0 && shouldEnableDvrr() && !mIsFrameRateConflicted; return shouldEnableDvrr() && mSurface.isValid() && mPreferredFrameRate >= 0 && !mIsFrameRateConflicted; } private boolean shouldTouchBoost(int motionEventAction, int windowType) { Loading Loading @@ -12965,7 +12967,7 @@ public final class ViewRootImpl implements ViewParent, * @param view The View with the ThreadedRenderer animation that started. */ public void addThreadedRendererView(View view) { if (!mThreadedRendererViews.contains(view)) { if (shouldEnableDvrr() && !mThreadedRendererViews.contains(view)) { mThreadedRendererViews.add(view); } } Loading @@ -12977,7 +12979,8 @@ public final class ViewRootImpl implements ViewParent, */ public void removeThreadedRendererView(View view) { mThreadedRendererViews.remove(view); if (!mInvalidationIdleMessagePosted && sSurfaceFlingerBugfixFlagValue) { if (shouldEnableDvrr() && !mInvalidationIdleMessagePosted && sSurfaceFlingerBugfixFlagValue) { mInvalidationIdleMessagePosted = true; mHandler.sendEmptyMessageDelayed(MSG_CHECK_INVALIDATION_IDLE, IDLE_TIME_MILLIS); } Loading Loading @@ -13198,7 +13201,7 @@ public final class ViewRootImpl implements ViewParent, private boolean shouldEnableDvrr() { // uncomment this when we are ready for enabling dVRR if (sToolkitFrameRateViewEnablingReadOnlyFlagValue) { if (sEnableVrr && sToolkitFrameRateViewEnablingReadOnlyFlagValue) { return sToolkitSetFrameRateReadOnlyFlagValue && isFrameRatePowerSavingsBalanced(); } return false; core/sysprop/Android.bp +7 −0 Original line number Diff line number Diff line Loading @@ -43,3 +43,10 @@ sysprop_library { property_owner: "Platform", api_packages: ["android.sysprop"], } sysprop_library { name: "com.android.sysprop.view", srcs: ["ViewProperties.sysprop"], property_owner: "Platform", api_packages: ["android.sysprop"], } core/sysprop/ViewProperties.sysprop 0 → 100644 +29 −0 Original line number Diff line number Diff line # Copyright (C) 2024 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. module: "android.sysprop.ViewProperties" owner: Platform # On low-end devices, the cost of calculating frame rate can # have noticeable overhead. These devices don't benefit from # reduced frame rate as much as they benefit from reduced # work. By setting this to false, the device won't do any # VRR frame rate calculation for Views. prop { api_name: "vrr_enabled" type: Boolean prop_name: "ro.view.vrr.enabled" scope: Internal access: Readonly } core/tests/coretests/src/android/view/ViewFrameRateTest.java +67 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import android.platform.test.annotations.LargeTest; import android.platform.test.annotations.RequiresFlagsEnabled; import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.DeviceFlagsValueProvider; import android.sysprop.ViewProperties; import android.util.DisplayMetrics; import android.widget.FrameLayout; import android.widget.ProgressBar; Loading Loading @@ -101,6 +102,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_VIEW_VELOCITY_API, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void frameRateChangesWhenContentMoves() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } waitForFrameRateCategoryToSettle(); mActivityRule.runOnUiThread(() -> { mMovingView.offsetLeftAndRight(100); Loading @@ -127,6 +131,9 @@ public class ViewFrameRateTest { @Test @RequiresFlagsEnabled(FLAG_VIEW_VELOCITY_API) public void frameBoostDisable() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mActivityRule.runOnUiThread(() -> { long now = SystemClock.uptimeMillis(); MotionEvent down = MotionEvent.obtain( Loading Loading @@ -155,6 +162,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VELOCITY_MAPPING_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void lowVelocity60() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mActivityRule.runOnUiThread(() -> { ViewGroup.LayoutParams layoutParams = mMovingView.getLayoutParams(); layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; Loading @@ -175,6 +185,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VELOCITY_MAPPING_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void velocityWithChildMovement() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } FrameLayout frameLayout = new FrameLayout(mActivity); mActivityRule.runOnUiThread(() -> { ViewGroup.LayoutParams fullSize = new ViewGroup.LayoutParams( Loading @@ -201,6 +214,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VELOCITY_MAPPING_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void highVelocity120() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mActivityRule.runOnUiThread(() -> { ViewGroup.LayoutParams layoutParams = mMovingView.getLayoutParams(); layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; Loading @@ -222,6 +238,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void noVelocityUsesCategorySmall() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } final CountDownLatch drawLatch1 = new CountDownLatch(1); mActivityRule.runOnUiThread(() -> { DisplayMetrics displayMetrics = mActivity.getResources().getDisplayMetrics(); Loading Loading @@ -259,6 +278,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void noVelocityUsesCategoryNarrowWidth() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } final CountDownLatch drawLatch1 = new CountDownLatch(1); mActivityRule.runOnUiThread(() -> { DisplayMetrics displayMetrics = mActivity.getResources().getDisplayMetrics(); Loading Loading @@ -295,6 +317,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void noVelocityUsesCategoryNarrowHeight() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } final CountDownLatch drawLatch1 = new CountDownLatch(1); mActivityRule.runOnUiThread(() -> { DisplayMetrics displayMetrics = mActivity.getResources().getDisplayMetrics(); Loading Loading @@ -331,6 +356,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void noVelocityUsesCategoryLargeWidth() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } final CountDownLatch drawLatch1 = new CountDownLatch(1); mActivityRule.runOnUiThread(() -> { DisplayMetrics displayMetrics = mActivity.getResources().getDisplayMetrics(); Loading Loading @@ -367,6 +395,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void noVelocityUsesCategoryLargeHeight() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } final CountDownLatch drawLatch1 = new CountDownLatch(1); mActivityRule.runOnUiThread(() -> { DisplayMetrics displayMetrics = mActivity.getResources().getDisplayMetrics(); Loading Loading @@ -403,6 +434,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void defaultNormal() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mActivityRule.runOnUiThread(() -> { View parent = (View) mMovingView.getParent(); ViewGroup.LayoutParams layoutParams = mMovingView.getLayoutParams(); Loading @@ -427,6 +461,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VELOCITY_MAPPING_READ_ONLY }) public void frameRateAndCategory() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE); waitForFrameRateCategoryToSettle(); mActivityRule.runOnUiThread(() -> { Loading @@ -447,6 +484,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY }) public void willNotDrawUsesCategory() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mActivityRule.runOnUiThread(() -> { mMovingView.setWillNotDraw(true); mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_LOW); Loading Loading @@ -480,6 +520,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void intermittentDoubleInvalidate() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } View parent = (View) mMovingView.getParent(); mActivityRule.runOnUiThread(() -> { parent.setWillNotDraw(false); Loading Loading @@ -526,6 +569,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY }) public void sameFrameMotion() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE); waitForFrameRateCategoryToSettle(); Loading @@ -549,6 +595,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY }) public void frameRateReset() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mMovingView.setRequestedFrameRate(120f); waitForFrameRateCategoryToSettle(); mActivityRule.runOnUiThread(() -> mMovingView.setVisibility(View.INVISIBLE)); Loading @@ -570,6 +619,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY }) public void frameRateResetWithInvalidations() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mMovingView.setRequestedFrameRate(120f); waitForFrameRateCategoryToSettle(); mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NORMAL); Loading @@ -590,6 +642,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY }) public void testQuickTouchBoost() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mActivityRule.runOnUiThread(() -> { mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_LOW); ViewGroup.LayoutParams layoutParams = mMovingView.getLayoutParams(); Loading Loading @@ -630,6 +685,9 @@ public class ViewFrameRateTest { com.android.graphics.surfaceflinger.flags.Flags.FLAG_VRR_BUGFIX_24Q4 }) public void idleDetected() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } waitForFrameRateCategoryToSettle(); mActivityRule.runOnUiThread(() -> { mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_HIGH); Loading @@ -654,6 +712,9 @@ public class ViewFrameRateTest { com.android.graphics.surfaceflinger.flags.Flags.FLAG_VRR_BUGFIX_24Q4 }) public void vectorDrawableFrameRate() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } final ProgressBar[] progressBars = new ProgressBar[3]; final ViewGroup[] parents = new ViewGroup[1]; mActivityRule.runOnUiThread(() -> { Loading Loading @@ -711,6 +772,9 @@ public class ViewFrameRateTest { com.android.graphics.surfaceflinger.flags.Flags.FLAG_VRR_BUGFIX_24Q4 }) public void renderNodeAnimatorFrameRateCanceled() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE); waitForFrameRateCategoryToSettle(); Loading Loading @@ -748,6 +812,9 @@ public class ViewFrameRateTest { com.android.graphics.surfaceflinger.flags.Flags.FLAG_VRR_BUGFIX_24Q4 }) public void renderNodeAnimatorFrameRateRemoved() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE); waitForFrameRateCategoryToSettle(); Loading Loading
Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -404,6 +404,7 @@ java_defaults { "android.hardware.common.fmq-V1-java", "bouncycastle-repackaged-unbundled", "com.android.sysprop.foldlockbehavior", "com.android.sysprop.view", "framework-internal-utils", // If MimeMap ever becomes its own APEX, then this dependency would need to be removed // in favor of an API stubs dependency in java_library "framework" below. Loading
core/java/android/view/ViewRootImpl.java +9 −6 Original line number Diff line number Diff line Loading @@ -203,6 +203,7 @@ import android.os.Trace; import android.os.UserHandle; import android.provider.Settings; import android.sysprop.DisplayProperties; import android.sysprop.ViewProperties; import android.text.TextUtils; import android.util.AndroidRuntimeException; import android.util.DisplayMetrics; Loading Loading @@ -1209,6 +1210,7 @@ public final class ViewRootImpl implements ViewParent, Flags.enableInvalidateCheckThread(); private static boolean sSurfaceFlingerBugfixFlagValue = com.android.graphics.surfaceflinger.flags.Flags.vrrBugfix24q4(); private static final boolean sEnableVrr = ViewProperties.vrr_enabled().orElse(true); static { sToolkitSetFrameRateReadOnlyFlagValue = toolkitSetFrameRateReadOnly(); Loading Loading @@ -12924,13 +12926,13 @@ public final class ViewRootImpl implements ViewParent, private boolean shouldSetFrameRateCategory() { // use toolkitSetFrameRate flag to gate the change return mSurface.isValid() && shouldEnableDvrr(); return shouldEnableDvrr() && mSurface.isValid() && shouldEnableDvrr(); } private boolean shouldSetFrameRate() { // use toolkitSetFrameRate flag to gate the change return mSurface.isValid() && mPreferredFrameRate >= 0 && shouldEnableDvrr() && !mIsFrameRateConflicted; return shouldEnableDvrr() && mSurface.isValid() && mPreferredFrameRate >= 0 && !mIsFrameRateConflicted; } private boolean shouldTouchBoost(int motionEventAction, int windowType) { Loading Loading @@ -12965,7 +12967,7 @@ public final class ViewRootImpl implements ViewParent, * @param view The View with the ThreadedRenderer animation that started. */ public void addThreadedRendererView(View view) { if (!mThreadedRendererViews.contains(view)) { if (shouldEnableDvrr() && !mThreadedRendererViews.contains(view)) { mThreadedRendererViews.add(view); } } Loading @@ -12977,7 +12979,8 @@ public final class ViewRootImpl implements ViewParent, */ public void removeThreadedRendererView(View view) { mThreadedRendererViews.remove(view); if (!mInvalidationIdleMessagePosted && sSurfaceFlingerBugfixFlagValue) { if (shouldEnableDvrr() && !mInvalidationIdleMessagePosted && sSurfaceFlingerBugfixFlagValue) { mInvalidationIdleMessagePosted = true; mHandler.sendEmptyMessageDelayed(MSG_CHECK_INVALIDATION_IDLE, IDLE_TIME_MILLIS); } Loading Loading @@ -13198,7 +13201,7 @@ public final class ViewRootImpl implements ViewParent, private boolean shouldEnableDvrr() { // uncomment this when we are ready for enabling dVRR if (sToolkitFrameRateViewEnablingReadOnlyFlagValue) { if (sEnableVrr && sToolkitFrameRateViewEnablingReadOnlyFlagValue) { return sToolkitSetFrameRateReadOnlyFlagValue && isFrameRatePowerSavingsBalanced(); } return false;
core/sysprop/Android.bp +7 −0 Original line number Diff line number Diff line Loading @@ -43,3 +43,10 @@ sysprop_library { property_owner: "Platform", api_packages: ["android.sysprop"], } sysprop_library { name: "com.android.sysprop.view", srcs: ["ViewProperties.sysprop"], property_owner: "Platform", api_packages: ["android.sysprop"], }
core/sysprop/ViewProperties.sysprop 0 → 100644 +29 −0 Original line number Diff line number Diff line # Copyright (C) 2024 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. module: "android.sysprop.ViewProperties" owner: Platform # On low-end devices, the cost of calculating frame rate can # have noticeable overhead. These devices don't benefit from # reduced frame rate as much as they benefit from reduced # work. By setting this to false, the device won't do any # VRR frame rate calculation for Views. prop { api_name: "vrr_enabled" type: Boolean prop_name: "ro.view.vrr.enabled" scope: Internal access: Readonly }
core/tests/coretests/src/android/view/ViewFrameRateTest.java +67 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import android.platform.test.annotations.LargeTest; import android.platform.test.annotations.RequiresFlagsEnabled; import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.DeviceFlagsValueProvider; import android.sysprop.ViewProperties; import android.util.DisplayMetrics; import android.widget.FrameLayout; import android.widget.ProgressBar; Loading Loading @@ -101,6 +102,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_VIEW_VELOCITY_API, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void frameRateChangesWhenContentMoves() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } waitForFrameRateCategoryToSettle(); mActivityRule.runOnUiThread(() -> { mMovingView.offsetLeftAndRight(100); Loading @@ -127,6 +131,9 @@ public class ViewFrameRateTest { @Test @RequiresFlagsEnabled(FLAG_VIEW_VELOCITY_API) public void frameBoostDisable() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mActivityRule.runOnUiThread(() -> { long now = SystemClock.uptimeMillis(); MotionEvent down = MotionEvent.obtain( Loading Loading @@ -155,6 +162,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VELOCITY_MAPPING_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void lowVelocity60() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mActivityRule.runOnUiThread(() -> { ViewGroup.LayoutParams layoutParams = mMovingView.getLayoutParams(); layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; Loading @@ -175,6 +185,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VELOCITY_MAPPING_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void velocityWithChildMovement() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } FrameLayout frameLayout = new FrameLayout(mActivity); mActivityRule.runOnUiThread(() -> { ViewGroup.LayoutParams fullSize = new ViewGroup.LayoutParams( Loading @@ -201,6 +214,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VELOCITY_MAPPING_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void highVelocity120() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mActivityRule.runOnUiThread(() -> { ViewGroup.LayoutParams layoutParams = mMovingView.getLayoutParams(); layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; Loading @@ -222,6 +238,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void noVelocityUsesCategorySmall() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } final CountDownLatch drawLatch1 = new CountDownLatch(1); mActivityRule.runOnUiThread(() -> { DisplayMetrics displayMetrics = mActivity.getResources().getDisplayMetrics(); Loading Loading @@ -259,6 +278,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void noVelocityUsesCategoryNarrowWidth() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } final CountDownLatch drawLatch1 = new CountDownLatch(1); mActivityRule.runOnUiThread(() -> { DisplayMetrics displayMetrics = mActivity.getResources().getDisplayMetrics(); Loading Loading @@ -295,6 +317,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void noVelocityUsesCategoryNarrowHeight() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } final CountDownLatch drawLatch1 = new CountDownLatch(1); mActivityRule.runOnUiThread(() -> { DisplayMetrics displayMetrics = mActivity.getResources().getDisplayMetrics(); Loading Loading @@ -331,6 +356,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void noVelocityUsesCategoryLargeWidth() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } final CountDownLatch drawLatch1 = new CountDownLatch(1); mActivityRule.runOnUiThread(() -> { DisplayMetrics displayMetrics = mActivity.getResources().getDisplayMetrics(); Loading Loading @@ -367,6 +395,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void noVelocityUsesCategoryLargeHeight() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } final CountDownLatch drawLatch1 = new CountDownLatch(1); mActivityRule.runOnUiThread(() -> { DisplayMetrics displayMetrics = mActivity.getResources().getDisplayMetrics(); Loading Loading @@ -403,6 +434,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void defaultNormal() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mActivityRule.runOnUiThread(() -> { View parent = (View) mMovingView.getParent(); ViewGroup.LayoutParams layoutParams = mMovingView.getLayoutParams(); Loading @@ -427,6 +461,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VELOCITY_MAPPING_READ_ONLY }) public void frameRateAndCategory() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE); waitForFrameRateCategoryToSettle(); mActivityRule.runOnUiThread(() -> { Loading @@ -447,6 +484,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY }) public void willNotDrawUsesCategory() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mActivityRule.runOnUiThread(() -> { mMovingView.setWillNotDraw(true); mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_LOW); Loading Loading @@ -480,6 +520,9 @@ public class ViewFrameRateTest { @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY}) public void intermittentDoubleInvalidate() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } View parent = (View) mMovingView.getParent(); mActivityRule.runOnUiThread(() -> { parent.setWillNotDraw(false); Loading Loading @@ -526,6 +569,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY }) public void sameFrameMotion() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE); waitForFrameRateCategoryToSettle(); Loading @@ -549,6 +595,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY }) public void frameRateReset() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mMovingView.setRequestedFrameRate(120f); waitForFrameRateCategoryToSettle(); mActivityRule.runOnUiThread(() -> mMovingView.setVisibility(View.INVISIBLE)); Loading @@ -570,6 +619,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY }) public void frameRateResetWithInvalidations() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mMovingView.setRequestedFrameRate(120f); waitForFrameRateCategoryToSettle(); mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NORMAL); Loading @@ -590,6 +642,9 @@ public class ViewFrameRateTest { FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY }) public void testQuickTouchBoost() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mActivityRule.runOnUiThread(() -> { mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_LOW); ViewGroup.LayoutParams layoutParams = mMovingView.getLayoutParams(); Loading Loading @@ -630,6 +685,9 @@ public class ViewFrameRateTest { com.android.graphics.surfaceflinger.flags.Flags.FLAG_VRR_BUGFIX_24Q4 }) public void idleDetected() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } waitForFrameRateCategoryToSettle(); mActivityRule.runOnUiThread(() -> { mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_HIGH); Loading @@ -654,6 +712,9 @@ public class ViewFrameRateTest { com.android.graphics.surfaceflinger.flags.Flags.FLAG_VRR_BUGFIX_24Q4 }) public void vectorDrawableFrameRate() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } final ProgressBar[] progressBars = new ProgressBar[3]; final ViewGroup[] parents = new ViewGroup[1]; mActivityRule.runOnUiThread(() -> { Loading Loading @@ -711,6 +772,9 @@ public class ViewFrameRateTest { com.android.graphics.surfaceflinger.flags.Flags.FLAG_VRR_BUGFIX_24Q4 }) public void renderNodeAnimatorFrameRateCanceled() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE); waitForFrameRateCategoryToSettle(); Loading Loading @@ -748,6 +812,9 @@ public class ViewFrameRateTest { com.android.graphics.surfaceflinger.flags.Flags.FLAG_VRR_BUGFIX_24Q4 }) public void renderNodeAnimatorFrameRateRemoved() throws Throwable { if (!ViewProperties.vrr_enabled().orElse(true)) { return; } mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE); waitForFrameRateCategoryToSettle(); Loading