Merge "Remove CarStatusBar reference from HUNs container" into rvc-dev
This commit is contained in:
@@ -30,7 +30,6 @@ import com.android.car.notification.R;
|
|||||||
import com.android.car.notification.headsup.CarHeadsUpNotificationContainer;
|
import com.android.car.notification.headsup.CarHeadsUpNotificationContainer;
|
||||||
import com.android.systemui.car.CarDeviceProvisionedController;
|
import com.android.systemui.car.CarDeviceProvisionedController;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.statusbar.car.CarStatusBar;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@@ -43,7 +42,7 @@ import dagger.Lazy;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotificationContainer {
|
public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotificationContainer {
|
||||||
private final CarDeviceProvisionedController mCarDeviceProvisionedController;
|
private final CarDeviceProvisionedController mCarDeviceProvisionedController;
|
||||||
private final Lazy<CarStatusBar> mCarStatusBarLazy;
|
private final Lazy<NotificationPanelViewController> mNotificationPanelViewControllerLazy;
|
||||||
|
|
||||||
private final ViewGroup mWindow;
|
private final ViewGroup mWindow;
|
||||||
private final FrameLayout mHeadsUpContentFrame;
|
private final FrameLayout mHeadsUpContentFrame;
|
||||||
@@ -55,10 +54,9 @@ public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotifica
|
|||||||
@Main Resources resources,
|
@Main Resources resources,
|
||||||
CarDeviceProvisionedController deviceProvisionedController,
|
CarDeviceProvisionedController deviceProvisionedController,
|
||||||
WindowManager windowManager,
|
WindowManager windowManager,
|
||||||
// TODO: Remove dependency on CarStatusBar
|
Lazy<NotificationPanelViewController> notificationPanelViewControllerLazy) {
|
||||||
Lazy<CarStatusBar> carStatusBarLazy) {
|
|
||||||
mCarDeviceProvisionedController = deviceProvisionedController;
|
mCarDeviceProvisionedController = deviceProvisionedController;
|
||||||
mCarStatusBarLazy = carStatusBarLazy;
|
mNotificationPanelViewControllerLazy = notificationPanelViewControllerLazy;
|
||||||
|
|
||||||
boolean showOnBottom = resources.getBoolean(R.bool.config_showHeadsUpNotificationOnBottom);
|
boolean showOnBottom = resources.getBoolean(R.bool.config_showHeadsUpNotificationOnBottom);
|
||||||
|
|
||||||
@@ -87,7 +85,8 @@ public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotifica
|
|||||||
|
|
||||||
private void animateShow() {
|
private void animateShow() {
|
||||||
if ((mEnableHeadsUpNotificationWhenNotificationShadeOpen
|
if ((mEnableHeadsUpNotificationWhenNotificationShadeOpen
|
||||||
|| !mCarStatusBarLazy.get().isPanelExpanded()) && isCurrentUserSetup()) {
|
|| !mNotificationPanelViewControllerLazy.get().isPanelExpanded())
|
||||||
|
&& mCarDeviceProvisionedController.isCurrentUserFullySetup()) {
|
||||||
mWindow.setVisibility(View.VISIBLE);
|
mWindow.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,9 +113,4 @@ public class CarHeadsUpNotificationSystemContainer implements CarHeadsUpNotifica
|
|||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
return mWindow.getVisibility() == View.VISIBLE;
|
return mWindow.getVisibility() == View.VISIBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCurrentUserSetup() {
|
|
||||||
return mCarDeviceProvisionedController.isCurrentUserSetup()
|
|
||||||
&& !mCarDeviceProvisionedController.isCurrentUserSetupInProgress();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import androidx.test.filters.SmallTest;
|
|||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.car.CarDeviceProvisionedController;
|
import com.android.systemui.car.CarDeviceProvisionedController;
|
||||||
import com.android.systemui.statusbar.car.CarStatusBar;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -48,7 +47,7 @@ public class CarHeadsUpNotificationSystemContainerTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private CarDeviceProvisionedController mCarDeviceProvisionedController;
|
private CarDeviceProvisionedController mCarDeviceProvisionedController;
|
||||||
@Mock
|
@Mock
|
||||||
private CarStatusBar mCarStatusBar;
|
private NotificationPanelViewController mNotificationPanelViewController;
|
||||||
@Mock
|
@Mock
|
||||||
private WindowManager mWindowManager;
|
private WindowManager mWindowManager;
|
||||||
|
|
||||||
@@ -61,7 +60,7 @@ public class CarHeadsUpNotificationSystemContainerTest extends SysuiTestCase {
|
|||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
when(mCarStatusBar.isPanelExpanded()).thenReturn(false);
|
when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(false);
|
||||||
when(mCarDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true);
|
when(mCarDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true);
|
||||||
when(mCarDeviceProvisionedController.isCurrentUserSetupInProgress()).thenReturn(false);
|
when(mCarDeviceProvisionedController.isCurrentUserSetupInProgress()).thenReturn(false);
|
||||||
|
|
||||||
@@ -72,14 +71,14 @@ public class CarHeadsUpNotificationSystemContainerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
mDefaultController = new CarHeadsUpNotificationSystemContainer(mContext,
|
mDefaultController = new CarHeadsUpNotificationSystemContainer(mContext,
|
||||||
testableResources.getResources(), mCarDeviceProvisionedController, mWindowManager,
|
testableResources.getResources(), mCarDeviceProvisionedController, mWindowManager,
|
||||||
() -> mCarStatusBar);
|
() -> mNotificationPanelViewController);
|
||||||
|
|
||||||
testableResources.addOverride(
|
testableResources.addOverride(
|
||||||
R.bool.config_enableHeadsUpNotificationWhenNotificationShadeOpen, true);
|
R.bool.config_enableHeadsUpNotificationWhenNotificationShadeOpen, true);
|
||||||
|
|
||||||
mOverrideEnabledController = new CarHeadsUpNotificationSystemContainer(mContext,
|
mOverrideEnabledController = new CarHeadsUpNotificationSystemContainer(mContext,
|
||||||
testableResources.getResources(), mCarDeviceProvisionedController, mWindowManager,
|
testableResources.getResources(), mCarDeviceProvisionedController, mWindowManager,
|
||||||
() -> mCarStatusBar);
|
() -> mNotificationPanelViewController);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -120,14 +119,14 @@ public class CarHeadsUpNotificationSystemContainerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDisplayNotification_notificationPanelExpanded_isInvisible() {
|
public void testDisplayNotification_notificationPanelExpanded_isInvisible() {
|
||||||
when(mCarStatusBar.isPanelExpanded()).thenReturn(true);
|
when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(true);
|
||||||
mDefaultController.displayNotification(mNotificationView);
|
mDefaultController.displayNotification(mNotificationView);
|
||||||
assertThat(mDefaultController.isVisible()).isFalse();
|
assertThat(mDefaultController.isVisible()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDisplayNotification_notificationPanelExpandedEnabledHUNWhenOpen_isVisible() {
|
public void testDisplayNotification_notificationPanelExpandedEnabledHUNWhenOpen_isVisible() {
|
||||||
when(mCarStatusBar.isPanelExpanded()).thenReturn(true);
|
when(mNotificationPanelViewController.isPanelExpanded()).thenReturn(true);
|
||||||
mOverrideEnabledController.displayNotification(mNotificationView);
|
mOverrideEnabledController.displayNotification(mNotificationView);
|
||||||
assertThat(mOverrideEnabledController.isVisible()).isTrue();
|
assertThat(mOverrideEnabledController.isVisible()).isTrue();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user