From b0838b3ac3150fff30f4bfd4db7c56506287b173 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Thu, 28 Apr 2022 20:23:24 +0000 Subject: [PATCH] [Bouncer] Force bouncer into portrait mode. Force bouncer into portrait mode unless user switcher feature is permitted. The goal here is to force portrait mode for standard phone devices but allow rotation on tablet devices. Bug: 230575196 Test: Test on phone and tablet device Change-Id: I2f74c27206bd9e796d301051be95f6c0cbedb9e9 --- .../NotificationShadeWindowControllerImpl.java | 2 +- .../NotificationShadeWindowControllerImplTest.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java index 01aa2ec9bfe6d..faae4bbbafd02 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java @@ -333,7 +333,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW } private void adjustScreenOrientation(State state) { - if (state.isKeyguardShowingAndNotOccluded() || state.mDozing) { + if (state.mBouncerShowing || state.isKeyguardShowingAndNotOccluded() || state.mDozing) { if (mKeyguardStateController.isKeyguardScreenRotationAllowed()) { mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER; } else { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java index 26199d53a2b4f..c402d2e47cf35 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java @@ -26,6 +26,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; @@ -309,4 +310,17 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase { }); verify(mWindowManager).updateViewLayout(any(), any()); } + + @Test + public void bouncerShowing_OrientationNoSensor() { + mNotificationShadeWindowController.setKeyguardShowing(true); + mNotificationShadeWindowController.setKeyguardOccluded(true); + mNotificationShadeWindowController.setBouncerShowing(true); + when(mKeyguardStateController.isKeyguardScreenRotationAllowed()).thenReturn(false); + mNotificationShadeWindowController.onConfigChanged(new Configuration()); + + verify(mWindowManager, atLeastOnce()).updateViewLayout(any(), mLayoutParameters.capture()); + assertThat(mLayoutParameters.getValue().screenOrientation) + .isEqualTo(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); + } }