Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b66340f authored by Yunfan Chen's avatar Yunfan Chen Committed by Android (Google) Code Review
Browse files

Merge "Update the cutout side override doc to encourage all side override" into main

parents bb036d42 ef7c09a4
Loading
Loading
Loading
Loading
+19 −28
Original line number Diff line number Diff line
@@ -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;

@@ -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,
@@ -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;
    }

    /**
+13 −7
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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))