Loading core/java/android/hardware/display/DisplayTopology.java +18 −37 Original line number Diff line number Diff line Loading @@ -169,7 +169,23 @@ public final class DisplayTopology implements Parcelable { * @hide */ public void addDisplay(int displayId, float width, float height) { addDisplay(displayId, width, height, /* shouldLog= */ true); if (findDisplay(displayId, mRoot) != null) { return; } if (mRoot == null) { mRoot = new TreeNode(displayId, width, height, POSITION_LEFT, /* offset= */ 0); mPrimaryDisplayId = displayId; } else if (mRoot.mChildren.isEmpty()) { // This is the 2nd display. Align the middles of the top and bottom edges. float offset = mRoot.mWidth / 2 - width / 2; TreeNode display = new TreeNode(displayId, width, height, POSITION_TOP, offset); mRoot.mChildren.add(display); } else { TreeNode rightMostDisplay = findRightMostDisplay(mRoot, mRoot.mWidth).first; TreeNode newDisplay = new TreeNode(displayId, width, height, POSITION_RIGHT, /* offset= */ 0); rightMostDisplay.mChildren.add(newDisplay); } } /** Loading Loading @@ -216,7 +232,7 @@ public final class DisplayTopology implements Parcelable { while (!queue.isEmpty()) { TreeNode node = queue.poll(); if (node.mDisplayId != displayId) { addDisplay(node.mDisplayId, node.mWidth, node.mHeight, /* shouldLog= */ false); addDisplay(node.mDisplayId, node.mWidth, node.mHeight); } queue.addAll(node.mChildren); } Loading @@ -227,10 +243,6 @@ public final class DisplayTopology implements Parcelable { } else { mPrimaryDisplayId = Display.INVALID_DISPLAY; } Slog.i(TAG, "Primary display with ID " + displayId + " removed, new primary display: " + mPrimaryDisplayId); } else { Slog.i(TAG, "Display with ID " + displayId + " removed"); } return true; } Loading Loading @@ -598,37 +610,6 @@ public final class DisplayTopology implements Parcelable { return out.toString(); } private void addDisplay(int displayId, float width, float height, boolean shouldLog) { if (findDisplay(displayId, mRoot) != null) { return; } if (mRoot == null) { mRoot = new TreeNode(displayId, width, height, POSITION_LEFT, /* offset= */ 0); mPrimaryDisplayId = displayId; if (shouldLog) { Slog.i(TAG, "First display added: " + mRoot); } } else if (mRoot.mChildren.isEmpty()) { // This is the 2nd display. Align the middles of the top and bottom edges. float offset = mRoot.mWidth / 2 - width / 2; TreeNode display = new TreeNode(displayId, width, height, POSITION_TOP, offset); mRoot.mChildren.add(display); if (shouldLog) { Slog.i(TAG, "Second display added: " + display + ", parent ID: " + mRoot.mDisplayId); } } else { TreeNode rightMostDisplay = findRightMostDisplay(mRoot, mRoot.mWidth).first; TreeNode newDisplay = new TreeNode(displayId, width, height, POSITION_RIGHT, /* offset= */ 0); rightMostDisplay.mChildren.add(newDisplay); if (shouldLog) { Slog.i(TAG, "Display added: " + newDisplay + ", parent ID: " + rightMostDisplay.mDisplayId); } } } /** * @param display The display from which the search should start. * @param xPos The x position of the right edge of that display. Loading services/core/java/com/android/server/display/DisplayTopologyCoordinator.java +17 −9 Original line number Diff line number Diff line Loading @@ -111,13 +111,14 @@ class DisplayTopologyCoordinator { * @param info The display info */ void onDisplayAdded(DisplayInfo info) { if (!isDisplayAllowedInTopology(info)) { if (!isDisplayAllowedInTopology(info, /* shouldLog= */ true)) { return; } synchronized (mSyncRoot) { addDisplayIdMappingLocked(info); mDensities.put(info.displayId, info.logicalDensityDpi); mTopology.addDisplay(info.displayId, getWidth(info), getHeight(info)); Slog.i(TAG, "Display " + info.displayId + " added, new topology: " + mTopology); restoreTopologyLocked(); sendTopologyUpdateLocked(); } Loading @@ -128,7 +129,7 @@ class DisplayTopologyCoordinator { * @param info The new display info */ void onDisplayChanged(DisplayInfo info) { if (!isDisplayAllowedInTopology(info)) { if (!isDisplayAllowedInTopology(info, /* shouldLog= */ false)) { return; } synchronized (mSyncRoot) { Loading @@ -149,6 +150,7 @@ class DisplayTopologyCoordinator { synchronized (mSyncRoot) { mDensities.delete(displayId); if (mTopology.removeDisplay(displayId)) { Slog.i(TAG, "Display " + displayId + " removed, new topology: " + mTopology); removeDisplayIdMappingLocked(displayId); restoreTopologyLocked(); sendTopologyUpdateLocked(); Loading Loading @@ -249,22 +251,28 @@ class DisplayTopologyCoordinator { return pxToDp(info.logicalHeight, info.logicalDensityDpi); } private boolean isDisplayAllowedInTopology(DisplayInfo info) { private boolean isDisplayAllowedInTopology(DisplayInfo info, boolean shouldLog) { if (info.type != Display.TYPE_INTERNAL && info.type != Display.TYPE_EXTERNAL && info.type != Display.TYPE_OVERLAY) { if (shouldLog) { Slog.d(TAG, "Display " + info.displayId + " not allowed in topology because " + "type is not INTERNAL, EXTERNAL or OVERLAY"); } return false; } if (info.type == Display.TYPE_INTERNAL && info.displayId != Display.DEFAULT_DISPLAY) { if (shouldLog) { Slog.d(TAG, "Display " + info.displayId + " not allowed in topology because " + "it is a non-default internal display"); } return false; } if ((info.type == Display.TYPE_EXTERNAL || info.type == Display.TYPE_OVERLAY) && !mIsExtendedDisplayAllowed.getAsBoolean()) { if (shouldLog) { Slog.d(TAG, "Display " + info.displayId + " not allowed in topology because " + "type is EXTERNAL or OVERLAY and !mIsExtendedDisplayAllowed"); } return false; } return true; Loading Loading
core/java/android/hardware/display/DisplayTopology.java +18 −37 Original line number Diff line number Diff line Loading @@ -169,7 +169,23 @@ public final class DisplayTopology implements Parcelable { * @hide */ public void addDisplay(int displayId, float width, float height) { addDisplay(displayId, width, height, /* shouldLog= */ true); if (findDisplay(displayId, mRoot) != null) { return; } if (mRoot == null) { mRoot = new TreeNode(displayId, width, height, POSITION_LEFT, /* offset= */ 0); mPrimaryDisplayId = displayId; } else if (mRoot.mChildren.isEmpty()) { // This is the 2nd display. Align the middles of the top and bottom edges. float offset = mRoot.mWidth / 2 - width / 2; TreeNode display = new TreeNode(displayId, width, height, POSITION_TOP, offset); mRoot.mChildren.add(display); } else { TreeNode rightMostDisplay = findRightMostDisplay(mRoot, mRoot.mWidth).first; TreeNode newDisplay = new TreeNode(displayId, width, height, POSITION_RIGHT, /* offset= */ 0); rightMostDisplay.mChildren.add(newDisplay); } } /** Loading Loading @@ -216,7 +232,7 @@ public final class DisplayTopology implements Parcelable { while (!queue.isEmpty()) { TreeNode node = queue.poll(); if (node.mDisplayId != displayId) { addDisplay(node.mDisplayId, node.mWidth, node.mHeight, /* shouldLog= */ false); addDisplay(node.mDisplayId, node.mWidth, node.mHeight); } queue.addAll(node.mChildren); } Loading @@ -227,10 +243,6 @@ public final class DisplayTopology implements Parcelable { } else { mPrimaryDisplayId = Display.INVALID_DISPLAY; } Slog.i(TAG, "Primary display with ID " + displayId + " removed, new primary display: " + mPrimaryDisplayId); } else { Slog.i(TAG, "Display with ID " + displayId + " removed"); } return true; } Loading Loading @@ -598,37 +610,6 @@ public final class DisplayTopology implements Parcelable { return out.toString(); } private void addDisplay(int displayId, float width, float height, boolean shouldLog) { if (findDisplay(displayId, mRoot) != null) { return; } if (mRoot == null) { mRoot = new TreeNode(displayId, width, height, POSITION_LEFT, /* offset= */ 0); mPrimaryDisplayId = displayId; if (shouldLog) { Slog.i(TAG, "First display added: " + mRoot); } } else if (mRoot.mChildren.isEmpty()) { // This is the 2nd display. Align the middles of the top and bottom edges. float offset = mRoot.mWidth / 2 - width / 2; TreeNode display = new TreeNode(displayId, width, height, POSITION_TOP, offset); mRoot.mChildren.add(display); if (shouldLog) { Slog.i(TAG, "Second display added: " + display + ", parent ID: " + mRoot.mDisplayId); } } else { TreeNode rightMostDisplay = findRightMostDisplay(mRoot, mRoot.mWidth).first; TreeNode newDisplay = new TreeNode(displayId, width, height, POSITION_RIGHT, /* offset= */ 0); rightMostDisplay.mChildren.add(newDisplay); if (shouldLog) { Slog.i(TAG, "Display added: " + newDisplay + ", parent ID: " + rightMostDisplay.mDisplayId); } } } /** * @param display The display from which the search should start. * @param xPos The x position of the right edge of that display. Loading
services/core/java/com/android/server/display/DisplayTopologyCoordinator.java +17 −9 Original line number Diff line number Diff line Loading @@ -111,13 +111,14 @@ class DisplayTopologyCoordinator { * @param info The display info */ void onDisplayAdded(DisplayInfo info) { if (!isDisplayAllowedInTopology(info)) { if (!isDisplayAllowedInTopology(info, /* shouldLog= */ true)) { return; } synchronized (mSyncRoot) { addDisplayIdMappingLocked(info); mDensities.put(info.displayId, info.logicalDensityDpi); mTopology.addDisplay(info.displayId, getWidth(info), getHeight(info)); Slog.i(TAG, "Display " + info.displayId + " added, new topology: " + mTopology); restoreTopologyLocked(); sendTopologyUpdateLocked(); } Loading @@ -128,7 +129,7 @@ class DisplayTopologyCoordinator { * @param info The new display info */ void onDisplayChanged(DisplayInfo info) { if (!isDisplayAllowedInTopology(info)) { if (!isDisplayAllowedInTopology(info, /* shouldLog= */ false)) { return; } synchronized (mSyncRoot) { Loading @@ -149,6 +150,7 @@ class DisplayTopologyCoordinator { synchronized (mSyncRoot) { mDensities.delete(displayId); if (mTopology.removeDisplay(displayId)) { Slog.i(TAG, "Display " + displayId + " removed, new topology: " + mTopology); removeDisplayIdMappingLocked(displayId); restoreTopologyLocked(); sendTopologyUpdateLocked(); Loading Loading @@ -249,22 +251,28 @@ class DisplayTopologyCoordinator { return pxToDp(info.logicalHeight, info.logicalDensityDpi); } private boolean isDisplayAllowedInTopology(DisplayInfo info) { private boolean isDisplayAllowedInTopology(DisplayInfo info, boolean shouldLog) { if (info.type != Display.TYPE_INTERNAL && info.type != Display.TYPE_EXTERNAL && info.type != Display.TYPE_OVERLAY) { if (shouldLog) { Slog.d(TAG, "Display " + info.displayId + " not allowed in topology because " + "type is not INTERNAL, EXTERNAL or OVERLAY"); } return false; } if (info.type == Display.TYPE_INTERNAL && info.displayId != Display.DEFAULT_DISPLAY) { if (shouldLog) { Slog.d(TAG, "Display " + info.displayId + " not allowed in topology because " + "it is a non-default internal display"); } return false; } if ((info.type == Display.TYPE_EXTERNAL || info.type == Display.TYPE_OVERLAY) && !mIsExtendedDisplayAllowed.getAsBoolean()) { if (shouldLog) { Slog.d(TAG, "Display " + info.displayId + " not allowed in topology because " + "type is EXTERNAL or OVERLAY and !mIsExtendedDisplayAllowed"); } return false; } return true; Loading