diff options
2 files changed, 45 insertions, 11 deletions
diff --git a/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java index b63162ba8090..3ee92bd7f3d0 100644 --- a/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java +++ b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java @@ -238,10 +238,12 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks } buildNavBarContent(); - // If the UI was rebuilt (day/night change) while the keyguard was up we need to - // correctly respect that state. + // If the UI was rebuilt (day/night change or user change) while the keyguard was up we need + // to correctly respect that state. if (mKeyguardStateControllerLazy.get().isShowing()) { mCarNavigationBarController.showAllKeyguardButtons(isDeviceSetupForUser()); + } else { + mCarNavigationBarController.hideAllKeyguardButtons(isDeviceSetupForUser()); } // Upon restarting the Navigation Bar, CarFacetButtonController should immediately apply the diff --git a/packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationBarTest.java b/packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationBarTest.java index c04e47f557f7..f2748b89c95c 100644 --- a/packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationBarTest.java +++ b/packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationBarTest.java @@ -46,8 +46,6 @@ import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import dagger.Lazy; - @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper @SmallTest @@ -68,12 +66,8 @@ public class CarNavigationBarTest extends SysuiTestCase { @Mock private ButtonSelectionStateListener mButtonSelectionStateListener; @Mock - private Lazy<KeyguardStateController> mKeyguardStateControllerLazy; - @Mock private KeyguardStateController mKeyguardStateController; @Mock - private Lazy<NavigationBarController> mNavigationBarControllerLazy; - @Mock private NavigationBarController mNavigationBarController; @Mock private SuperStatusBarViewFactory mSuperStatusBarViewFactory; @@ -89,13 +83,11 @@ public class CarNavigationBarTest extends SysuiTestCase { mCarNavigationBar = new CarNavigationBar(mContext, mCarNavigationBarController, mWindowManager, mDeviceProvisionedController, new CommandQueue(mContext), mAutoHideController, mButtonSelectionStateListener, mHandler, - mKeyguardStateControllerLazy, mNavigationBarControllerLazy, + () -> mKeyguardStateController, () -> mNavigationBarController, mSuperStatusBarViewFactory, mButtonSelectionStateController); StatusBarWindowView statusBarWindowView = (StatusBarWindowView) LayoutInflater.from( mContext).inflate(R.layout.super_status_bar, /* root= */ null); when(mSuperStatusBarViewFactory.getStatusBarWindowView()).thenReturn(statusBarWindowView); - when(mNavigationBarControllerLazy.get()).thenReturn(mNavigationBarController); - when(mKeyguardStateControllerLazy.get()).thenReturn(mKeyguardStateController); when(mKeyguardStateController.isShowing()).thenReturn(false); mDependency.injectMockDependency(WindowManager.class); // Needed to inflate top navigation bar. @@ -119,4 +111,44 @@ public class CarNavigationBarTest extends SysuiTestCase { verify(mButtonSelectionStateListener).onTaskStackChanged(); } + + @Test + public void restartNavBars_newUserNotSetupWithKeyguardShowing_showsKeyguardButtons() { + ArgumentCaptor<CarDeviceProvisionedController.DeviceProvisionedListener> + deviceProvisionedCallbackCaptor = ArgumentCaptor.forClass( + CarDeviceProvisionedController.DeviceProvisionedListener.class); + when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); + mCarNavigationBar.start(); + when(mKeyguardStateController.isShowing()).thenReturn(true); + // switching the currentUserSetup value to force restart the navbars. + when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(false); + verify(mDeviceProvisionedController).addCallback(deviceProvisionedCallbackCaptor.capture()); + + deviceProvisionedCallbackCaptor.getValue().onUserSwitched(); + waitForIdleSync(mHandler); + + verify(mCarNavigationBarController).showAllKeyguardButtons(false); + } + + @Test + public void restartNavbars_newUserIsSetupWithKeyguardHidden_hidesKeyguardButtons() { + ArgumentCaptor<CarDeviceProvisionedController.DeviceProvisionedListener> + deviceProvisionedCallbackCaptor = ArgumentCaptor.forClass( + CarDeviceProvisionedController.DeviceProvisionedListener.class); + when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); + mCarNavigationBar.start(); + when(mKeyguardStateController.isShowing()).thenReturn(true); + // switching the currentUserSetup value to force restart the navbars. + when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(false); + verify(mDeviceProvisionedController).addCallback(deviceProvisionedCallbackCaptor.capture()); + deviceProvisionedCallbackCaptor.getValue().onUserSwitched(); + waitForIdleSync(mHandler); + when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); + when(mKeyguardStateController.isShowing()).thenReturn(false); + + deviceProvisionedCallbackCaptor.getValue().onUserSetupChanged(); + waitForIdleSync(mHandler); + + verify(mCarNavigationBarController).hideAllKeyguardButtons(true); + } } |