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

Commit b14ff5b2 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Correct rounding in PipSizeSpecHandler" into udc-qpr-dev am:...

Merge "Merge "Correct rounding in PipSizeSpecHandler" into udc-qpr-dev am: 5bad85f8 am: 04893399" into main
parents 6d4718f3 f7de678c
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -123,18 +123,19 @@ public class PipSizeSpecHandler {
            final int totalVerticalPadding = getInsetBounds().top
                    + (getDisplayBounds().height() - getInsetBounds().bottom);

            final int shorterLength = (int) (1f * Math.min(
                    getDisplayBounds().width() - totalHorizontalPadding,
                    getDisplayBounds().height() - totalVerticalPadding));
            final int shorterLength = Math.min(getDisplayBounds().width() - totalHorizontalPadding,
                    getDisplayBounds().height() - totalVerticalPadding);

            int maxWidth, maxHeight;

            // use the optimized max sizing logic only within a certain aspect ratio range
            if (aspectRatio >= mOptimizedAspectRatio && aspectRatio <= 1 / mOptimizedAspectRatio) {
                // this formula and its derivation is explained in b/198643358#comment16
                maxWidth = (int) (mOptimizedAspectRatio * shorterLength
                maxWidth = Math.round(mOptimizedAspectRatio * shorterLength
                        + shorterLength * (aspectRatio - mOptimizedAspectRatio) / (1
                        + aspectRatio));
                // make sure the max width doesn't go beyond shorter screen length after rounding
                maxWidth = Math.min(maxWidth, shorterLength);
                maxHeight = Math.round(maxWidth / aspectRatio);
            } else {
                if (aspectRatio > 1f) {
+8 −8
Original line number Diff line number Diff line
@@ -110,17 +110,17 @@ public class PipSizeSpecHandlerTest extends ShellTestCase {
        sExpectedDefaultSizes.put(16f / 9, new Size(600, 338));
        sExpectedMinSizes.put(16f / 9, new Size(501, 282));

        sExpectedMaxSizes.put(4f / 3, new Size(892, 669));
        sExpectedDefaultSizes.put(4f / 3, new Size(535, 401));
        sExpectedMaxSizes.put(4f / 3, new Size(893, 670));
        sExpectedDefaultSizes.put(4f / 3, new Size(536, 402));
        sExpectedMinSizes.put(4f / 3, new Size(447, 335));

        sExpectedMaxSizes.put(3f / 4, new Size(669, 892));
        sExpectedDefaultSizes.put(3f / 4, new Size(401, 535));
        sExpectedMaxSizes.put(3f / 4, new Size(670, 893));
        sExpectedDefaultSizes.put(3f / 4, new Size(402, 536));
        sExpectedMinSizes.put(3f / 4, new Size(335, 447));

        sExpectedMaxSizes.put(9f / 16, new Size(562, 999));
        sExpectedDefaultSizes.put(9f / 16, new Size(337, 599));
        sExpectedMinSizes.put(9f / 16, new Size(281, 500));
        sExpectedMaxSizes.put(9f / 16, new Size(563, 1001));
        sExpectedDefaultSizes.put(9f / 16, new Size(338, 601));
        sExpectedMinSizes.put(9f / 16, new Size(282, 501));
    }

    private void forEveryTestCaseCheck(Map<Float, Size> expectedSizes,
@@ -192,7 +192,7 @@ public class PipSizeSpecHandlerTest extends ShellTestCase {
        // an initial size with 16:9 aspect ratio
        Size initSize = new Size(600, 337);

        Size expectedSize = new Size(337, 599);
        Size expectedSize = new Size(338, 601);
        Size actualSize = mPipSizeSpecHandler.getSizeForAspectRatio(initSize, 9f / 16);

        Assert.assertEquals(expectedSize, actualSize);