summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2022-02-23 17:00:56 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-02-23 17:00:56 +0000
commitaa6d81514c98a849b99400e85ba5c17a8d96b435 (patch)
tree40b1b94591a443267b60bddd5171fe4baf7bb693
parent11c572a2487c23eeced3c24792b6512e7eefa892 (diff)
parent9f017c7fdf5002498509056961ffdf4ec9fd4834 (diff)
Merge "Apply new keyguard orientation when it becomes non-rotatable" into tm-dev
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java15
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java32
2 files changed, 46 insertions, 1 deletions
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 9f9e7d9a276e..5caf4f604fcd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java
@@ -26,6 +26,7 @@ import static com.android.systemui.statusbar.NotificationRemoteInputManager.ENAB
import android.app.IActivityManager;
import android.content.Context;
import android.content.pm.ActivityInfo;
+import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Region;
import android.os.Binder;
@@ -117,6 +118,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
* @see #batchApplyWindowLayoutParams(Runnable)
*/
private int mDeferWindowLayoutParams;
+ private boolean mLastKeyguardRotationAllowed;
@Inject
public NotificationShadeWindowControllerImpl(Context context, WindowManager windowManager,
@@ -143,7 +145,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
mScreenOffAnimationController = screenOffAnimationController;
dumpManager.registerDumpable(getClass().getName(), this);
mAuthController = authController;
-
+ mLastKeyguardRotationAllowed = mKeyguardStateController.isKeyguardScreenRotationAllowed();
mLockScreenDisplayTimeout = context.getResources()
.getInteger(R.integer.config_lockScreenDisplayTimeout);
((SysuiStatusBarStateController) statusBarStateController)
@@ -779,6 +781,17 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
setKeyguardDark(useDarkText);
}
+ @Override
+ public void onConfigChanged(Configuration newConfig) {
+ final boolean newScreenRotationAllowed = mKeyguardStateController
+ .isKeyguardScreenRotationAllowed();
+
+ if (mLastKeyguardRotationAllowed != newScreenRotationAllowed) {
+ apply(mCurrentState);
+ mLastKeyguardRotationAllowed = newScreenRotationAllowed;
+ }
+ }
+
/**
* When keyguard will be dismissed but didn't start animation yet.
*/
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 671ab597eb2a..c797bc8bdf60 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
@@ -32,6 +32,8 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.IActivityManager;
+import android.content.pm.ActivityInfo;
+import android.content.res.Configuration;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
import android.view.View;
@@ -228,6 +230,36 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
}
@Test
+ public void rotationBecameAllowed_layoutParamsUpdated() {
+ mNotificationShadeWindowController.setKeyguardShowing(true);
+ when(mKeyguardStateController.isKeyguardScreenRotationAllowed()).thenReturn(false);
+ mNotificationShadeWindowController.onConfigChanged(new Configuration());
+ clearInvocations(mWindowManager);
+
+ when(mKeyguardStateController.isKeyguardScreenRotationAllowed()).thenReturn(true);
+ mNotificationShadeWindowController.onConfigChanged(new Configuration());
+
+ verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
+ assertThat(mLayoutParameters.getValue().screenOrientation)
+ .isEqualTo(ActivityInfo.SCREEN_ORIENTATION_USER);
+ }
+
+ @Test
+ public void rotationBecameNotAllowed_layoutParamsUpdated() {
+ mNotificationShadeWindowController.setKeyguardShowing(true);
+ when(mKeyguardStateController.isKeyguardScreenRotationAllowed()).thenReturn(true);
+ mNotificationShadeWindowController.onConfigChanged(new Configuration());
+ clearInvocations(mWindowManager);
+
+ when(mKeyguardStateController.isKeyguardScreenRotationAllowed()).thenReturn(false);
+ mNotificationShadeWindowController.onConfigChanged(new Configuration());
+
+ verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
+ assertThat(mLayoutParameters.getValue().screenOrientation)
+ .isEqualTo(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
+ }
+
+ @Test
public void batchApplyWindowLayoutParams_doesNotDispatchEvents() {
mNotificationShadeWindowController.setForceDozeBrightness(true);
verify(mWindowManager).updateViewLayout(any(), any());