Loading core/java/android/view/DisplayCutout.java +19 −28 Original line number Diff line number Diff line Loading @@ -27,9 +27,7 @@ import static android.view.DisplayCutoutProto.INSETS; import static android.view.DisplayCutoutProto.SIDE_OVERRIDES; import static android.view.DisplayCutoutProto.WATERFALL_INSETS; import static android.view.Surface.ROTATION_0; import static android.view.Surface.ROTATION_180; import static android.view.Surface.ROTATION_270; import static android.view.Surface.ROTATION_90; import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIVATE; Loading Loading @@ -168,6 +166,9 @@ public final class DisplayCutout { // The side index is always under the natural rotation of the device. private int[] mSideOverrides; static final int[] INVALID_OVERRIDES = new int[]{INVALID_SIDE_OVERRIDE, INVALID_SIDE_OVERRIDE, INVALID_SIDE_OVERRIDE, INVALID_SIDE_OVERRIDE}; /** @hide */ @IntDef(prefix = { "BOUNDS_POSITION_" }, value = { BOUNDS_POSITION_LEFT, Loading Loading @@ -1157,35 +1158,25 @@ public final class DisplayCutout { final int resourceId = index >= 0 && index < array.length() ? array.getResourceId(index, ID_NULL) : ID_NULL; final String[] rawOverrides = resourceId != ID_NULL ? array.getResources().getStringArray(resourceId) : res.getStringArray(R.array.config_mainBuiltInDisplayCutoutSideOverride); final int[] rawOverrides = resourceId != ID_NULL ? array.getResources().getIntArray(resourceId) : res.getIntArray(R.array.config_mainBuiltInDisplayCutoutSideOverride); array.recycle(); final int[] override = new int[]{INVALID_SIDE_OVERRIDE, INVALID_SIDE_OVERRIDE, INVALID_SIDE_OVERRIDE, INVALID_SIDE_OVERRIDE}; for (String rawOverride : rawOverrides) { int rotation; String[] split = rawOverride.split(" *, *"); switch (split[0]) { case "0" -> rotation = ROTATION_0; case "90" -> rotation = ROTATION_90; case "180" -> rotation = ROTATION_180; case "270" -> rotation = ROTATION_270; default -> throw new IllegalArgumentException("Invalid side override definition: " + rawOverride); } int side; switch (split[1]) { case SIDE_STRING_LEFT -> side = BOUNDS_POSITION_LEFT; case SIDE_STRING_TOP -> side = BOUNDS_POSITION_TOP; case SIDE_STRING_RIGHT -> side = BOUNDS_POSITION_RIGHT; case SIDE_STRING_BOTTOM -> side = BOUNDS_POSITION_BOTTOM; default -> throw new IllegalArgumentException("Invalid side override definition: " + rawOverride); } override[rotation] = side; } return override; if (rawOverrides.length == 0) { return INVALID_OVERRIDES; } else if (rawOverrides.length != 4) { throw new IllegalArgumentException( "Invalid side override definition, exact 4 overrides required: " + Arrays.toString(rawOverrides)); } for (int rotation = ROTATION_0; rotation <= ROTATION_270; rotation++) { if (rawOverrides[rotation] < BOUNDS_POSITION_LEFT || rawOverrides[rotation] >= BOUNDS_POSITION_LENGTH) { throw new IllegalArgumentException("Invalid side override definition: " + Arrays.toString(rawOverrides)); } } return rawOverrides; } /** Loading core/res/res/values/config.xml +13 −7 Original line number Diff line number Diff line Loading @@ -4055,16 +4055,22 @@ <bool name="config_maskMainBuiltInDisplayCutout">false</bool> <!-- This string array provide override side of each rotation of the given insets. Array of "[rotation],[side]". Undefined rotation will apply the default behavior. Array of [side] for rotation 0, 90, 180 and 270 in order. The options of [side] are: - Option 0 - Left. - Option 1 - Top. - Option 2 - Right. - Option 3 - Bottom. When there are cutouts on multiple edges of the display, the override won't take any effect. --> <string-array name="config_mainBuiltInDisplayCutoutSideOverride" translatable="false"> <!-- Example: <item>90,top</item> <item>270,bottom</item> <integer-array name="config_mainBuiltInDisplayCutoutSideOverride"> <!-- Example of at top for rotation 0 and 90, and at bottom for rotation 180 and 270: <item>1</item> <item>1</item> <item>3</item> <item>3</item> --> </string-array> </integer-array> <!-- Ultrasound support for Mic/speaker path --> <!-- Whether the default microphone audio source supports near-ultrasound frequencies Loading services/tests/displayservicetests/src/com/android/server/display/LocalDisplayAdapterTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -178,8 +178,8 @@ public class LocalDisplayAdapterTest { .thenReturn(mockArray); when(mMockedResources.obtainTypedArray(R.array.config_displayCutoutSideOverrideArray)) .thenReturn(mockArray); when(mMockedResources.getStringArray(R.array.config_mainBuiltInDisplayCutoutSideOverride)) .thenReturn(new String[]{}); when(mMockedResources.getIntArray(R.array.config_mainBuiltInDisplayCutoutSideOverride)) .thenReturn(new int[]{}); when(mMockedResources.obtainTypedArray(R.array.config_waterfallCutoutArray)) .thenReturn(mockArray); when(mMockedResources.obtainTypedArray(R.array.config_roundedCornerRadiusArray)) Loading Loading
core/java/android/view/DisplayCutout.java +19 −28 Original line number Diff line number Diff line Loading @@ -27,9 +27,7 @@ import static android.view.DisplayCutoutProto.INSETS; import static android.view.DisplayCutoutProto.SIDE_OVERRIDES; import static android.view.DisplayCutoutProto.WATERFALL_INSETS; import static android.view.Surface.ROTATION_0; import static android.view.Surface.ROTATION_180; import static android.view.Surface.ROTATION_270; import static android.view.Surface.ROTATION_90; import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIVATE; Loading Loading @@ -168,6 +166,9 @@ public final class DisplayCutout { // The side index is always under the natural rotation of the device. private int[] mSideOverrides; static final int[] INVALID_OVERRIDES = new int[]{INVALID_SIDE_OVERRIDE, INVALID_SIDE_OVERRIDE, INVALID_SIDE_OVERRIDE, INVALID_SIDE_OVERRIDE}; /** @hide */ @IntDef(prefix = { "BOUNDS_POSITION_" }, value = { BOUNDS_POSITION_LEFT, Loading Loading @@ -1157,35 +1158,25 @@ public final class DisplayCutout { final int resourceId = index >= 0 && index < array.length() ? array.getResourceId(index, ID_NULL) : ID_NULL; final String[] rawOverrides = resourceId != ID_NULL ? array.getResources().getStringArray(resourceId) : res.getStringArray(R.array.config_mainBuiltInDisplayCutoutSideOverride); final int[] rawOverrides = resourceId != ID_NULL ? array.getResources().getIntArray(resourceId) : res.getIntArray(R.array.config_mainBuiltInDisplayCutoutSideOverride); array.recycle(); final int[] override = new int[]{INVALID_SIDE_OVERRIDE, INVALID_SIDE_OVERRIDE, INVALID_SIDE_OVERRIDE, INVALID_SIDE_OVERRIDE}; for (String rawOverride : rawOverrides) { int rotation; String[] split = rawOverride.split(" *, *"); switch (split[0]) { case "0" -> rotation = ROTATION_0; case "90" -> rotation = ROTATION_90; case "180" -> rotation = ROTATION_180; case "270" -> rotation = ROTATION_270; default -> throw new IllegalArgumentException("Invalid side override definition: " + rawOverride); } int side; switch (split[1]) { case SIDE_STRING_LEFT -> side = BOUNDS_POSITION_LEFT; case SIDE_STRING_TOP -> side = BOUNDS_POSITION_TOP; case SIDE_STRING_RIGHT -> side = BOUNDS_POSITION_RIGHT; case SIDE_STRING_BOTTOM -> side = BOUNDS_POSITION_BOTTOM; default -> throw new IllegalArgumentException("Invalid side override definition: " + rawOverride); } override[rotation] = side; } return override; if (rawOverrides.length == 0) { return INVALID_OVERRIDES; } else if (rawOverrides.length != 4) { throw new IllegalArgumentException( "Invalid side override definition, exact 4 overrides required: " + Arrays.toString(rawOverrides)); } for (int rotation = ROTATION_0; rotation <= ROTATION_270; rotation++) { if (rawOverrides[rotation] < BOUNDS_POSITION_LEFT || rawOverrides[rotation] >= BOUNDS_POSITION_LENGTH) { throw new IllegalArgumentException("Invalid side override definition: " + Arrays.toString(rawOverrides)); } } return rawOverrides; } /** Loading
core/res/res/values/config.xml +13 −7 Original line number Diff line number Diff line Loading @@ -4055,16 +4055,22 @@ <bool name="config_maskMainBuiltInDisplayCutout">false</bool> <!-- This string array provide override side of each rotation of the given insets. Array of "[rotation],[side]". Undefined rotation will apply the default behavior. Array of [side] for rotation 0, 90, 180 and 270 in order. The options of [side] are: - Option 0 - Left. - Option 1 - Top. - Option 2 - Right. - Option 3 - Bottom. When there are cutouts on multiple edges of the display, the override won't take any effect. --> <string-array name="config_mainBuiltInDisplayCutoutSideOverride" translatable="false"> <!-- Example: <item>90,top</item> <item>270,bottom</item> <integer-array name="config_mainBuiltInDisplayCutoutSideOverride"> <!-- Example of at top for rotation 0 and 90, and at bottom for rotation 180 and 270: <item>1</item> <item>1</item> <item>3</item> <item>3</item> --> </string-array> </integer-array> <!-- Ultrasound support for Mic/speaker path --> <!-- Whether the default microphone audio source supports near-ultrasound frequencies Loading
services/tests/displayservicetests/src/com/android/server/display/LocalDisplayAdapterTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -178,8 +178,8 @@ public class LocalDisplayAdapterTest { .thenReturn(mockArray); when(mMockedResources.obtainTypedArray(R.array.config_displayCutoutSideOverrideArray)) .thenReturn(mockArray); when(mMockedResources.getStringArray(R.array.config_mainBuiltInDisplayCutoutSideOverride)) .thenReturn(new String[]{}); when(mMockedResources.getIntArray(R.array.config_mainBuiltInDisplayCutoutSideOverride)) .thenReturn(new int[]{}); when(mMockedResources.obtainTypedArray(R.array.config_waterfallCutoutArray)) .thenReturn(mockArray); when(mMockedResources.obtainTypedArray(R.array.config_roundedCornerRadiusArray)) Loading