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

Commit f18a9fec authored by Shawn Lin's avatar Shawn Lin Committed by Automerger Merge Worker
Browse files

Merge "Replace DisplayManager.getStableDisplaySize with max Display.Mode" into...

Merge "Replace DisplayManager.getStableDisplaySize with max Display.Mode" into tm-dev am: 15cb562b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18485561



Change-Id: Ie42fd58945ef2b4d0490661a72db88c954fb1cb2
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents ec5e0bad 15cb562b
Loading
Loading
Loading
Loading
+24 −5
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package android.util;
package android.util;


import android.content.res.Resources;
import android.content.res.Resources;
import android.view.Display;


import com.android.internal.R;
import com.android.internal.R;


@@ -53,15 +54,33 @@ public class DisplayUtils {
    }
    }


    /**
    /**
     * Get the display size ratio based on the stable display size.
     * Returns the Display.Mode with maximum resolution.
     */
    public static Display.Mode getMaximumResolutionDisplayMode(Display.Mode[] modes) {
        if (modes == null || modes.length == 0) {
            return null;
        }
        int maxWidth = 0;
        Display.Mode target = null;
        for (Display.Mode mode : modes) {
            if (mode.getPhysicalWidth() > maxWidth) {
                maxWidth = mode.getPhysicalWidth();
                target = mode;
            }
        }
        return target;
    }

    /**
     * Get the display size ratio based on the physical display size.
     */
     */
    public static float getPhysicalPixelDisplaySizeRatio(
    public static float getPhysicalPixelDisplaySizeRatio(
            int stableWidth, int stableHeight, int currentWidth, int currentHeight) {
            int physicalWidth, int physicalHeight, int currentWidth, int currentHeight) {
        if (stableWidth == currentWidth && stableHeight == currentHeight) {
        if (physicalWidth == currentWidth && physicalHeight == currentHeight) {
            return 1f;
            return 1f;
        }
        }
        final float widthRatio = (float) currentWidth / stableWidth;
        final float widthRatio = (float) currentWidth / physicalWidth;
        final float heightRatio = (float) currentHeight / stableHeight;
        final float heightRatio = (float) currentHeight / physicalHeight;
        return Math.min(widthRatio, heightRatio);
        return Math.min(widthRatio, heightRatio);
    }
    }
}
}
+25 −24
Original line number Original line Diff line number Diff line
@@ -203,8 +203,8 @@ public class CutoutSpecification {
    public static class Parser {
    public static class Parser {
        private final boolean mIsShortEdgeOnTop;
        private final boolean mIsShortEdgeOnTop;
        private final float mStableDensity;
        private final float mStableDensity;
        private final int mStableDisplayWidth;
        private final int mPhysicalDisplayWidth;
        private final int mStableDisplayHeight;
        private final int mPhysicalDisplayHeight;
        private final float mPhysicalPixelDisplaySizeRatio;
        private final float mPhysicalPixelDisplaySizeRatio;
        private final Matrix mMatrix;
        private final Matrix mMatrix;
        private Insets mInsets;
        private Insets mInsets;
@@ -238,25 +238,26 @@ public class CutoutSpecification {
        private boolean mIsCloserToStartSide;
        private boolean mIsCloserToStartSide;


        @VisibleForTesting(visibility = PACKAGE)
        @VisibleForTesting(visibility = PACKAGE)
        public Parser(float stableDensity, int stableDisplayWidth, int stableDisplayHeight) {
        public Parser(float stableDensity, int physicalDisplayWidth,
            this(stableDensity, stableDisplayWidth, stableDisplayHeight, 1f);
                int physicalDisplayHeight) {
            this(stableDensity, physicalDisplayWidth, physicalDisplayHeight, 1f);
        }
        }


        /**
        /**
         * The constructor of the CutoutSpecification parser to parse the specification of cutout.
         * The constructor of the CutoutSpecification parser to parse the specification of cutout.
         * @param stableDensity the display density.
         * @param stableDensity the display density.
         * @param stableDisplayWidth the display width.
         * @param physicalDisplayWidth the display width.
         * @param stableDisplayHeight the display height.
         * @param physicalDisplayHeight the display height.
         * @param physicalPixelDisplaySizeRatio the display size ratio based on stable display size.
         * @param physicalPixelDisplaySizeRatio the display size ratio based on stable display size.
         */
         */
        Parser(float stableDensity, int stableDisplayWidth, int stableDisplayHeight,
        Parser(float stableDensity, int physicalDisplayWidth, int physicalDisplayHeight,
                float physicalPixelDisplaySizeRatio) {
                float physicalPixelDisplaySizeRatio) {
            mStableDensity = stableDensity;
            mStableDensity = stableDensity;
            mStableDisplayWidth = stableDisplayWidth;
            mPhysicalDisplayWidth = physicalDisplayWidth;
            mStableDisplayHeight = stableDisplayHeight;
            mPhysicalDisplayHeight = physicalDisplayHeight;
            mPhysicalPixelDisplaySizeRatio = physicalPixelDisplaySizeRatio;
            mPhysicalPixelDisplaySizeRatio = physicalPixelDisplaySizeRatio;
            mMatrix = new Matrix();
            mMatrix = new Matrix();
            mIsShortEdgeOnTop = mStableDisplayWidth < mStableDisplayHeight;
            mIsShortEdgeOnTop = mPhysicalDisplayWidth < mPhysicalDisplayHeight;
        }
        }


        private void computeBoundsRectAndAddToRegion(Path p, Region inoutRegion, Rect inoutRect) {
        private void computeBoundsRectAndAddToRegion(Path p, Region inoutRegion, Rect inoutRect) {
@@ -281,18 +282,18 @@ public class CutoutSpecification {
        private void translateMatrix() {
        private void translateMatrix() {
            final float offsetX;
            final float offsetX;
            if (mPositionFromRight) {
            if (mPositionFromRight) {
                offsetX = mStableDisplayWidth;
                offsetX = mPhysicalDisplayWidth;
            } else if (mPositionFromLeft) {
            } else if (mPositionFromLeft) {
                offsetX = 0;
                offsetX = 0;
            } else {
            } else {
                offsetX = mStableDisplayWidth / 2f;
                offsetX = mPhysicalDisplayWidth / 2f;
            }
            }


            final float offsetY;
            final float offsetY;
            if (mPositionFromBottom) {
            if (mPositionFromBottom) {
                offsetY = mStableDisplayHeight;
                offsetY = mPhysicalDisplayHeight;
            } else if (mPositionFromCenterVertical) {
            } else if (mPositionFromCenterVertical) {
                offsetY = mStableDisplayHeight / 2f;
                offsetY = mPhysicalDisplayHeight / 2f;
            } else {
            } else {
                offsetY = 0;
                offsetY = 0;
            }
            }
@@ -305,14 +306,14 @@ public class CutoutSpecification {
        }
        }


        private int computeSafeInsets(int gravity, Rect rect) {
        private int computeSafeInsets(int gravity, Rect rect) {
            if (gravity == LEFT && rect.right > 0 && rect.right < mStableDisplayWidth) {
            if (gravity == LEFT && rect.right > 0 && rect.right < mPhysicalDisplayWidth) {
                return rect.right;
                return rect.right;
            } else if (gravity == TOP && rect.bottom > 0 && rect.bottom < mStableDisplayHeight) {
            } else if (gravity == TOP && rect.bottom > 0 && rect.bottom < mPhysicalDisplayHeight) {
                return rect.bottom;
                return rect.bottom;
            } else if (gravity == RIGHT && rect.left > 0 && rect.left < mStableDisplayWidth) {
            } else if (gravity == RIGHT && rect.left > 0 && rect.left < mPhysicalDisplayWidth) {
                return mStableDisplayWidth - rect.left;
                return mPhysicalDisplayWidth - rect.left;
            } else if (gravity == BOTTOM && rect.top > 0 && rect.top < mStableDisplayHeight) {
            } else if (gravity == BOTTOM && rect.top > 0 && rect.top < mPhysicalDisplayHeight) {
                return mStableDisplayHeight - rect.top;
                return mPhysicalDisplayHeight - rect.top;
            }
            }
            return 0;
            return 0;
        }
        }
@@ -415,12 +416,12 @@ public class CutoutSpecification {


            if (mIsShortEdgeOnTop) {
            if (mIsShortEdgeOnTop) {
                mIsTouchShortEdgeStart = mTmpRect.top <= 0;
                mIsTouchShortEdgeStart = mTmpRect.top <= 0;
                mIsTouchShortEdgeEnd = mTmpRect.bottom >= mStableDisplayHeight;
                mIsTouchShortEdgeEnd = mTmpRect.bottom >= mPhysicalDisplayHeight;
                mIsCloserToStartSide = mTmpRect.centerY() < mStableDisplayHeight / 2;
                mIsCloserToStartSide = mTmpRect.centerY() < mPhysicalDisplayHeight / 2;
            } else {
            } else {
                mIsTouchShortEdgeStart = mTmpRect.left <= 0;
                mIsTouchShortEdgeStart = mTmpRect.left <= 0;
                mIsTouchShortEdgeEnd = mTmpRect.right >= mStableDisplayWidth;
                mIsTouchShortEdgeEnd = mTmpRect.right >= mPhysicalDisplayWidth;
                mIsCloserToStartSide = mTmpRect.centerX() < mStableDisplayWidth / 2;
                mIsCloserToStartSide = mTmpRect.centerX() < mPhysicalDisplayWidth / 2;
            }
            }


            setEdgeCutout(newPath);
            setEdgeCutout(newPath);
+43 −42
Original line number Original line Diff line number Diff line
@@ -77,8 +77,8 @@ public final class DisplayCutout {


    private static final Rect ZERO_RECT = new Rect();
    private static final Rect ZERO_RECT = new Rect();
    private static final CutoutPathParserInfo EMPTY_PARSER_INFO = new CutoutPathParserInfo(
    private static final CutoutPathParserInfo EMPTY_PARSER_INFO = new CutoutPathParserInfo(
            0 /* displayWidth */, 0 /* stableDisplayHeight */,
            0 /* displayWidth */, 0 /* physicalDisplayHeight */,
            0 /* stableDisplayHeight */, 0 /* displayHeight */, 0f /* density */,
            0 /* physicalDisplayHeight */, 0 /* displayHeight */, 0f /* density */,
            "" /* cutoutSpec */, 0 /* ROTATION_0 */, 0f /* scale */,
            "" /* cutoutSpec */, 0 /* ROTATION_0 */, 0f /* scale */,
            0f /* physicalPixelDisplaySizeRatio*/);
            0f /* physicalPixelDisplaySizeRatio*/);


@@ -258,21 +258,21 @@ public final class DisplayCutout {
    public static class CutoutPathParserInfo {
    public static class CutoutPathParserInfo {
        private final int mDisplayWidth;
        private final int mDisplayWidth;
        private final int mDisplayHeight;
        private final int mDisplayHeight;
        private final int mStableDisplayWidth;
        private final int mPhysicalDisplayWidth;
        private final int mStableDisplayHeight;
        private final int mPhysicalDisplayHeight;
        private final float mDensity;
        private final float mDensity;
        private final String mCutoutSpec;
        private final String mCutoutSpec;
        private final @Rotation int mRotation;
        private final @Rotation int mRotation;
        private final float mScale;
        private final float mScale;
        private final float mPhysicalPixelDisplaySizeRatio;
        private final float mPhysicalPixelDisplaySizeRatio;


        public CutoutPathParserInfo(int displayWidth, int displayHeight, int stableDisplayWidth,
        public CutoutPathParserInfo(int displayWidth, int displayHeight, int physicalDisplayWidth,
                int stableDisplayHeight, float density, @Nullable String cutoutSpec,
                int physicalDisplayHeight, float density, @Nullable String cutoutSpec,
                @Rotation int rotation, float scale, float physicalPixelDisplaySizeRatio) {
                @Rotation int rotation, float scale, float physicalPixelDisplaySizeRatio) {
            mDisplayWidth = displayWidth;
            mDisplayWidth = displayWidth;
            mDisplayHeight = displayHeight;
            mDisplayHeight = displayHeight;
            mStableDisplayWidth = stableDisplayWidth;
            mPhysicalDisplayWidth = physicalDisplayWidth;
            mStableDisplayHeight = stableDisplayHeight;
            mPhysicalDisplayHeight = physicalDisplayHeight;
            mDensity = density;
            mDensity = density;
            mCutoutSpec = cutoutSpec == null ? "" : cutoutSpec;
            mCutoutSpec = cutoutSpec == null ? "" : cutoutSpec;
            mRotation = rotation;
            mRotation = rotation;
@@ -283,8 +283,8 @@ public final class DisplayCutout {
        public CutoutPathParserInfo(@NonNull CutoutPathParserInfo cutoutPathParserInfo) {
        public CutoutPathParserInfo(@NonNull CutoutPathParserInfo cutoutPathParserInfo) {
            mDisplayWidth = cutoutPathParserInfo.mDisplayWidth;
            mDisplayWidth = cutoutPathParserInfo.mDisplayWidth;
            mDisplayHeight = cutoutPathParserInfo.mDisplayHeight;
            mDisplayHeight = cutoutPathParserInfo.mDisplayHeight;
            mStableDisplayWidth = cutoutPathParserInfo.mStableDisplayWidth;
            mPhysicalDisplayWidth = cutoutPathParserInfo.mPhysicalDisplayWidth;
            mStableDisplayHeight = cutoutPathParserInfo.mStableDisplayHeight;
            mPhysicalDisplayHeight = cutoutPathParserInfo.mPhysicalDisplayHeight;
            mDensity = cutoutPathParserInfo.mDensity;
            mDensity = cutoutPathParserInfo.mDensity;
            mCutoutSpec = cutoutPathParserInfo.mCutoutSpec;
            mCutoutSpec = cutoutPathParserInfo.mCutoutSpec;
            mRotation = cutoutPathParserInfo.mRotation;
            mRotation = cutoutPathParserInfo.mRotation;
@@ -300,12 +300,12 @@ public final class DisplayCutout {
            return mDisplayHeight;
            return mDisplayHeight;
        }
        }


        public int getStableDisplayWidth() {
        public int getPhysicalDisplayWidth() {
            return mStableDisplayWidth;
            return mPhysicalDisplayWidth;
        }
        }


        public int getStableDisplayHeight() {
        public int getPhysicalDisplayHeight() {
            return mStableDisplayHeight;
            return mPhysicalDisplayHeight;
        }
        }


        public float getDensity() {
        public float getDensity() {
@@ -342,8 +342,8 @@ public final class DisplayCutout {
            result = result * 48271 + Integer.hashCode(mRotation);
            result = result * 48271 + Integer.hashCode(mRotation);
            result = result * 48271 + Float.hashCode(mScale);
            result = result * 48271 + Float.hashCode(mScale);
            result = result * 48271 + Float.hashCode(mPhysicalPixelDisplaySizeRatio);
            result = result * 48271 + Float.hashCode(mPhysicalPixelDisplaySizeRatio);
            result = result * 48271 + Integer.hashCode(mStableDisplayWidth);
            result = result * 48271 + Integer.hashCode(mPhysicalDisplayWidth);
            result = result * 48271 + Integer.hashCode(mStableDisplayHeight);
            result = result * 48271 + Integer.hashCode(mPhysicalDisplayHeight);
            return result;
            return result;
        }
        }


@@ -355,8 +355,8 @@ public final class DisplayCutout {
            if (o instanceof CutoutPathParserInfo) {
            if (o instanceof CutoutPathParserInfo) {
                CutoutPathParserInfo c = (CutoutPathParserInfo) o;
                CutoutPathParserInfo c = (CutoutPathParserInfo) o;
                return mDisplayWidth == c.mDisplayWidth && mDisplayHeight == c.mDisplayHeight
                return mDisplayWidth == c.mDisplayWidth && mDisplayHeight == c.mDisplayHeight
                        && mStableDisplayWidth == c.mStableDisplayWidth
                        && mPhysicalDisplayWidth == c.mPhysicalDisplayWidth
                        && mStableDisplayHeight == c.mStableDisplayHeight
                        && mPhysicalDisplayHeight == c.mPhysicalDisplayHeight
                        && mDensity == c.mDensity && mCutoutSpec.equals(c.mCutoutSpec)
                        && mDensity == c.mDensity && mCutoutSpec.equals(c.mCutoutSpec)
                        && mRotation == c.mRotation && mScale == c.mScale
                        && mRotation == c.mRotation && mScale == c.mScale
                        && mPhysicalPixelDisplaySizeRatio == c.mPhysicalPixelDisplaySizeRatio;
                        && mPhysicalPixelDisplaySizeRatio == c.mPhysicalPixelDisplaySizeRatio;
@@ -368,8 +368,8 @@ public final class DisplayCutout {
        public String toString() {
        public String toString() {
            return "CutoutPathParserInfo{displayWidth=" + mDisplayWidth
            return "CutoutPathParserInfo{displayWidth=" + mDisplayWidth
                    + " displayHeight=" + mDisplayHeight
                    + " displayHeight=" + mDisplayHeight
                    + " stableDisplayHeight=" + mStableDisplayWidth
                    + " physicalDisplayWidth=" + mPhysicalDisplayWidth
                    + " stableDisplayHeight=" + mStableDisplayHeight
                    + " physicalDisplayHeight=" + mPhysicalDisplayHeight
                    + " density={" + mDensity + "}"
                    + " density={" + mDensity + "}"
                    + " cutoutSpec={" + mCutoutSpec + "}"
                    + " cutoutSpec={" + mCutoutSpec + "}"
                    + " rotation={" + mRotation + "}"
                    + " rotation={" + mRotation + "}"
@@ -750,8 +750,8 @@ public final class DisplayCutout {
            }
            }
        }
        }
        final CutoutSpecification cutoutSpec = new CutoutSpecification.Parser(
        final CutoutSpecification cutoutSpec = new CutoutSpecification.Parser(
                mCutoutPathParserInfo.getDensity(), mCutoutPathParserInfo.getStableDisplayWidth(),
                mCutoutPathParserInfo.getDensity(), mCutoutPathParserInfo.getPhysicalDisplayWidth(),
                mCutoutPathParserInfo.getStableDisplayHeight(),
                mCutoutPathParserInfo.getPhysicalDisplayHeight(),
                mCutoutPathParserInfo.getPhysicalPixelDisplaySizeRatio())
                mCutoutPathParserInfo.getPhysicalPixelDisplaySizeRatio())
                .parse(mCutoutPathParserInfo.getCutoutSpec());
                .parse(mCutoutPathParserInfo.getCutoutSpec());


@@ -1053,11 +1053,11 @@ public final class DisplayCutout {
     * @hide
     * @hide
     */
     */
    public static DisplayCutout fromResourcesRectApproximation(Resources res,
    public static DisplayCutout fromResourcesRectApproximation(Resources res,
            String displayUniqueId, int stableDisplayWidth, int stableDisplayHeight,
            String displayUniqueId, int physicalDisplayWidth, int physicalDisplayHeight,
            int displayWidth, int displayHeight) {
            int displayWidth, int displayHeight) {
        return pathAndDisplayCutoutFromSpec(getDisplayCutoutPath(res, displayUniqueId),
        return pathAndDisplayCutoutFromSpec(getDisplayCutoutPath(res, displayUniqueId),
                getDisplayCutoutApproximationRect(res, displayUniqueId), stableDisplayWidth,
                getDisplayCutoutApproximationRect(res, displayUniqueId), physicalDisplayWidth,
                stableDisplayHeight, displayWidth, displayHeight,
                physicalDisplayHeight, displayWidth, displayHeight,
                DENSITY_DEVICE_STABLE / (float) DENSITY_DEFAULT,
                DENSITY_DEVICE_STABLE / (float) DENSITY_DEFAULT,
                getWaterfallInsets(res, displayUniqueId)).second;
                getWaterfallInsets(res, displayUniqueId)).second;
    }
    }
@@ -1080,8 +1080,8 @@ public final class DisplayCutout {
     *
     *
     * @param pathSpec the spec string read from config_mainBuiltInDisplayCutout.
     * @param pathSpec the spec string read from config_mainBuiltInDisplayCutout.
     * @param rectSpec the spec string read from config_mainBuiltInDisplayCutoutRectApproximation.
     * @param rectSpec the spec string read from config_mainBuiltInDisplayCutoutRectApproximation.
     * @param stableDisplayWidth the stable display width.
     * @param physicalDisplayWidth the max physical display width the display supports.
     * @param stableDisplayHeight the stable display height.
     * @param physicalDisplayHeight the max physical display height the display supports.
     * @param displayWidth the display width.
     * @param displayWidth the display width.
     * @param displayHeight the display height.
     * @param displayHeight the display height.
     * @param density the display density.
     * @param density the display density.
@@ -1089,7 +1089,7 @@ public final class DisplayCutout {
     * @return a Pair contains the cutout path and the corresponding DisplayCutout instance.
     * @return a Pair contains the cutout path and the corresponding DisplayCutout instance.
     */
     */
    private static Pair<Path, DisplayCutout> pathAndDisplayCutoutFromSpec(
    private static Pair<Path, DisplayCutout> pathAndDisplayCutoutFromSpec(
            String pathSpec, String rectSpec, int stableDisplayWidth, int stableDisplayHeight,
            String pathSpec, String rectSpec, int physicalDisplayWidth, int physicalDisplayHeight,
            int displayWidth, int displayHeight, float density, Insets waterfallInsets) {
            int displayWidth, int displayHeight, float density, Insets waterfallInsets) {
        // Always use the rect approximation spec to create the cutout if it's not null because
        // Always use the rect approximation spec to create the cutout if it's not null because
        // transforming and sending a Region constructed from a path is very costly.
        // transforming and sending a Region constructed from a path is very costly.
@@ -1099,7 +1099,7 @@ public final class DisplayCutout {
        }
        }


        final float physicalPixelDisplaySizeRatio = DisplayUtils.getPhysicalPixelDisplaySizeRatio(
        final float physicalPixelDisplaySizeRatio = DisplayUtils.getPhysicalPixelDisplaySizeRatio(
                stableDisplayWidth, stableDisplayHeight, displayWidth, displayHeight);
                physicalDisplayWidth, physicalDisplayHeight, displayWidth, displayHeight);


        synchronized (CACHE_LOCK) {
        synchronized (CACHE_LOCK) {
            if (spec.equals(sCachedSpec) && sCachedDisplayWidth == displayWidth
            if (spec.equals(sCachedSpec) && sCachedDisplayWidth == displayWidth
@@ -1114,7 +1114,8 @@ public final class DisplayCutout {
        spec = spec.trim();
        spec = spec.trim();


        CutoutSpecification cutoutSpec = new CutoutSpecification.Parser(density,
        CutoutSpecification cutoutSpec = new CutoutSpecification.Parser(density,
                stableDisplayWidth, stableDisplayHeight, physicalPixelDisplaySizeRatio).parse(spec);
                physicalDisplayWidth, physicalDisplayHeight, physicalPixelDisplaySizeRatio)
                .parse(spec);
        Rect safeInset = cutoutSpec.getSafeInset();
        Rect safeInset = cutoutSpec.getSafeInset();
        final Rect boundLeft = cutoutSpec.getLeftBound();
        final Rect boundLeft = cutoutSpec.getLeftBound();
        final Rect boundTop = cutoutSpec.getTopBound();
        final Rect boundTop = cutoutSpec.getTopBound();
@@ -1131,7 +1132,7 @@ public final class DisplayCutout {
        }
        }


        final CutoutPathParserInfo cutoutPathParserInfo = new CutoutPathParserInfo(
        final CutoutPathParserInfo cutoutPathParserInfo = new CutoutPathParserInfo(
                displayWidth, displayHeight, stableDisplayWidth, stableDisplayHeight, density,
                displayWidth, displayHeight, physicalDisplayWidth, physicalDisplayHeight, density,
                pathSpec.trim(), ROTATION_0, 1f /* scale */, physicalPixelDisplaySizeRatio);
                pathSpec.trim(), ROTATION_0, 1f /* scale */, physicalPixelDisplaySizeRatio);


        final DisplayCutout cutout = new DisplayCutout(
        final DisplayCutout cutout = new DisplayCutout(
@@ -1182,9 +1183,9 @@ public final class DisplayCutout {
        Collections.rotate(Arrays.asList(newBounds), -rotation);
        Collections.rotate(Arrays.asList(newBounds), -rotation);
        final CutoutPathParserInfo info = getCutoutPathParserInfo();
        final CutoutPathParserInfo info = getCutoutPathParserInfo();
        final CutoutPathParserInfo newInfo = new CutoutPathParserInfo(
        final CutoutPathParserInfo newInfo = new CutoutPathParserInfo(
                info.getDisplayWidth(), info.getDisplayHeight(), info.getStableDisplayWidth(),
                info.getDisplayWidth(), info.getDisplayHeight(), info.getPhysicalDisplayWidth(),
                info.getStableDisplayHeight(), info.getDensity(), info.getCutoutSpec(), toRotation,
                info.getPhysicalDisplayHeight(), info.getDensity(), info.getCutoutSpec(),
                info.getScale(), info.getPhysicalPixelDisplaySizeRatio());
                toRotation, info.getScale(), info.getPhysicalPixelDisplaySizeRatio());
        final boolean swapAspect = (rotation % 2) != 0;
        final boolean swapAspect = (rotation % 2) != 0;
        final int endWidth = swapAspect ? startHeight : startWidth;
        final int endWidth = swapAspect ? startHeight : startWidth;
        final int endHeight = swapAspect ? startWidth : startHeight;
        final int endHeight = swapAspect ? startWidth : startHeight;
@@ -1284,8 +1285,8 @@ public final class DisplayCutout {
                out.writeTypedObject(cutout.mWaterfallInsets, flags);
                out.writeTypedObject(cutout.mWaterfallInsets, flags);
                out.writeInt(cutout.mCutoutPathParserInfo.getDisplayWidth());
                out.writeInt(cutout.mCutoutPathParserInfo.getDisplayWidth());
                out.writeInt(cutout.mCutoutPathParserInfo.getDisplayHeight());
                out.writeInt(cutout.mCutoutPathParserInfo.getDisplayHeight());
                out.writeInt(cutout.mCutoutPathParserInfo.getStableDisplayWidth());
                out.writeInt(cutout.mCutoutPathParserInfo.getPhysicalDisplayWidth());
                out.writeInt(cutout.mCutoutPathParserInfo.getStableDisplayHeight());
                out.writeInt(cutout.mCutoutPathParserInfo.getPhysicalDisplayHeight());
                out.writeFloat(cutout.mCutoutPathParserInfo.getDensity());
                out.writeFloat(cutout.mCutoutPathParserInfo.getDensity());
                out.writeString(cutout.mCutoutPathParserInfo.getCutoutSpec());
                out.writeString(cutout.mCutoutPathParserInfo.getCutoutSpec());
                out.writeInt(cutout.mCutoutPathParserInfo.getRotation());
                out.writeInt(cutout.mCutoutPathParserInfo.getRotation());
@@ -1336,16 +1337,16 @@ public final class DisplayCutout {
            Insets waterfallInsets = in.readTypedObject(Insets.CREATOR);
            Insets waterfallInsets = in.readTypedObject(Insets.CREATOR);
            int displayWidth = in.readInt();
            int displayWidth = in.readInt();
            int displayHeight = in.readInt();
            int displayHeight = in.readInt();
            int stableDisplayWidth = in.readInt();
            int physicalDisplayWidth = in.readInt();
            int stableDisplayHeight = in.readInt();
            int physicalDisplayHeight = in.readInt();
            float density = in.readFloat();
            float density = in.readFloat();
            String cutoutSpec = in.readString();
            String cutoutSpec = in.readString();
            int rotation = in.readInt();
            int rotation = in.readInt();
            float scale = in.readFloat();
            float scale = in.readFloat();
            float physicalPixelDisplaySizeRatio = in.readFloat();
            float physicalPixelDisplaySizeRatio = in.readFloat();
            final CutoutPathParserInfo info = new CutoutPathParserInfo(
            final CutoutPathParserInfo info = new CutoutPathParserInfo(
                    displayWidth, displayHeight, stableDisplayWidth, stableDisplayHeight, density,
                    displayWidth, displayHeight, physicalDisplayWidth, physicalDisplayHeight,
                    cutoutSpec, rotation, scale, physicalPixelDisplaySizeRatio);
                    density, cutoutSpec, rotation, scale, physicalPixelDisplaySizeRatio);


            return new DisplayCutout(
            return new DisplayCutout(
                    safeInsets, waterfallInsets, bounds, info, false /* copyArguments */);
                    safeInsets, waterfallInsets, bounds, info, false /* copyArguments */);
@@ -1373,8 +1374,8 @@ public final class DisplayCutout {
            final CutoutPathParserInfo info = new CutoutPathParserInfo(
            final CutoutPathParserInfo info = new CutoutPathParserInfo(
                    mInner.mCutoutPathParserInfo.getDisplayWidth(),
                    mInner.mCutoutPathParserInfo.getDisplayWidth(),
                    mInner.mCutoutPathParserInfo.getDisplayHeight(),
                    mInner.mCutoutPathParserInfo.getDisplayHeight(),
                    mInner.mCutoutPathParserInfo.getStableDisplayWidth(),
                    mInner.mCutoutPathParserInfo.getPhysicalDisplayWidth(),
                    mInner.mCutoutPathParserInfo.getStableDisplayHeight(),
                    mInner.mCutoutPathParserInfo.getPhysicalDisplayHeight(),
                    mInner.mCutoutPathParserInfo.getDensity(),
                    mInner.mCutoutPathParserInfo.getDensity(),
                    mInner.mCutoutPathParserInfo.getCutoutSpec(),
                    mInner.mCutoutPathParserInfo.getCutoutSpec(),
                    mInner.mCutoutPathParserInfo.getRotation(),
                    mInner.mCutoutPathParserInfo.getRotation(),
+7 −7
Original line number Original line Diff line number Diff line
@@ -98,10 +98,10 @@ public class RoundedCorners implements Parcelable {
     * @android:dimen/rounded_corner_radius_top and @android:dimen/rounded_corner_radius_bottom
     * @android:dimen/rounded_corner_radius_top and @android:dimen/rounded_corner_radius_bottom
     */
     */
    public static RoundedCorners fromResources(
    public static RoundedCorners fromResources(
            Resources res, String displayUniqueId, int stableDisplayWidth, int stableDisplayHeight,
            Resources res, String displayUniqueId, int physicalDisplayWidth,
            int displayWidth, int displayHeight) {
            int physicalDisplayHeight, int displayWidth, int displayHeight) {
        return fromRadii(loadRoundedCornerRadii(res, displayUniqueId), stableDisplayWidth,
        return fromRadii(loadRoundedCornerRadii(res, displayUniqueId), physicalDisplayWidth,
                stableDisplayHeight, displayWidth, displayHeight);
                physicalDisplayHeight, displayWidth, displayHeight);
    }
    }


    /**
    /**
@@ -113,14 +113,14 @@ public class RoundedCorners implements Parcelable {
        return fromRadii(radii, displayWidth, displayHeight, displayWidth, displayHeight);
        return fromRadii(radii, displayWidth, displayHeight, displayWidth, displayHeight);
    }
    }


    private static RoundedCorners fromRadii(Pair<Integer, Integer> radii, int stableDisplayWidth,
    private static RoundedCorners fromRadii(Pair<Integer, Integer> radii, int physicalDisplayWidth,
            int stableDisplayHeight, int displayWidth, int displayHeight) {
            int physicalDisplayHeight, int displayWidth, int displayHeight) {
        if (radii == null) {
        if (radii == null) {
            return null;
            return null;
        }
        }


        final float physicalPixelDisplaySizeRatio = DisplayUtils.getPhysicalPixelDisplaySizeRatio(
        final float physicalPixelDisplaySizeRatio = DisplayUtils.getPhysicalPixelDisplaySizeRatio(
                stableDisplayWidth, stableDisplayHeight, displayWidth, displayHeight);
                physicalDisplayWidth, physicalDisplayHeight, displayWidth, displayHeight);


        synchronized (CACHE_LOCK) {
        synchronized (CACHE_LOCK) {
            if (radii.equals(sCachedRadii) && sCachedDisplayWidth == displayWidth
            if (radii.equals(sCachedRadii) && sCachedDisplayWidth == displayWidth
+3 −0
Original line number Original line Diff line number Diff line
@@ -3527,6 +3527,9 @@
         appended after the path string to interpret coordinates in dp instead of px units.
         appended after the path string to interpret coordinates in dp instead of px units.
         Note that a physical cutout should be configured in pixels for the best results.
         Note that a physical cutout should be configured in pixels for the best results.


         If the display supports multiple resolutions, please define the path config based on the
         highest resolution so that it can be scaled correctly in each resolution.

         Example for a 10px x 10px square top-center cutout:
         Example for a 10px x 10px square top-center cutout:
                <string ...>M -5,0 L -5,10 L 5,10 L 5,0 Z</string>
                <string ...>M -5,0 L -5,10 L 5,10 L 5,0 Z</string>
         Example for a 10dp x 10dp square top-center cutout:
         Example for a 10dp x 10dp square top-center cutout:
Loading