summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/display/DisplayManagerService.java44
-rw-r--r--services/core/java/com/android/server/display/DisplayManagerShellCommand.java15
-rw-r--r--services/core/java/com/android/server/display/ExternalDisplayPolicy.java42
-rw-r--r--services/core/java/com/android/server/display/LogicalDisplayMapper.java54
-rw-r--r--services/core/java/com/android/server/display/feature/DisplayManagerFlags.java10
-rw-r--r--services/core/java/com/android/server/display/feature/display_flags.aconfig8
-rw-r--r--services/core/java/com/android/server/wm/ContentRecorder.java4
-rw-r--r--services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java55
-rw-r--r--services/tests/displayservicetests/src/com/android/server/display/ExternalDisplayPolicyTest.java28
-rw-r--r--services/tests/displayservicetests/src/com/android/server/display/LogicalDisplayMapperTest.java16
10 files changed, 52 insertions, 224 deletions
diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java
index c8192e534f5c..b530da2a5f5e 100644
--- a/services/core/java/com/android/server/display/DisplayManagerService.java
+++ b/services/core/java/com/android/server/display/DisplayManagerService.java
@@ -2246,10 +2246,6 @@ public final class DisplayManagerService extends SystemService {
@GuardedBy("mSyncRoot")
private void handleLogicalDisplayDisconnectedLocked(LogicalDisplay display) {
- if (!mFlags.isConnectedDisplayManagementEnabled()) {
- Slog.e(TAG, "DisplayDisconnected shouldn't be received when the flag is off");
- return;
- }
releaseDisplayAndEmitEvent(display, DisplayManagerGlobal.EVENT_DISPLAY_DISCONNECTED);
mExternalDisplayPolicy.handleLogicalDisplayDisconnectedLocked(display);
}
@@ -2315,11 +2311,6 @@ public final class DisplayManagerService extends SystemService {
@SuppressLint("AndroidFrameworkRequiresPermission")
private void handleLogicalDisplayConnectedLocked(LogicalDisplay display) {
- if (!mFlags.isConnectedDisplayManagementEnabled()) {
- Slog.e(TAG, "DisplayConnected shouldn't be received when the flag is off");
- return;
- }
-
setupLogicalDisplay(display);
if (ExternalDisplayPolicy.isExternalDisplayLocked(display)) {
@@ -2346,9 +2337,6 @@ public final class DisplayManagerService extends SystemService {
private void handleLogicalDisplayAddedLocked(LogicalDisplay display) {
final int displayId = display.getDisplayIdLocked();
final boolean isDefault = displayId == Display.DEFAULT_DISPLAY;
- if (!mFlags.isConnectedDisplayManagementEnabled()) {
- setupLogicalDisplay(display);
- }
// Wake up waitForDefaultDisplay.
if (isDefault) {
@@ -2443,21 +2431,17 @@ public final class DisplayManagerService extends SystemService {
}
private void handleLogicalDisplayRemovedLocked(@NonNull LogicalDisplay display) {
- // With display management, the display is removed when disabled, and it might still exist.
+ // The display is removed when disabled, and it might still exist.
// Resources must only be released when the disconnected signal is received.
- if (mFlags.isConnectedDisplayManagementEnabled()) {
- if (display.isValidLocked()) {
- updateViewportPowerStateLocked(display);
- }
+ if (display.isValidLocked()) {
+ updateViewportPowerStateLocked(display);
+ }
- // Note: This method is only called if the display was enabled before being removed.
- sendDisplayEventLocked(display, DisplayManagerGlobal.EVENT_DISPLAY_REMOVED);
+ // Note: This method is only called if the display was enabled before being removed.
+ sendDisplayEventLocked(display, DisplayManagerGlobal.EVENT_DISPLAY_REMOVED);
- if (display.isValidLocked()) {
- applyDisplayChangedLocked(display);
- }
- } else {
- releaseDisplayAndEmitEvent(display, DisplayManagerGlobal.EVENT_DISPLAY_REMOVED);
+ if (display.isValidLocked()) {
+ applyDisplayChangedLocked(display);
}
if (mDisplayTopologyCoordinator != null) {
mDisplayTopologyCoordinator.onDisplayRemoved(display.getDisplayIdLocked());
@@ -4565,13 +4549,11 @@ public final class DisplayManagerService extends SystemService {
final int callingPid = Binder.getCallingPid();
final int callingUid = Binder.getCallingUid();
- if (mFlags.isConnectedDisplayManagementEnabled()) {
- if ((internalEventFlagsMask
- & DisplayManagerGlobal
- .INTERNAL_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED) != 0) {
- mContext.enforceCallingOrSelfPermission(MANAGE_DISPLAYS,
- "Permission required to get signals about connection events.");
- }
+ if ((internalEventFlagsMask
+ & DisplayManagerGlobal
+ .INTERNAL_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED) != 0) {
+ mContext.enforceCallingOrSelfPermission(MANAGE_DISPLAYS,
+ "Permission required to get signals about connection events.");
}
final long token = Binder.clearCallingIdentity();
diff --git a/services/core/java/com/android/server/display/DisplayManagerShellCommand.java b/services/core/java/com/android/server/display/DisplayManagerShellCommand.java
index e46397bc8ab7..f6b2591ea440 100644
--- a/services/core/java/com/android/server/display/DisplayManagerShellCommand.java
+++ b/services/core/java/com/android/server/display/DisplayManagerShellCommand.java
@@ -179,12 +179,10 @@ class DisplayManagerShellCommand extends ShellCommand {
pw.println(" Sets brightness to docked + idle screen brightness mode");
pw.println(" undock");
pw.println(" Sets brightness to active (normal) screen brightness mode");
- if (mFlags.isConnectedDisplayManagementEnabled()) {
- pw.println(" enable-display DISPLAY_ID");
- pw.println(" Enable the DISPLAY_ID. Only possible if this is a connected display.");
- pw.println(" disable-display DISPLAY_ID");
- pw.println(" Disable the DISPLAY_ID. Only possible if this is a connected display.");
- }
+ pw.println(" enable-display DISPLAY_ID");
+ pw.println(" Enable the DISPLAY_ID. Only possible if this is a connected display.");
+ pw.println(" disable-display DISPLAY_ID");
+ pw.println(" Disable the DISPLAY_ID. Only possible if this is a connected display.");
pw.println(" power-reset DISPLAY_ID");
pw.println(" Turn the DISPLAY_ID power to a state the display supposed to have.");
pw.println(" power-off DISPLAY_ID");
@@ -601,11 +599,6 @@ class DisplayManagerShellCommand extends ShellCommand {
}
private int setDisplayEnabled(boolean enable) {
- if (!mFlags.isConnectedDisplayManagementEnabled()) {
- getErrPrintWriter()
- .println("Error: external display management is not available on this device.");
- return 1;
- }
final String displayIdText = getNextArg();
if (displayIdText == null) {
getErrPrintWriter().println("Error: no displayId specified");
diff --git a/services/core/java/com/android/server/display/ExternalDisplayPolicy.java b/services/core/java/com/android/server/display/ExternalDisplayPolicy.java
index 519763a1c3db..a47853c8e555 100644
--- a/services/core/java/com/android/server/display/ExternalDisplayPolicy.java
+++ b/services/core/java/com/android/server/display/ExternalDisplayPolicy.java
@@ -142,14 +142,6 @@ class ExternalDisplayPolicy {
mDisplayIdsWaitingForBootCompletion.clear();
}
- if (!mFlags.isConnectedDisplayManagementEnabled()) {
- if (DEBUG) {
- Slog.d(TAG, "External display management is not enabled on your device:"
- + " cannot register thermal listener.");
- }
- return;
- }
-
if (!mFlags.isConnectedDisplayErrorHandlingEnabled()) {
if (DEBUG) {
Slog.d(TAG, "ConnectedDisplayErrorHandlingEnabled is not enabled on your device:"
@@ -173,14 +165,6 @@ class ExternalDisplayPolicy {
return;
}
- if (!mFlags.isConnectedDisplayManagementEnabled()) {
- if (DEBUG) {
- Slog.d(TAG, "setExternalDisplayEnabledLocked: External display management is not"
- + " enabled on your device, cannot enable/disable display.");
- }
- return;
- }
-
if (enabled && !isExternalDisplayAllowed()) {
Slog.w(TAG, "setExternalDisplayEnabledLocked: External display can not be enabled"
+ " because it is currently not allowed.");
@@ -202,14 +186,6 @@ class ExternalDisplayPolicy {
return;
}
- if (!mFlags.isConnectedDisplayManagementEnabled()) {
- if (DEBUG) {
- Slog.d(TAG, "handleExternalDisplayConnectedLocked connected display management"
- + " flag is off");
- }
- return;
- }
-
if (!mIsBootCompleted) {
mDisplayIdsWaitingForBootCompletion.add(logicalDisplay.getDisplayIdLocked());
return;
@@ -251,10 +227,6 @@ class ExternalDisplayPolicy {
void handleLogicalDisplayDisconnectedLocked(@NonNull final LogicalDisplay logicalDisplay) {
// Type of the display here is always UNKNOWN, so we can't verify it is an external display
- if (!mFlags.isConnectedDisplayManagementEnabled()) {
- return;
- }
-
var displayId = logicalDisplay.getDisplayIdLocked();
if (mDisplayIdsWaitingForBootCompletion.remove(displayId)) {
return;
@@ -271,10 +243,6 @@ class ExternalDisplayPolicy {
return;
}
- if (!mFlags.isConnectedDisplayManagementEnabled()) {
- return;
- }
-
mExternalDisplayStatsService.onDisplayAdded(logicalDisplay.getDisplayIdLocked());
}
@@ -289,10 +257,6 @@ class ExternalDisplayPolicy {
}
}
- if (!mFlags.isConnectedDisplayManagementEnabled()) {
- return;
- }
-
if (isShown) {
mExternalDisplayStatsService.onPresentationWindowAdded(displayId);
} else {
@@ -306,12 +270,6 @@ class ExternalDisplayPolicy {
return;
}
- if (!mFlags.isConnectedDisplayManagementEnabled()) {
- Slog.e(TAG, "disableExternalDisplayLocked shouldn't be called when the"
- + " connected display management flag is off");
- return;
- }
-
if (!mFlags.isConnectedDisplayErrorHandlingEnabled()) {
if (DEBUG) {
Slog.d(TAG, "disableExternalDisplayLocked shouldn't be called when the"
diff --git a/services/core/java/com/android/server/display/LogicalDisplayMapper.java b/services/core/java/com/android/server/display/LogicalDisplayMapper.java
index 006921572977..ecc8896b69c6 100644
--- a/services/core/java/com/android/server/display/LogicalDisplayMapper.java
+++ b/services/core/java/com/android/server/display/LogicalDisplayMapper.java
@@ -823,18 +823,13 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
if (wasPreviouslyUpdated) {
// The display isn't actually removed from our internal data structures until
// after the notification is sent; see {@link #sendUpdatesForDisplaysLocked}.
- if (mFlags.isConnectedDisplayManagementEnabled()) {
- if (mDisplaysEnabledCache.get(displayId)) {
- // We still need to send LOGICAL_DISPLAY_EVENT_DISCONNECTED
- reloop = true;
- logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_REMOVED;
- } else {
- mUpdatedLogicalDisplays.delete(displayId);
- logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_DISCONNECTED;
- }
+ if (mDisplaysEnabledCache.get(displayId)) {
+ // We still need to send LOGICAL_DISPLAY_EVENT_DISCONNECTED
+ reloop = true;
+ logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_REMOVED;
} else {
mUpdatedLogicalDisplays.delete(displayId);
- logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_REMOVED;
+ logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_DISCONNECTED;
}
} else {
// This display never left this class, safe to remove without notification
@@ -845,20 +840,15 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
// The display is new.
} else if (!wasPreviouslyUpdated) {
- if (mFlags.isConnectedDisplayManagementEnabled()) {
- // We still need to send LOGICAL_DISPLAY_EVENT_ADDED
- reloop = true;
- logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_CONNECTED;
- } else {
- logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_ADDED;
- }
+ // We still need to send LOGICAL_DISPLAY_EVENT_ADDED
+ reloop = true;
+ logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_CONNECTED;
// Underlying displays device has changed to a different one.
} else if (!TextUtils.equals(mTempDisplayInfo.uniqueId, newDisplayInfo.uniqueId)) {
logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_SWAPPED;
// Something about the display device has changed.
- } else if (mFlags.isConnectedDisplayManagementEnabled()
- && wasPreviouslyEnabled != isCurrentlyEnabled) {
+ } else if (wasPreviouslyEnabled != isCurrentlyEnabled) {
int event = isCurrentlyEnabled ? LOGICAL_DISPLAY_EVENT_ADDED :
LOGICAL_DISPLAY_EVENT_REMOVED;
logicalDisplayEventMask |= event;
@@ -936,17 +926,13 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_DEVICE_STATE_TRANSITION);
sendUpdatesForGroupsLocked(DISPLAY_GROUP_EVENT_ADDED);
sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_REMOVED);
- if (mFlags.isConnectedDisplayManagementEnabled()) {
- sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_DISCONNECTED);
- }
+ sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_DISCONNECTED);
sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_BASIC_CHANGED);
sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_REFRESH_RATE_CHANGED);
sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_STATE_CHANGED);
sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_FRAME_RATE_OVERRIDES_CHANGED);
sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_SWAPPED);
- if (mFlags.isConnectedDisplayManagementEnabled()) {
- sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_CONNECTED);
- }
+ sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_CONNECTED);
sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_ADDED);
sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_HDR_SDR_RATIO_CHANGED);
sendUpdatesForGroupsLocked(DISPLAY_GROUP_EVENT_CHANGED);
@@ -996,23 +982,15 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
+ "display=" + id + " with device=" + uniqueId);
}
- if (mFlags.isConnectedDisplayManagementEnabled()) {
- if (logicalDisplayEvent == LOGICAL_DISPLAY_EVENT_ADDED) {
- mDisplaysEnabledCache.put(id, true);
- } else if (logicalDisplayEvent == LOGICAL_DISPLAY_EVENT_REMOVED) {
- mDisplaysEnabledCache.delete(id);
- }
+ if (logicalDisplayEvent == LOGICAL_DISPLAY_EVENT_ADDED) {
+ mDisplaysEnabledCache.put(id, true);
+ } else if (logicalDisplayEvent == LOGICAL_DISPLAY_EVENT_REMOVED) {
+ mDisplaysEnabledCache.delete(id);
}
mListener.onLogicalDisplayEventLocked(display, logicalDisplayEvent);
- if (mFlags.isConnectedDisplayManagementEnabled()) {
- if (logicalDisplayEvent == LOGICAL_DISPLAY_EVENT_DISCONNECTED) {
- mLogicalDisplays.delete(id);
- }
- } else if (logicalDisplayEvent == LOGICAL_DISPLAY_EVENT_REMOVED) {
- // We wait until we sent the EVENT_REMOVED event before actually removing the
- // display.
+ if (logicalDisplayEvent == LOGICAL_DISPLAY_EVENT_DISCONNECTED) {
mLogicalDisplays.delete(id);
}
}
diff --git a/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java b/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java
index addfbf1833b9..4e57d6791ff6 100644
--- a/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java
+++ b/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java
@@ -42,10 +42,6 @@ public class DisplayManagerFlags {
Flags.FLAG_ENABLE_PORT_IN_DISPLAY_LAYOUT,
Flags::enablePortInDisplayLayout);
- private final FlagState mConnectedDisplayManagementFlagState = new FlagState(
- Flags.FLAG_ENABLE_CONNECTED_DISPLAY_MANAGEMENT,
- Flags::enableConnectedDisplayManagement);
-
private final FlagState mAdaptiveToneImprovements1 = new FlagState(
Flags.FLAG_ENABLE_ADAPTIVE_TONE_IMPROVEMENTS_1,
Flags::enableAdaptiveToneImprovements1);
@@ -269,11 +265,6 @@ public class DisplayManagerFlags {
return mPortInDisplayLayoutFlagState.isEnabled();
}
- /** Returns whether connected display management is enabled or not. */
- public boolean isConnectedDisplayManagementEnabled() {
- return mConnectedDisplayManagementFlagState.isEnabled();
- }
-
/** Returns whether power throttling clamper is enabled on not. */
public boolean isPowerThrottlingClamperEnabled() {
return mPowerThrottlingClamperFlagState.isEnabled();
@@ -572,7 +563,6 @@ public class DisplayManagerFlags {
pw.println(" " + mAdaptiveToneImprovements2);
pw.println(" " + mBackUpSmoothDisplayAndForcePeakRefreshRateFlagState);
pw.println(" " + mConnectedDisplayErrorHandlingFlagState);
- pw.println(" " + mConnectedDisplayManagementFlagState);
pw.println(" " + mDisplayOffloadFlagState);
pw.println(" " + mExternalDisplayLimitModeState);
pw.println(" " + mDisplayTopology);
diff --git a/services/core/java/com/android/server/display/feature/display_flags.aconfig b/services/core/java/com/android/server/display/feature/display_flags.aconfig
index eccbbb14c4ea..afae07c88f8d 100644
--- a/services/core/java/com/android/server/display/feature/display_flags.aconfig
+++ b/services/core/java/com/android/server/display/feature/display_flags.aconfig
@@ -29,14 +29,6 @@ flag {
}
flag {
- name: "enable_connected_display_management"
- namespace: "display_manager"
- description: "Feature flag for Connected Display management"
- bug: "280739508"
- is_fixed_read_only: true
-}
-
-flag {
name: "enable_power_throttling_clamper"
namespace: "display_manager"
description: "Feature flag for Power Throttling Clamper"
diff --git a/services/core/java/com/android/server/wm/ContentRecorder.java b/services/core/java/com/android/server/wm/ContentRecorder.java
index a4e58ef923b8..d6ae65193121 100644
--- a/services/core/java/com/android/server/wm/ContentRecorder.java
+++ b/services/core/java/com/android/server/wm/ContentRecorder.java
@@ -108,9 +108,7 @@ final class ContentRecorder implements WindowContainerListener {
ContentRecorder(@NonNull DisplayContent displayContent) {
this(displayContent, new RemoteMediaProjectionManagerWrapper(displayContent.mDisplayId),
- new DisplayManagerFlags().isConnectedDisplayManagementEnabled()
- && !new DisplayManagerFlags()
- .isPixelAnisotropyCorrectionInLogicalDisplayEnabled()
+ !new DisplayManagerFlags().isPixelAnisotropyCorrectionInLogicalDisplayEnabled()
&& displayContent.getDisplayInfo().type == Display.TYPE_EXTERNAL);
}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java b/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java
index a9ad435762ad..02e5470e8673 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java
@@ -415,7 +415,6 @@ public class DisplayManagerServiceTest {
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(false);
mLocalServiceKeeperRule.overrideLocalService(
InputManagerInternal.class, mMockInputManagerInternal);
@@ -2797,30 +2796,7 @@ public class DisplayManagerServiceTest {
}
@Test
- public void testConnectExternalDisplay_withoutDisplayManagement_shouldAddDisplay() {
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(false);
- manageDisplaysPermission(/* granted= */ true);
- DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector);
- DisplayManagerService.BinderService bs = displayManager.new BinderService();
- LogicalDisplayMapper logicalDisplayMapper = displayManager.getLogicalDisplayMapper();
- FakeDisplayManagerCallback callback = new FakeDisplayManagerCallback();
- bs.registerCallbackWithEventMask(callback, STANDARD_AND_CONNECTION_DISPLAY_EVENTS);
- callback.expectsEvent(EVENT_DISPLAY_ADDED);
-
- FakeDisplayDevice displayDevice =
- createFakeDisplayDevice(displayManager, new float[]{60f}, Display.TYPE_EXTERNAL);
- callback.waitForExpectedEvent();
-
- LogicalDisplay display =
- logicalDisplayMapper.getDisplayLocked(displayDevice, /* includeDisabled= */ true);
- assertThat(display.isEnabledLocked()).isTrue();
- assertThat(callback.receivedEvents()).containsExactly(EVENT_DISPLAY_ADDED);
-
- }
-
- @Test
- public void testConnectExternalDisplay_withDisplayManagement_shouldDisableDisplay() {
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
+ public void testConnectExternalDisplay_shouldDisableDisplay() {
manageDisplaysPermission(/* granted= */ true);
DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector);
displayManager.onBootPhase(SystemService.PHASE_BOOT_COMPLETED);
@@ -2849,9 +2825,8 @@ public class DisplayManagerServiceTest {
}
@Test
- public void testConnectExternalDisplay_withDisplayManagementAndSysprop_shouldEnableDisplay() {
+ public void testConnectExternalDisplay_withSysprop_shouldEnableDisplay() {
Assume.assumeTrue(Build.IS_ENG || Build.IS_USERDEBUG);
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
doAnswer((Answer<Boolean>) invocationOnMock -> true)
.when(() -> SystemProperties.getBoolean(ENABLE_ON_CONNECT, false));
manageDisplaysPermission(/* granted= */ true);
@@ -2883,8 +2858,7 @@ public class DisplayManagerServiceTest {
}
@Test
- public void testConnectExternalDisplay_withDisplayManagement_allowsEnableAndDisableDisplay() {
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
+ public void testConnectExternalDisplay_allowsEnableAndDisableDisplay() {
when(mMockFlags.isApplyDisplayChangedDuringDisplayAddedEnabled()).thenReturn(true);
manageDisplaysPermission(/* granted= */ true);
LocalServices.addService(WindowManagerPolicy.class, mMockedWindowManagerPolicy);
@@ -2955,8 +2929,7 @@ public class DisplayManagerServiceTest {
}
@Test
- public void testConnectInternalDisplay_withDisplayManagement_shouldConnectAndAddDisplay() {
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
+ public void testConnectInternalDisplay_shouldConnectAndAddDisplay() {
manageDisplaysPermission(/* granted= */ true);
DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector);
DisplayManagerService.BinderService bs = displayManager.new BinderService();
@@ -3011,7 +2984,7 @@ public class DisplayManagerServiceTest {
DisplayManagerService.BinderService bs = displayManager.new BinderService();
LogicalDisplayMapper logicalDisplayMapper = displayManager.getLogicalDisplayMapper();
FakeDisplayManagerCallback callback = new FakeDisplayManagerCallback();
- bs.registerCallbackWithEventMask(callback, STANDARD_AND_CONNECTION_DISPLAY_EVENTS);
+ bs.registerCallbackWithEventMask(callback, STANDARD_DISPLAY_EVENTS);
callback.expectsEvent(EVENT_DISPLAY_ADDED);
FakeDisplayDevice displayDevice =
@@ -3032,8 +3005,7 @@ public class DisplayManagerServiceTest {
}
@Test
- public void testEnableExternalDisplay_withDisplayManagement_shouldSignalDisplayAdded() {
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
+ public void testEnableExternalDisplay_shouldSignalDisplayAdded() {
manageDisplaysPermission(/* granted= */ true);
DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector);
displayManager.onBootPhase(SystemService.PHASE_BOOT_COMPLETED);
@@ -3062,8 +3034,7 @@ public class DisplayManagerServiceTest {
}
@Test
- public void testEnableExternalDisplay_withoutPermission_shouldThrowException() {
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
+ public void testEnableExternalDisplay_shouldThrowException() {
DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector);
DisplayManagerService.BinderService bs = displayManager.new BinderService();
LogicalDisplayMapper logicalDisplayMapper = displayManager.getLogicalDisplayMapper();
@@ -3087,8 +3058,7 @@ public class DisplayManagerServiceTest {
}
@Test
- public void testEnableInternalDisplay_withManageDisplays_shouldSignalAdded() {
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
+ public void testEnableInternalDisplay_shouldSignalAdded() {
DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector);
DisplayManagerService.BinderService bs = displayManager.new BinderService();
LogicalDisplayMapper logicalDisplayMapper = displayManager.getLogicalDisplayMapper();
@@ -3115,8 +3085,7 @@ public class DisplayManagerServiceTest {
}
@Test
- public void testDisableInternalDisplay_withDisplayManagement_shouldSignalRemove() {
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
+ public void testDisableInternalDisplay_shouldSignalRemove() {
DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector);
DisplayManagerService.BinderService bs = displayManager.new BinderService();
LogicalDisplayMapper logicalDisplayMapper = displayManager.getLogicalDisplayMapper();
@@ -3140,7 +3109,6 @@ public class DisplayManagerServiceTest {
@Test
public void testDisableExternalDisplay_shouldSignalDisplayRemoved() {
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector);
DisplayManagerService.BinderService bs = displayManager.new BinderService();
LogicalDisplayMapper logicalDisplayMapper = displayManager.getLogicalDisplayMapper();
@@ -3181,7 +3149,6 @@ public class DisplayManagerServiceTest {
@Test
public void testDisableExternalDisplay_withoutPermission_shouldThrowException() {
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector);
DisplayManagerService.BinderService bs = displayManager.new BinderService();
LogicalDisplayMapper logicalDisplayMapper = displayManager.getLogicalDisplayMapper();
@@ -3207,7 +3174,6 @@ public class DisplayManagerServiceTest {
@Test
public void testRemoveExternalDisplay_whenDisabled_shouldSignalDisconnected() {
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
manageDisplaysPermission(/* granted= */ true);
DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector);
displayManager.onBootPhase(SystemService.PHASE_BOOT_COMPLETED);
@@ -3244,7 +3210,6 @@ public class DisplayManagerServiceTest {
@Test
public void testRegisterCallback_withoutPermission_shouldThrow() {
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector);
DisplayManagerService.BinderService bs = displayManager.new BinderService();
FakeDisplayManagerCallback callback = new FakeDisplayManagerCallback();
@@ -3255,7 +3220,6 @@ public class DisplayManagerServiceTest {
@Test
public void testRemoveExternalDisplay_whenEnabled_shouldSignalRemovedAndDisconnected() {
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
manageDisplaysPermission(/* granted= */ true);
DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector);
displayManager.onBootPhase(SystemService.PHASE_BOOT_COMPLETED);
@@ -3288,7 +3252,6 @@ public class DisplayManagerServiceTest {
@Test
public void testRemoveInternalDisplay_whenEnabled_shouldSignalRemovedAndDisconnected() {
- when(mMockFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
manageDisplaysPermission(/* granted= */ true);
DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector);
DisplayManagerService.BinderService bs = displayManager.new BinderService();
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 782262d3f7c9..a48a88cecbc2 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/ExternalDisplayPolicyTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/ExternalDisplayPolicyTest.java
@@ -22,7 +22,6 @@ import static android.view.Display.TYPE_INTERNAL;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assume.assumeFalse;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -47,7 +46,6 @@ import com.android.server.display.feature.DisplayManagerFlags;
import com.android.server.display.notifications.DisplayNotificationManager;
import com.android.server.testutils.TestHandler;
-import com.google.testing.junit.testparameterinjector.TestParameter;
import com.google.testing.junit.testparameterinjector.TestParameterInjector;
import org.junit.Before;
@@ -124,7 +122,6 @@ public class ExternalDisplayPolicyTest {
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
mHandler = new TestHandler(/*callback=*/ null);
- when(mMockedFlags.isConnectedDisplayManagementEnabled()).thenReturn(true);
when(mMockedFlags.isConnectedDisplayErrorHandlingEnabled()).thenReturn(true);
when(mMockedInjector.getFlags()).thenReturn(mMockedFlags);
when(mMockedInjector.getLogicalDisplayMapper()).thenReturn(mMockedLogicalDisplayMapper);
@@ -173,16 +170,6 @@ public class ExternalDisplayPolicyTest {
}
@Test
- public void testTryEnableExternalDisplay_featureDisabled(@TestParameter final boolean enable) {
- when(mMockedFlags.isConnectedDisplayManagementEnabled()).thenReturn(false);
- mExternalDisplayPolicy.setExternalDisplayEnabledLocked(mMockedLogicalDisplay, enable);
- mHandler.flush();
- verify(mMockedLogicalDisplayMapper, never()).setDisplayEnabledLocked(any(), anyBoolean());
- verify(mMockedDisplayNotificationManager, never())
- .onHighTemperatureExternalDisplayNotAllowed();
- }
-
- @Test
public void testTryDisableExternalDisplay_criticalThermalCondition() throws RemoteException {
// Disallow external displays due to thermals.
setTemperature(registerThermalListener(), List.of(CRITICAL_TEMPERATURE));
@@ -278,21 +265,6 @@ public class ExternalDisplayPolicyTest {
}
@Test
- public void testNoThermalListenerRegistered_featureDisabled(
- @TestParameter final boolean isConnectedDisplayManagementEnabled,
- @TestParameter final boolean isErrorHandlingEnabled) throws RemoteException {
- assumeFalse(isConnectedDisplayManagementEnabled && isErrorHandlingEnabled);
- when(mMockedFlags.isConnectedDisplayManagementEnabled()).thenReturn(
- isConnectedDisplayManagementEnabled);
- when(mMockedFlags.isConnectedDisplayErrorHandlingEnabled()).thenReturn(
- isErrorHandlingEnabled);
-
- mExternalDisplayPolicy.onBootCompleted();
- verify(mMockedThermalService, never()).registerThermalEventListenerWithType(
- any(), anyInt());
- }
-
- @Test
public void testOnCriticalTemperature_disallowAndAllowExternalDisplay() throws RemoteException {
final var thermalListener = registerThermalListener();
diff --git a/services/tests/displayservicetests/src/com/android/server/display/LogicalDisplayMapperTest.java b/services/tests/displayservicetests/src/com/android/server/display/LogicalDisplayMapperTest.java
index 0dbb6ba58b3c..7d3cd8a8a9ae 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/LogicalDisplayMapperTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/LogicalDisplayMapperTest.java
@@ -222,7 +222,6 @@ public class LogicalDisplayMapperTest {
when(mSyntheticModeManagerMock.createAppSupportedModes(any(), any(), anyBoolean()))
.thenAnswer(AdditionalAnswers.returnsSecondArg());
- when(mFlagsMock.isConnectedDisplayManagementEnabled()).thenReturn(false);
mLooper = new TestLooper();
mHandler = new Handler(mLooper.getLooper());
mLogicalDisplayMapper = new LogicalDisplayMapper(mContextMock, mFoldSettingProviderMock,
@@ -351,8 +350,7 @@ public class LogicalDisplayMapperTest {
}
@Test
- public void testDisplayDeviceAddAndRemove_withDisplayManagement() {
- when(mFlagsMock.isConnectedDisplayManagementEnabled()).thenReturn(true);
+ public void testDisplayDeviceAddAndRemove() {
DisplayDevice device = createDisplayDevice(TYPE_INTERNAL, 600, 800,
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
@@ -390,8 +388,7 @@ public class LogicalDisplayMapperTest {
}
@Test
- public void testDisplayDisableEnable_withDisplayManagement() {
- when(mFlagsMock.isConnectedDisplayManagementEnabled()).thenReturn(true);
+ public void testDisplayDisableEnable() {
DisplayDevice device = createDisplayDevice(TYPE_INTERNAL, 600, 800,
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
LogicalDisplay displayAdded = add(device);
@@ -1350,9 +1347,14 @@ public class LogicalDisplayMapperTest {
ArgumentCaptor<LogicalDisplay> displayCaptor =
ArgumentCaptor.forClass(LogicalDisplay.class);
verify(mListenerMock).onLogicalDisplayEventLocked(
- displayCaptor.capture(), eq(LOGICAL_DISPLAY_EVENT_ADDED));
+ displayCaptor.capture(), eq(LOGICAL_DISPLAY_EVENT_CONNECTED));
+ LogicalDisplay display = displayCaptor.getValue();
+ if (display.isEnabledLocked()) {
+ verify(mListenerMock).onLogicalDisplayEventLocked(
+ eq(display), eq(LOGICAL_DISPLAY_EVENT_ADDED));
+ }
clearInvocations(mListenerMock);
- return displayCaptor.getValue();
+ return display;
}
private void testDisplayDeviceAddAndRemove_NonInternal(int type) {