Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32ba6b35 authored by George Mount's avatar George Mount
Browse files

[VRR] Ensure refresh rate is reset when only categories are voted

Fixes: 338219378

When frame rate is boosted due to velocity or other reasons,
when the velocity drops to 0 and the category is the only thing
that votes, the refresh rate should be reset.

Test: new test, manual testing
Change-Id: Ia3c0537b35a99f98e447cdcbc0eacf5f8efe0f80
parent 58422967
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -4261,7 +4261,9 @@ public final class ViewRootImpl implements ViewParent,
            updateInfrequentCount();
            setPreferredFrameRate(mPreferredFrameRate);
            setPreferredFrameRateCategory(mPreferredFrameRateCategory);
            if (!mIsFrameRateConflicted) {
            if (mPreferredFrameRate > 0
                    || (mLastPreferredFrameRate != 0 && mPreferredFrameRate == 0)
            ) {
                mHandler.removeMessages(MSG_FRAME_RATE_SETTING);
                mHandler.sendEmptyMessageDelayed(MSG_FRAME_RATE_SETTING,
                        FRAME_RATE_SETTING_REEVALUATE_TIME);
+20 −0
Original line number Diff line number Diff line
@@ -561,6 +561,26 @@ public class ViewFrameRateTest {
        assertEquals(0f, mViewRoot.getLastPreferredFrameRate(), 0f);
    }

    @Test
    @RequiresFlagsEnabled({FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY,
            FLAG_TOOLKIT_FRAME_RATE_VIEW_ENABLING_READ_ONLY
    })
    public void frameRateResetWithInvalidations() throws Throwable {
        mMovingView.setRequestedFrameRate(120f);
        waitForFrameRateCategoryToSettle();
        mMovingView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NORMAL);

        for (int i = 0; i < 120; i++) {
            mActivityRule.runOnUiThread(() -> {
                mMovingView.invalidate();
                runAfterDraw(() -> {});
            });
            waitForAfterDraw();
        }

        assertEquals(0f, mViewRoot.getLastPreferredFrameRate(), 0f);
    }

    private void runAfterDraw(@NonNull Runnable runnable) {
        Handler handler = new Handler(Looper.getMainLooper());
        mAfterDrawLatch = new CountDownLatch(1);