Loading packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java +4 −2 Original line number Original line Diff line number Diff line Loading @@ -238,10 +238,12 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks } } buildNavBarContent(); buildNavBarContent(); // If the UI was rebuilt (day/night change) while the keyguard was up we need to // If the UI was rebuilt (day/night change or user change) while the keyguard was up we need // correctly respect that state. // to correctly respect that state. if (mKeyguardStateControllerLazy.get().isShowing()) { if (mKeyguardStateControllerLazy.get().isShowing()) { mCarNavigationBarController.showAllKeyguardButtons(isDeviceSetupForUser()); mCarNavigationBarController.showAllKeyguardButtons(isDeviceSetupForUser()); } else { mCarNavigationBarController.hideAllKeyguardButtons(isDeviceSetupForUser()); } } // Upon restarting the Navigation Bar, CarFacetButtonController should immediately apply the // Upon restarting the Navigation Bar, CarFacetButtonController should immediately apply the Loading packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationBarTest.java +41 −9 Original line number Original line Diff line number Diff line Loading @@ -46,8 +46,6 @@ import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations; import dagger.Lazy; @RunWith(AndroidTestingRunner.class) @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper @TestableLooper.RunWithLooper @SmallTest @SmallTest Loading @@ -68,12 +66,8 @@ public class CarNavigationBarTest extends SysuiTestCase { @Mock @Mock private ButtonSelectionStateListener mButtonSelectionStateListener; private ButtonSelectionStateListener mButtonSelectionStateListener; @Mock @Mock private Lazy<KeyguardStateController> mKeyguardStateControllerLazy; @Mock private KeyguardStateController mKeyguardStateController; private KeyguardStateController mKeyguardStateController; @Mock @Mock private Lazy<NavigationBarController> mNavigationBarControllerLazy; @Mock private NavigationBarController mNavigationBarController; private NavigationBarController mNavigationBarController; @Mock @Mock private SuperStatusBarViewFactory mSuperStatusBarViewFactory; private SuperStatusBarViewFactory mSuperStatusBarViewFactory; Loading @@ -89,13 +83,11 @@ public class CarNavigationBarTest extends SysuiTestCase { mCarNavigationBar = new CarNavigationBar(mContext, mCarNavigationBarController, mCarNavigationBar = new CarNavigationBar(mContext, mCarNavigationBarController, mWindowManager, mDeviceProvisionedController, new CommandQueue(mContext), mWindowManager, mDeviceProvisionedController, new CommandQueue(mContext), mAutoHideController, mButtonSelectionStateListener, mHandler, mAutoHideController, mButtonSelectionStateListener, mHandler, mKeyguardStateControllerLazy, mNavigationBarControllerLazy, () -> mKeyguardStateController, () -> mNavigationBarController, mSuperStatusBarViewFactory, mButtonSelectionStateController); mSuperStatusBarViewFactory, mButtonSelectionStateController); StatusBarWindowView statusBarWindowView = (StatusBarWindowView) LayoutInflater.from( StatusBarWindowView statusBarWindowView = (StatusBarWindowView) LayoutInflater.from( mContext).inflate(R.layout.super_status_bar, /* root= */ null); mContext).inflate(R.layout.super_status_bar, /* root= */ null); when(mSuperStatusBarViewFactory.getStatusBarWindowView()).thenReturn(statusBarWindowView); when(mSuperStatusBarViewFactory.getStatusBarWindowView()).thenReturn(statusBarWindowView); when(mNavigationBarControllerLazy.get()).thenReturn(mNavigationBarController); when(mKeyguardStateControllerLazy.get()).thenReturn(mKeyguardStateController); when(mKeyguardStateController.isShowing()).thenReturn(false); when(mKeyguardStateController.isShowing()).thenReturn(false); mDependency.injectMockDependency(WindowManager.class); mDependency.injectMockDependency(WindowManager.class); // Needed to inflate top navigation bar. // Needed to inflate top navigation bar. Loading @@ -119,4 +111,44 @@ public class CarNavigationBarTest extends SysuiTestCase { verify(mButtonSelectionStateListener).onTaskStackChanged(); 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); } } } Loading
packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java +4 −2 Original line number Original line Diff line number Diff line Loading @@ -238,10 +238,12 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks } } buildNavBarContent(); buildNavBarContent(); // If the UI was rebuilt (day/night change) while the keyguard was up we need to // If the UI was rebuilt (day/night change or user change) while the keyguard was up we need // correctly respect that state. // to correctly respect that state. if (mKeyguardStateControllerLazy.get().isShowing()) { if (mKeyguardStateControllerLazy.get().isShowing()) { mCarNavigationBarController.showAllKeyguardButtons(isDeviceSetupForUser()); mCarNavigationBarController.showAllKeyguardButtons(isDeviceSetupForUser()); } else { mCarNavigationBarController.hideAllKeyguardButtons(isDeviceSetupForUser()); } } // Upon restarting the Navigation Bar, CarFacetButtonController should immediately apply the // Upon restarting the Navigation Bar, CarFacetButtonController should immediately apply the Loading
packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationBarTest.java +41 −9 Original line number Original line Diff line number Diff line Loading @@ -46,8 +46,6 @@ import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations; import dagger.Lazy; @RunWith(AndroidTestingRunner.class) @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper @TestableLooper.RunWithLooper @SmallTest @SmallTest Loading @@ -68,12 +66,8 @@ public class CarNavigationBarTest extends SysuiTestCase { @Mock @Mock private ButtonSelectionStateListener mButtonSelectionStateListener; private ButtonSelectionStateListener mButtonSelectionStateListener; @Mock @Mock private Lazy<KeyguardStateController> mKeyguardStateControllerLazy; @Mock private KeyguardStateController mKeyguardStateController; private KeyguardStateController mKeyguardStateController; @Mock @Mock private Lazy<NavigationBarController> mNavigationBarControllerLazy; @Mock private NavigationBarController mNavigationBarController; private NavigationBarController mNavigationBarController; @Mock @Mock private SuperStatusBarViewFactory mSuperStatusBarViewFactory; private SuperStatusBarViewFactory mSuperStatusBarViewFactory; Loading @@ -89,13 +83,11 @@ public class CarNavigationBarTest extends SysuiTestCase { mCarNavigationBar = new CarNavigationBar(mContext, mCarNavigationBarController, mCarNavigationBar = new CarNavigationBar(mContext, mCarNavigationBarController, mWindowManager, mDeviceProvisionedController, new CommandQueue(mContext), mWindowManager, mDeviceProvisionedController, new CommandQueue(mContext), mAutoHideController, mButtonSelectionStateListener, mHandler, mAutoHideController, mButtonSelectionStateListener, mHandler, mKeyguardStateControllerLazy, mNavigationBarControllerLazy, () -> mKeyguardStateController, () -> mNavigationBarController, mSuperStatusBarViewFactory, mButtonSelectionStateController); mSuperStatusBarViewFactory, mButtonSelectionStateController); StatusBarWindowView statusBarWindowView = (StatusBarWindowView) LayoutInflater.from( StatusBarWindowView statusBarWindowView = (StatusBarWindowView) LayoutInflater.from( mContext).inflate(R.layout.super_status_bar, /* root= */ null); mContext).inflate(R.layout.super_status_bar, /* root= */ null); when(mSuperStatusBarViewFactory.getStatusBarWindowView()).thenReturn(statusBarWindowView); when(mSuperStatusBarViewFactory.getStatusBarWindowView()).thenReturn(statusBarWindowView); when(mNavigationBarControllerLazy.get()).thenReturn(mNavigationBarController); when(mKeyguardStateControllerLazy.get()).thenReturn(mKeyguardStateController); when(mKeyguardStateController.isShowing()).thenReturn(false); when(mKeyguardStateController.isShowing()).thenReturn(false); mDependency.injectMockDependency(WindowManager.class); mDependency.injectMockDependency(WindowManager.class); // Needed to inflate top navigation bar. // Needed to inflate top navigation bar. Loading @@ -119,4 +111,44 @@ public class CarNavigationBarTest extends SysuiTestCase { verify(mButtonSelectionStateListener).onTaskStackChanged(); 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); } } }