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

Commit f0ea201f authored by Jian-Syuan (Shane) Wong's avatar Jian-Syuan (Shane) Wong Committed by Android (Google) Code Review
Browse files

Merge "[dVRR] Allow the intermittent update to set frame rate category to...

Merge "[dVRR] Allow the intermittent update to set frame rate category to NORMAL immediately" into main
parents a0ffab1c 40bfa730
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -12565,6 +12565,13 @@ public final class ViewRootImpl implements ViewParent,
            case FRAME_RATE_CATEGORY_HIGH ->
                    mFrameRateCategoryHighCount = FRAME_RATE_CATEGORY_COUNT;
        }
        // If it's currently an intermittent update,
        // we should keep mPreferredFrameRateCategory as NORMAL
        if (intermittentUpdateState() == INTERMITTENT_STATE_INTERMITTENT) {
            return;
        }
        if (mFrameRateCategoryHighCount > 0) {
            mPreferredFrameRateCategory = FRAME_RATE_CATEGORY_HIGH;
        } else if (mFrameRateCategoryHighHintCount > 0) {
+3 −23
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import static android.view.Surface.FRAME_RATE_CATEGORY_HIGH;
import static android.view.Surface.FRAME_RATE_CATEGORY_HIGH_HINT;
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.Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE;
import static android.view.Surface.FRAME_RATE_COMPATIBILITY_GTE;
import static android.view.View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
@@ -1165,34 +1164,15 @@ public class ViewRootImplTest {
        });
        waitForAfterDraw();

        // reset the frame rate category counts
        for (int i = 0; i < 5; i++) {
            sInstrumentation.runOnMainSync(() -> {
                mView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE);
                mView.invalidate();
            });
            sInstrumentation.waitForIdleSync();
        }

        // In transition from frequent update to infrequent update
        Thread.sleep(delay);
        sInstrumentation.runOnMainSync(() -> {
            mView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_NO_PREFERENCE);
            mView.invalidate();
            runAfterDraw(() -> {
                assertEquals(FRAME_RATE_CATEGORY_NO_PREFERENCE,
                        mViewRootImpl.getLastPreferredFrameRateCategory());
            });
        });
        waitForAfterDraw();
        Thread.sleep(delay);
        sInstrumentation.runOnMainSync(() -> {
            mView.setRequestedFrameRate(View.REQUESTED_FRAME_RATE_CATEGORY_DEFAULT);
            mView.invalidate();
            runAfterDraw(() -> assertEquals(FRAME_RATE_CATEGORY_NO_PREFERENCE,
            int expected = toolkitFrameRateDefaultNormalReadOnly()
                    ? FRAME_RATE_CATEGORY_NORMAL : FRAME_RATE_CATEGORY_HIGH;
            runAfterDraw(() -> assertEquals(expected,
                    mViewRootImpl.getLastPreferredFrameRateCategory()));
        });
        waitForAfterDraw();

        // Infrequent update
        Thread.sleep(delay);