From 4acb971f6c3c02ae526fe8c38e964b029fcb5c05 Mon Sep 17 00:00:00 2001 From: Heemin Seog Date: Tue, 21 Apr 2020 11:26:43 -0700 Subject: [PATCH] Remove CarStatusBar reference from HUNs container Bug: 154357193 Test: manual, atest CarHeadsUpNotificationSystemContainerTest Change-Id: I9cdf393eab5dc5b4d6ba5448e0a2c2316ef7a191 --- .../CarHeadsUpNotificationSystemContainer.java | 16 +++++----------- ...arHeadsUpNotificationSystemContainerTest.java | 13 ++++++------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/packages/CarSystemUI/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainer.java b/packages/CarSystemUI/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainer.java index 53e5d9fe91ec4..20fcca0d0220a 100644 --- a/packages/CarSystemUI/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainer.java +++ b/packages/CarSystemUI/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainer.java @@ -30,7 +30,6 @@ import com.android.car.notification.R; import com.android.car.notification.headsup.CarHeadsUpNotificationContainer; import com.android.systemui.car.CarDeviceProvisionedController; import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.statusbar.car.CarStatusBar; import javax.inject.Inject; import javax.inject.Singleton; @@ -43,7 +42,7 @@ import dagger.Lazy; @Singleton public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotificationContainer { private final CarDeviceProvisionedController mCarDeviceProvisionedController; - private final Lazy mCarStatusBarLazy; + private final Lazy mNotificationPanelViewControllerLazy; private final ViewGroup mWindow; private final FrameLayout mHeadsUpContentFrame; @@ -55,10 +54,9 @@ public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotifica @Main Resources resources, CarDeviceProvisionedController deviceProvisionedController, WindowManager windowManager, - // TODO: Remove dependency on CarStatusBar - Lazy carStatusBarLazy) { + Lazy notificationPanelViewControllerLazy) { mCarDeviceProvisionedController = deviceProvisionedController; - mCarStatusBarLazy = carStatusBarLazy; + mNotificationPanelViewControllerLazy = notificationPanelViewControllerLazy; boolean showOnBottom = resources.getBoolean(R.bool.config_showHeadsUpNotificationOnBottom); @@ -87,7 +85,8 @@ public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotifica private void animateShow() { if ((mEnableHeadsUpNotificationWhenNotificationShadeOpen - || !mCarStatusBarLazy.get().isPanelExpanded()) && isCurrentUserSetup()) { + || !mNotificationPanelViewControllerLazy.get().isPanelExpanded()) + && mCarDeviceProvisionedController.isCurrentUserFullySetup()) { mWindow.setVisibility(View.VISIBLE); } } @@ -114,9 +113,4 @@ public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotifica public boolean isVisible() { return mWindow.getVisibility() == View.VISIBLE; } - - private boolean isCurrentUserSetup() { - return mCarDeviceProvisionedController.isCurrentUserSetup() - && !mCarDeviceProvisionedController.isCurrentUserSetupInProgress(); - } } diff --git a/packages/CarSystemUI/tests/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainerTest.java b/packages/CarSystemUI/tests/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainerTest.java index 05b8e6a540990..6ac72a681bfe6 100644 --- a/packages/CarSystemUI/tests/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainerTest.java +++ b/packages/CarSystemUI/tests/src/com/android/systemui/car/notification/CarHeadsUpNotificationSystemContainerTest.java @@ -31,7 +31,6 @@ import androidx.test.filters.SmallTest; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; import com.android.systemui.car.CarDeviceProvisionedController; -import com.android.systemui.statusbar.car.CarStatusBar; import org.junit.Before; import org.junit.Test; @@ -48,7 +47,7 @@ public class CarHeadsUpNotificationSystemContainerTest extends SysuiTestCase { @Mock private CarDeviceProvisionedController mCarDeviceProvisionedController; @Mock - private CarStatusBar mCarStatusBar; + private NotificationPanelViewController mNotificationPanelViewController; @Mock private WindowManager mWindowManager; @@ -61,7 +60,7 @@ public class CarHeadsUpNotificationSystemContainerTest extends SysuiTestCase { public void setUp() { MockitoAnnotations.initMocks(this); - when(mCarStatusBar.isPanelExpanded()).thenReturn(false); + when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(false); when(mCarDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); when(mCarDeviceProvisionedController.isCurrentUserSetupInProgress()).thenReturn(false); @@ -72,14 +71,14 @@ public class CarHeadsUpNotificationSystemContainerTest extends SysuiTestCase { mDefaultController = new CarHeadsUpNotificationSystemContainer(mContext, testableResources.getResources(), mCarDeviceProvisionedController, mWindowManager, - () -> mCarStatusBar); + () -> mNotificationPanelViewController); testableResources.addOverride( R.bool.config_enableHeadsUpNotificationWhenNotificationShadeOpen, true); mOverrideEnabledController = new CarHeadsUpNotificationSystemContainer(mContext, testableResources.getResources(), mCarDeviceProvisionedController, mWindowManager, - () -> mCarStatusBar); + () -> mNotificationPanelViewController); } @Test @@ -120,14 +119,14 @@ public class CarHeadsUpNotificationSystemContainerTest extends SysuiTestCase { @Test public void testDisplayNotification_notificationPanelExpanded_isInvisible() { - when(mCarStatusBar.isPanelExpanded()).thenReturn(true); + when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(true); mDefaultController.displayNotification(mNotificationView); assertThat(mDefaultController.isVisible()).isFalse(); } @Test public void testDisplayNotification_notificationPanelExpandedEnabledHUNWhenOpen_isVisible() { - when(mCarStatusBar.isPanelExpanded()).thenReturn(true); + when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(true); mOverrideEnabledController.displayNotification(mNotificationView); assertThat(mOverrideEnabledController.isVisible()).isTrue(); }