Loading core/java/android/view/DisplayInfo.java +3 −0 Original line number Diff line number Diff line Loading @@ -810,6 +810,9 @@ public final class DisplayInfo implements Parcelable { if ((flags & Display.FLAG_TRUSTED) != 0) { result.append(", FLAG_TRUSTED"); } if ((flags & Display.FLAG_OWN_DISPLAY_GROUP) != 0) { result.append(", FLAG_OWN_DISPLAY_GROUP"); } return result.toString(); } } core/res/res/values/config.xml +9 −0 Original line number Diff line number Diff line Loading @@ -673,6 +673,15 @@ --> </integer-array> <!-- The device states (supplied by DeviceStateManager) that should be treated as unfolded by the display fold controller. Default is empty. --> <integer-array name="config_unfoldedDeviceStates"> <!-- Example: <item>3</item> <item>4</item> --> </integer-array> <!-- Indicate the display area rect for foldable devices in folded state. --> <string name="config_foldedArea"></string> Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -3765,6 +3765,7 @@ <!-- For Foldables --> <java-symbol type="array" name="config_foldedDeviceStates" /> <java-symbol type="array" name="config_unfoldedDeviceStates" /> <java-symbol type="string" name="config_foldedArea" /> <java-symbol type="array" name="config_disableApksUnlessMatchedSku_apk_list" /> Loading services/core/java/com/android/server/display/DeviceStateToLayoutMap.java +17 −15 Original line number Diff line number Diff line Loading @@ -39,10 +39,6 @@ class DeviceStateToLayoutMap { public static final int STATE_DEFAULT = DeviceStateManager.INVALID_DEVICE_STATE; // TODO - b/168208162 - Remove these when we check in static definitions for layouts public static final int STATE_FOLDED = 100; public static final int STATE_UNFOLDED = 101; private final SparseArray<Layout> mLayoutMap = new SparseArray<>(); DeviceStateToLayoutMap(Context context) { Loading @@ -68,7 +64,7 @@ class DeviceStateToLayoutMap { return layout; } private Layout create(int state) { private Layout createLayout(int state) { if (mLayoutMap.contains(state)) { Slog.e(TAG, "Attempted to create a second layout for state " + state); return null; Loading @@ -79,10 +75,12 @@ class DeviceStateToLayoutMap { return layout; } /** * Loads config.xml-specified folded configurations for foldable devices. */ private void loadFoldedDisplayConfig(Context context) { final String[] strDisplayIds = context.getResources().getStringArray( com.android.internal.R.array.config_internalFoldedPhysicalDisplayIds); if (strDisplayIds.length != 2 || TextUtils.isEmpty(strDisplayIds[0]) || TextUtils.isEmpty(strDisplayIds[1])) { Slog.w(TAG, "Folded display configuration invalid: [" + Arrays.toString(strDisplayIds) Loading @@ -103,19 +101,23 @@ class DeviceStateToLayoutMap { final int[] foldedDeviceStates = context.getResources().getIntArray( com.android.internal.R.array.config_foldedDeviceStates); final int[] unfoldedDeviceStates = context.getResources().getIntArray( com.android.internal.R.array.config_unfoldedDeviceStates); // Only add folded states if folded state config is not empty if (foldedDeviceStates.length == 0) { if (foldedDeviceStates.length == 0 || unfoldedDeviceStates.length == 0) { return; } for (int state : foldedDeviceStates) { // Create the folded state layout final Layout foldedLayout = create(STATE_FOLDED); foldedLayout.createDisplayLocked( createLayout(state).createDisplayLocked( DisplayAddress.fromPhysicalDisplayId(displayIds[0]), true /*isDefault*/); } for (int state : unfoldedDeviceStates) { // Create the unfolded state layout final Layout unfoldedLayout = create(STATE_UNFOLDED); unfoldedLayout.createDisplayLocked( createLayout(state).createDisplayLocked( DisplayAddress.fromPhysicalDisplayId(displayIds[1]), true /*isDefault*/); } } } services/core/java/com/android/server/display/DisplayGroup.java +14 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ public class DisplayGroup { private final List<LogicalDisplay> mDisplays = new ArrayList<>(); private final int mGroupId; private int mChangeCount; DisplayGroup(int groupId) { mGroupId = groupId; } Loading @@ -45,11 +47,16 @@ public class DisplayGroup { * @param display the {@link LogicalDisplay} to add to the Group */ void addDisplayLocked(LogicalDisplay display) { if (!mDisplays.contains(display)) { if (!containsLocked(display)) { mChangeCount++; mDisplays.add(display); } } boolean containsLocked(LogicalDisplay display) { return mDisplays.contains(display); } /** * Removes the provided {@code display} from the Group. * Loading @@ -57,6 +64,7 @@ public class DisplayGroup { * @return {@code true} if the {@code display} was removed; otherwise {@code false} */ boolean removeDisplayLocked(LogicalDisplay display) { mChangeCount++; return mDisplays.remove(display); } Loading @@ -65,6 +73,11 @@ public class DisplayGroup { return mDisplays.isEmpty(); } /** Returns a count of the changes made to this display group. */ int getChangeCountLocked() { return mChangeCount; } /** Returns the number of {@link LogicalDisplay LogicalDisplays} in the Group. */ int getSizeLocked() { return mDisplays.size(); Loading Loading
core/java/android/view/DisplayInfo.java +3 −0 Original line number Diff line number Diff line Loading @@ -810,6 +810,9 @@ public final class DisplayInfo implements Parcelable { if ((flags & Display.FLAG_TRUSTED) != 0) { result.append(", FLAG_TRUSTED"); } if ((flags & Display.FLAG_OWN_DISPLAY_GROUP) != 0) { result.append(", FLAG_OWN_DISPLAY_GROUP"); } return result.toString(); } }
core/res/res/values/config.xml +9 −0 Original line number Diff line number Diff line Loading @@ -673,6 +673,15 @@ --> </integer-array> <!-- The device states (supplied by DeviceStateManager) that should be treated as unfolded by the display fold controller. Default is empty. --> <integer-array name="config_unfoldedDeviceStates"> <!-- Example: <item>3</item> <item>4</item> --> </integer-array> <!-- Indicate the display area rect for foldable devices in folded state. --> <string name="config_foldedArea"></string> Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -3765,6 +3765,7 @@ <!-- For Foldables --> <java-symbol type="array" name="config_foldedDeviceStates" /> <java-symbol type="array" name="config_unfoldedDeviceStates" /> <java-symbol type="string" name="config_foldedArea" /> <java-symbol type="array" name="config_disableApksUnlessMatchedSku_apk_list" /> Loading
services/core/java/com/android/server/display/DeviceStateToLayoutMap.java +17 −15 Original line number Diff line number Diff line Loading @@ -39,10 +39,6 @@ class DeviceStateToLayoutMap { public static final int STATE_DEFAULT = DeviceStateManager.INVALID_DEVICE_STATE; // TODO - b/168208162 - Remove these when we check in static definitions for layouts public static final int STATE_FOLDED = 100; public static final int STATE_UNFOLDED = 101; private final SparseArray<Layout> mLayoutMap = new SparseArray<>(); DeviceStateToLayoutMap(Context context) { Loading @@ -68,7 +64,7 @@ class DeviceStateToLayoutMap { return layout; } private Layout create(int state) { private Layout createLayout(int state) { if (mLayoutMap.contains(state)) { Slog.e(TAG, "Attempted to create a second layout for state " + state); return null; Loading @@ -79,10 +75,12 @@ class DeviceStateToLayoutMap { return layout; } /** * Loads config.xml-specified folded configurations for foldable devices. */ private void loadFoldedDisplayConfig(Context context) { final String[] strDisplayIds = context.getResources().getStringArray( com.android.internal.R.array.config_internalFoldedPhysicalDisplayIds); if (strDisplayIds.length != 2 || TextUtils.isEmpty(strDisplayIds[0]) || TextUtils.isEmpty(strDisplayIds[1])) { Slog.w(TAG, "Folded display configuration invalid: [" + Arrays.toString(strDisplayIds) Loading @@ -103,19 +101,23 @@ class DeviceStateToLayoutMap { final int[] foldedDeviceStates = context.getResources().getIntArray( com.android.internal.R.array.config_foldedDeviceStates); final int[] unfoldedDeviceStates = context.getResources().getIntArray( com.android.internal.R.array.config_unfoldedDeviceStates); // Only add folded states if folded state config is not empty if (foldedDeviceStates.length == 0) { if (foldedDeviceStates.length == 0 || unfoldedDeviceStates.length == 0) { return; } for (int state : foldedDeviceStates) { // Create the folded state layout final Layout foldedLayout = create(STATE_FOLDED); foldedLayout.createDisplayLocked( createLayout(state).createDisplayLocked( DisplayAddress.fromPhysicalDisplayId(displayIds[0]), true /*isDefault*/); } for (int state : unfoldedDeviceStates) { // Create the unfolded state layout final Layout unfoldedLayout = create(STATE_UNFOLDED); unfoldedLayout.createDisplayLocked( createLayout(state).createDisplayLocked( DisplayAddress.fromPhysicalDisplayId(displayIds[1]), true /*isDefault*/); } } }
services/core/java/com/android/server/display/DisplayGroup.java +14 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ public class DisplayGroup { private final List<LogicalDisplay> mDisplays = new ArrayList<>(); private final int mGroupId; private int mChangeCount; DisplayGroup(int groupId) { mGroupId = groupId; } Loading @@ -45,11 +47,16 @@ public class DisplayGroup { * @param display the {@link LogicalDisplay} to add to the Group */ void addDisplayLocked(LogicalDisplay display) { if (!mDisplays.contains(display)) { if (!containsLocked(display)) { mChangeCount++; mDisplays.add(display); } } boolean containsLocked(LogicalDisplay display) { return mDisplays.contains(display); } /** * Removes the provided {@code display} from the Group. * Loading @@ -57,6 +64,7 @@ public class DisplayGroup { * @return {@code true} if the {@code display} was removed; otherwise {@code false} */ boolean removeDisplayLocked(LogicalDisplay display) { mChangeCount++; return mDisplays.remove(display); } Loading @@ -65,6 +73,11 @@ public class DisplayGroup { return mDisplays.isEmpty(); } /** Returns a count of the changes made to this display group. */ int getChangeCountLocked() { return mChangeCount; } /** Returns the number of {@link LogicalDisplay LogicalDisplays} in the Group. */ int getSizeLocked() { return mDisplays.size(); Loading