Loading services/core/java/com/android/server/wm/LetterboxUiController.java +12 −0 Original line number Diff line number Diff line Loading @@ -661,6 +661,10 @@ final class LetterboxUiController { @ScreenOrientation int overrideOrientationIfNeeded(@ScreenOrientation int candidate) { if (shouldApplyUserFullscreenOverride()) { Slog.v(TAG, "Requested orientation " + screenOrientationToString(candidate) + " for " + mActivityRecord + " is overridden to " + screenOrientationToString(SCREEN_ORIENTATION_USER) + " by user aspect ratio settings."); return SCREEN_ORIENTATION_USER; } Loading @@ -668,6 +672,14 @@ final class LetterboxUiController { // orientation. candidate = mActivityRecord.mWmService.mapOrientationRequest(candidate); if (shouldApplyUserMinAspectRatioOverride() && !isFixedOrientation(candidate)) { Slog.v(TAG, "Requested orientation " + screenOrientationToString(candidate) + " for " + mActivityRecord + " is overridden to " + screenOrientationToString(SCREEN_ORIENTATION_PORTRAIT) + " by user aspect ratio settings."); return SCREEN_ORIENTATION_PORTRAIT; } if (FALSE.equals(mBooleanPropertyAllowOrientationOverride)) { return candidate; } Loading services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -811,6 +811,28 @@ public class LetterboxUiControllerTest extends WindowTestsBase { /* candidate */ SCREEN_ORIENTATION_PORTRAIT), SCREEN_ORIENTATION_PORTRAIT); } @Test public void testOverrideOrientationIfNeeded_userAspectRatioApplied_unspecifiedOverridden() { spyOn(mController); doReturn(true).when(mController).shouldApplyUserMinAspectRatioOverride(); assertEquals(mController.overrideOrientationIfNeeded( /* candidate */ SCREEN_ORIENTATION_UNSPECIFIED), SCREEN_ORIENTATION_PORTRAIT); // unchanged if orientation is specified assertEquals(mController.overrideOrientationIfNeeded( /* candidate */ SCREEN_ORIENTATION_LANDSCAPE), SCREEN_ORIENTATION_LANDSCAPE); } @Test public void testOverrideOrientationIfNeeded_userAspectRatioNotApplied_returnsUnchanged() { spyOn(mController); doReturn(false).when(mController).shouldApplyUserMinAspectRatioOverride(); assertEquals(mController.overrideOrientationIfNeeded( /* candidate */ SCREEN_ORIENTATION_UNSPECIFIED), SCREEN_ORIENTATION_UNSPECIFIED); } // shouldApplyUser...Override @Test public void testShouldApplyUserFullscreenOverride_trueProperty_returnsFalse() throws Exception { Loading Loading
services/core/java/com/android/server/wm/LetterboxUiController.java +12 −0 Original line number Diff line number Diff line Loading @@ -661,6 +661,10 @@ final class LetterboxUiController { @ScreenOrientation int overrideOrientationIfNeeded(@ScreenOrientation int candidate) { if (shouldApplyUserFullscreenOverride()) { Slog.v(TAG, "Requested orientation " + screenOrientationToString(candidate) + " for " + mActivityRecord + " is overridden to " + screenOrientationToString(SCREEN_ORIENTATION_USER) + " by user aspect ratio settings."); return SCREEN_ORIENTATION_USER; } Loading @@ -668,6 +672,14 @@ final class LetterboxUiController { // orientation. candidate = mActivityRecord.mWmService.mapOrientationRequest(candidate); if (shouldApplyUserMinAspectRatioOverride() && !isFixedOrientation(candidate)) { Slog.v(TAG, "Requested orientation " + screenOrientationToString(candidate) + " for " + mActivityRecord + " is overridden to " + screenOrientationToString(SCREEN_ORIENTATION_PORTRAIT) + " by user aspect ratio settings."); return SCREEN_ORIENTATION_PORTRAIT; } if (FALSE.equals(mBooleanPropertyAllowOrientationOverride)) { return candidate; } Loading
services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -811,6 +811,28 @@ public class LetterboxUiControllerTest extends WindowTestsBase { /* candidate */ SCREEN_ORIENTATION_PORTRAIT), SCREEN_ORIENTATION_PORTRAIT); } @Test public void testOverrideOrientationIfNeeded_userAspectRatioApplied_unspecifiedOverridden() { spyOn(mController); doReturn(true).when(mController).shouldApplyUserMinAspectRatioOverride(); assertEquals(mController.overrideOrientationIfNeeded( /* candidate */ SCREEN_ORIENTATION_UNSPECIFIED), SCREEN_ORIENTATION_PORTRAIT); // unchanged if orientation is specified assertEquals(mController.overrideOrientationIfNeeded( /* candidate */ SCREEN_ORIENTATION_LANDSCAPE), SCREEN_ORIENTATION_LANDSCAPE); } @Test public void testOverrideOrientationIfNeeded_userAspectRatioNotApplied_returnsUnchanged() { spyOn(mController); doReturn(false).when(mController).shouldApplyUserMinAspectRatioOverride(); assertEquals(mController.overrideOrientationIfNeeded( /* candidate */ SCREEN_ORIENTATION_UNSPECIFIED), SCREEN_ORIENTATION_UNSPECIFIED); } // shouldApplyUser...Override @Test public void testShouldApplyUserFullscreenOverride_trueProperty_returnsFalse() throws Exception { Loading