Loading services/core/java/com/android/server/display/DisplayManagerService.java +8 −4 Original line number Diff line number Diff line Loading @@ -1134,8 +1134,13 @@ 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); } mDisplayBrightnesses.append(displayId, display.getDisplayInfoLocked().brightnessDefault); DisplayManagerGlobal.invalidateLocalDisplayInfoCaches(); Loading Loading @@ -1214,8 +1219,7 @@ public final class DisplayManagerService extends SystemService { final int displayId = display.getDisplayIdLocked(); final int state = mDisplayStates.get(displayId); // Only send a request for display state if the display state has already been // initialized by DisplayPowercontroller. // Only send a request for display state if display state has already been initialized. if (state != Display.STATE_UNKNOWN) { final float brightness = mDisplayBrightnesses.get(displayId); return device.requestDisplayStateLocked(state, brightness); Loading services/core/java/com/android/server/display/LogicalDisplayMapper.java +19 −13 Original line number Diff line number Diff line Loading @@ -433,31 +433,37 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { final int displayId = display.getDisplayIdLocked(); // Get current display group data int groupId = getDisplayGroupIdFromDisplayIdLocked(displayId); final 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); if (oldGroup != null) { oldGroup.removeDisplayLocked(display); } final int newGroupId = assignDisplayGroupIdLocked(needsOwnDisplayGroup); // Create a new group if needed DisplayGroup newGroup = getDisplayGroupLocked(groupId); DisplayGroup newGroup = getDisplayGroupLocked(newGroupId); if (newGroup == null) { newGroup = new DisplayGroup(groupId); mDisplayGroups.append(groupId, newGroup); } if (oldGroup != newGroup) { if (oldGroup != null) { oldGroup.removeDisplayLocked(display); newGroup = new DisplayGroup(newGroupId); mDisplayGroups.append(newGroupId, newGroup); } newGroup.addDisplayLocked(display); display.updateDisplayGroupIdLocked(groupId); Slog.i(TAG, "Setting new display group " + groupId + " for display " display.updateDisplayGroupIdLocked(newGroupId); Slog.i(TAG, "Setting new display group " + newGroupId + " for display " + displayId + ", from previous group: " + (oldGroup != null ? oldGroup.getGroupId() : "null")); } Loading services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java +7 −4 Original line number Diff line number Diff line Loading @@ -186,11 +186,14 @@ 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))); assertEquals(Display.DEFAULT_DISPLAY_GROUP, // Virtual displays should belong to no group by default. assertEquals(Display.INVALID_DISPLAY_GROUP, mLogicalDisplayMapper.getDisplayGroupIdFromDisplayIdLocked(id(display3))); } Loading @@ -212,13 +215,13 @@ public class LogicalDisplayMapperTest { assertNotEquals(Display.DEFAULT_DISPLAY_GROUP, mLogicalDisplayMapper.getDisplayGroupIdFromDisplayIdLocked(id(display3))); // Now switch it back to the default group by removing the flag and issuing an update // Now switch it to the invalid 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 new group is correct. assertEquals(Display.DEFAULT_DISPLAY_GROUP, // Verify the virtual display has not been placed into a group. assertEquals(Display.INVALID_DISPLAY_GROUP, mLogicalDisplayMapper.getDisplayGroupIdFromDisplayIdLocked(id(display3))); } Loading Loading
services/core/java/com/android/server/display/DisplayManagerService.java +8 −4 Original line number Diff line number Diff line Loading @@ -1134,8 +1134,13 @@ 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); } mDisplayBrightnesses.append(displayId, display.getDisplayInfoLocked().brightnessDefault); DisplayManagerGlobal.invalidateLocalDisplayInfoCaches(); Loading Loading @@ -1214,8 +1219,7 @@ public final class DisplayManagerService extends SystemService { final int displayId = display.getDisplayIdLocked(); final int state = mDisplayStates.get(displayId); // Only send a request for display state if the display state has already been // initialized by DisplayPowercontroller. // Only send a request for display state if display state has already been initialized. if (state != Display.STATE_UNKNOWN) { final float brightness = mDisplayBrightnesses.get(displayId); return device.requestDisplayStateLocked(state, brightness); Loading
services/core/java/com/android/server/display/LogicalDisplayMapper.java +19 −13 Original line number Diff line number Diff line Loading @@ -433,31 +433,37 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { final int displayId = display.getDisplayIdLocked(); // Get current display group data int groupId = getDisplayGroupIdFromDisplayIdLocked(displayId); final 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); if (oldGroup != null) { oldGroup.removeDisplayLocked(display); } final int newGroupId = assignDisplayGroupIdLocked(needsOwnDisplayGroup); // Create a new group if needed DisplayGroup newGroup = getDisplayGroupLocked(groupId); DisplayGroup newGroup = getDisplayGroupLocked(newGroupId); if (newGroup == null) { newGroup = new DisplayGroup(groupId); mDisplayGroups.append(groupId, newGroup); } if (oldGroup != newGroup) { if (oldGroup != null) { oldGroup.removeDisplayLocked(display); newGroup = new DisplayGroup(newGroupId); mDisplayGroups.append(newGroupId, newGroup); } newGroup.addDisplayLocked(display); display.updateDisplayGroupIdLocked(groupId); Slog.i(TAG, "Setting new display group " + groupId + " for display " display.updateDisplayGroupIdLocked(newGroupId); Slog.i(TAG, "Setting new display group " + newGroupId + " for display " + displayId + ", from previous group: " + (oldGroup != null ? oldGroup.getGroupId() : "null")); } Loading
services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java +7 −4 Original line number Diff line number Diff line Loading @@ -186,11 +186,14 @@ 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))); assertEquals(Display.DEFAULT_DISPLAY_GROUP, // Virtual displays should belong to no group by default. assertEquals(Display.INVALID_DISPLAY_GROUP, mLogicalDisplayMapper.getDisplayGroupIdFromDisplayIdLocked(id(display3))); } Loading @@ -212,13 +215,13 @@ public class LogicalDisplayMapperTest { assertNotEquals(Display.DEFAULT_DISPLAY_GROUP, mLogicalDisplayMapper.getDisplayGroupIdFromDisplayIdLocked(id(display3))); // Now switch it back to the default group by removing the flag and issuing an update // Now switch it to the invalid 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 new group is correct. assertEquals(Display.DEFAULT_DISPLAY_GROUP, // Verify the virtual display has not been placed into a group. assertEquals(Display.INVALID_DISPLAY_GROUP, mLogicalDisplayMapper.getDisplayGroupIdFromDisplayIdLocked(id(display3))); } Loading