Loading services/core/java/com/android/server/wm/Task.java +17 −3 Original line number Diff line number Diff line Loading @@ -2921,13 +2921,27 @@ class Task extends WindowContainer<WindowContainer> { final int parentWidth = parentBounds.width(); final int parentHeight = parentBounds.height(); final float aspect = ((float) parentHeight) / parentWidth; float aspect = Math.max(parentWidth, parentHeight) / (float) Math.min(parentWidth, parentHeight); // Adjust the Task letterbox bounds to fit the app request aspect ratio in order to use the // extra available space. if (refActivity != null) { final float maxAspectRatio = refActivity.info.maxAspectRatio; final float minAspectRatio = refActivity.info.minAspectRatio; if (aspect > maxAspectRatio && maxAspectRatio != 0) { aspect = maxAspectRatio; } else if (aspect < minAspectRatio) { aspect = minAspectRatio; } } if (forcedOrientation == ORIENTATION_LANDSCAPE) { final int height = (int) (parentWidth / aspect); final int height = (int) Math.rint(parentWidth / aspect); final int top = parentBounds.centerY() - height / 2; outBounds.set(parentBounds.left, top, parentBounds.right, top + height); } else { final int width = (int) (parentHeight * aspect); final int width = (int) Math.rint(parentHeight / aspect); final int left = parentBounds.centerX() - width / 2; outBounds.set(left, parentBounds.top, left + width, parentBounds.bottom); } Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +4 −6 Original line number Diff line number Diff line Loading @@ -750,17 +750,15 @@ public class SizeCompatTests extends WindowTestsBase { final Rect taskBounds = mTask.getBounds(); final Rect newActivityBounds = newActivity.getBounds(); // Task bounds should be 700x1400 with the ratio as the display. // Task bounds should be (1400 / 1.3 = 1076)x1400 with the app requested ratio. assertTrue(mTask.isTaskLetterboxed()); assertEquals(displayBounds.height(), taskBounds.height()); assertEquals(displayBounds.height() * displayBounds.height() / displayBounds.width(), assertEquals((long) Math.rint(taskBounds.height() / newActivity.info.maxAspectRatio), taskBounds.width()); // App bounds should be 700x(710 x 1.3 = 910) // App bounds should be fullscreen in Task bounds. assertFalse(newActivity.inSizeCompatMode()); assertEquals(taskBounds.width(), newActivityBounds.width()); assertEquals((long) Math.rint(taskBounds.width() * newActivity.info.maxAspectRatio), newActivityBounds.height()); assertEquals(taskBounds, newActivityBounds); } private static WindowState addWindowToActivity(ActivityRecord activity) { Loading Loading
services/core/java/com/android/server/wm/Task.java +17 −3 Original line number Diff line number Diff line Loading @@ -2921,13 +2921,27 @@ class Task extends WindowContainer<WindowContainer> { final int parentWidth = parentBounds.width(); final int parentHeight = parentBounds.height(); final float aspect = ((float) parentHeight) / parentWidth; float aspect = Math.max(parentWidth, parentHeight) / (float) Math.min(parentWidth, parentHeight); // Adjust the Task letterbox bounds to fit the app request aspect ratio in order to use the // extra available space. if (refActivity != null) { final float maxAspectRatio = refActivity.info.maxAspectRatio; final float minAspectRatio = refActivity.info.minAspectRatio; if (aspect > maxAspectRatio && maxAspectRatio != 0) { aspect = maxAspectRatio; } else if (aspect < minAspectRatio) { aspect = minAspectRatio; } } if (forcedOrientation == ORIENTATION_LANDSCAPE) { final int height = (int) (parentWidth / aspect); final int height = (int) Math.rint(parentWidth / aspect); final int top = parentBounds.centerY() - height / 2; outBounds.set(parentBounds.left, top, parentBounds.right, top + height); } else { final int width = (int) (parentHeight * aspect); final int width = (int) Math.rint(parentHeight / aspect); final int left = parentBounds.centerX() - width / 2; outBounds.set(left, parentBounds.top, left + width, parentBounds.bottom); } Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +4 −6 Original line number Diff line number Diff line Loading @@ -750,17 +750,15 @@ public class SizeCompatTests extends WindowTestsBase { final Rect taskBounds = mTask.getBounds(); final Rect newActivityBounds = newActivity.getBounds(); // Task bounds should be 700x1400 with the ratio as the display. // Task bounds should be (1400 / 1.3 = 1076)x1400 with the app requested ratio. assertTrue(mTask.isTaskLetterboxed()); assertEquals(displayBounds.height(), taskBounds.height()); assertEquals(displayBounds.height() * displayBounds.height() / displayBounds.width(), assertEquals((long) Math.rint(taskBounds.height() / newActivity.info.maxAspectRatio), taskBounds.width()); // App bounds should be 700x(710 x 1.3 = 910) // App bounds should be fullscreen in Task bounds. assertFalse(newActivity.inSizeCompatMode()); assertEquals(taskBounds.width(), newActivityBounds.width()); assertEquals((long) Math.rint(taskBounds.width() * newActivity.info.maxAspectRatio), newActivityBounds.height()); assertEquals(taskBounds, newActivityBounds); } private static WindowState addWindowToActivity(ActivityRecord activity) { Loading