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

Commit a78641dc authored by George Mount's avatar George Mount
Browse files

[VRR] Step 3: infrequent updates should have category LOW

Bug: 329156449

Test: modified tests
Change-Id: I249dcfe24259253d502c30ae1986911d97052c11
parent 58422967
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -33942,8 +33942,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    protected int calculateFrameRateCategory() {
        int category;
        switch (getViewRootImpl().intermittentUpdateState()) {
            case ViewRootImpl.INTERMITTENT_STATE_INTERMITTENT ->
                    category = FRAME_RATE_CATEGORY_NORMAL | FRAME_RATE_CATEGORY_REASON_INTERMITTENT;
            case ViewRootImpl.INTERMITTENT_STATE_INTERMITTENT -> category =
                    (sToolkitFrameRateBySizeReadOnlyFlagValue ? FRAME_RATE_CATEGORY_LOW
                            : FRAME_RATE_CATEGORY_NORMAL) | FRAME_RATE_CATEGORY_REASON_INTERMITTENT;
            case ViewRootImpl.INTERMITTENT_STATE_NOT_INTERMITTENT ->
                    category = mSizeBasedFrameRateCategoryAndReason;
            default -> category = mLastFrameRateCategory;
+6 −3
Original line number Diff line number Diff line
@@ -488,16 +488,19 @@ public class ViewFrameRateTest {
        waitForFrameRateCategoryToSettle();
        for (int i = 0; i < 5; i++) {
            int expectedCategory;
            if (i < 4) {
            if (i < 2) {
                // not intermittent yet.
                // It takes 2 frames of intermittency before Views vote as intermittent.
                // It takes 4 more frames for the category to drop to the next category.
                expectedCategory =
                        toolkitFrameRateDefaultNormalReadOnly() ? FRAME_RATE_CATEGORY_NORMAL
                                : FRAME_RATE_CATEGORY_HIGH;
            } else {
                // intermittent
                expectedCategory = FRAME_RATE_CATEGORY_NORMAL;
                // Even though this is not a small View, step 3 is triggered by this flag, which
                // brings intermittent to LOW
                expectedCategory = toolkitFrameRateBySizeReadOnly()
                        ? FRAME_RATE_CATEGORY_LOW
                        : FRAME_RATE_CATEGORY_NORMAL;
            }
            mActivityRule.runOnUiThread(() -> {
                mMovingView.invalidate();
+9 −2
Original line number Diff line number Diff line
@@ -1174,9 +1174,16 @@ public class ViewRootImplTest {

        // Infrequent update
        Thread.sleep(delay);

        // Even though this is not a small View, step 3 is triggered by this flag, which
        // brings intermittent to LOW
        int intermittentExpected = toolkitFrameRateBySizeReadOnly()
                ? FRAME_RATE_CATEGORY_LOW
                : FRAME_RATE_CATEGORY_NORMAL;

        sInstrumentation.runOnMainSync(() -> {
            mView.invalidate();
            runAfterDraw(() -> assertEquals(FRAME_RATE_CATEGORY_NORMAL,
            runAfterDraw(() -> assertEquals(intermittentExpected,
                    mViewRootImpl.getLastPreferredFrameRateCategory()));
        });
        waitForAfterDraw();
@@ -1184,7 +1191,7 @@ public class ViewRootImplTest {
        // When the View vote, it's still considered as intermittent update state
        sInstrumentation.runOnMainSync(() -> {
            mView.invalidate();
            runAfterDraw(() -> assertEquals(FRAME_RATE_CATEGORY_NORMAL,
            runAfterDraw(() -> assertEquals(intermittentExpected,
                    mViewRootImpl.getLastPreferredFrameRateCategory()));
        });
        waitForAfterDraw();