Loading core/java/android/view/ViewRootImpl.java +0 −42 Original line number Diff line number Diff line Loading @@ -427,12 +427,6 @@ public final class ViewRootImpl implements ViewParent, private static final long NANOS_PER_SEC = 1000000000; // If the ViewRootImpl has been idle for more than 200ms, clear the preferred // frame rate category and frame rate. private static final int IDLE_TIME_MILLIS = 250; private static final long NANOS_PER_MILLI = 1_000_000; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) static final ThreadLocal<HandlerActionQueue> sRunQueues = new ThreadLocal<HandlerActionQueue>(); Loading Loading @@ -665,8 +659,6 @@ public final class ViewRootImpl implements ViewParent, private int mMinusOneFrameIntervalMillis = 0; // VRR interval between the previous and the frame before private int mMinusTwoFrameIntervalMillis = 0; // VRR has the invalidation idle message been posted? private boolean mInvalidationIdleMessagePosted = false; /** * Update the Choreographer's FrameInfo object with the timing information for the current Loading Loading @@ -4278,10 +4270,6 @@ public final class ViewRootImpl implements ViewParent, // when the values are applicable. if (mDrawnThisFrame) { mDrawnThisFrame = false; if (!mInvalidationIdleMessagePosted) { mInvalidationIdleMessagePosted = true; mHandler.sendEmptyMessageDelayed(MSG_CHECK_INVALIDATION_IDLE, IDLE_TIME_MILLIS); } setCategoryFromCategoryCounts(); updateInfrequentCount(); setPreferredFrameRate(mPreferredFrameRate); Loading Loading @@ -6523,8 +6511,6 @@ public final class ViewRootImpl implements ViewParent, return "MSG_WINDOW_TOUCH_MODE_CHANGED"; case MSG_KEEP_CLEAR_RECTS_CHANGED: return "MSG_KEEP_CLEAR_RECTS_CHANGED"; case MSG_CHECK_INVALIDATION_IDLE: return "MSG_CHECK_INVALIDATION_IDLE"; case MSG_REFRESH_POINTER_ICON: return "MSG_REFRESH_POINTER_ICON"; case MSG_TOUCH_BOOST_TIMEOUT: Loading Loading @@ -6789,30 +6775,6 @@ public final class ViewRootImpl implements ViewParent, mNumPausedForSync = 0; scheduleTraversals(); break; case MSG_CHECK_INVALIDATION_IDLE: { long delta; if (mIsTouchBoosting || mIsFrameRateBoosting || mInsetsAnimationRunning) { delta = 0; } else { delta = System.nanoTime() / NANOS_PER_MILLI - mLastUpdateTimeMillis; } if (delta >= IDLE_TIME_MILLIS) { mFrameRateCategoryHighCount = 0; mFrameRateCategoryHighHintCount = 0; mFrameRateCategoryNormalCount = 0; mFrameRateCategoryLowCount = 0; mPreferredFrameRate = 0; mPreferredFrameRateCategory = FRAME_RATE_CATEGORY_NO_PREFERENCE; setPreferredFrameRateCategory(FRAME_RATE_CATEGORY_NO_PREFERENCE); setPreferredFrameRate(0f); mInvalidationIdleMessagePosted = false; } else { mInvalidationIdleMessagePosted = true; mHandler.sendEmptyMessageDelayed(MSG_CHECK_INVALIDATION_IDLE, IDLE_TIME_MILLIS - delta); } break; } case MSG_TOUCH_BOOST_TIMEOUT: /** * Lower the frame rate after the boosting period (FRAME_RATE_TOUCH_BOOST_TIME). Loading Loading @@ -13041,10 +13003,6 @@ public final class ViewRootImpl implements ViewParent, private void removeVrrMessages() { mHandler.removeMessages(MSG_TOUCH_BOOST_TIMEOUT); mHandler.removeMessages(MSG_FRAME_RATE_SETTING); if (mInvalidationIdleMessagePosted) { mInvalidationIdleMessagePosted = false; mHandler.removeMessages(MSG_CHECK_INVALIDATION_IDLE); } } /** core/tests/coretests/src/android/view/ViewFrameRateTest.java +0 −22 Original line number Diff line number Diff line Loading @@ -623,28 +623,6 @@ public class ViewFrameRateTest { assertEquals(FRAME_RATE_CATEGORY_HIGH_HINT, mViewRoot.getLastPreferredFrameRateCategory()); } @Test @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY }) public void idleDetected() throws Throwable { waitForFrameRateCategoryToSettle(); mActivityRule.runOnUiThread(() -> { mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_HIGH); mMovingView.setFrameContentVelocity(Float.MAX_VALUE); mMovingView.invalidate(); runAfterDraw(() -> assertEquals(FRAME_RATE_CATEGORY_HIGH, mViewRoot.getLastPreferredFrameRateCategory())); }); waitForAfterDraw(); // Wait for idle timeout Thread.sleep(500); assertEquals(0f, mViewRoot.getLastPreferredFrameRate()); assertEquals(FRAME_RATE_CATEGORY_NO_PREFERENCE, mViewRoot.getLastPreferredFrameRateCategory()); } private void runAfterDraw(@NonNull Runnable runnable) { Handler handler = new Handler(Looper.getMainLooper()); mAfterDrawLatch = new CountDownLatch(1); Loading Loading
core/java/android/view/ViewRootImpl.java +0 −42 Original line number Diff line number Diff line Loading @@ -427,12 +427,6 @@ public final class ViewRootImpl implements ViewParent, private static final long NANOS_PER_SEC = 1000000000; // If the ViewRootImpl has been idle for more than 200ms, clear the preferred // frame rate category and frame rate. private static final int IDLE_TIME_MILLIS = 250; private static final long NANOS_PER_MILLI = 1_000_000; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) static final ThreadLocal<HandlerActionQueue> sRunQueues = new ThreadLocal<HandlerActionQueue>(); Loading Loading @@ -665,8 +659,6 @@ public final class ViewRootImpl implements ViewParent, private int mMinusOneFrameIntervalMillis = 0; // VRR interval between the previous and the frame before private int mMinusTwoFrameIntervalMillis = 0; // VRR has the invalidation idle message been posted? private boolean mInvalidationIdleMessagePosted = false; /** * Update the Choreographer's FrameInfo object with the timing information for the current Loading Loading @@ -4278,10 +4270,6 @@ public final class ViewRootImpl implements ViewParent, // when the values are applicable. if (mDrawnThisFrame) { mDrawnThisFrame = false; if (!mInvalidationIdleMessagePosted) { mInvalidationIdleMessagePosted = true; mHandler.sendEmptyMessageDelayed(MSG_CHECK_INVALIDATION_IDLE, IDLE_TIME_MILLIS); } setCategoryFromCategoryCounts(); updateInfrequentCount(); setPreferredFrameRate(mPreferredFrameRate); Loading Loading @@ -6523,8 +6511,6 @@ public final class ViewRootImpl implements ViewParent, return "MSG_WINDOW_TOUCH_MODE_CHANGED"; case MSG_KEEP_CLEAR_RECTS_CHANGED: return "MSG_KEEP_CLEAR_RECTS_CHANGED"; case MSG_CHECK_INVALIDATION_IDLE: return "MSG_CHECK_INVALIDATION_IDLE"; case MSG_REFRESH_POINTER_ICON: return "MSG_REFRESH_POINTER_ICON"; case MSG_TOUCH_BOOST_TIMEOUT: Loading Loading @@ -6789,30 +6775,6 @@ public final class ViewRootImpl implements ViewParent, mNumPausedForSync = 0; scheduleTraversals(); break; case MSG_CHECK_INVALIDATION_IDLE: { long delta; if (mIsTouchBoosting || mIsFrameRateBoosting || mInsetsAnimationRunning) { delta = 0; } else { delta = System.nanoTime() / NANOS_PER_MILLI - mLastUpdateTimeMillis; } if (delta >= IDLE_TIME_MILLIS) { mFrameRateCategoryHighCount = 0; mFrameRateCategoryHighHintCount = 0; mFrameRateCategoryNormalCount = 0; mFrameRateCategoryLowCount = 0; mPreferredFrameRate = 0; mPreferredFrameRateCategory = FRAME_RATE_CATEGORY_NO_PREFERENCE; setPreferredFrameRateCategory(FRAME_RATE_CATEGORY_NO_PREFERENCE); setPreferredFrameRate(0f); mInvalidationIdleMessagePosted = false; } else { mInvalidationIdleMessagePosted = true; mHandler.sendEmptyMessageDelayed(MSG_CHECK_INVALIDATION_IDLE, IDLE_TIME_MILLIS - delta); } break; } case MSG_TOUCH_BOOST_TIMEOUT: /** * Lower the frame rate after the boosting period (FRAME_RATE_TOUCH_BOOST_TIME). Loading Loading @@ -13041,10 +13003,6 @@ public final class ViewRootImpl implements ViewParent, private void removeVrrMessages() { mHandler.removeMessages(MSG_TOUCH_BOOST_TIMEOUT); mHandler.removeMessages(MSG_FRAME_RATE_SETTING); if (mInvalidationIdleMessagePosted) { mInvalidationIdleMessagePosted = false; mHandler.removeMessages(MSG_CHECK_INVALIDATION_IDLE); } } /**
core/tests/coretests/src/android/view/ViewFrameRateTest.java +0 −22 Original line number Diff line number Diff line Loading @@ -623,28 +623,6 @@ public class ViewFrameRateTest { assertEquals(FRAME_RATE_CATEGORY_HIGH_HINT, mViewRoot.getLastPreferredFrameRateCategory()); } @Test @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY, FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY }) public void idleDetected() throws Throwable { waitForFrameRateCategoryToSettle(); mActivityRule.runOnUiThread(() -> { mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_HIGH); mMovingView.setFrameContentVelocity(Float.MAX_VALUE); mMovingView.invalidate(); runAfterDraw(() -> assertEquals(FRAME_RATE_CATEGORY_HIGH, mViewRoot.getLastPreferredFrameRateCategory())); }); waitForAfterDraw(); // Wait for idle timeout Thread.sleep(500); assertEquals(0f, mViewRoot.getLastPreferredFrameRate()); assertEquals(FRAME_RATE_CATEGORY_NO_PREFERENCE, mViewRoot.getLastPreferredFrameRateCategory()); } private void runAfterDraw(@NonNull Runnable runnable) { Handler handler = new Handler(Looper.getMainLooper()); mAfterDrawLatch = new CountDownLatch(1); Loading