Loading services/core/java/com/android/server/wm/LetterboxUiController.java +9 −10 Original line number Diff line number Diff line Loading @@ -648,10 +648,9 @@ final class LetterboxUiController { if (mLetterbox != null) { outBounds.set(mLetterbox.getInnerFrame()); final WindowState w = mActivityRecord.findMainWindow(); if (w == null) { return; if (w != null) { adjustBoundsForTaskbar(w, outBounds); } adjustBoundsIfNeeded(w, outBounds); } else { outBounds.setEmpty(); } Loading Loading @@ -1086,7 +1085,12 @@ final class LetterboxUiController { // It is important to call {@link #adjustBoundsIfNeeded} before {@link cropBounds.offsetTo} // because taskbar bounds used in {@link #adjustBoundsIfNeeded} // are in screen coordinates adjustBoundsIfNeeded(mainWindow, cropBounds); adjustBoundsForTaskbar(mainWindow, cropBounds); final float scale = mainWindow.mInvGlobalScale; if (scale != 1f && scale > 0f) { cropBounds.scale(scale); } // ActivityRecord bounds are in screen coordinates while (0,0) for activity's surface // control is in the top left corner of an app window so offsetting bounds Loading Loading @@ -1139,7 +1143,7 @@ final class LetterboxUiController { return null; } private void adjustBoundsIfNeeded(final WindowState mainWindow, final Rect bounds) { private void adjustBoundsForTaskbar(final WindowState mainWindow, final Rect bounds) { // Rounded corners should be displayed above the taskbar. When taskbar is hidden, // an insets frame is equal to a navigation bar which shouldn't affect position of // rounded corners since apps are expected to handle navigation bar inset. Loading @@ -1153,11 +1157,6 @@ final class LetterboxUiController { // Rounded corners should be displayed above the expanded taskbar. bounds.bottom = Math.min(bounds.bottom, expandedTaskbarOrNull.getFrame().top); } final float scale = mainWindow.mInvGlobalScale; if (scale != 1f && scale > 0f) { bounds.scale(scale); } } private int getInsetsStateCornerRadius( Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +59 −0 Original line number Diff line number Diff line Loading @@ -1433,6 +1433,65 @@ public class SizeCompatTests extends WindowTestsBase { activity.getBounds().width(), 0.5); } @Test public void testGetLetterboxInnerBounds_noScalingApplied() { // Set up a display in portrait and ignoring orientation request. final int dw = 1400; final int dh = 2800; setUpDisplaySizeWithApp(dw, dh); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); // Rotate display to landscape. rotateDisplay(mActivity.mDisplayContent, ROTATION_90); // Portrait fixed app without max aspect. prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_LANDSCAPE); // Need a window to call adjustBoundsForTaskbar with. addWindowToActivity(mActivity); // App should launch in fullscreen. assertFalse(mActivity.isLetterboxedForFixedOrientationAndAspectRatio()); assertFalse(mActivity.inSizeCompatMode()); // Activity inherits max bounds from TaskDisplayArea. assertMaxBoundsInheritDisplayAreaBounds(); // Rotate display to portrait. rotateDisplay(mActivity.mDisplayContent, ROTATION_0); final Rect rotatedDisplayBounds = new Rect(mActivity.mDisplayContent.getBounds()); final Rect rotatedActivityBounds = new Rect(mActivity.getBounds()); assertTrue(rotatedDisplayBounds.width() < rotatedDisplayBounds.height()); // App should be in size compat. assertFalse(mActivity.isLetterboxedForFixedOrientationAndAspectRatio()); assertScaled(); assertThat(mActivity.inSizeCompatMode()).isTrue(); assertActivityMaxBoundsSandboxed(); final int scale = dh / dw; // App bounds should be dh / scale x dw / scale assertEquals(dw, rotatedDisplayBounds.width()); assertEquals(dh, rotatedDisplayBounds.height()); assertEquals(dh / scale, rotatedActivityBounds.width()); assertEquals(dw / scale, rotatedActivityBounds.height()); // Compute the frames of the window and invoke {@link ActivityRecord#layoutLetterbox}. mActivity.mRootWindowContainer.performSurfacePlacement(); LetterboxDetails letterboxDetails = mActivity.mLetterboxUiController.getLetterboxDetails(); assertEquals(dh / scale, letterboxDetails.getLetterboxInnerBounds().width()); assertEquals(dw / scale, letterboxDetails.getLetterboxInnerBounds().height()); assertEquals(dw, letterboxDetails.getLetterboxFullBounds().width()); assertEquals(dh, letterboxDetails.getLetterboxFullBounds().height()); } @Test public void testLaunchWithFixedRotationTransform() { final int dw = 1000; Loading Loading
services/core/java/com/android/server/wm/LetterboxUiController.java +9 −10 Original line number Diff line number Diff line Loading @@ -648,10 +648,9 @@ final class LetterboxUiController { if (mLetterbox != null) { outBounds.set(mLetterbox.getInnerFrame()); final WindowState w = mActivityRecord.findMainWindow(); if (w == null) { return; if (w != null) { adjustBoundsForTaskbar(w, outBounds); } adjustBoundsIfNeeded(w, outBounds); } else { outBounds.setEmpty(); } Loading Loading @@ -1086,7 +1085,12 @@ final class LetterboxUiController { // It is important to call {@link #adjustBoundsIfNeeded} before {@link cropBounds.offsetTo} // because taskbar bounds used in {@link #adjustBoundsIfNeeded} // are in screen coordinates adjustBoundsIfNeeded(mainWindow, cropBounds); adjustBoundsForTaskbar(mainWindow, cropBounds); final float scale = mainWindow.mInvGlobalScale; if (scale != 1f && scale > 0f) { cropBounds.scale(scale); } // ActivityRecord bounds are in screen coordinates while (0,0) for activity's surface // control is in the top left corner of an app window so offsetting bounds Loading Loading @@ -1139,7 +1143,7 @@ final class LetterboxUiController { return null; } private void adjustBoundsIfNeeded(final WindowState mainWindow, final Rect bounds) { private void adjustBoundsForTaskbar(final WindowState mainWindow, final Rect bounds) { // Rounded corners should be displayed above the taskbar. When taskbar is hidden, // an insets frame is equal to a navigation bar which shouldn't affect position of // rounded corners since apps are expected to handle navigation bar inset. Loading @@ -1153,11 +1157,6 @@ final class LetterboxUiController { // Rounded corners should be displayed above the expanded taskbar. bounds.bottom = Math.min(bounds.bottom, expandedTaskbarOrNull.getFrame().top); } final float scale = mainWindow.mInvGlobalScale; if (scale != 1f && scale > 0f) { bounds.scale(scale); } } private int getInsetsStateCornerRadius( Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +59 −0 Original line number Diff line number Diff line Loading @@ -1433,6 +1433,65 @@ public class SizeCompatTests extends WindowTestsBase { activity.getBounds().width(), 0.5); } @Test public void testGetLetterboxInnerBounds_noScalingApplied() { // Set up a display in portrait and ignoring orientation request. final int dw = 1400; final int dh = 2800; setUpDisplaySizeWithApp(dw, dh); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); // Rotate display to landscape. rotateDisplay(mActivity.mDisplayContent, ROTATION_90); // Portrait fixed app without max aspect. prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_LANDSCAPE); // Need a window to call adjustBoundsForTaskbar with. addWindowToActivity(mActivity); // App should launch in fullscreen. assertFalse(mActivity.isLetterboxedForFixedOrientationAndAspectRatio()); assertFalse(mActivity.inSizeCompatMode()); // Activity inherits max bounds from TaskDisplayArea. assertMaxBoundsInheritDisplayAreaBounds(); // Rotate display to portrait. rotateDisplay(mActivity.mDisplayContent, ROTATION_0); final Rect rotatedDisplayBounds = new Rect(mActivity.mDisplayContent.getBounds()); final Rect rotatedActivityBounds = new Rect(mActivity.getBounds()); assertTrue(rotatedDisplayBounds.width() < rotatedDisplayBounds.height()); // App should be in size compat. assertFalse(mActivity.isLetterboxedForFixedOrientationAndAspectRatio()); assertScaled(); assertThat(mActivity.inSizeCompatMode()).isTrue(); assertActivityMaxBoundsSandboxed(); final int scale = dh / dw; // App bounds should be dh / scale x dw / scale assertEquals(dw, rotatedDisplayBounds.width()); assertEquals(dh, rotatedDisplayBounds.height()); assertEquals(dh / scale, rotatedActivityBounds.width()); assertEquals(dw / scale, rotatedActivityBounds.height()); // Compute the frames of the window and invoke {@link ActivityRecord#layoutLetterbox}. mActivity.mRootWindowContainer.performSurfacePlacement(); LetterboxDetails letterboxDetails = mActivity.mLetterboxUiController.getLetterboxDetails(); assertEquals(dh / scale, letterboxDetails.getLetterboxInnerBounds().width()); assertEquals(dw / scale, letterboxDetails.getLetterboxInnerBounds().height()); assertEquals(dw, letterboxDetails.getLetterboxFullBounds().width()); assertEquals(dh, letterboxDetails.getLetterboxFullBounds().height()); } @Test public void testLaunchWithFixedRotationTransform() { final int dw = 1000; Loading