diff options
6 files changed, 58 insertions, 14 deletions
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index 0e5fb2cad08f..c664ccba4ca7 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -121,6 +121,19 @@ public final class Display { public static final int INVALID_DISPLAY = -1; /** + * The default display group id, which is the display group id of the primary display assuming + * there is one. + * @hide + */ + public static final int DEFAULT_DISPLAY_GROUP = 0; + + /** + * Invalid display group id. + * @hide + */ + public static final int INVALID_DISPLAY_GROUP = -1; + + /** * Display flag: Indicates that the display supports compositing content * that is stored in protected graphics buffers. * <p> diff --git a/core/java/android/view/DisplayInfo.java b/core/java/android/view/DisplayInfo.java index ab35af89f0b3..d200a328773b 100644 --- a/core/java/android/view/DisplayInfo.java +++ b/core/java/android/view/DisplayInfo.java @@ -66,6 +66,11 @@ public final class DisplayInfo implements Parcelable { public int displayId; /** + * Display Group identifier. + */ + public int displayGroupId; + + /** * Display address, or null if none. * Interpretation varies by display type. */ @@ -331,6 +336,7 @@ public final class DisplayInfo implements Parcelable { && flags == other.flags && type == other.type && displayId == other.displayId + && displayGroupId == other.displayGroupId && Objects.equals(address, other.address) && Objects.equals(deviceProductInfo, other.deviceProductInfo) && Objects.equals(uniqueId, other.uniqueId) @@ -376,6 +382,7 @@ public final class DisplayInfo implements Parcelable { flags = other.flags; type = other.type; displayId = other.displayId; + displayGroupId = other.displayGroupId; address = other.address; deviceProductInfo = other.deviceProductInfo; name = other.name; @@ -418,6 +425,7 @@ public final class DisplayInfo implements Parcelable { flags = source.readInt(); type = source.readInt(); displayId = source.readInt(); + displayGroupId = source.readInt(); address = source.readParcelable(null); deviceProductInfo = source.readParcelable(null); name = source.readString8(); @@ -468,6 +476,7 @@ public final class DisplayInfo implements Parcelable { dest.writeInt(this.flags); dest.writeInt(type); dest.writeInt(displayId); + dest.writeInt(displayGroupId); dest.writeParcelable(address, flags); dest.writeParcelable(deviceProductInfo, flags); dest.writeString8(name); @@ -662,6 +671,8 @@ public final class DisplayInfo implements Parcelable { sb.append(name); sb.append("\", displayId "); sb.append(displayId); + sb.append("\", displayGroupId "); + sb.append(displayGroupId); sb.append(flagsToString(flags)); sb.append(", real "); sb.append(logicalWidth); diff --git a/services/core/java/com/android/server/display/DisplayGroup.java b/services/core/java/com/android/server/display/DisplayGroup.java index 2ba875813734..a11a745d0b7e 100644 --- a/services/core/java/com/android/server/display/DisplayGroup.java +++ b/services/core/java/com/android/server/display/DisplayGroup.java @@ -26,8 +26,6 @@ import java.util.List; */ public class DisplayGroup { - public static final int DEFAULT = 0; - private final List<LogicalDisplay> mDisplays = new ArrayList<>(); private final int mGroupId; diff --git a/services/core/java/com/android/server/display/LogicalDisplay.java b/services/core/java/com/android/server/display/LogicalDisplay.java index 5bf83db4ee34..86de159b5824 100644 --- a/services/core/java/com/android/server/display/LogicalDisplay.java +++ b/services/core/java/com/android/server/display/LogicalDisplay.java @@ -71,6 +71,9 @@ final class LogicalDisplay { private final int mDisplayId; private final int mLayerStack; + + private int mDisplayGroupId = Display.INVALID_DISPLAY_GROUP; + /** * Override information set by the window manager. Will be reported instead of {@link #mInfo} * if not null. @@ -265,6 +268,19 @@ final class LogicalDisplay { } /** + * Updates the {@link DisplayGroup} to which the logical display belongs. + * + * @param groupId Identifier for the {@link DisplayGroup}. + */ + public void updateDisplayGroupIdLocked(int groupId) { + if (groupId != mDisplayGroupId) { + mDisplayGroupId = groupId; + mBaseDisplayInfo.displayGroupId = groupId; + mInfo.set(null); + } + } + + /** * Updates the state of the logical display based on the available display devices. * The logical display might become invalid if it is attached to a display device * that no longer exists. @@ -365,6 +381,7 @@ final class LogicalDisplay { (deviceInfo.flags & DisplayDeviceInfo.FLAG_MASK_DISPLAY_CUTOUT) != 0; mBaseDisplayInfo.displayCutout = maskCutout ? null : deviceInfo.displayCutout; mBaseDisplayInfo.displayId = mDisplayId; + mBaseDisplayInfo.displayGroupId = mDisplayGroupId; updateFrameRateOverrides(deviceInfo); mBaseDisplayInfo.brightnessMinimum = deviceInfo.brightnessMinimum; mBaseDisplayInfo.brightnessMaximum = deviceInfo.brightnessMaximum; diff --git a/services/core/java/com/android/server/display/LogicalDisplayMapper.java b/services/core/java/com/android/server/display/LogicalDisplayMapper.java index bb2fbed354aa..e7388787ecf9 100644 --- a/services/core/java/com/android/server/display/LogicalDisplayMapper.java +++ b/services/core/java/com/android/server/display/LogicalDisplayMapper.java @@ -96,7 +96,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { private final SparseArray<LogicalDisplay> mLogicalDisplays = new SparseArray<LogicalDisplay>(); private int mNextNonDefaultDisplayId = Display.DEFAULT_DISPLAY + 1; - private int mNextNonDefaultGroupId = DisplayGroup.DEFAULT + 1; + private int mNextNonDefaultGroupId = Display.DEFAULT_DISPLAY_GROUP + 1; /** A mapping from logical display id to display group. */ private final SparseArray<DisplayGroup> mDisplayGroups = new SparseArray<>(); @@ -313,7 +313,18 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { final int displayId = assignDisplayIdLocked(isDefault); final int layerStack = assignLayerStackLocked(displayId); + final DisplayGroup displayGroup; + final boolean addNewDisplayGroup = + isDefault || (deviceInfo.flags & DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP) != 0; + if (addNewDisplayGroup) { + final int groupId = assignDisplayGroupIdLocked(isDefault); + displayGroup = new DisplayGroup(groupId); + } else { + displayGroup = mDisplayGroups.get(Display.DEFAULT_DISPLAY); + } + LogicalDisplay display = new LogicalDisplay(displayId, layerStack, device); + display.updateDisplayGroupIdLocked(displayGroup.getGroupId()); display.updateLocked(mDisplayDeviceRepo); if (!display.isValidLocked()) { // This should never happen currently. @@ -324,13 +335,6 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { mLogicalDisplays.put(displayId, display); - final DisplayGroup displayGroup; - if (isDefault || (deviceInfo.flags & DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP) != 0) { - final int groupId = assignDisplayGroupIdLocked(isDefault); - displayGroup = new DisplayGroup(groupId); - } else { - displayGroup = mDisplayGroups.get(Display.DEFAULT_DISPLAY); - } displayGroup.addDisplay(display); mDisplayGroups.append(displayId, displayGroup); @@ -369,6 +373,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { final DisplayGroup displayGroup = new DisplayGroup(groupId); displayGroup.addDisplay(display); mDisplayGroups.append(display.getDisplayIdLocked(), displayGroup); + display.updateDisplayGroupIdLocked(groupId); } } else { // The display should be a part of the default DisplayGroup. @@ -377,6 +382,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { displayGroup.removeDisplay(display); defaultDisplayGroup.addDisplay(display); mDisplayGroups.put(displayId, defaultDisplayGroup); + display.updateDisplayGroupIdLocked(defaultDisplayGroup.getGroupId()); } } @@ -406,7 +412,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { } private int assignDisplayGroupIdLocked(boolean isDefault) { - return isDefault ? DisplayGroup.DEFAULT : mNextNonDefaultGroupId++; + return isDefault ? Display.DEFAULT_DISPLAY_GROUP : mNextNonDefaultGroupId++; } private int assignLayerStackLocked(int displayId) { diff --git a/services/core/java/com/android/server/power/DisplayPowerRequestMapper.java b/services/core/java/com/android/server/power/DisplayPowerRequestMapper.java index 6477552eb550..2fc3e40acd4d 100644 --- a/services/core/java/com/android/server/power/DisplayPowerRequestMapper.java +++ b/services/core/java/com/android/server/power/DisplayPowerRequestMapper.java @@ -25,7 +25,6 @@ import android.util.SparseIntArray; import android.view.Display; import com.android.internal.annotations.GuardedBy; -import com.android.server.display.DisplayGroup; /** * Responsible for creating {@link DisplayPowerRequest}s and associating them with @@ -110,8 +109,8 @@ class DisplayPowerRequestMapper { DisplayManagerInternal displayManagerInternal, Handler handler) { mDisplayManagerInternal = displayManagerInternal; displayManager.registerDisplayListener(mDisplayListener, handler); - mDisplayPowerRequests.append(DisplayGroup.DEFAULT, new DisplayPowerRequest()); - mDisplayGroupIds.append(Display.DEFAULT_DISPLAY, DisplayGroup.DEFAULT); + mDisplayPowerRequests.append(Display.DEFAULT_DISPLAY_GROUP, new DisplayPowerRequest()); + mDisplayGroupIds.append(Display.DEFAULT_DISPLAY, Display.DEFAULT_DISPLAY_GROUP); } DisplayPowerRequest get(int displayId) { |