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

Commit 16680355 authored by Oleg Blinnikov's avatar Oleg Blinnikov
Browse files

External display limit on ready to enable

SurfaceFlinger needs to receive configuration
for the external display as soon as possible.
This will help to prevent additional mode change.

Change-Id: I18564c3b7e9719e1d951061a95026a794a650557
Bug: 333855343
Test: atest DisplayModeDirectorTest DisplayObserverTest
ExternalDisplayPolicyTest DisplayManagerServiceTest

Change-Id: I4f9266ce13c44d3eb3c74677be87824a8d0125d5
parent 01d88d2b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -5271,5 +5271,13 @@ public final class DisplayManagerService extends SystemService {
        public ExternalDisplayStatsService getExternalDisplayStatsService() {
            return mExternalDisplayStatsService;
        }

        /**
         * Called on external display is ready to be enabled.
         */
        @Override
        public void onExternalDisplayReadyToBeEnabled(int displayId) {
            mDisplayModeDirector.onExternalDisplayReadyToBeEnabled(displayId);
        }
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@ class ExternalDisplayPolicy {

        @NonNull
        ExternalDisplayStatsService getExternalDisplayStatsService();

        void onExternalDisplayReadyToBeEnabled(int displayId);
    }

    @NonNull
@@ -185,6 +187,10 @@ class ExternalDisplayPolicy {
            return;
        }

        if (enabled) {
            mInjector.onExternalDisplayReadyToBeEnabled(logicalDisplay.getDisplayIdLocked());
        }

        mLogicalDisplayMapper.setDisplayEnabledLocked(logicalDisplay, enabled);
    }

@@ -217,6 +223,7 @@ class ExternalDisplayPolicy {
        if ((Build.IS_ENG || Build.IS_USERDEBUG)
                && SystemProperties.getBoolean(ENABLE_ON_CONNECT, false)) {
            Slog.w(TAG, "External display is enabled by default, bypassing user consent.");
            mInjector.onExternalDisplayReadyToBeEnabled(logicalDisplay.getDisplayIdLocked());
            mInjector.sendExternalDisplayEventLocked(logicalDisplay, EVENT_DISPLAY_CONNECTED);
            return;
        } else {
+14 −2
Original line number Diff line number Diff line
@@ -693,6 +693,13 @@ public class DisplayModeDirector {
        }
    }

    /**
     * Called when external display is ready to be enabled.
     */
    public void onExternalDisplayReadyToBeEnabled(int displayId) {
        mDisplayObserver.onExternalDisplayReadyToBeEnabled(displayId);
    }

    /**
     * Listens for changes refresh rate coordination.
     */
@@ -1379,6 +1386,13 @@ public class DisplayModeDirector {
            }
        }


        void onExternalDisplayReadyToBeEnabled(int displayId) {
            DisplayInfo displayInfo = getDisplayInfo(displayId);
            updateDisplaysPeakRefreshRateAndResolution(displayInfo);
            addDisplaysSynchronizedPeakRefreshRate(displayInfo);
        }

        @Override
        public void onDisplayAdded(int displayId) {
            updateVrrStatus(displayId);
@@ -1386,8 +1400,6 @@ public class DisplayModeDirector {
            updateDisplayModes(displayId, displayInfo);
            updateLayoutLimitedFrameRate(displayId, displayInfo);
            updateUserSettingDisplayPreferredSize(displayInfo);
            updateDisplaysPeakRefreshRateAndResolution(displayInfo);
            addDisplaysSynchronizedPeakRefreshRate(displayInfo);
        }

        @Override
+4 −0
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ public class ExternalDisplayPolicyTest {
        verify(mMockedLogicalDisplayMapper, never()).setDisplayEnabledLocked(any(), anyBoolean());
        verify(mMockedDisplayNotificationManager, times(2))
                .onHighTemperatureExternalDisplayNotAllowed();
        verify(mMockedInjector, never()).onExternalDisplayReadyToBeEnabled(anyInt());
    }

    @Test
@@ -167,6 +168,7 @@ public class ExternalDisplayPolicyTest {
        verify(mMockedLogicalDisplayMapper, never()).setDisplayEnabledLocked(any(), anyBoolean());
        verify(mMockedDisplayNotificationManager, never())
                .onHighTemperatureExternalDisplayNotAllowed();
        verify(mMockedInjector, never()).onExternalDisplayReadyToBeEnabled(anyInt());
    }

    @Test
@@ -184,6 +186,7 @@ public class ExternalDisplayPolicyTest {
        // Expected only 1 invocation, upon critical temperature.
        verify(mMockedDisplayNotificationManager).onHighTemperatureExternalDisplayNotAllowed();
        verify(mMockedExternalDisplayStatsService).onDisplayDisabled(eq(EXTERNAL_DISPLAY_ID));
        verify(mMockedInjector, never()).onExternalDisplayReadyToBeEnabled(anyInt());
    }

    @Test
@@ -191,6 +194,7 @@ public class ExternalDisplayPolicyTest {
        mExternalDisplayPolicy.setExternalDisplayEnabledLocked(mMockedLogicalDisplay,
                /*enabled=*/ true);
        assertDisplaySetEnabled(/*enabled=*/ true);
        verify(mMockedInjector).onExternalDisplayReadyToBeEnabled(eq(EXTERNAL_DISPLAY_ID));
    }

    @Test
+1 −1
Original line number Diff line number Diff line
@@ -1945,7 +1945,7 @@ public class DisplayModeDirectorTest {
        SparseArray<SparseArray<Vote>> votesByDisplay = new SparseArray<>();
        votesByDisplay.put(DISPLAY_ID_2, votes);

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

        var desiredSpecs = director.getDesiredDisplayModeSpecs(DISPLAY_ID_2);
Loading