Loading services/core/java/com/android/server/wm/ActivityRecord.java +6 −0 Original line number Diff line number Diff line Loading @@ -8185,6 +8185,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * aspect ratio. */ boolean shouldCreateCompatDisplayInsets() { if (mLetterboxUiController.shouldApplyUserFullscreenOverride()) { // If the user has forced the applications aspect ratio to be fullscreen, don't use size // compatibility mode in any situation. The user has been warned and therefore accepts // the risk of the application misbehaving. return false; } switch (supportsSizeChanges()) { case SIZE_CHANGES_SUPPORTED_METADATA: case SIZE_CHANGES_SUPPORTED_OVERRIDE: Loading services/core/java/com/android/server/wm/LetterboxUiController.java +7 −5 Original line number Diff line number Diff line Loading @@ -254,7 +254,9 @@ final class LetterboxUiController { // Counter for ActivityRecord#setRequestedOrientation private int mSetOrientationRequestCounter = 0; // The min aspect ratio override set by user // The min aspect ratio override set by user. Stores the last selected aspect ratio after // {@link #shouldApplyUserFullscreenOverride} or {@link #shouldApplyUserMinAspectRatioOverride} // have been invoked. @PackageManager.UserMinAspectRatio private int mUserAspectRatio = USER_MIN_ASPECT_RATIO_UNSET; Loading Loading @@ -661,7 +663,9 @@ final class LetterboxUiController { @ScreenOrientation int overrideOrientationIfNeeded(@ScreenOrientation int candidate) { if (shouldApplyUserFullscreenOverride()) { if (shouldApplyUserFullscreenOverride() && mActivityRecord.mDisplayContent != null && mActivityRecord.mDisplayContent.getIgnoreOrientationRequest()) { Slog.v(TAG, "Requested orientation " + screenOrientationToString(candidate) + " for " + mActivityRecord + " is overridden to " + screenOrientationToString(SCREEN_ORIENTATION_USER) Loading Loading @@ -1171,9 +1175,7 @@ final class LetterboxUiController { boolean shouldApplyUserFullscreenOverride() { if (FALSE.equals(mBooleanPropertyAllowUserAspectRatioOverride) || FALSE.equals(mBooleanPropertyAllowUserAspectRatioFullscreenOverride) || !mLetterboxConfiguration.isUserAppAspectRatioFullscreenEnabled() || mActivityRecord.mDisplayContent == null || !mActivityRecord.mDisplayContent.getIgnoreOrientationRequest()) { || !mLetterboxConfiguration.isUserAppAspectRatioFullscreenEnabled()) { return false; } Loading services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java +22 −8 Original line number Diff line number Diff line Loading @@ -787,21 +787,43 @@ public class LetterboxUiControllerTest extends WindowTestsBase { public void testOverrideOrientationIfNeeded_userFullscreenOverride_returnsUser() { spyOn(mController); doReturn(true).when(mController).shouldApplyUserFullscreenOverride(); mDisplayContent.setIgnoreOrientationRequest(true); assertEquals(SCREEN_ORIENTATION_USER, mController.overrideOrientationIfNeeded( /* candidate */ SCREEN_ORIENTATION_UNSPECIFIED)); } @Test public void testOverrideOrientationIfNeeded_respectOrientationRequestOverUserFullScreen() { spyOn(mController); doReturn(true).when(mController).shouldApplyUserFullscreenOverride(); mDisplayContent.setIgnoreOrientationRequest(false); assertNotEquals(SCREEN_ORIENTATION_USER, mController.overrideOrientationIfNeeded( /* candidate */ SCREEN_ORIENTATION_UNSPECIFIED)); } @Test @EnableCompatChanges({OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT, OVERRIDE_ANY_ORIENTATION}) public void testOverrideOrientationIfNeeded_userFullScreenOverrideOverSystem_returnsUser() { spyOn(mController); doReturn(true).when(mController).shouldApplyUserFullscreenOverride(); mDisplayContent.setIgnoreOrientationRequest(true); assertEquals(SCREEN_ORIENTATION_USER, mController.overrideOrientationIfNeeded( /* candidate */ SCREEN_ORIENTATION_PORTRAIT)); } @Test @EnableCompatChanges({OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT, OVERRIDE_ANY_ORIENTATION}) public void testOverrideOrientationIfNeeded_respectOrientationReqOverUserFullScreenAndSystem() { spyOn(mController); doReturn(true).when(mController).shouldApplyUserFullscreenOverride(); mDisplayContent.setIgnoreOrientationRequest(false); assertNotEquals(SCREEN_ORIENTATION_USER, mController.overrideOrientationIfNeeded( /* candidate */ SCREEN_ORIENTATION_PORTRAIT)); } @Test public void testOverrideOrientationIfNeeded_userFullScreenOverrideDisabled_returnsUnchanged() { spyOn(mController); Loading Loading @@ -871,14 +893,6 @@ public class LetterboxUiControllerTest extends WindowTestsBase { assertFalse(mController.shouldApplyUserFullscreenOverride()); } @Test public void testShouldApplyUserFullscreenOverride_disabledIgnoreOrientationRequest() { prepareActivityThatShouldApplyUserFullscreenOverride(); mDisplayContent.setIgnoreOrientationRequest(false); assertFalse(mController.shouldApplyUserFullscreenOverride()); } @Test public void testShouldApplyUserFullscreenOverride_returnsTrue() { prepareActivityThatShouldApplyUserFullscreenOverride(); Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +22 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_16_9; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_3_2; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_4_3; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_DISPLAY_SIZE; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_FULLSCREEN; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_SPLIT_SCREEN; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; import static android.content.res.Configuration.ORIENTATION_PORTRAIT; Loading Loading @@ -1300,6 +1301,27 @@ public class SizeCompatTests extends WindowTestsBase { assertTrue(activity.shouldCreateCompatDisplayInsets()); } @Test public void testShouldCreateCompatDisplayUserAspectRatioFullscreenOverride() { setUpDisplaySizeWithApp(1000, 2500); // Make the task root resizable. mActivity.info.resizeMode = RESIZE_MODE_RESIZEABLE; // Create an activity on the same task. final ActivityRecord activity = buildActivityRecord(/* supportsSizeChanges= */false, RESIZE_MODE_UNRESIZEABLE, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Simulate the user selecting the fullscreen user aspect ratio override spyOn(activity.mWmService.mLetterboxConfiguration); spyOn(activity.mLetterboxUiController); doReturn(true).when(activity.mWmService.mLetterboxConfiguration) .isUserAppAspectRatioFullscreenEnabled(); doReturn(USER_MIN_ASPECT_RATIO_FULLSCREEN).when(activity.mLetterboxUiController) .getUserMinAspectRatioOverrideCode(); assertFalse(activity.shouldCreateCompatDisplayInsets()); } @Test @EnableCompatChanges({ActivityInfo.NEVER_SANDBOX_DISPLAY_APIS}) public void testNeverSandboxDisplayApis_configEnabled_sandboxingNotApplied() { Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +6 −0 Original line number Diff line number Diff line Loading @@ -8185,6 +8185,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * aspect ratio. */ boolean shouldCreateCompatDisplayInsets() { if (mLetterboxUiController.shouldApplyUserFullscreenOverride()) { // If the user has forced the applications aspect ratio to be fullscreen, don't use size // compatibility mode in any situation. The user has been warned and therefore accepts // the risk of the application misbehaving. return false; } switch (supportsSizeChanges()) { case SIZE_CHANGES_SUPPORTED_METADATA: case SIZE_CHANGES_SUPPORTED_OVERRIDE: Loading
services/core/java/com/android/server/wm/LetterboxUiController.java +7 −5 Original line number Diff line number Diff line Loading @@ -254,7 +254,9 @@ final class LetterboxUiController { // Counter for ActivityRecord#setRequestedOrientation private int mSetOrientationRequestCounter = 0; // The min aspect ratio override set by user // The min aspect ratio override set by user. Stores the last selected aspect ratio after // {@link #shouldApplyUserFullscreenOverride} or {@link #shouldApplyUserMinAspectRatioOverride} // have been invoked. @PackageManager.UserMinAspectRatio private int mUserAspectRatio = USER_MIN_ASPECT_RATIO_UNSET; Loading Loading @@ -661,7 +663,9 @@ final class LetterboxUiController { @ScreenOrientation int overrideOrientationIfNeeded(@ScreenOrientation int candidate) { if (shouldApplyUserFullscreenOverride()) { if (shouldApplyUserFullscreenOverride() && mActivityRecord.mDisplayContent != null && mActivityRecord.mDisplayContent.getIgnoreOrientationRequest()) { Slog.v(TAG, "Requested orientation " + screenOrientationToString(candidate) + " for " + mActivityRecord + " is overridden to " + screenOrientationToString(SCREEN_ORIENTATION_USER) Loading Loading @@ -1171,9 +1175,7 @@ final class LetterboxUiController { boolean shouldApplyUserFullscreenOverride() { if (FALSE.equals(mBooleanPropertyAllowUserAspectRatioOverride) || FALSE.equals(mBooleanPropertyAllowUserAspectRatioFullscreenOverride) || !mLetterboxConfiguration.isUserAppAspectRatioFullscreenEnabled() || mActivityRecord.mDisplayContent == null || !mActivityRecord.mDisplayContent.getIgnoreOrientationRequest()) { || !mLetterboxConfiguration.isUserAppAspectRatioFullscreenEnabled()) { return false; } Loading
services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java +22 −8 Original line number Diff line number Diff line Loading @@ -787,21 +787,43 @@ public class LetterboxUiControllerTest extends WindowTestsBase { public void testOverrideOrientationIfNeeded_userFullscreenOverride_returnsUser() { spyOn(mController); doReturn(true).when(mController).shouldApplyUserFullscreenOverride(); mDisplayContent.setIgnoreOrientationRequest(true); assertEquals(SCREEN_ORIENTATION_USER, mController.overrideOrientationIfNeeded( /* candidate */ SCREEN_ORIENTATION_UNSPECIFIED)); } @Test public void testOverrideOrientationIfNeeded_respectOrientationRequestOverUserFullScreen() { spyOn(mController); doReturn(true).when(mController).shouldApplyUserFullscreenOverride(); mDisplayContent.setIgnoreOrientationRequest(false); assertNotEquals(SCREEN_ORIENTATION_USER, mController.overrideOrientationIfNeeded( /* candidate */ SCREEN_ORIENTATION_UNSPECIFIED)); } @Test @EnableCompatChanges({OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT, OVERRIDE_ANY_ORIENTATION}) public void testOverrideOrientationIfNeeded_userFullScreenOverrideOverSystem_returnsUser() { spyOn(mController); doReturn(true).when(mController).shouldApplyUserFullscreenOverride(); mDisplayContent.setIgnoreOrientationRequest(true); assertEquals(SCREEN_ORIENTATION_USER, mController.overrideOrientationIfNeeded( /* candidate */ SCREEN_ORIENTATION_PORTRAIT)); } @Test @EnableCompatChanges({OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT, OVERRIDE_ANY_ORIENTATION}) public void testOverrideOrientationIfNeeded_respectOrientationReqOverUserFullScreenAndSystem() { spyOn(mController); doReturn(true).when(mController).shouldApplyUserFullscreenOverride(); mDisplayContent.setIgnoreOrientationRequest(false); assertNotEquals(SCREEN_ORIENTATION_USER, mController.overrideOrientationIfNeeded( /* candidate */ SCREEN_ORIENTATION_PORTRAIT)); } @Test public void testOverrideOrientationIfNeeded_userFullScreenOverrideDisabled_returnsUnchanged() { spyOn(mController); Loading Loading @@ -871,14 +893,6 @@ public class LetterboxUiControllerTest extends WindowTestsBase { assertFalse(mController.shouldApplyUserFullscreenOverride()); } @Test public void testShouldApplyUserFullscreenOverride_disabledIgnoreOrientationRequest() { prepareActivityThatShouldApplyUserFullscreenOverride(); mDisplayContent.setIgnoreOrientationRequest(false); assertFalse(mController.shouldApplyUserFullscreenOverride()); } @Test public void testShouldApplyUserFullscreenOverride_returnsTrue() { prepareActivityThatShouldApplyUserFullscreenOverride(); Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +22 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_16_9; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_3_2; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_4_3; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_DISPLAY_SIZE; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_FULLSCREEN; import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_SPLIT_SCREEN; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; import static android.content.res.Configuration.ORIENTATION_PORTRAIT; Loading Loading @@ -1300,6 +1301,27 @@ public class SizeCompatTests extends WindowTestsBase { assertTrue(activity.shouldCreateCompatDisplayInsets()); } @Test public void testShouldCreateCompatDisplayUserAspectRatioFullscreenOverride() { setUpDisplaySizeWithApp(1000, 2500); // Make the task root resizable. mActivity.info.resizeMode = RESIZE_MODE_RESIZEABLE; // Create an activity on the same task. final ActivityRecord activity = buildActivityRecord(/* supportsSizeChanges= */false, RESIZE_MODE_UNRESIZEABLE, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Simulate the user selecting the fullscreen user aspect ratio override spyOn(activity.mWmService.mLetterboxConfiguration); spyOn(activity.mLetterboxUiController); doReturn(true).when(activity.mWmService.mLetterboxConfiguration) .isUserAppAspectRatioFullscreenEnabled(); doReturn(USER_MIN_ASPECT_RATIO_FULLSCREEN).when(activity.mLetterboxUiController) .getUserMinAspectRatioOverrideCode(); assertFalse(activity.shouldCreateCompatDisplayInsets()); } @Test @EnableCompatChanges({ActivityInfo.NEVER_SANDBOX_DISPLAY_APIS}) public void testNeverSandboxDisplayApis_configEnabled_sandboxingNotApplied() { Loading