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

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

Merge "Apply HIGH_HINT to hint refresh rate boost by user interactions" into main

parents 5d269216 6742c3f1
Loading
Loading
Loading
Loading
+18 −6
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;
@@ -1013,8 +1014,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;
@@ -6445,11 +6448,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;
@@ -7482,7 +7486,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);
            }
            /**
@@ -7490,7 +7494,7 @@ public final class ViewRootImpl implements ViewParent,
             * MotionEvent.ACTION_CANCEL is detected.
             * Not using ACTION_MOVE to avoid checking and sending messages too frequently.
             */
            if (mIsFrameRateBoosting && (action == MotionEvent.ACTION_UP
            if (mIsTouchBoosting && (action == MotionEvent.ACTION_UP
                    || action == MotionEvent.ACTION_CANCEL)) {
                mHandler.removeMessages(MSG_TOUCH_BOOST_TIMEOUT);
                mHandler.sendEmptyMessageDelayed(MSG_TOUCH_BOOST_TIMEOUT,
@@ -12234,8 +12238,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
@@ -20,6 +20,7 @@ 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.flags.Flags.FLAG_TOOLKIT_FRAME_RATE_BY_SIZE_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;
@@ -669,8 +670,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);