diff options
| author | 2024-04-17 10:40:41 +0000 | |
|---|---|---|
| committer | 2024-04-17 10:40:41 +0000 | |
| commit | 154b4627b036de15d2cc211e76c1360930b478dc (patch) | |
| tree | c2640f34217beb42de79e63d16a6dc79262f0105 | |
| parent | d3f6fd8cbaa39e59da6adea322c426b50ec0b5f1 (diff) | |
| parent | 94f34f397f3f5e945992831ec9e30659108ec3ba (diff) | |
Merge "Revert "External display limit on ready to enable"" into main
6 files changed, 5 insertions, 45 deletions
diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java index df5f0079765c..68e2bd685fac 100644 --- a/services/core/java/com/android/server/display/DisplayManagerService.java +++ b/services/core/java/com/android/server/display/DisplayManagerService.java @@ -5271,13 +5271,5 @@ 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); - } } } diff --git a/services/core/java/com/android/server/display/ExternalDisplayPolicy.java b/services/core/java/com/android/server/display/ExternalDisplayPolicy.java index 3c2918f833ba..b24caf4ced76 100644 --- a/services/core/java/com/android/server/display/ExternalDisplayPolicy.java +++ b/services/core/java/com/android/server/display/ExternalDisplayPolicy.java @@ -91,8 +91,6 @@ class ExternalDisplayPolicy { @NonNull ExternalDisplayStatsService getExternalDisplayStatsService(); - - void onExternalDisplayReadyToBeEnabled(int displayId); } @NonNull @@ -187,10 +185,6 @@ class ExternalDisplayPolicy { return; } - if (enabled) { - mInjector.onExternalDisplayReadyToBeEnabled(logicalDisplay.getDisplayIdLocked()); - } - mLogicalDisplayMapper.setDisplayEnabledLocked(logicalDisplay, enabled); } @@ -223,7 +217,6 @@ 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 { diff --git a/services/core/java/com/android/server/display/mode/DisplayModeDirector.java b/services/core/java/com/android/server/display/mode/DisplayModeDirector.java index 90d33458f112..fa423162985e 100644 --- a/services/core/java/com/android/server/display/mode/DisplayModeDirector.java +++ b/services/core/java/com/android/server/display/mode/DisplayModeDirector.java @@ -700,13 +700,6 @@ public class DisplayModeDirector { } /** - * Called when external display is ready to be enabled. - */ - public void onExternalDisplayReadyToBeEnabled(int displayId) { - mDisplayObserver.onExternalDisplayReadyToBeEnabled(displayId); - } - - /** * Provides access to DisplayDeviceConfig for specific display */ public interface DisplayDeviceConfigProvider { @@ -1372,13 +1365,6 @@ public class DisplayModeDirector { } } - - void onExternalDisplayReadyToBeEnabled(int displayId) { - DisplayInfo displayInfo = getDisplayInfo(displayId); - updateDisplaysPeakRefreshRateAndResolution(displayInfo); - addDisplaysSynchronizedPeakRefreshRate(displayInfo); - } - @Override public void onDisplayAdded(int displayId) { updateDisplayDeviceConfig(displayId); @@ -1386,6 +1372,8 @@ public class DisplayModeDirector { updateDisplayModes(displayId, displayInfo); updateLayoutLimitedFrameRate(displayId, displayInfo); updateUserSettingDisplayPreferredSize(displayInfo); + updateDisplaysPeakRefreshRateAndResolution(displayInfo); + addDisplaysSynchronizedPeakRefreshRate(displayInfo); } @Override diff --git a/services/tests/displayservicetests/src/com/android/server/display/ExternalDisplayPolicyTest.java b/services/tests/displayservicetests/src/com/android/server/display/ExternalDisplayPolicyTest.java index fe7bbe0ecf4b..ea08be4f1be4 100644 --- a/services/tests/displayservicetests/src/com/android/server/display/ExternalDisplayPolicyTest.java +++ b/services/tests/displayservicetests/src/com/android/server/display/ExternalDisplayPolicyTest.java @@ -157,7 +157,6 @@ public class ExternalDisplayPolicyTest { verify(mMockedLogicalDisplayMapper, never()).setDisplayEnabledLocked(any(), anyBoolean()); verify(mMockedDisplayNotificationManager, times(2)) .onHighTemperatureExternalDisplayNotAllowed(); - verify(mMockedInjector, never()).onExternalDisplayReadyToBeEnabled(anyInt()); } @Test @@ -168,7 +167,6 @@ public class ExternalDisplayPolicyTest { verify(mMockedLogicalDisplayMapper, never()).setDisplayEnabledLocked(any(), anyBoolean()); verify(mMockedDisplayNotificationManager, never()) .onHighTemperatureExternalDisplayNotAllowed(); - verify(mMockedInjector, never()).onExternalDisplayReadyToBeEnabled(anyInt()); } @Test @@ -186,7 +184,6 @@ 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 @@ -194,7 +191,6 @@ public class ExternalDisplayPolicyTest { mExternalDisplayPolicy.setExternalDisplayEnabledLocked(mMockedLogicalDisplay, /*enabled=*/ true); assertDisplaySetEnabled(/*enabled=*/ true); - verify(mMockedInjector).onExternalDisplayReadyToBeEnabled(eq(EXTERNAL_DISPLAY_ID)); } @Test diff --git a/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayModeDirectorTest.java b/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayModeDirectorTest.java index 040ae96d902e..4591d91ceea7 100644 --- a/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayModeDirectorTest.java +++ b/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayModeDirectorTest.java @@ -1952,7 +1952,7 @@ public class DisplayModeDirectorTest { SparseArray<SparseArray<Vote>> votesByDisplay = new SparseArray<>(); votesByDisplay.put(DISPLAY_ID_2, votes); - director.getDisplayObserver().onExternalDisplayReadyToBeEnabled(DISPLAY_ID_2); + director.getDisplayObserver().onDisplayAdded(DISPLAY_ID_2); director.injectVotesByDisplay(votesByDisplay); var desiredSpecs = director.getDesiredDisplayModeSpecs(DISPLAY_ID_2); diff --git a/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayObserverTest.java b/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayObserverTest.java index 7cfc1dd8db65..2d317af3d85d 100644 --- a/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayObserverTest.java +++ b/services/tests/displayservicetests/src/com/android/server/display/mode/DisplayObserverTest.java @@ -38,6 +38,7 @@ import static org.mockito.Mockito.when; import android.content.Context; import android.content.ContextWrapper; import android.content.res.Resources; +import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManagerInternal; import android.os.Handler; import android.os.Looper; @@ -108,7 +109,7 @@ public class DisplayObserverTest { private Context mContext; private DisplayModeDirector.Injector mInjector; private Handler mHandler; - private DisplayModeDirector.DisplayObserver mObserver; + private DisplayManager.DisplayListener mObserver; private Resources mResources; @Mock private DisplayManagerFlags mDisplayManagerFlags; @@ -162,7 +163,6 @@ public class DisplayObserverTest { .isEqualTo(null); // Testing that the vote is not added when display is added because feature is disabled - mObserver.onExternalDisplayReadyToBeEnabled(EXTERNAL_DISPLAY); mObserver.onDisplayAdded(EXTERNAL_DISPLAY); assertThat(getVote(DEFAULT_DISPLAY, PRIORITY_USER_SETTING_DISPLAY_PREFERRED_SIZE)) .isEqualTo(null); @@ -196,7 +196,6 @@ public class DisplayObserverTest { init(); assertThat(getVote(EXTERNAL_DISPLAY, PRIORITY_USER_SETTING_DISPLAY_PREFERRED_SIZE)) .isEqualTo(null); - mObserver.onExternalDisplayReadyToBeEnabled(EXTERNAL_DISPLAY); mObserver.onDisplayAdded(EXTERNAL_DISPLAY); assertThat(getVote(DEFAULT_DISPLAY, PRIORITY_USER_SETTING_DISPLAY_PREFERRED_SIZE)) .isEqualTo(null); @@ -248,7 +247,6 @@ public class DisplayObserverTest { init(); assertThat(getVote(EXTERNAL_DISPLAY, PRIORITY_USER_SETTING_DISPLAY_PREFERRED_SIZE)) .isEqualTo(null); - mObserver.onExternalDisplayReadyToBeEnabled(EXTERNAL_DISPLAY); mObserver.onDisplayAdded(EXTERNAL_DISPLAY); assertThat(getVote(DEFAULT_DISPLAY, PRIORITY_USER_SETTING_DISPLAY_PREFERRED_SIZE)) .isEqualTo(null); @@ -281,7 +279,6 @@ public class DisplayObserverTest { init(); assertThat(getVote(DEFAULT_DISPLAY, PRIORITY_USER_SETTING_DISPLAY_PREFERRED_SIZE)) .isEqualTo(null); - mObserver.onExternalDisplayReadyToBeEnabled(DEFAULT_DISPLAY); mObserver.onDisplayAdded(DEFAULT_DISPLAY); assertThat(getVote(DEFAULT_DISPLAY, PRIORITY_USER_SETTING_DISPLAY_PREFERRED_SIZE)) .isEqualTo(expectedResolutionVote); @@ -303,7 +300,6 @@ public class DisplayObserverTest { .thenReturn(MAX_HEIGHT); init(); assertThat(getVote(DEFAULT_DISPLAY, PRIORITY_LIMIT_MODE)).isEqualTo(null); - mObserver.onExternalDisplayReadyToBeEnabled(DEFAULT_DISPLAY); mObserver.onDisplayAdded(DEFAULT_DISPLAY); assertThat(getVote(DEFAULT_DISPLAY, PRIORITY_LIMIT_MODE)).isEqualTo(null); assertThat(getVote(EXTERNAL_DISPLAY, PRIORITY_LIMIT_MODE)).isEqualTo(null); @@ -323,7 +319,6 @@ public class DisplayObserverTest { .thenReturn(MAX_HEIGHT); init(); assertThat(getVote(EXTERNAL_DISPLAY, PRIORITY_LIMIT_MODE)).isEqualTo(null); - mObserver.onExternalDisplayReadyToBeEnabled(EXTERNAL_DISPLAY); mObserver.onDisplayAdded(EXTERNAL_DISPLAY); assertThat(getVote(DEFAULT_DISPLAY, PRIORITY_LIMIT_MODE)).isEqualTo(null); assertThat(getVote(EXTERNAL_DISPLAY, PRIORITY_LIMIT_MODE)).isEqualTo( @@ -343,7 +338,6 @@ public class DisplayObserverTest { when(mDisplayManagerFlags.isExternalDisplayLimitModeEnabled()).thenReturn(true); init(); assertThat(getVote(EXTERNAL_DISPLAY, PRIORITY_LIMIT_MODE)).isEqualTo(null); - mObserver.onExternalDisplayReadyToBeEnabled(EXTERNAL_DISPLAY); mObserver.onDisplayAdded(EXTERNAL_DISPLAY); assertThat(getVote(DEFAULT_DISPLAY, PRIORITY_LIMIT_MODE)).isEqualTo(null); assertThat(getVote(EXTERNAL_DISPLAY, PRIORITY_LIMIT_MODE)).isEqualTo(null); @@ -366,7 +360,6 @@ public class DisplayObserverTest { .thenReturn(true); init(); assertThat(getVote(GLOBAL_ID, PRIORITY_SYNCHRONIZED_REFRESH_RATE)).isEqualTo(null); - mObserver.onExternalDisplayReadyToBeEnabled(EXTERNAL_DISPLAY); mObserver.onDisplayAdded(EXTERNAL_DISPLAY); assertThat(getVote(GLOBAL_ID, PRIORITY_SYNCHRONIZED_REFRESH_RATE)).isEqualTo( Vote.forPhysicalRefreshRates( @@ -390,7 +383,6 @@ public class DisplayObserverTest { .thenReturn(true); init(); assertThat(getVote(GLOBAL_ID, PRIORITY_SYNCHRONIZED_REFRESH_RATE)).isEqualTo(null); - mObserver.onExternalDisplayReadyToBeEnabled(EXTERNAL_DISPLAY); mObserver.onDisplayAdded(EXTERNAL_DISPLAY); assertThat(getVote(GLOBAL_ID, PRIORITY_SYNCHRONIZED_REFRESH_RATE)).isEqualTo(null); } @@ -405,7 +397,6 @@ public class DisplayObserverTest { when(mDisplayManagerFlags.isDisplaysRefreshRatesSynchronizationEnabled()).thenReturn(true); init(); assertThat(getVote(GLOBAL_ID, PRIORITY_SYNCHRONIZED_REFRESH_RATE)).isEqualTo(null); - mObserver.onExternalDisplayReadyToBeEnabled(EXTERNAL_DISPLAY); mObserver.onDisplayAdded(EXTERNAL_DISPLAY); assertThat(getVote(GLOBAL_ID, PRIORITY_SYNCHRONIZED_REFRESH_RATE)).isEqualTo(null); } |