Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java +5 −4 Original line number Diff line number Diff line Loading @@ -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) { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipSizeSpecHandlerTest.java +8 −8 Original line number Diff line number Diff line Loading @@ -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, Loading Loading @@ -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); Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java +5 −4 Original line number Diff line number Diff line Loading @@ -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) { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipSizeSpecHandlerTest.java +8 −8 Original line number Diff line number Diff line Loading @@ -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, Loading Loading @@ -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); Loading