diff options
| author | 2021-03-22 23:55:15 -0700 | |
|---|---|---|
| committer | 2021-03-23 17:43:51 -0700 | |
| commit | 71b3ede6343e8568abd836c3b46fd48ca63cccb6 (patch) | |
| tree | ed10cc2a586f594c247a75af40c0ae694e845f75 | |
| parent | 71cf0b48ceb1717bec463cf838690e597bd415a6 (diff) | |
Have each Display be associated with a DisplayGroup and DPC
Previously the behavior was for each Display to be associated with a
DisplayGroup. This CL restores that behavior.
Additionally, this CL restores that each Display should have its own
DisplayPowerController as this is the mechanism by which each display is
updated.
Fixes: 183403444
Test: atest MultiDisplayKeyguardTests#testUnlockScreen_decoredSystemDisplayChanged_dismissesKeyguardOnUnlock
Change-Id: I31515822d3412948458f8da5c1e89f92f35e495d
3 files changed, 31 insertions, 39 deletions
diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java index c0109065fea4..ea467b0a98a1 100644 --- a/services/core/java/com/android/server/display/DisplayManagerService.java +++ b/services/core/java/com/android/server/display/DisplayManagerService.java @@ -1134,13 +1134,9 @@ public final class DisplayManagerService extends SystemService { recordStableDisplayStatsIfNeededLocked(display); recordTopInsetLocked(display); } - final int groupId = mLogicalDisplayMapper.getDisplayGroupIdFromDisplayIdLocked(displayId); - if (groupId != Display.INVALID_DISPLAY_GROUP) { - addDisplayPowerControllerLocked(display); - mDisplayStates.append(displayId, Display.STATE_UNKNOWN); - } else { - mDisplayStates.append(displayId, Display.STATE_ON); - } + addDisplayPowerControllerLocked(display); + mDisplayStates.append(displayId, Display.STATE_UNKNOWN); + mDisplayBrightnesses.append(displayId, display.getDisplayInfoLocked().brightnessDefault); DisplayManagerGlobal.invalidateLocalDisplayInfoCaches(); @@ -1943,8 +1939,7 @@ public final class DisplayManagerService extends SystemService { } private void initializeDisplayPowerControllersLocked() { - mLogicalDisplayMapper.forEachLocked((logicalDisplay) -> addDisplayPowerControllerLocked( - logicalDisplay)); + mLogicalDisplayMapper.forEachLocked(this::addDisplayPowerControllerLocked); } private void addDisplayPowerControllerLocked(LogicalDisplay display) { @@ -2839,10 +2834,16 @@ public final class DisplayManagerService extends SystemService { final int size = displayGroup.getSizeLocked(); boolean ready = true; for (int i = 0; i < size; i++) { - final DisplayPowerController displayPowerController = - mDisplayPowerControllers.get(displayGroup.getIdLocked(i)); - ready &= displayPowerController.requestPowerState(request, - waitForNegativeProximity); + final int id = displayGroup.getIdLocked(i); + final DisplayDevice displayDevice = mLogicalDisplayMapper.getDisplayLocked( + id).getPrimaryDisplayDeviceLocked(); + final int flags = displayDevice.getDisplayDeviceInfoLocked().flags; + if ((flags & DisplayDeviceInfo.FLAG_NEVER_BLANK) == 0) { + final DisplayPowerController displayPowerController = + mDisplayPowerControllers.get(id); + ready &= displayPowerController.requestPowerState(request, + waitForNegativeProximity); + } } return ready; diff --git a/services/core/java/com/android/server/display/LogicalDisplayMapper.java b/services/core/java/com/android/server/display/LogicalDisplayMapper.java index 6c2e6ebf91ea..fcfa674dcc4e 100644 --- a/services/core/java/com/android/server/display/LogicalDisplayMapper.java +++ b/services/core/java/com/android/server/display/LogicalDisplayMapper.java @@ -433,37 +433,31 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { final int displayId = display.getDisplayIdLocked(); // Get current display group data - final int groupId = getDisplayGroupIdFromDisplayIdLocked(displayId); + int groupId = getDisplayGroupIdFromDisplayIdLocked(displayId); final DisplayGroup oldGroup = getDisplayGroupLocked(groupId); // Get the new display group if a change is needed final DisplayInfo info = display.getDisplayInfoLocked(); final boolean needsOwnDisplayGroup = (info.flags & Display.FLAG_OWN_DISPLAY_GROUP) != 0; final boolean hasOwnDisplayGroup = groupId != Display.DEFAULT_DISPLAY_GROUP; - final boolean needsDisplayGroup = needsOwnDisplayGroup || info.type == Display.TYPE_INTERNAL - || info.type == Display.TYPE_EXTERNAL; - if (!needsDisplayGroup) { - if (oldGroup != null) { - oldGroup.removeDisplayLocked(display); - } - return; - } if (groupId == Display.INVALID_DISPLAY_GROUP || hasOwnDisplayGroup != needsOwnDisplayGroup) { + groupId = assignDisplayGroupIdLocked(needsOwnDisplayGroup); + } + + // Create a new group if needed + DisplayGroup newGroup = getDisplayGroupLocked(groupId); + if (newGroup == null) { + newGroup = new DisplayGroup(groupId); + mDisplayGroups.append(groupId, newGroup); + } + if (oldGroup != newGroup) { if (oldGroup != null) { oldGroup.removeDisplayLocked(display); } - - final int newGroupId = assignDisplayGroupIdLocked(needsOwnDisplayGroup); - // Create a new group if needed - DisplayGroup newGroup = getDisplayGroupLocked(newGroupId); - if (newGroup == null) { - newGroup = new DisplayGroup(newGroupId); - mDisplayGroups.append(newGroupId, newGroup); - } newGroup.addDisplayLocked(display); - display.updateDisplayGroupIdLocked(newGroupId); - Slog.i(TAG, "Setting new display group " + newGroupId + " for display " + display.updateDisplayGroupIdLocked(groupId); + Slog.i(TAG, "Setting new display group " + groupId + " for display " + displayId + ", from previous group: " + (oldGroup != null ? oldGroup.getGroupId() : "null")); } diff --git a/services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java b/services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java index dcb2c1573424..bcd853c76a79 100644 --- a/services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java +++ b/services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java @@ -186,14 +186,11 @@ public class LogicalDisplayMapperTest { LogicalDisplay display2 = add(createDisplayDevice(Display.TYPE_INTERNAL, 600, 800, 0)); LogicalDisplay display3 = add(createDisplayDevice(Display.TYPE_VIRTUAL, 600, 800, 0)); - // Physical displays should be automatically put into the default group. assertEquals(Display.DEFAULT_DISPLAY_GROUP, mLogicalDisplayMapper.getDisplayGroupIdFromDisplayIdLocked(id(display1))); assertEquals(Display.DEFAULT_DISPLAY_GROUP, mLogicalDisplayMapper.getDisplayGroupIdFromDisplayIdLocked(id(display2))); - - // Virtual displays should belong to no group by default. - assertEquals(Display.INVALID_DISPLAY_GROUP, + assertEquals(Display.DEFAULT_DISPLAY_GROUP, mLogicalDisplayMapper.getDisplayGroupIdFromDisplayIdLocked(id(display3))); } @@ -215,13 +212,13 @@ public class LogicalDisplayMapperTest { assertNotEquals(Display.DEFAULT_DISPLAY_GROUP, mLogicalDisplayMapper.getDisplayGroupIdFromDisplayIdLocked(id(display3))); - // Now switch it to the invalid group by removing the flag and issuing an update + // Now switch it back to the default group by removing the flag and issuing an update DisplayDeviceInfo info = device3.getSourceInfo(); info.flags = info.flags & ~DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP; mDisplayDeviceRepo.onDisplayDeviceEvent(device3, DISPLAY_DEVICE_EVENT_CHANGED); - // Verify the virtual display has not been placed into a group. - assertEquals(Display.INVALID_DISPLAY_GROUP, + // Verify the new group is correct. + assertEquals(Display.DEFAULT_DISPLAY_GROUP, mLogicalDisplayMapper.getDisplayGroupIdFromDisplayIdLocked(id(display3))); } |