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

Commit 2e8e218e authored by Shane's avatar Shane
Browse files

[VRR] Reapply frame rate and frame rate category when SurfaceControl is

replaced.

Reapply frame rate and frame rate category when SurfaceControl is
replaced. Otherwise, the vote won't be able to send to the new
SurfaceControl.

Flag: EXEMPT bugfix
Bug: 352280380
Test: atest ViweFrameRateTest / atest ViewRootImplTest
Change-Id: I56d2975f93f8b876a678682baad8e4483089970b
parent 12690f29
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -1135,6 +1135,8 @@ public final class ViewRootImpl implements ViewParent,
    // Take 24 and 30 as an example, 24 is not a divisor of 30.
    // We consider there is a conflict.
    private boolean mIsFrameRateConflicted = false;
    // Used to check whether SurfaceControl has been replaced.
    private boolean mSurfaceReplaced = false;
    // Used to set frame rate compatibility.
    @Surface.FrameRateCompatibility int mFrameRateCompatibility =
            FRAME_RATE_COMPATIBILITY_FIXED_SOURCE;
@@ -3831,6 +3833,7 @@ public final class ViewRootImpl implements ViewParent,
                surfaceReplaced = (surfaceGenerationId != mSurface.getGenerationId()
                        || surfaceControlChanged) && mSurface.isValid();
                if (surfaceReplaced) {
                    mSurfaceReplaced = true;
                    mSurfaceSequenceId++;
                }
                if (alwaysConsumeSystemBarsChanged) {
@@ -4443,6 +4446,7 @@ public final class ViewRootImpl implements ViewParent,
            mPreferredFrameRate = -1;
            mIsFrameRateConflicted = false;
            mFrameRateCategoryChangeReason = FRAME_RATE_CATEGORY_REASON_UNKNOWN;
            mSurfaceReplaced = false;
        } else if (mPreferredFrameRate == 0) {
            // From MSG_FRAME_RATE_SETTING, where mPreferredFrameRate is set to 0
            setPreferredFrameRate(0);
@@ -12933,8 +12937,9 @@ public final class ViewRootImpl implements ViewParent,
        boolean traceFrameRateCategory = false;
        try {
            if (frameRateCategory != FRAME_RATE_CATEGORY_DEFAULT
                    && mLastPreferredFrameRateCategory != frameRateCategory) {
            if ((frameRateCategory != FRAME_RATE_CATEGORY_DEFAULT
                    && mLastPreferredFrameRateCategory != frameRateCategory)
                    || mSurfaceReplaced) {
                traceFrameRateCategory = Trace.isTagEnabled(Trace.TRACE_TAG_VIEW);
                if (traceFrameRateCategory) {
                    String reason = reasonToString(frameRateReason);
@@ -12998,7 +13003,7 @@ public final class ViewRootImpl implements ViewParent,
        boolean traceFrameRate = false;
        try {
            if (mLastPreferredFrameRate != preferredFrameRate) {
            if (mLastPreferredFrameRate != preferredFrameRate || mSurfaceReplaced) {
                traceFrameRate = Trace.isTagEnabled(Trace.TRACE_TAG_VIEW);
                if (traceFrameRate) {
                    Trace.traceBegin(
+2 −2
Original line number Diff line number Diff line
@@ -237,8 +237,8 @@ public class ViewFrameRateTest {
            return;
        }
        waitForFrameRateCategoryToSettle();
        assertEquals(FRAME_RATE_CATEGORY_LOW,
                        mViewRoot.getLastPreferredFrameRateCategory());
        assertTrue(mViewRoot.getLastPreferredFrameRateCategory()
                < FRAME_RATE_CATEGORY_HIGH_HINT);

        int width = mMovingView.getWidth();
        int height = mMovingView.getHeight();