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

Commit 92db7e3e authored by Shane's avatar Shane
Browse files

Apply HIGH_HINT to hint refresh rate boost by user interactions

Use HIGH_HINT instead of HIGH to boost frame rate if touch boost happens. This
information is helpful for CoGs team to disable touch boost for games.

Bug: 315071842
Test: atest ViewRootImplTest
Change-Id: Ia4bf1c10c2b36c4f2e422d31305a47e5da2e75d0
parent 4d29ed23
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import static android.view.Display.INVALID_DISPLAY;
import static android.view.InputDevice.SOURCE_CLASS_NONE;
import static android.view.InsetsSource.ID_IME;
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_NO_PREFERENCE;
import static android.view.View.PFLAG_DRAW_ANIMATION;
import static android.view.View.SYSTEM_UI_FLAG_FULLSCREEN;
@@ -1009,8 +1010,10 @@ public final class ViewRootImpl implements ViewParent,
    // Used to check if there were any view invalidations in
    // the previous time frame (FRAME_RATE_IDLENESS_REEVALUATE_TIME).
    private boolean mHasInvalidation = false;
    // Used to check if it is in the touch boosting period.
    // Used to check if it is in the frame rate boosting period.
    private boolean mIsFrameRateBoosting = false;
    // Used to check if it is in touch boosting period.
    private boolean mIsTouchBoosting = false;
    // Used to check if there is a message in the message queue
    // for idleness handling.
    private boolean mHasIdledMessage = false;
@@ -6425,11 +6428,12 @@ public final class ViewRootImpl implements ViewParent,
                     * Lower the frame rate after the boosting period (FRAME_RATE_TOUCH_BOOST_TIME).
                     */
                    mIsFrameRateBoosting = false;
                    mIsTouchBoosting = false;
                    setPreferredFrameRateCategory(Math.max(mPreferredFrameRateCategory,
                            mLastPreferredFrameRateCategory));
                    break;
                case MSG_CHECK_INVALIDATION_IDLE:
                    if (!mHasInvalidation && !mIsFrameRateBoosting) {
                    if (!mHasInvalidation && !mIsFrameRateBoosting && !mIsTouchBoosting) {
                        mPreferredFrameRateCategory = FRAME_RATE_CATEGORY_NO_PREFERENCE;
                        setPreferredFrameRateCategory(mPreferredFrameRateCategory);
                        mHasIdledMessage = false;
@@ -7452,7 +7456,7 @@ public final class ViewRootImpl implements ViewParent,
            // For the variable refresh rate project
            if (handled && shouldTouchBoost(action, mWindowAttributes.type)) {
                // set the frame rate to the maximum value.
                mIsFrameRateBoosting = true;
                mIsTouchBoosting = true;
                setPreferredFrameRateCategory(mPreferredFrameRateCategory);
            }
            /**
@@ -12177,8 +12181,16 @@ public final class ViewRootImpl implements ViewParent,
            return;
        }
        int frameRateCategory = mIsFrameRateBoosting || mInsetsAnimationRunning
                ? FRAME_RATE_CATEGORY_HIGH : preferredFrameRateCategory;
        int frameRateCategory = mIsTouchBoosting
                ? FRAME_RATE_CATEGORY_HIGH_HINT : preferredFrameRateCategory;
        // FRAME_RATE_CATEGORY_HIGH has a higher precedence than FRAME_RATE_CATEGORY_HIGH_HINT
        // For now, FRAME_RATE_CATEGORY_HIGH_HINT is used for boosting with user interaction.
        // FRAME_RATE_CATEGORY_HIGH is for boosting without user interaction
        // (e.g., Window Initialization).
        if (mIsFrameRateBoosting || mInsetsAnimationRunning) {
            frameRateCategory = FRAME_RATE_CATEGORY_HIGH;
        }
        try {
            if (mLastPreferredFrameRateCategory != frameRateCategory) {
+6 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.view;
import static android.view.accessibility.Flags.FLAG_FORCE_INVERT_COLOR;
import static android.view.flags.Flags.FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY;
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;
@@ -575,8 +576,13 @@ public class ViewRootImplTest {
            assertEquals(viewRootImpl.getPreferredFrameRateCategory(), FRAME_RATE_CATEGORY_LOW);
            viewRootImpl.votePreferredFrameRateCategory(FRAME_RATE_CATEGORY_NORMAL);
            assertEquals(viewRootImpl.getPreferredFrameRateCategory(), FRAME_RATE_CATEGORY_NORMAL);
            viewRootImpl.votePreferredFrameRateCategory(FRAME_RATE_CATEGORY_HIGH_HINT);
            assertEquals(viewRootImpl.getPreferredFrameRateCategory(),
                    FRAME_RATE_CATEGORY_HIGH_HINT);
            viewRootImpl.votePreferredFrameRateCategory(FRAME_RATE_CATEGORY_HIGH);
            assertEquals(viewRootImpl.getPreferredFrameRateCategory(), FRAME_RATE_CATEGORY_HIGH);
            viewRootImpl.votePreferredFrameRateCategory(FRAME_RATE_CATEGORY_HIGH_HINT);
            assertEquals(viewRootImpl.getPreferredFrameRateCategory(), FRAME_RATE_CATEGORY_HIGH);
            viewRootImpl.votePreferredFrameRateCategory(FRAME_RATE_CATEGORY_NORMAL);
            assertEquals(viewRootImpl.getPreferredFrameRateCategory(), FRAME_RATE_CATEGORY_HIGH);
            viewRootImpl.votePreferredFrameRateCategory(FRAME_RATE_CATEGORY_LOW);