Loading core/java/android/hardware/display/DisplayManagerInternal.java +11 −0 Original line number Diff line number Diff line Loading @@ -431,6 +431,17 @@ public abstract class DisplayManagerInternal { */ public abstract IntArray getDisplayGroupIds(); /** * Get all display ids belonging to the display group with given id. */ public abstract int[] getDisplayIdsForGroup(int groupId); /** * Get the mapping of display group ids to the display ids that belong to them. */ public abstract SparseArray<int[]> getDisplayIdsByGroupsIds(); /** * Get all available display ids. */ Loading services/core/java/com/android/server/display/DisplayGroup.java +10 −0 Original line number Diff line number Diff line Loading @@ -87,4 +87,14 @@ public class DisplayGroup { int getIdLocked(int index) { return mDisplays.get(index).getDisplayIdLocked(); } /** Returns the IDs of the {@link LogicalDisplay}s belonging to the DisplayGroup. */ int[] getIdsLocked() { final int numDisplays = mDisplays.size(); final int[] displayIds = new int[numDisplays]; for (int i = 0; i < numDisplays; i++) { displayIds[i] = mDisplays.get(i).getDisplayIdLocked(); } return displayIds; } } services/core/java/com/android/server/display/DisplayManagerService.java +14 −0 Original line number Diff line number Diff line Loading @@ -5588,6 +5588,20 @@ public final class DisplayManagerService extends SystemService { return displayGroupIds; } @Override public int[] getDisplayIdsForGroup(int groupId) { synchronized (mSyncRoot) { return mLogicalDisplayMapper.getDisplayIdsForGroupLocked(groupId); } } @Override public SparseArray<int[]> getDisplayIdsByGroupsIds() { synchronized (mSyncRoot) { return mLogicalDisplayMapper.getDisplayIdsByGroupIdLocked(); } } @Override public IntArray getDisplayIds() { IntArray displayIds = new IntArray(); Loading services/core/java/com/android/server/display/LogicalDisplayMapper.java +17 −0 Original line number Diff line number Diff line Loading @@ -344,6 +344,23 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { return displayIds; } public int[] getDisplayIdsForGroupLocked(int groupId) { DisplayGroup displayGroup = mDisplayGroups.get(groupId); if (displayGroup == null) { return new int[]{}; } return displayGroup.getIdsLocked(); } public SparseArray<int[]> getDisplayIdsByGroupIdLocked() { SparseArray<int[]> displayIdsByGroupIds = new SparseArray<>(); for (int i = 0; i < mDisplayGroups.size(); i++) { int groupId = mDisplayGroups.get(i).getGroupId(); displayIdsByGroupIds.put(groupId, getDisplayIdsForGroupLocked(groupId)); } return displayIdsByGroupIds; } public void forEachLocked(Consumer<LogicalDisplay> consumer) { forEachLocked(consumer, /* includeDisabled= */ true); } Loading services/core/java/com/android/server/power/Notifier.java +53 −0 Original line number Diff line number Diff line Loading @@ -164,6 +164,7 @@ public class Notifier { } private final SparseArray<Interactivity> mInteractivityByGroupId = new SparseArray<>(); private SparseBooleanArray mDisplayInteractivities = new SparseBooleanArray(); // The current global interactive state. This is set as soon as an interactive state // transition begins so as to capture the reason that it happened. At some point Loading Loading @@ -689,6 +690,42 @@ public class Notifier { } } /** * Update the interactivities of the displays in given DisplayGroup. * * @param groupId The group id of the DisplayGroup to update display interactivities for. */ private void updateDisplayInteractivities(int groupId, boolean interactive) { final int[] displayIds = mDisplayManagerInternal.getDisplayIdsForGroup(groupId); for (int displayId : displayIds) { mDisplayInteractivities.put(displayId, interactive); } } private void resetDisplayInteractivities() { final SparseArray<int[]> displaysByGroupId = mDisplayManagerInternal.getDisplayIdsByGroupsIds(); SparseBooleanArray newDisplayInteractivities = new SparseBooleanArray(); for (int i = 0; i < displaysByGroupId.size(); i++) { final int groupId = displaysByGroupId.keyAt(i); for (int displayId : displaysByGroupId.get(i)) { // If we already know display interactivity, use that if (mDisplayInteractivities.indexOfKey(displayId) > 0) { newDisplayInteractivities.put( displayId, mDisplayInteractivities.get(displayId)); } else { // If display is new to Notifier, use the power group's interactive value final Interactivity groupInteractivity = mInteractivityByGroupId.get(groupId); // If group Interactivity hasn't been initialized, assume group is interactive final boolean groupInteractive = groupInteractivity == null || groupInteractivity.isInteractive; newDisplayInteractivities.put(displayId, groupInteractive); } } } mDisplayInteractivities = newDisplayInteractivities; } /** * Called when an individual PowerGroup changes wakefulness. */ Loading Loading @@ -717,6 +754,12 @@ public class Notifier { handleEarlyInteractiveChange(groupId); mWakefulnessSessionObserver.onWakefulnessChangeStarted(groupId, wakefulness, changeReason, eventTime); // Update input on which displays are interactive if (mFlags.isPerDisplayWakeByTouchEnabled()) { updateDisplayInteractivities(groupId, isInteractive); mInputManagerInternal.setDisplayInteractivities(mDisplayInteractivities); } } } Loading @@ -730,6 +773,16 @@ public class Notifier { mWakefulnessSessionObserver.removePowerGroup(groupId); } /** * Called when a PowerGroup has been changed. */ public void onGroupChanged() { if (mFlags.isPerDisplayWakeByTouchEnabled()) { resetDisplayInteractivities(); mInputManagerInternal.setDisplayInteractivities(mDisplayInteractivities); } } /** * Called when there has been user activity. */ Loading Loading
core/java/android/hardware/display/DisplayManagerInternal.java +11 −0 Original line number Diff line number Diff line Loading @@ -431,6 +431,17 @@ public abstract class DisplayManagerInternal { */ public abstract IntArray getDisplayGroupIds(); /** * Get all display ids belonging to the display group with given id. */ public abstract int[] getDisplayIdsForGroup(int groupId); /** * Get the mapping of display group ids to the display ids that belong to them. */ public abstract SparseArray<int[]> getDisplayIdsByGroupsIds(); /** * Get all available display ids. */ Loading
services/core/java/com/android/server/display/DisplayGroup.java +10 −0 Original line number Diff line number Diff line Loading @@ -87,4 +87,14 @@ public class DisplayGroup { int getIdLocked(int index) { return mDisplays.get(index).getDisplayIdLocked(); } /** Returns the IDs of the {@link LogicalDisplay}s belonging to the DisplayGroup. */ int[] getIdsLocked() { final int numDisplays = mDisplays.size(); final int[] displayIds = new int[numDisplays]; for (int i = 0; i < numDisplays; i++) { displayIds[i] = mDisplays.get(i).getDisplayIdLocked(); } return displayIds; } }
services/core/java/com/android/server/display/DisplayManagerService.java +14 −0 Original line number Diff line number Diff line Loading @@ -5588,6 +5588,20 @@ public final class DisplayManagerService extends SystemService { return displayGroupIds; } @Override public int[] getDisplayIdsForGroup(int groupId) { synchronized (mSyncRoot) { return mLogicalDisplayMapper.getDisplayIdsForGroupLocked(groupId); } } @Override public SparseArray<int[]> getDisplayIdsByGroupsIds() { synchronized (mSyncRoot) { return mLogicalDisplayMapper.getDisplayIdsByGroupIdLocked(); } } @Override public IntArray getDisplayIds() { IntArray displayIds = new IntArray(); Loading
services/core/java/com/android/server/display/LogicalDisplayMapper.java +17 −0 Original line number Diff line number Diff line Loading @@ -344,6 +344,23 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener { return displayIds; } public int[] getDisplayIdsForGroupLocked(int groupId) { DisplayGroup displayGroup = mDisplayGroups.get(groupId); if (displayGroup == null) { return new int[]{}; } return displayGroup.getIdsLocked(); } public SparseArray<int[]> getDisplayIdsByGroupIdLocked() { SparseArray<int[]> displayIdsByGroupIds = new SparseArray<>(); for (int i = 0; i < mDisplayGroups.size(); i++) { int groupId = mDisplayGroups.get(i).getGroupId(); displayIdsByGroupIds.put(groupId, getDisplayIdsForGroupLocked(groupId)); } return displayIdsByGroupIds; } public void forEachLocked(Consumer<LogicalDisplay> consumer) { forEachLocked(consumer, /* includeDisabled= */ true); } Loading
services/core/java/com/android/server/power/Notifier.java +53 −0 Original line number Diff line number Diff line Loading @@ -164,6 +164,7 @@ public class Notifier { } private final SparseArray<Interactivity> mInteractivityByGroupId = new SparseArray<>(); private SparseBooleanArray mDisplayInteractivities = new SparseBooleanArray(); // The current global interactive state. This is set as soon as an interactive state // transition begins so as to capture the reason that it happened. At some point Loading Loading @@ -689,6 +690,42 @@ public class Notifier { } } /** * Update the interactivities of the displays in given DisplayGroup. * * @param groupId The group id of the DisplayGroup to update display interactivities for. */ private void updateDisplayInteractivities(int groupId, boolean interactive) { final int[] displayIds = mDisplayManagerInternal.getDisplayIdsForGroup(groupId); for (int displayId : displayIds) { mDisplayInteractivities.put(displayId, interactive); } } private void resetDisplayInteractivities() { final SparseArray<int[]> displaysByGroupId = mDisplayManagerInternal.getDisplayIdsByGroupsIds(); SparseBooleanArray newDisplayInteractivities = new SparseBooleanArray(); for (int i = 0; i < displaysByGroupId.size(); i++) { final int groupId = displaysByGroupId.keyAt(i); for (int displayId : displaysByGroupId.get(i)) { // If we already know display interactivity, use that if (mDisplayInteractivities.indexOfKey(displayId) > 0) { newDisplayInteractivities.put( displayId, mDisplayInteractivities.get(displayId)); } else { // If display is new to Notifier, use the power group's interactive value final Interactivity groupInteractivity = mInteractivityByGroupId.get(groupId); // If group Interactivity hasn't been initialized, assume group is interactive final boolean groupInteractive = groupInteractivity == null || groupInteractivity.isInteractive; newDisplayInteractivities.put(displayId, groupInteractive); } } } mDisplayInteractivities = newDisplayInteractivities; } /** * Called when an individual PowerGroup changes wakefulness. */ Loading Loading @@ -717,6 +754,12 @@ public class Notifier { handleEarlyInteractiveChange(groupId); mWakefulnessSessionObserver.onWakefulnessChangeStarted(groupId, wakefulness, changeReason, eventTime); // Update input on which displays are interactive if (mFlags.isPerDisplayWakeByTouchEnabled()) { updateDisplayInteractivities(groupId, isInteractive); mInputManagerInternal.setDisplayInteractivities(mDisplayInteractivities); } } } Loading @@ -730,6 +773,16 @@ public class Notifier { mWakefulnessSessionObserver.removePowerGroup(groupId); } /** * Called when a PowerGroup has been changed. */ public void onGroupChanged() { if (mFlags.isPerDisplayWakeByTouchEnabled()) { resetDisplayInteractivities(); mInputManagerInternal.setDisplayInteractivities(mDisplayInteractivities); } } /** * Called when there has been user activity. */ Loading