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

Commit 533eb93a authored by Oleg Blinnikov's avatar Oleg Blinnikov Committed by Android (Google) Code Review
Browse files

Merge "External Display render rate at mode rate" into main

parents 9008813f 6a018266
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -388,6 +388,14 @@ public class DisplayModeDirector {
            boolean allowGroupSwitching =
                    mModeSwitchingType == DisplayManager.SWITCHING_TYPE_ACROSS_AND_WITHIN_GROUPS;

            // Some external displays physical refresh rate modes are slightly above 60hz.
            // SurfaceFlinger will not enable these display modes unless it is configured to allow
            // render rate at least at this frame rate.
            if (mDisplayObserver.isExternalDisplayLocked(displayId)) {
                primarySummary.maxRenderFrameRate = Math.max(baseMode.getRefreshRate(),
                        primarySummary.maxRenderFrameRate);
            }

            return new DesiredDisplayModeSpecs(baseMode.getModeId(),
                    allowGroupSwitching,
                    new RefreshRateRanges(
@@ -1311,6 +1319,10 @@ public class DisplayModeDirector {
            updateUserSettingDisplayPreferredSize(displayInfo);
        }

        boolean isExternalDisplayLocked(int displayId) {
            return mExternalDisplaysConnected.contains(displayId);
        }

        @Nullable
        private DisplayInfo getDisplayInfo(int displayId) {
            DisplayInfo info = new DisplayInfo();
@@ -1419,7 +1431,7 @@ public class DisplayModeDirector {
                return;
            }
            synchronized (mLock) {
                if (!mExternalDisplaysConnected.contains(displayId)) {
                if (!isExternalDisplayLocked(displayId)) {
                    return;
                }
                mExternalDisplaysConnected.remove(displayId);
+31 −0
Original line number Diff line number Diff line
@@ -1698,6 +1698,37 @@ public class DisplayModeDirectorTest {
        assertVoteForRenderFrameRateRange(vote, /* frameRateLow= */ 0, /* frameRateHigh= */ 140);
    }

    @Test
    @Parameters({
        "true, true, 60",
        "false, true, 50",
        "true, false, 50"
    })
    public void testExternalDisplayMaxRefreshRate(boolean isRefreshRateSynchronizationEnabled,
            boolean isExternalDisplay, float expectedMaxRenderFrameRate) {
        when(mDisplayManagerFlags.isDisplaysRefreshRatesSynchronizationEnabled())
                .thenReturn(isRefreshRateSynchronizationEnabled);
        when(mResources.getBoolean(R.bool.config_refreshRateSynchronizationEnabled))
                .thenReturn(isRefreshRateSynchronizationEnabled);
        mInjector.mDisplayInfo.type =
                isExternalDisplay ? Display.TYPE_EXTERNAL : Display.TYPE_INTERNAL;
        mInjector.mDisplayInfo.displayId = DISPLAY_ID_2;

        DisplayModeDirector director = createDirectorFromModeArray(TEST_MODES, DEFAULT_MODE_60);

        SparseArray<Vote> votes = new SparseArray<>();
        votes.put(Vote.PRIORITY_LOW_POWER_MODE, Vote.forRenderFrameRates(0, 50f));

        SparseArray<SparseArray<Vote>> votesByDisplay = new SparseArray<>();
        votesByDisplay.put(DISPLAY_ID_2, votes);

        director.getDisplayObserver().onDisplayAdded(DISPLAY_ID_2);
        director.injectVotesByDisplay(votesByDisplay);

        var desiredSpecs = director.getDesiredDisplayModeSpecs(DISPLAY_ID_2);
        assertThat(desiredSpecs.primary.render.max).isEqualTo(expectedMaxRenderFrameRate);
    }

    @Test
    public void testMinRefreshRate_FlagEnabled() {
        when(mDisplayManagerFlags.isBackUpSmoothDisplayAndForcePeakRefreshRateEnabled())