diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java index 567ddb680848c..2e4a929ded5b8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java @@ -279,7 +279,7 @@ public class NotificationShadeWindowController implements Callback, Dumpable, } else if (state.isKeyguardShowingAndNotOccluded() || panelFocusable) { mLpChanged.flags &= ~LayoutParams.FLAG_NOT_FOCUSABLE; // Make sure to remove FLAG_ALT_FOCUSABLE_IM when keyguard needs input. - if (state.mKeyguardNeedsInput) { + if (state.mKeyguardNeedsInput && state.isKeyguardShowingAndNotOccluded()) { mLpChanged.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM; } else { mLpChanged.flags |= LayoutParams.FLAG_ALT_FOCUSABLE_IM; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java index 5320ecd46d62c..ca6c16f91ad80 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerTest.java @@ -16,11 +16,15 @@ package com.android.systemui.statusbar.phone; +import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; +import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; + 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.clearInvocations; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -44,6 +48,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; +import org.mockito.Captor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -62,6 +67,7 @@ public class NotificationShadeWindowControllerTest extends SysuiTestCase { @Mock private SysuiColorExtractor mColorExtractor; @Mock ColorExtractor.GradientColors mGradientColors; @Mock private DumpManager mDumpManager; + @Captor private ArgumentCaptor mLayoutParameters; private NotificationShadeWindowController mNotificationShadeWindowController; @@ -121,4 +127,46 @@ public class NotificationShadeWindowControllerTest extends SysuiTestCase { mNotificationShadeWindowController.setBackgroundBlurRadius(0); verify(mNotificationShadeWindowView).setVisibility(eq(View.INVISIBLE)); } + + @Test + public void setBouncerShowing_isFocusable_whenNeedsInput() { + mNotificationShadeWindowController.setKeyguardNeedsInput(true); + clearInvocations(mWindowManager); + mNotificationShadeWindowController.setBouncerShowing(true); + + verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture()); + assertThat((mLayoutParameters.getValue().flags & FLAG_NOT_FOCUSABLE) == 0).isTrue(); + assertThat((mLayoutParameters.getValue().flags & FLAG_ALT_FOCUSABLE_IM) == 0).isTrue(); + } + + @Test + public void setKeyguardShowing_focusable_notAltFocusable_whenNeedsInput() { + mNotificationShadeWindowController.setKeyguardShowing(true); + clearInvocations(mWindowManager); + mNotificationShadeWindowController.setKeyguardNeedsInput(true); + + verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture()); + assertThat((mLayoutParameters.getValue().flags & FLAG_NOT_FOCUSABLE) == 0).isTrue(); + assertThat((mLayoutParameters.getValue().flags & FLAG_ALT_FOCUSABLE_IM) == 0).isTrue(); + } + + @Test + public void setPanelExpanded_notFocusable_altFocusable_whenPanelIsOpen() { + mNotificationShadeWindowController.setPanelExpanded(true); + clearInvocations(mWindowManager); + mNotificationShadeWindowController.setNotificationShadeFocusable(true); + + verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture()); + assertThat((mLayoutParameters.getValue().flags & FLAG_NOT_FOCUSABLE) == 0).isTrue(); + assertThat((mLayoutParameters.getValue().flags & FLAG_ALT_FOCUSABLE_IM) != 0).isTrue(); + } + + @Test + public void setKeyguardShowing_notFocusable_byDefault() { + mNotificationShadeWindowController.setKeyguardShowing(false); + + verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture()); + assertThat((mLayoutParameters.getValue().flags & FLAG_NOT_FOCUSABLE) != 0).isTrue(); + assertThat((mLayoutParameters.getValue().flags & FLAG_ALT_FOCUSABLE_IM) == 0).isTrue(); + } }