Loading services/core/java/com/android/server/wm/ActivityRecord.java +3 −1 Original line number Diff line number Diff line Loading @@ -8519,7 +8519,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } // If activity in fullscreen mode is letterboxed because of fixed orientation then bounds // are already calculated in resolveFixedOrientationConfiguration. } else if (!isLetterboxedForFixedOrientationAndAspectRatio()) { // Don't apply aspect ratio if app is overridden to fullscreen by device user/manufacturer. } else if (!isLetterboxedForFixedOrientationAndAspectRatio() && !mLetterboxUiController.hasFullscreenOverride()) { resolveAspectRatioRestriction(newParentConfiguration); } Loading services/core/java/com/android/server/wm/LetterboxUiController.java +4 −0 Original line number Diff line number Diff line Loading @@ -1216,6 +1216,10 @@ final class LetterboxUiController { || mUserAspectRatio == USER_MIN_ASPECT_RATIO_FULLSCREEN); } boolean hasFullscreenOverride() { return isSystemOverrideToFullscreenEnabled() || shouldApplyUserFullscreenOverride(); } float getUserMinAspectRatio() { switch (mUserAspectRatio) { case USER_MIN_ASPECT_RATIO_DISPLAY_SIZE: Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +86 −0 Original line number Diff line number Diff line Loading @@ -2325,6 +2325,92 @@ public class SizeCompatTests extends WindowTestsBase { assertFitted(); } @Test public void testUserOverrideFullscreenForLandscapeDisplay() { final int displayWidth = 1600; final int displayHeight = 1400; setUpDisplaySizeWithApp(displayWidth, displayHeight); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); spyOn(mActivity.mWmService.mLetterboxConfiguration); doReturn(true).when(mActivity.mWmService.mLetterboxConfiguration) .isUserAppAspectRatioFullscreenEnabled(); // Set user aspect ratio override spyOn(mActivity.mLetterboxUiController); doReturn(USER_MIN_ASPECT_RATIO_FULLSCREEN).when(mActivity.mLetterboxUiController) .getUserMinAspectRatioOverrideCode(); prepareMinAspectRatio(mActivity, 16 / 9f, SCREEN_ORIENTATION_PORTRAIT); final Rect bounds = mActivity.getBounds(); // bounds should be fullscreen assertEquals(displayHeight, bounds.height()); assertEquals(displayWidth, bounds.width()); } @Test public void testUserOverrideFullscreenForPortraitDisplay() { final int displayWidth = 1400; final int displayHeight = 1600; setUpDisplaySizeWithApp(displayWidth, displayHeight); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); spyOn(mActivity.mWmService.mLetterboxConfiguration); doReturn(true).when(mActivity.mWmService.mLetterboxConfiguration) .isUserAppAspectRatioFullscreenEnabled(); // Set user aspect ratio override spyOn(mActivity.mLetterboxUiController); doReturn(USER_MIN_ASPECT_RATIO_FULLSCREEN).when(mActivity.mLetterboxUiController) .getUserMinAspectRatioOverrideCode(); prepareMinAspectRatio(mActivity, 16 / 9f, SCREEN_ORIENTATION_LANDSCAPE); final Rect bounds = mActivity.getBounds(); // bounds should be fullscreen assertEquals(displayHeight, bounds.height()); assertEquals(displayWidth, bounds.width()); } @Test public void testSystemFullscreenOverrideForLandscapeDisplay() { final int displayWidth = 1600; final int displayHeight = 1400; setUpDisplaySizeWithApp(displayWidth, displayHeight); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); spyOn(mActivity.mLetterboxUiController); doReturn(true).when(mActivity.mLetterboxUiController) .isSystemOverrideToFullscreenEnabled(); prepareMinAspectRatio(mActivity, 16 / 9f, SCREEN_ORIENTATION_PORTRAIT); final Rect bounds = mActivity.getBounds(); // bounds should be fullscreen assertEquals(displayHeight, bounds.height()); assertEquals(displayWidth, bounds.width()); } @Test public void testSystemFullscreenOverrideForPortraitDisplay() { final int displayWidth = 1400; final int displayHeight = 1600; setUpDisplaySizeWithApp(displayWidth, displayHeight); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); spyOn(mActivity.mLetterboxUiController); doReturn(true).when(mActivity.mLetterboxUiController) .isSystemOverrideToFullscreenEnabled(); prepareMinAspectRatio(mActivity, 16 / 9f, SCREEN_ORIENTATION_LANDSCAPE); final Rect bounds = mActivity.getBounds(); // bounds should be fullscreen assertEquals(displayHeight, bounds.height()); assertEquals(displayWidth, bounds.width()); } @Test public void testUserOverrideSplitScreenAspectRatioForLandscapeDisplay() { final int displayWidth = 1600; Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +3 −1 Original line number Diff line number Diff line Loading @@ -8519,7 +8519,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } // If activity in fullscreen mode is letterboxed because of fixed orientation then bounds // are already calculated in resolveFixedOrientationConfiguration. } else if (!isLetterboxedForFixedOrientationAndAspectRatio()) { // Don't apply aspect ratio if app is overridden to fullscreen by device user/manufacturer. } else if (!isLetterboxedForFixedOrientationAndAspectRatio() && !mLetterboxUiController.hasFullscreenOverride()) { resolveAspectRatioRestriction(newParentConfiguration); } Loading
services/core/java/com/android/server/wm/LetterboxUiController.java +4 −0 Original line number Diff line number Diff line Loading @@ -1216,6 +1216,10 @@ final class LetterboxUiController { || mUserAspectRatio == USER_MIN_ASPECT_RATIO_FULLSCREEN); } boolean hasFullscreenOverride() { return isSystemOverrideToFullscreenEnabled() || shouldApplyUserFullscreenOverride(); } float getUserMinAspectRatio() { switch (mUserAspectRatio) { case USER_MIN_ASPECT_RATIO_DISPLAY_SIZE: Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +86 −0 Original line number Diff line number Diff line Loading @@ -2325,6 +2325,92 @@ public class SizeCompatTests extends WindowTestsBase { assertFitted(); } @Test public void testUserOverrideFullscreenForLandscapeDisplay() { final int displayWidth = 1600; final int displayHeight = 1400; setUpDisplaySizeWithApp(displayWidth, displayHeight); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); spyOn(mActivity.mWmService.mLetterboxConfiguration); doReturn(true).when(mActivity.mWmService.mLetterboxConfiguration) .isUserAppAspectRatioFullscreenEnabled(); // Set user aspect ratio override spyOn(mActivity.mLetterboxUiController); doReturn(USER_MIN_ASPECT_RATIO_FULLSCREEN).when(mActivity.mLetterboxUiController) .getUserMinAspectRatioOverrideCode(); prepareMinAspectRatio(mActivity, 16 / 9f, SCREEN_ORIENTATION_PORTRAIT); final Rect bounds = mActivity.getBounds(); // bounds should be fullscreen assertEquals(displayHeight, bounds.height()); assertEquals(displayWidth, bounds.width()); } @Test public void testUserOverrideFullscreenForPortraitDisplay() { final int displayWidth = 1400; final int displayHeight = 1600; setUpDisplaySizeWithApp(displayWidth, displayHeight); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); spyOn(mActivity.mWmService.mLetterboxConfiguration); doReturn(true).when(mActivity.mWmService.mLetterboxConfiguration) .isUserAppAspectRatioFullscreenEnabled(); // Set user aspect ratio override spyOn(mActivity.mLetterboxUiController); doReturn(USER_MIN_ASPECT_RATIO_FULLSCREEN).when(mActivity.mLetterboxUiController) .getUserMinAspectRatioOverrideCode(); prepareMinAspectRatio(mActivity, 16 / 9f, SCREEN_ORIENTATION_LANDSCAPE); final Rect bounds = mActivity.getBounds(); // bounds should be fullscreen assertEquals(displayHeight, bounds.height()); assertEquals(displayWidth, bounds.width()); } @Test public void testSystemFullscreenOverrideForLandscapeDisplay() { final int displayWidth = 1600; final int displayHeight = 1400; setUpDisplaySizeWithApp(displayWidth, displayHeight); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); spyOn(mActivity.mLetterboxUiController); doReturn(true).when(mActivity.mLetterboxUiController) .isSystemOverrideToFullscreenEnabled(); prepareMinAspectRatio(mActivity, 16 / 9f, SCREEN_ORIENTATION_PORTRAIT); final Rect bounds = mActivity.getBounds(); // bounds should be fullscreen assertEquals(displayHeight, bounds.height()); assertEquals(displayWidth, bounds.width()); } @Test public void testSystemFullscreenOverrideForPortraitDisplay() { final int displayWidth = 1400; final int displayHeight = 1600; setUpDisplaySizeWithApp(displayWidth, displayHeight); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); spyOn(mActivity.mLetterboxUiController); doReturn(true).when(mActivity.mLetterboxUiController) .isSystemOverrideToFullscreenEnabled(); prepareMinAspectRatio(mActivity, 16 / 9f, SCREEN_ORIENTATION_LANDSCAPE); final Rect bounds = mActivity.getBounds(); // bounds should be fullscreen assertEquals(displayHeight, bounds.height()); assertEquals(displayWidth, bounds.width()); } @Test public void testUserOverrideSplitScreenAspectRatioForLandscapeDisplay() { final int displayWidth = 1600; Loading