Merge changes Iaceff2ba,I58d142bf
* changes:
Clean up nav bar logic from StatusBar
Create a single car service to share in sysui
diff --git a/packages/CarSystemUI/src/com/android/systemui/car/CarServiceProvider.java b/packages/CarSystemUI/src/com/android/systemui/car/CarServiceProvider.java
new file mode 100644
index 0000000..f8bfeec
--- /dev/null
+++ b/packages/CarSystemUI/src/com/android/systemui/car/CarServiceProvider.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.car;
+
+import android.car.Car;
+import android.content.Context;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+/** Provides a common connection to the car service that can be shared. */
+@Singleton
+public class CarServiceProvider {
+
+ private final Context mContext;
+ private final List<CarServiceOnConnectedListener> mListeners = new ArrayList<>();
+ private Car mCar;
+
+ @Inject
+ public CarServiceProvider(Context context) {
+ mContext = context;
+ mCar = Car.createCar(mContext, /* handler= */ null, Car.CAR_WAIT_TIMEOUT_DO_NOT_WAIT,
+ (car, ready) -> {
+ mCar = car;
+
+ synchronized (mListeners) {
+ for (CarServiceOnConnectedListener listener : mListeners) {
+ if (ready) {
+ listener.onConnected(mCar);
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * Let's other components hook into the connection to the car service. If we're already
+ * connected to the car service, the callback is immediately triggered.
+ */
+ public void addListener(CarServiceOnConnectedListener listener) {
+ if (mCar.isConnected()) {
+ listener.onConnected(mCar);
+ }
+ mListeners.add(listener);
+ }
+
+ /**
+ * Listener which is triggered when Car Service is connected.
+ */
+ public interface CarServiceOnConnectedListener {
+ /** This will be called when the car service has successfully been connected. */
+ void onConnected(Car car);
+ }
+}
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 af92767..08ab492 100644
--- a/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java
+++ b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java
@@ -37,6 +37,7 @@
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.NavigationBarController;
+import com.android.systemui.statusbar.SuperStatusBarViewFactory;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -54,10 +55,12 @@
private final WindowManager mWindowManager;
private final DeviceProvisionedController mDeviceProvisionedController;
private final CommandQueue mCommandQueue;
- private final Lazy<FacetButtonTaskStackListener> mFacetButtonTaskStackListener;
+ private final Lazy<FacetButtonTaskStackListener> mFacetButtonTaskStackListenerLazy;
private final Handler mMainHandler;
- private final Lazy<KeyguardStateController> mKeyguardStateController;
- private final Lazy<NavigationBarController> mNavigationBarController;
+ private final Lazy<KeyguardStateController> mKeyguardStateControllerLazy;
+ private final Lazy<NavigationBarController> mNavigationBarControllerLazy;
+ private final SuperStatusBarViewFactory mSuperStatusBarViewFactory;
+ private final Lazy<CarFacetButtonController> mCarFacetButtonControllerLazy;
private IStatusBarService mBarService;
private ActivityManagerWrapper mActivityManagerWrapper;
@@ -67,10 +70,12 @@
private boolean mBottomNavBarVisible;
// Nav bar views.
- private ViewGroup mNavigationBarWindow;
+ private ViewGroup mTopNavigationBarWindow;
+ private ViewGroup mBottomNavigationBarWindow;
private ViewGroup mLeftNavigationBarWindow;
private ViewGroup mRightNavigationBarWindow;
- private CarNavigationBarView mNavigationBarView;
+ private CarNavigationBarView mTopNavigationBarView;
+ private CarNavigationBarView mBottomNavigationBarView;
private CarNavigationBarView mLeftNavigationBarView;
private CarNavigationBarView mRightNavigationBarView;
@@ -84,19 +89,23 @@
WindowManager windowManager,
DeviceProvisionedController deviceProvisionedController,
CommandQueue commandQueue,
- Lazy<FacetButtonTaskStackListener> facetButtonTaskStackListener,
+ Lazy<FacetButtonTaskStackListener> facetButtonTaskStackListenerLazy,
@MainHandler Handler mainHandler,
- Lazy<KeyguardStateController> keyguardStateController,
- Lazy<NavigationBarController> navigationBarController) {
+ Lazy<KeyguardStateController> keyguardStateControllerLazy,
+ Lazy<NavigationBarController> navigationBarControllerLazy,
+ SuperStatusBarViewFactory superStatusBarViewFactory,
+ Lazy<CarFacetButtonController> carFacetButtonControllerLazy) {
super(context);
mCarNavigationBarController = carNavigationBarController;
mWindowManager = windowManager;
mDeviceProvisionedController = deviceProvisionedController;
mCommandQueue = commandQueue;
- mFacetButtonTaskStackListener = facetButtonTaskStackListener;
+ mFacetButtonTaskStackListenerLazy = facetButtonTaskStackListenerLazy;
mMainHandler = mainHandler;
- mKeyguardStateController = keyguardStateController;
- mNavigationBarController = navigationBarController;
+ mKeyguardStateControllerLazy = keyguardStateControllerLazy;
+ mNavigationBarControllerLazy = navigationBarControllerLazy;
+ mSuperStatusBarViewFactory = superStatusBarViewFactory;
+ mCarFacetButtonControllerLazy = carFacetButtonControllerLazy;
}
@Override
@@ -137,7 +146,7 @@
createNavigationBar(result);
mActivityManagerWrapper = ActivityManagerWrapper.getInstance();
- mActivityManagerWrapper.registerTaskStackListener(mFacetButtonTaskStackListener.get());
+ mActivityManagerWrapper.registerTaskStackListener(mFacetButtonTaskStackListenerLazy.get());
mCarNavigationBarController.connectToHvac();
}
@@ -158,10 +167,16 @@
// remove and reattach all hvac components such that we don't keep a reference to unused
// ui elements
mCarNavigationBarController.removeAllFromHvac();
+ mCarFacetButtonControllerLazy.get().removeAll();
- if (mNavigationBarWindow != null) {
- mNavigationBarWindow.removeAllViews();
- mNavigationBarView = null;
+ if (mTopNavigationBarWindow != null) {
+ mTopNavigationBarWindow.removeAllViews();
+ mTopNavigationBarView = null;
+ }
+
+ if (mBottomNavigationBarWindow != null) {
+ mBottomNavigationBarWindow.removeAllViews();
+ mBottomNavigationBarView = null;
}
if (mLeftNavigationBarWindow != null) {
@@ -177,8 +192,8 @@
buildNavBarContent();
// If the UI was rebuilt (day/night change) while the keyguard was up we need to
// correctly respect that state.
- if (mKeyguardStateController.get().isShowing()) {
- updateNavBarForKeyguardContent();
+ if (mKeyguardStateControllerLazy.get().isShowing()) {
+ mCarNavigationBarController.showAllKeyguardButtons(mDeviceIsSetUpForUser);
}
}
@@ -196,20 +211,28 @@
// There has been a car customized nav bar on the default display, so just create nav bars
// on external displays.
- mNavigationBarController.get().createNavigationBars(/* includeDefaultDisplay= */ false,
+ mNavigationBarControllerLazy.get().createNavigationBars(/* includeDefaultDisplay= */ false,
result);
}
private void buildNavBarWindows() {
- mNavigationBarWindow = mCarNavigationBarController.getBottomWindow();
+ mTopNavigationBarWindow = mSuperStatusBarViewFactory
+ .getStatusBarWindowView()
+ .findViewById(R.id.car_top_navigation_bar_container);
+ mBottomNavigationBarWindow = mCarNavigationBarController.getBottomWindow();
mLeftNavigationBarWindow = mCarNavigationBarController.getLeftWindow();
mRightNavigationBarWindow = mCarNavigationBarController.getRightWindow();
}
private void buildNavBarContent() {
- mNavigationBarView = mCarNavigationBarController.getBottomBar(mDeviceIsSetUpForUser);
- if (mNavigationBarView != null) {
- mNavigationBarWindow.addView(mNavigationBarView);
+ mTopNavigationBarView = mCarNavigationBarController.getTopBar(mDeviceIsSetUpForUser);
+ if (mTopNavigationBarView != null) {
+ mTopNavigationBarWindow.addView(mTopNavigationBarView);
+ }
+
+ mBottomNavigationBarView = mCarNavigationBarController.getBottomBar(mDeviceIsSetUpForUser);
+ if (mBottomNavigationBarView != null) {
+ mBottomNavigationBarWindow.addView(mBottomNavigationBarView);
}
mLeftNavigationBarView = mCarNavigationBarController.getLeftBar(mDeviceIsSetUpForUser);
@@ -224,7 +247,7 @@
}
private void attachNavBarWindows() {
- if (mNavigationBarWindow != null && !mBottomNavBarVisible) {
+ if (mBottomNavigationBarWindow != null && !mBottomNavBarVisible) {
mBottomNavBarVisible = true;
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
@@ -237,7 +260,7 @@
PixelFormat.TRANSLUCENT);
lp.setTitle("CarNavigationBar");
lp.windowAnimations = 0;
- mWindowManager.addView(mNavigationBarWindow, lp);
+ mWindowManager.addView(mBottomNavigationBarWindow, lp);
}
if (mLeftNavigationBarWindow != null) {
@@ -297,23 +320,11 @@
isKeyboardVisible ? View.GONE : View.VISIBLE);
}
- private void updateNavBarForKeyguardContent() {
- if (mNavigationBarView != null) {
- mNavigationBarView.showKeyguardButtons();
- }
- if (mLeftNavigationBarView != null) {
- mLeftNavigationBarView.showKeyguardButtons();
- }
- if (mRightNavigationBarView != null) {
- mRightNavigationBarView.showKeyguardButtons();
- }
- }
-
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.print(" mTaskStackListener=");
- pw.println(mFacetButtonTaskStackListener.get());
- pw.print(" mNavigationBarView=");
- pw.println(mNavigationBarView);
+ pw.println(mFacetButtonTaskStackListenerLazy.get());
+ pw.print(" mBottomNavigationBarView=");
+ pw.println(mBottomNavigationBarView);
}
}
diff --git a/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBarController.java b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBarController.java
index 6bed69b..6f28843 100644
--- a/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBarController.java
+++ b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBarController.java
@@ -24,8 +24,7 @@
import androidx.annotation.Nullable;
import com.android.systemui.R;
-import com.android.systemui.statusbar.car.hvac.HvacController;
-import com.android.systemui.statusbar.car.hvac.TemperatureView;
+import com.android.systemui.navigationbar.car.hvac.HvacController;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -38,6 +37,7 @@
private final Context mContext;
private final NavigationBarViewFactory mNavigationBarViewFactory;
+ private final Lazy<CarFacetButtonController> mCarFacetButtonControllerLazy;
private final Lazy<HvacController> mHvacControllerLazy;
private boolean mShowBottom;
@@ -58,9 +58,11 @@
@Inject
public CarNavigationBarController(Context context,
NavigationBarViewFactory navigationBarViewFactory,
+ Lazy<CarFacetButtonController> carFacetButtonControllerLazy,
Lazy<HvacController> hvacControllerLazy) {
mContext = context;
mNavigationBarViewFactory = navigationBarViewFactory;
+ mCarFacetButtonControllerLazy = carFacetButtonControllerLazy;
mHvacControllerLazy = hvacControllerLazy;
// Read configuration.
@@ -129,9 +131,7 @@
@NonNull
public CarNavigationBarView getTopBar(boolean isSetUp) {
mTopView = mNavigationBarViewFactory.getTopBar(isSetUp);
- mTopView.setStatusBarWindowTouchListener(mTopBarTouchListener);
- mTopView.setNotificationsPanelController(mNotificationsShadeController);
- addTemperatureViewToController(mTopView);
+ setupBar(mTopView, mTopBarTouchListener, mNotificationsShadeController);
return mTopView;
}
@@ -143,9 +143,7 @@
}
mBottomView = mNavigationBarViewFactory.getBottomBar(isSetUp);
- mBottomView.setStatusBarWindowTouchListener(mBottomBarTouchListener);
- mBottomView.setNotificationsPanelController(mNotificationsShadeController);
- addTemperatureViewToController(mBottomView);
+ setupBar(mBottomView, mBottomBarTouchListener, mNotificationsShadeController);
return mBottomView;
}
@@ -157,9 +155,7 @@
}
mLeftView = mNavigationBarViewFactory.getLeftBar(isSetUp);
- mLeftView.setStatusBarWindowTouchListener(mLeftBarTouchListener);
- mLeftView.setNotificationsPanelController(mNotificationsShadeController);
- addTemperatureViewToController(mLeftView);
+ setupBar(mLeftView, mLeftBarTouchListener, mNotificationsShadeController);
return mLeftView;
}
@@ -171,12 +167,18 @@
}
mRightView = mNavigationBarViewFactory.getRightBar(isSetUp);
- mRightView.setStatusBarWindowTouchListener(mRightBarTouchListener);
- mRightView.setNotificationsPanelController(mNotificationsShadeController);
- addTemperatureViewToController(mRightView);
+ setupBar(mRightView, mRightBarTouchListener, mNotificationsShadeController);
return mRightView;
}
+ private void setupBar(CarNavigationBarView view, View.OnTouchListener statusBarTouchListener,
+ NotificationsShadeController notifShadeController) {
+ view.setStatusBarWindowTouchListener(statusBarTouchListener);
+ view.setNotificationsPanelController(notifShadeController);
+ mCarFacetButtonControllerLazy.get().addAllFacetButtons(view);
+ mHvacControllerLazy.get().addTemperatureViewToController(view);
+ }
+
/** Sets a touch listener for the top navigation bar. */
public void registerTopBarTouchListener(View.OnTouchListener listener) {
mTopBarTouchListener = listener;
@@ -290,17 +292,6 @@
void togglePanel();
}
- private void addTemperatureViewToController(View v) {
- if (v instanceof TemperatureView) {
- mHvacControllerLazy.get().addHvacTextView((TemperatureView) v);
- } else if (v instanceof ViewGroup) {
- ViewGroup viewGroup = (ViewGroup) v;
- for (int i = 0; i < viewGroup.getChildCount(); i++) {
- addTemperatureViewToController(viewGroup.getChildAt(i));
- }
- }
- }
-
private void checkAllBars(boolean isSetUp) {
mTopView = getTopBar(isSetUp);
mBottomView = getBottomBar(isSetUp);
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/hvac/HvacController.java b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/hvac/HvacController.java
similarity index 79%
rename from packages/CarSystemUI/src/com/android/systemui/statusbar/car/hvac/HvacController.java
rename to packages/CarSystemUI/src/com/android/systemui/navigationbar/car/hvac/HvacController.java
index 41914d2..af2cb0a 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/hvac/HvacController.java
+++ b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/hvac/HvacController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,20 +14,21 @@
* limitations under the License.
*/
-package com.android.systemui.statusbar.car.hvac;
+package com.android.systemui.navigationbar.car.hvac;
import static android.car.VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL;
import static android.car.VehiclePropertyIds.HVAC_TEMPERATURE_DISPLAY_UNITS;
import android.car.Car;
-import android.car.Car.CarServiceLifecycleListener;
import android.car.VehicleUnit;
import android.car.hardware.CarPropertyValue;
import android.car.hardware.hvac.CarHvacManager;
import android.car.hardware.hvac.CarHvacManager.CarHvacEventCallback;
-import android.content.Context;
-import android.os.Handler;
import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.android.systemui.car.CarServiceProvider;
import java.util.ArrayList;
import java.util.HashMap;
@@ -37,19 +38,18 @@
import java.util.Objects;
import javax.inject.Inject;
+import javax.inject.Singleton;
/**
* Manages the connection to the Car service and delegates value changes to the registered
* {@link TemperatureView}s
*/
+@Singleton
public class HvacController {
-
public static final String TAG = "HvacController";
- public static final int BIND_TO_HVAC_RETRY_DELAY = 5000;
- private Context mContext;
- private Handler mHandler;
- private Car mCar;
+ private final CarServiceProvider mCarServiceProvider;
+
private CarHvacManager mHvacManager;
private HashMap<HvacKey, List<TemperatureView>> mTempComponents = new HashMap<>();
@@ -85,22 +85,20 @@
}
};
- private final CarServiceLifecycleListener mCarServiceLifecycleListener = (car, ready) -> {
- if (!ready) {
- return;
- }
- try {
- mHvacManager = (CarHvacManager) car.getCarManager(Car.HVAC_SERVICE);
- mHvacManager.registerCallback(mHardwareCallback);
- initComponents();
- } catch (Exception e) {
- Log.e(TAG, "Failed to correctly connect to HVAC", e);
- }
- };
+ private final CarServiceProvider.CarServiceOnConnectedListener mCarServiceLifecycleListener =
+ car -> {
+ try {
+ mHvacManager = (CarHvacManager) car.getCarManager(Car.HVAC_SERVICE);
+ mHvacManager.registerCallback(mHardwareCallback);
+ initComponents();
+ } catch (Exception e) {
+ Log.e(TAG, "Failed to correctly connect to HVAC", e);
+ }
+ };
@Inject
- public HvacController(Context context) {
- mContext = context;
+ public HvacController(CarServiceProvider carServiceProvider) {
+ mCarServiceProvider = carServiceProvider;
}
/**
@@ -108,9 +106,7 @@
* ({@link CarHvacManager}) will happen on the same thread this method was called from.
*/
public void connectToCarService() {
- mHandler = new Handler();
- mCar = Car.createCar(mContext, /* handler= */ mHandler, Car.CAR_WAIT_TIMEOUT_DO_NOT_WAIT,
- mCarServiceLifecycleListener);
+ mCarServiceProvider.addListener(mCarServiceLifecycleListener);
}
/**
@@ -172,6 +168,21 @@
}
/**
+ * Iterate through a view, looking for {@link TemperatureView} instances and add them to the
+ * controller if found.
+ */
+ public void addTemperatureViewToController(View v) {
+ if (v instanceof TemperatureView) {
+ addHvacTextView((TemperatureView) v);
+ } else if (v instanceof ViewGroup) {
+ ViewGroup viewGroup = (ViewGroup) v;
+ for (int i = 0; i < viewGroup.getChildCount(); i++) {
+ addTemperatureViewToController(viewGroup.getChildAt(i));
+ }
+ }
+ }
+
+ /**
* Key for storing {@link TemperatureView}s in a hash map
*/
private static class HvacKey {
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/hvac/TemperatureTextView.java b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/hvac/TemperatureTextView.java
similarity index 95%
rename from packages/CarSystemUI/src/com/android/systemui/statusbar/car/hvac/TemperatureTextView.java
rename to packages/CarSystemUI/src/com/android/systemui/navigationbar/car/hvac/TemperatureTextView.java
index 17ef3c0..ad4fcd9 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/hvac/TemperatureTextView.java
+++ b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/hvac/TemperatureTextView.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 The Android Open Source Project
+ * Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.systemui.statusbar.car.hvac;
+package com.android.systemui.navigationbar.car.hvac;
import android.content.Context;
import android.content.res.TypedArray;
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/hvac/TemperatureView.java b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/hvac/TemperatureView.java
similarity index 93%
rename from packages/CarSystemUI/src/com/android/systemui/statusbar/car/hvac/TemperatureView.java
rename to packages/CarSystemUI/src/com/android/systemui/navigationbar/car/hvac/TemperatureView.java
index c17da18..963f318 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/hvac/TemperatureView.java
+++ b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/hvac/TemperatureView.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 The Android Open Source Project
+ * Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.systemui.statusbar.car.hvac;
+package com.android.systemui.navigationbar.car.hvac;
/**
* Interface for Views that display temperature HVAC properties
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
index 78ac960..10527b2 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
@@ -57,15 +57,14 @@
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.BatteryMeterView;
-import com.android.systemui.CarSystemUIFactory;
import com.android.systemui.Dependency;
import com.android.systemui.Prefs;
import com.android.systemui.R;
-import com.android.systemui.SystemUIFactory;
import com.android.systemui.UiOffloadThread;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.bubbles.BubbleController;
+import com.android.systemui.car.CarServiceProvider;
import com.android.systemui.classifier.FalsingLog;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.fragments.FragmentHostManager;
@@ -73,9 +72,7 @@
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.keyguard.WakefulnessLifecycle;
-import com.android.systemui.navigationbar.car.CarFacetButtonController;
import com.android.systemui.navigationbar.car.CarNavigationBarController;
-import com.android.systemui.navigationbar.car.CarNavigationBarView;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.qs.car.CarQSFragment;
@@ -164,20 +161,20 @@
private float mBackgroundAlphaDiff;
private float mInitialBackgroundAlpha;
+ private final Lazy<FullscreenUserSwitcher> mFullscreenUserSwitcherLazy;
private FullscreenUserSwitcher mFullscreenUserSwitcher;
private CarBatteryController mCarBatteryController;
private BatteryMeterView mBatteryMeterView;
private Drawable mNotificationPanelBackground;
- private ViewGroup mTopNavigationBarContainer;
- private CarNavigationBarView mTopNavigationBarView;
-
private final Object mQueueLock = new Object();
private final CarNavigationBarController mCarNavigationBarController;
- private CarFacetButtonController mCarFacetButtonController;
+ private final Lazy<DrivingStateHelper> mDrivingStateHelperLazy;
+ private final Lazy<PowerManagerHelper> mPowerManagerHelperLazy;
+ private final CarServiceProvider mCarServiceProvider;
+
private DeviceProvisionedController mDeviceProvisionedController;
- private boolean mDeviceIsSetUpForUser = true;
private DrivingStateHelper mDrivingStateHelper;
private PowerManagerHelper mPowerManagerHelper;
private FlingAnimationUtils mFlingAnimationUtils;
@@ -311,6 +308,10 @@
ViewMediatorCallback viewMediatorCallback,
DismissCallbackRegistry dismissCallbackRegistry,
/* Car Settings injected components. */
+ CarServiceProvider carServiceProvider,
+ Lazy<DrivingStateHelper> drivingStateHelperLazy,
+ Lazy<PowerManagerHelper> powerManagerHelperLazy,
+ Lazy<FullscreenUserSwitcher> fullscreenUserSwitcherLazy,
CarNavigationBarController carNavigationBarController) {
super(
context,
@@ -384,16 +385,16 @@
viewMediatorCallback,
dismissCallbackRegistry);
mScrimController = scrimController;
+ mDeviceProvisionedController = deviceProvisionedController;
+ mCarServiceProvider = carServiceProvider;
+ mDrivingStateHelperLazy = drivingStateHelperLazy;
+ mPowerManagerHelperLazy = powerManagerHelperLazy;
+ mFullscreenUserSwitcherLazy = fullscreenUserSwitcherLazy;
mCarNavigationBarController = carNavigationBarController;
}
@Override
public void start() {
- // get the provisioned state before calling the parent class since it's that flow that
- // builds the nav bar
- mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
- mDeviceIsSetUpForUser = mDeviceProvisionedController.isCurrentUserSetup();
-
// Need to initialize screen lifecycle before calling super.start - before switcher is
// created.
mScreenLifecycle = Dependency.get(ScreenLifecycle.class);
@@ -431,52 +432,20 @@
createBatteryController();
mCarBatteryController.startListening();
- mDeviceProvisionedController.addCallback(
- new DeviceProvisionedController.DeviceProvisionedListener() {
- @Override
- public void onUserSetupChanged() {
- mHandler.post(() -> resetSystemBarsIfNecessary());
- }
-
- @Override
- public void onUserSwitched() {
- mHandler.post(() -> resetSystemBarsIfNecessary());
- }
- });
-
// Used by onDrivingStateChanged and it can be called inside
// DrivingStateHelper.connectToCarService()
mSwitchToGuestTimer = new SwitchToGuestTimer(mContext);
// Register a listener for driving state changes.
- mDrivingStateHelper = new DrivingStateHelper(mContext, this::onDrivingStateChanged);
+ mDrivingStateHelper = mDrivingStateHelperLazy.get();
+ mDrivingStateHelper.setCarDrivingStateEventListener(this::onDrivingStateChanged);
mDrivingStateHelper.connectToCarService();
- mPowerManagerHelper = new PowerManagerHelper(mContext, mCarPowerStateListener);
+ mPowerManagerHelper = mPowerManagerHelperLazy.get();
+ mPowerManagerHelper.setCarPowerStateListener(mCarPowerStateListener);
mPowerManagerHelper.connectToCarService();
}
- private void resetSystemBarsIfNecessary() {
- boolean currentUserSetup = mDeviceProvisionedController.isCurrentUserSetup();
- if (mDeviceIsSetUpForUser != currentUserSetup) {
- mDeviceIsSetUpForUser = currentUserSetup;
- resetSystemBars();
- }
- }
-
- /**
- * Remove all content from navbars and rebuild them. Used to allow for different nav bars
- * before and after the device is provisioned. . Also for change of density and font size.
- */
- private void resetSystemBars() {
- mCarFacetButtonController.removeAll();
-
- buildNavBarContent();
- // CarFacetButtonController was reset therefore we need to re-add the status bar elements
- // to the controller.
- mCarFacetButtonController.addAllFacetButtons(mStatusBarWindow);
- }
-
/**
* Allows for showing or hiding just the navigation bars. This is indented to be used when
* the full screen user selector is shown.
@@ -490,23 +459,22 @@
@Override
public boolean hideKeyguard() {
boolean result = super.hideKeyguard();
- mCarNavigationBarController.hideAllKeyguardButtons(mDeviceIsSetUpForUser);
+ mCarNavigationBarController.hideAllKeyguardButtons(
+ mDeviceProvisionedController.isCurrentUserSetup());
return result;
}
@Override
public void showKeyguard() {
super.showKeyguard();
- mCarNavigationBarController.showAllKeyguardButtons(mDeviceIsSetUpForUser);
+ mCarNavigationBarController.showAllKeyguardButtons(
+ mDeviceProvisionedController.isCurrentUserSetup());
}
@Override
protected void makeStatusBarView(@Nullable RegisterStatusBarResult result) {
super.makeStatusBarView(result);
- CarSystemUIFactory factory = SystemUIFactory.getInstance();
- mCarFacetButtonController = factory.getCarDependencyComponent()
- .getCarFacetButtonController();
mNotificationPanelBackground = getDefaultWallpaper();
mScrimController.setScrimBehindDrawable(mNotificationPanelBackground);
@@ -562,7 +530,7 @@
new HandleBarCloseNotificationGestureListener());
mTopNavBarNotificationTouchListener = (v, event) -> {
- if (!mDeviceIsSetUpForUser) {
+ if (!mDeviceProvisionedController.isCurrentUserSetup()) {
return true;
}
boolean consumed = openGestureDetector.onTouchEvent(event);
@@ -592,20 +560,13 @@
});
CarNotificationListener carNotificationListener = new CarNotificationListener();
mCarUxRestrictionManagerWrapper = new CarUxRestrictionManagerWrapper();
- // This can take time if car service is not ready up to this time.
- // TODO(b/142808072) Refactor CarUxRestrictionManagerWrapper to allow setting
- // CarUxRestrictionsManager later and switch to Car.CAR_WAIT_TIMEOUT_DO_NOT_WAIT.
- Car.createCar(mContext, /* handler= */ null, Car.CAR_WAIT_TIMEOUT_WAIT_FOREVER,
- (car, ready) -> {
- if (!ready) {
- return;
- }
- CarUxRestrictionsManager carUxRestrictionsManager =
- (CarUxRestrictionsManager)
- car.getCarManager(Car.CAR_UX_RESTRICTION_SERVICE);
- mCarUxRestrictionManagerWrapper.setCarUxRestrictionsManager(
- carUxRestrictionsManager);
- });
+ mCarServiceProvider.addListener(car -> {
+ CarUxRestrictionsManager carUxRestrictionsManager =
+ (CarUxRestrictionsManager)
+ car.getCarManager(Car.CAR_UX_RESTRICTION_SERVICE);
+ mCarUxRestrictionManagerWrapper.setCarUxRestrictionsManager(
+ carUxRestrictionsManager);
+ });
mNotificationDataManager = new NotificationDataManager();
mNotificationDataManager.setOnUnseenCountUpdateListener(
@@ -614,7 +575,7 @@
boolean hasUnseen =
mNotificationDataManager.getUnseenNotificationCount() > 0;
mCarNavigationBarController.toggleAllNotificationsUnseenIndicator(
- mDeviceIsSetUpForUser, hasUnseen);
+ mDeviceProvisionedController.isCurrentUserSetup(), hasUnseen);
}
});
@@ -868,14 +829,14 @@
@Override
protected void createNavigationBar(@Nullable RegisterStatusBarResult result) {
- mTopNavigationBarContainer = mStatusBarWindow
- .findViewById(R.id.car_top_navigation_bar_container);
-
- buildNavBarContent();
+ registerNavBarListeners();
}
- private void buildNavBarContent() {
- buildTopBar();
+ private void registerNavBarListeners() {
+ // In CarStatusBar, navigation bars are built by NavigationBar.java
+ // Instead, we register necessary callbacks to the navigation bar controller.
+ mCarNavigationBarController.registerTopBarTouchListener(
+ mTopNavBarNotificationTouchListener);
mCarNavigationBarController.registerBottomBarTouchListener(
mNavBarNotificationTouchListener);
@@ -889,14 +850,6 @@
mCarNavigationBarController.registerNotificationController(() -> togglePanel());
}
- private void buildTopBar() {
- mTopNavigationBarContainer.removeAllViews();
- mTopNavigationBarView = mCarNavigationBarController.getTopBar(mDeviceIsSetUpForUser);
- mCarNavigationBarController.registerTopBarTouchListener(
- mTopNavBarNotificationTouchListener);
- mTopNavigationBarContainer.addView(mTopNavigationBarView);
- }
-
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
//When executing dump() function simultaneously, we need to serialize them
@@ -908,8 +861,6 @@
+ "," + mStackScroller.getScrollY());
}
- pw.print(" mCarFacetButtonController=");
- pw.println(mCarFacetButtonController);
pw.print(" mFullscreenUserSwitcher=");
pw.println(mFullscreenUserSwitcher);
pw.print(" mCarBatteryController=");
@@ -974,8 +925,10 @@
UserSwitcherController userSwitcherController =
Dependency.get(UserSwitcherController.class);
if (userSwitcherController.useFullscreenUserSwitcher()) {
- mFullscreenUserSwitcher = new FullscreenUserSwitcher(this,
- mStatusBarWindow.findViewById(R.id.fullscreen_user_switcher_stub), mContext);
+ mFullscreenUserSwitcher = mFullscreenUserSwitcherLazy.get();
+ mFullscreenUserSwitcher.setStatusBar(this);
+ mFullscreenUserSwitcher.setContainer(
+ mStatusBarWindow.findViewById(R.id.fullscreen_user_switcher_stub));
} else {
super.createUserSwitcher();
}
@@ -1058,7 +1011,7 @@
@Override
public void onDensityOrFontScaleChanged() {
super.onDensityOrFontScaleChanged();
- resetSystemBars();
+ registerNavBarListeners();
// Need to update the background on density changed in case the change was due to night
// mode.
mNotificationPanelBackground = getDefaultWallpaper();
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java
index b9dacc0..5418ebe 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java
@@ -29,6 +29,7 @@
import com.android.systemui.assist.AssistManager;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.bubbles.BubbleController;
+import com.android.systemui.car.CarServiceProvider;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -179,6 +180,10 @@
StatusBarKeyguardViewManager statusBarKeyguardViewManager,
ViewMediatorCallback viewMediatorCallback,
DismissCallbackRegistry dismissCallbackRegistry,
+ CarServiceProvider carServiceProvider,
+ Lazy<DrivingStateHelper> drivingStateHelperLazy,
+ Lazy<PowerManagerHelper> powerManagerHelperLazy,
+ Lazy<FullscreenUserSwitcher> fullscreenUserSwitcherLazy,
CarNavigationBarController carNavigationBarController) {
return new CarStatusBar(
context,
@@ -250,6 +255,10 @@
statusBarKeyguardViewManager,
viewMediatorCallback,
dismissCallbackRegistry,
+ carServiceProvider,
+ drivingStateHelperLazy,
+ powerManagerHelperLazy,
+ fullscreenUserSwitcherLazy,
carNavigationBarController);
}
}
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java
index ec72ee7..ec46433 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java
@@ -22,6 +22,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.os.Handler;
import android.os.UserHandle;
@@ -36,15 +37,21 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.systemui.R;
+import com.android.systemui.dagger.qualifiers.MainResources;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
/**
* A helper class displays an unlock dialog and receives broadcast about detecting trusted device
* & unlocking state to show the appropriate message on the dialog.
*/
+@Singleton
class CarTrustAgentUnlockDialogHelper extends BroadcastReceiver{
private static final String TAG = CarTrustAgentUnlockDialogHelper.class.getSimpleName();
private final Context mContext;
+ private final Resources mResources;
private final WindowManager mWindowManager;
private final UserManager mUserManager;
private final WindowManager.LayoutParams mParams;
@@ -60,10 +67,13 @@
private boolean mIsDialogShowing;
private OnHideListener mOnHideListener;
- CarTrustAgentUnlockDialogHelper(Context context) {
+ @Inject
+ CarTrustAgentUnlockDialogHelper(Context context, @MainResources Resources resources,
+ UserManager userManager, WindowManager windowManager) {
mContext = context;
- mUserManager = mContext.getSystemService(UserManager.class);
- mWindowManager = mContext.getSystemService(WindowManager.class);
+ mResources = resources;
+ mUserManager = userManager;
+ mWindowManager = windowManager;
mParams = createLayoutParams();
mFilter = getIntentFilter();
@@ -125,7 +135,7 @@
* @param listener listener that listens to dialog hide
*/
void showUnlockDialogAfterDelay(int uid, OnHideListener listener) {
- long delayMillis = mContext.getResources().getInteger(R.integer.unlock_dialog_delay_ms);
+ long delayMillis = mResources.getInteger(R.integer.unlock_dialog_delay_ms);
showUnlockDialogAfterDelay(uid, delayMillis, listener);
}
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/DrivingStateHelper.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/DrivingStateHelper.java
index cd87e78..60934ab 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/DrivingStateHelper.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/DrivingStateHelper.java
@@ -17,31 +17,43 @@
package com.android.systemui.statusbar.car;
import android.car.Car;
-import android.car.Car.CarServiceLifecycleListener;
import android.car.drivingstate.CarDrivingStateEvent;
import android.car.drivingstate.CarDrivingStateManager;
import android.car.drivingstate.CarDrivingStateManager.CarDrivingStateEventListener;
-import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
+import com.android.systemui.car.CarServiceProvider;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
* Helper class for connecting to the {@link CarDrivingStateManager} and listening for driving state
* changes.
*/
+@Singleton
public class DrivingStateHelper {
public static final String TAG = "DrivingStateHelper";
- private final Context mContext;
+ private final CarServiceProvider mCarServiceProvider;
+
private CarDrivingStateManager mDrivingStateManager;
- private Car mCar;
private CarDrivingStateEventListener mDrivingStateHandler;
- public DrivingStateHelper(Context context,
- @NonNull CarDrivingStateEventListener drivingStateHandler) {
- mContext = context;
- mDrivingStateHandler = drivingStateHandler;
+ @Inject
+ public DrivingStateHelper(CarServiceProvider carServiceProvider) {
+ mCarServiceProvider = carServiceProvider;
+ }
+
+ /**
+ * Sets the {@link CarDrivingStateEventListener}. Should be set before calling {@link
+ * #connectToCarService()}.
+ */
+ public void setCarDrivingStateEventListener(
+ @NonNull CarDrivingStateEventListener carDrivingStateEventListener) {
+ mDrivingStateHandler = carDrivingStateEventListener;
}
/**
@@ -64,25 +76,22 @@
* Establishes connection with the Car service.
*/
public void connectToCarService() {
- mCar = Car.createCar(mContext, /* handler= */ null, Car.CAR_WAIT_TIMEOUT_DO_NOT_WAIT,
- mCarServiceLifecycleListener);
+ mCarServiceProvider.addListener(mCarServiceLifecycleListener);
}
- private final CarServiceLifecycleListener mCarServiceLifecycleListener = (car, ready) -> {
- if (!ready) {
- return;
- }
- logD("Car Service connected");
- mDrivingStateManager = (CarDrivingStateManager) car.getCarManager(
- Car.CAR_DRIVING_STATE_SERVICE);
- if (mDrivingStateManager != null) {
- mDrivingStateManager.registerListener(mDrivingStateHandler);
- mDrivingStateHandler.onDrivingStateChanged(
- mDrivingStateManager.getCurrentCarDrivingState());
- } else {
- Log.e(TAG, "CarDrivingStateService service not available");
- }
- };
+ private final CarServiceProvider.CarServiceOnConnectedListener mCarServiceLifecycleListener =
+ car -> {
+ logD("Car Service connected");
+ mDrivingStateManager = (CarDrivingStateManager) car.getCarManager(
+ Car.CAR_DRIVING_STATE_SERVICE);
+ if (mDrivingStateManager != null) {
+ mDrivingStateManager.registerListener(mDrivingStateHandler);
+ mDrivingStateHandler.onDrivingStateChanged(
+ mDrivingStateManager.getCurrentCarDrivingState());
+ } else {
+ Log.e(TAG, "CarDrivingStateService service not available");
+ }
+ };
private void logD(String message) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
index 31aced0..b188dc3 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
@@ -26,6 +26,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.UserInfo;
+import android.content.res.Resources;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
@@ -35,24 +36,34 @@
import androidx.recyclerview.widget.GridLayoutManager;
import com.android.systemui.R;
+import com.android.systemui.car.CarServiceProvider;
+import com.android.systemui.dagger.qualifiers.MainResources;
import com.android.systemui.statusbar.car.CarTrustAgentUnlockDialogHelper.OnHideListener;
import com.android.systemui.statusbar.car.UserGridRecyclerView.UserRecord;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
* Manages the fullscreen user switcher.
*/
+@Singleton
public class FullscreenUserSwitcher {
private static final String TAG = FullscreenUserSwitcher.class.getSimpleName();
// Because user 0 is headless, user count for single user is 2
private static final int NUMBER_OF_BACKGROUND_USERS = 1;
- private final UserGridRecyclerView mUserGridView;
- private final View mParent;
- private final int mShortAnimDuration;
- private final CarStatusBar mStatusBar;
+
private final Context mContext;
+ private final Resources mResources;
private final UserManager mUserManager;
+ private final CarServiceProvider mCarServiceProvider;
+ private final CarTrustAgentUnlockDialogHelper mUnlockDialogHelper;
+ private final int mShortAnimDuration;
+
+ private CarStatusBar mStatusBar;
+ private View mParent;
+ private UserGridRecyclerView mUserGridView;
private CarTrustAgentEnrollmentManager mEnrollmentManager;
- private CarTrustAgentUnlockDialogHelper mUnlockDialogHelper;
private UserGridRecyclerView.UserRecord mSelectedUser;
private CarUserManagerHelper mCarUserManagerHelper;
private final BroadcastReceiver mUserUnlockReceiver = new BroadcastReceiver() {
@@ -65,37 +76,46 @@
mContext.unregisterReceiver(mUserUnlockReceiver);
}
};
- private final Car mCar;
- public FullscreenUserSwitcher(CarStatusBar statusBar, ViewStub containerStub, Context context) {
- mStatusBar = statusBar;
- mParent = containerStub.inflate();
+ @Inject
+ public FullscreenUserSwitcher(
+ Context context,
+ @MainResources Resources resources,
+ UserManager userManager,
+ CarServiceProvider carServiceProvider,
+ CarTrustAgentUnlockDialogHelper carTrustAgentUnlockDialogHelper) {
mContext = context;
+ mResources = resources;
+ mUserManager = userManager;
+ mCarServiceProvider = carServiceProvider;
+ mUnlockDialogHelper = carTrustAgentUnlockDialogHelper;
+
+ mShortAnimDuration = mResources.getInteger(android.R.integer.config_shortAnimTime);
+ }
+
+ /** Sets the status bar which controls the keyguard. */
+ public void setStatusBar(CarStatusBar statusBar) {
+ mStatusBar = statusBar;
+ }
+
+ /** Sets the {@link ViewStub} to show the user switcher. */
+ public void setContainer(ViewStub containerStub) {
+ mParent = containerStub.inflate();
View container = mParent.findViewById(R.id.container);
// Initialize user grid.
mUserGridView = container.findViewById(R.id.user_grid);
- GridLayoutManager layoutManager = new GridLayoutManager(context,
- context.getResources().getInteger(R.integer.user_fullscreen_switcher_num_col));
+ GridLayoutManager layoutManager = new GridLayoutManager(mContext,
+ mResources.getInteger(R.integer.user_fullscreen_switcher_num_col));
mUserGridView.setLayoutManager(layoutManager);
mUserGridView.buildAdapter();
mUserGridView.setUserSelectionListener(this::onUserSelected);
- mCarUserManagerHelper = new CarUserManagerHelper(context);
- mUnlockDialogHelper = new CarTrustAgentUnlockDialogHelper(mContext);
- mUserManager = mContext.getSystemService(UserManager.class);
+ mCarUserManagerHelper = new CarUserManagerHelper(mContext);
+ mCarServiceProvider.addListener(
+ car -> mEnrollmentManager = (CarTrustAgentEnrollmentManager) car.getCarManager(
+ Car.CAR_TRUST_AGENT_ENROLLMENT_SERVICE));
- mCar = Car.createCar(mContext, /* handler= */ null, Car.CAR_WAIT_TIMEOUT_DO_NOT_WAIT,
- (car, ready) -> {
- if (!ready) {
- return;
- }
- mEnrollmentManager = (CarTrustAgentEnrollmentManager) car
- .getCarManager(Car.CAR_TRUST_AGENT_ENROLLMENT_SERVICE);
- });
-
- mShortAnimDuration = container.getResources()
- .getInteger(android.R.integer.config_shortAnimTime);
IntentFilter filter = new IntentFilter(Intent.ACTION_USER_UNLOCKED);
if (mUserManager.isUserUnlocked(UserHandle.USER_SYSTEM)) {
// User0 is unlocked, switched to the initial user
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/PowerManagerHelper.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/PowerManagerHelper.java
index a27dd34..71847bb 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/PowerManagerHelper.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/PowerManagerHelper.java
@@ -18,33 +18,33 @@
import android.annotation.NonNull;
import android.car.Car;
-import android.car.Car.CarServiceLifecycleListener;
import android.car.hardware.power.CarPowerManager;
import android.car.hardware.power.CarPowerManager.CarPowerStateListener;
-import android.content.Context;
import android.util.Log;
+import com.android.systemui.car.CarServiceProvider;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
* Helper class for connecting to the {@link CarPowerManager} and listening for power state changes.
*/
+@Singleton
public class PowerManagerHelper {
public static final String TAG = "PowerManagerHelper";
- private final Context mContext;
- private final CarPowerStateListener mCarPowerStateListener;
+ private final CarServiceProvider mCarServiceProvider;
- private Car mCar;
private CarPowerManager mCarPowerManager;
+ private CarPowerStateListener mCarPowerStateListener;
- private final CarServiceLifecycleListener mCarServiceLifecycleListener;
+ private final CarServiceProvider.CarServiceOnConnectedListener mCarServiceLifecycleListener;
- PowerManagerHelper(Context context, @NonNull CarPowerStateListener listener) {
- mContext = context;
- mCarPowerStateListener = listener;
- mCarServiceLifecycleListener = (car, ready) -> {
- if (!ready) {
- return;
- }
+ @Inject
+ PowerManagerHelper(CarServiceProvider carServiceProvider) {
+ mCarServiceProvider = carServiceProvider;
+ mCarServiceLifecycleListener = car -> {
Log.d(TAG, "Car Service connected");
mCarPowerManager = (CarPowerManager) car.getCarManager(Car.POWER_SERVICE);
if (mCarPowerManager != null) {
@@ -56,10 +56,16 @@
}
/**
+ * Sets a {@link CarPowerStateListener}. Should be set before {@link #connectToCarService()}.
+ */
+ void setCarPowerStateListener(@NonNull CarPowerStateListener listener) {
+ mCarPowerStateListener = listener;
+ }
+
+ /**
* Connect to Car service.
*/
void connectToCarService() {
- mCar = Car.createCar(mContext, /* handler= */ null, Car.CAR_WAIT_TIMEOUT_DO_NOT_WAIT,
- mCarServiceLifecycleListener);
+ mCarServiceProvider.addListener(mCarServiceLifecycleListener);
}
}
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/hvac/AnimatedTemperatureView.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/hvac/AnimatedTemperatureView.java
index 76126fc..908aaad 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/hvac/AnimatedTemperatureView.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/hvac/AnimatedTemperatureView.java
@@ -35,7 +35,7 @@
import android.widget.TextView;
import com.android.systemui.R;
-import com.android.systemui.statusbar.car.hvac.TemperatureView;
+import com.android.systemui.navigationbar.car.hvac.TemperatureView;
/**
* Simple text display of HVAC properties, It is designed to show mTemperature and is configured in
diff --git a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogComponent.java b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogComponent.java
index 9d39684..5a34436 100644
--- a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogComponent.java
+++ b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogComponent.java
@@ -18,6 +18,7 @@
import android.content.Context;
+import com.android.systemui.car.CarServiceProvider;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.plugins.VolumeDialog;
@@ -30,13 +31,20 @@
@Singleton
public class CarVolumeDialogComponent extends VolumeDialogComponent {
+ private CarVolumeDialogImpl mCarVolumeDialog;
+
@Inject
public CarVolumeDialogComponent(Context context, KeyguardViewMediator keyguardViewMediator,
- VolumeDialogControllerImpl volumeDialogController) {
+ VolumeDialogControllerImpl volumeDialogController,
+ CarServiceProvider carServiceProvider) {
super(context, keyguardViewMediator, volumeDialogController);
+ mCarVolumeDialog.setCarServiceProvider(carServiceProvider);
}
+ /** This method is called while calling the super constructor. */
+ @Override
protected VolumeDialog createDefault() {
- return new CarVolumeDialogImpl(mContext);
+ mCarVolumeDialog = new CarVolumeDialogImpl(mContext);
+ return mCarVolumeDialog;
}
}
diff --git a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
index 09223e8..367959e 100644
--- a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
+++ b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
@@ -24,7 +24,6 @@
import android.app.Dialog;
import android.app.KeyguardManager;
import android.car.Car;
-import android.car.Car.CarServiceLifecycleListener;
import android.car.media.CarAudioManager;
import android.content.Context;
import android.content.DialogInterface;
@@ -56,6 +55,7 @@
import androidx.recyclerview.widget.RecyclerView;
import com.android.systemui.R;
+import com.android.systemui.car.CarServiceProvider;
import com.android.systemui.plugins.VolumeDialog;
import org.xmlpull.v1.XmlPullParserException;
@@ -95,7 +95,6 @@
private CustomDialog mDialog;
private RecyclerView mListView;
private CarVolumeItemAdapter mVolumeItemsAdapter;
- private Car mCar;
private CarAudioManager mCarAudioManager;
private boolean mHovering;
private int mCurrentlyDisplayingGroupId;
@@ -147,30 +146,28 @@
}
};
- private final CarServiceLifecycleListener mCarServiceLifecycleListener = (car, ready) -> {
- if (!ready) {
- return;
- }
- mExpanded = false;
- mCarAudioManager = (CarAudioManager) car.getCarManager(Car.AUDIO_SERVICE);
- int volumeGroupCount = mCarAudioManager.getVolumeGroupCount();
- // Populates volume slider items from volume groups to UI.
- for (int groupId = 0; groupId < volumeGroupCount; groupId++) {
- VolumeItem volumeItem = getVolumeItemForUsages(
- mCarAudioManager.getUsagesForVolumeGroupId(groupId));
- mAvailableVolumeItems.add(volumeItem);
- // The first one is the default item.
- if (groupId == 0) {
- clearAllAndSetupDefaultCarVolumeLineItem(0);
- }
- }
+ private final CarServiceProvider.CarServiceOnConnectedListener mCarServiceOnConnectedListener =
+ car -> {
+ mExpanded = false;
+ mCarAudioManager = (CarAudioManager) car.getCarManager(Car.AUDIO_SERVICE);
+ int volumeGroupCount = mCarAudioManager.getVolumeGroupCount();
+ // Populates volume slider items from volume groups to UI.
+ for (int groupId = 0; groupId < volumeGroupCount; groupId++) {
+ VolumeItem volumeItem = getVolumeItemForUsages(
+ mCarAudioManager.getUsagesForVolumeGroupId(groupId));
+ mAvailableVolumeItems.add(volumeItem);
+ // The first one is the default item.
+ if (groupId == 0) {
+ clearAllAndSetupDefaultCarVolumeLineItem(0);
+ }
+ }
- // If list is already initiated, update its content.
- if (mVolumeItemsAdapter != null) {
- mVolumeItemsAdapter.notifyDataSetChanged();
- }
- mCarAudioManager.registerCarVolumeCallback(mVolumeChangeCallback);
- };
+ // If list is already initiated, update its content.
+ if (mVolumeItemsAdapter != null) {
+ mVolumeItemsAdapter.notifyDataSetChanged();
+ }
+ mCarAudioManager.registerCarVolumeCallback(mVolumeChangeCallback);
+ };
public CarVolumeDialogImpl(Context context) {
mContext = context;
@@ -181,6 +178,11 @@
R.integer.car_volume_dialog_display_hovering_timeout);
}
+ /** Sets a {@link CarServiceProvider} which connects to the audio service. */
+ public void setCarServiceProvider(CarServiceProvider carServiceProvider) {
+ carServiceProvider.addListener(mCarServiceOnConnectedListener);
+ }
+
private static int getSeekbarValue(CarAudioManager carAudioManager, int volumeGroupId) {
return carAudioManager.getGroupVolume(volumeGroupId);
}
@@ -196,8 +198,6 @@
@Override
public void init(int windowType, Callback callback) {
initDialog();
- mCar = Car.createCar(mContext, /* handler= */ null, Car.CAR_WAIT_TIMEOUT_DO_NOT_WAIT,
- mCarServiceLifecycleListener);
}
@Override
@@ -205,12 +205,6 @@
mHandler.removeCallbacksAndMessages(/* token= */ null);
cleanupAudioManager();
- // unregisterVolumeCallback is not being called when disconnect car, so we manually cleanup
- // audio manager beforehand.
- if (mCar != null) {
- mCar.disconnect();
- mCar = null;
- }
}
private void initDialog() {
diff --git a/packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationBarControllerTest.java b/packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationBarControllerTest.java
index 901d200..642b114 100644
--- a/packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationBarControllerTest.java
+++ b/packages/CarSystemUI/tests/src/com/android/systemui/navigationbar/car/CarNavigationBarControllerTest.java
@@ -31,8 +31,8 @@
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
+import com.android.systemui.navigationbar.car.hvac.HvacController;
import com.android.systemui.plugins.DarkIconDispatcher;
-import com.android.systemui.statusbar.car.hvac.HvacController;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import org.junit.Before;
@@ -41,8 +41,6 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import dagger.Lazy;
-
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
@SmallTest
@@ -50,17 +48,17 @@
private CarNavigationBarController mCarNavigationBar;
private NavigationBarViewFactory mNavigationBarViewFactory;
- private Lazy<HvacController> mHvacControllerLazy;
private TestableResources mTestableResources;
@Mock
+ private CarFacetButtonController mCarFacetButtonController;
+ @Mock
private HvacController mHvacController;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mNavigationBarViewFactory = new NavigationBarViewFactory(mContext);
- mHvacControllerLazy = () -> mHvacController;
mTestableResources = mContext.getOrCreateTestableResources();
// Needed to inflate top navigation bar.
@@ -71,7 +69,7 @@
@Test
public void testConnectToHvac_callsConnect() {
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
mCarNavigationBar.connectToHvac();
@@ -81,7 +79,7 @@
@Test
public void testRemoveAllFromHvac_callsRemoveAll() {
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
mCarNavigationBar.removeAllFromHvac();
@@ -92,7 +90,7 @@
public void testGetBottomWindow_bottomDisabled_returnsNull() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, false);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window = mCarNavigationBar.getBottomWindow();
@@ -103,7 +101,7 @@
public void testGetBottomWindow_bottomEnabled_returnsWindow() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window = mCarNavigationBar.getBottomWindow();
@@ -114,7 +112,7 @@
public void testGetBottomWindow_bottomEnabled_calledTwice_returnsSameWindow() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window1 = mCarNavigationBar.getBottomWindow();
ViewGroup window2 = mCarNavigationBar.getBottomWindow();
@@ -126,7 +124,7 @@
public void testGetLeftWindow_leftDisabled_returnsNull() {
mTestableResources.addOverride(R.bool.config_enableLeftNavigationBar, false);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window = mCarNavigationBar.getLeftWindow();
assertThat(window).isNull();
}
@@ -135,7 +133,7 @@
public void testGetLeftWindow_leftEnabled_returnsWindow() {
mTestableResources.addOverride(R.bool.config_enableLeftNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window = mCarNavigationBar.getLeftWindow();
@@ -146,7 +144,7 @@
public void testGetLeftWindow_leftEnabled_calledTwice_returnsSameWindow() {
mTestableResources.addOverride(R.bool.config_enableLeftNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window1 = mCarNavigationBar.getLeftWindow();
ViewGroup window2 = mCarNavigationBar.getLeftWindow();
@@ -158,7 +156,7 @@
public void testGetRightWindow_rightDisabled_returnsNull() {
mTestableResources.addOverride(R.bool.config_enableRightNavigationBar, false);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window = mCarNavigationBar.getRightWindow();
@@ -169,7 +167,7 @@
public void testGetRightWindow_rightEnabled_returnsWindow() {
mTestableResources.addOverride(R.bool.config_enableRightNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window = mCarNavigationBar.getRightWindow();
@@ -180,7 +178,7 @@
public void testGetRightWindow_rightEnabled_calledTwice_returnsSameWindow() {
mTestableResources.addOverride(R.bool.config_enableRightNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window1 = mCarNavigationBar.getRightWindow();
ViewGroup window2 = mCarNavigationBar.getRightWindow();
@@ -192,7 +190,7 @@
public void testSetBottomWindowVisibility_setTrue_isVisible() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window = mCarNavigationBar.getBottomWindow();
mCarNavigationBar.setBottomWindowVisibility(View.VISIBLE);
@@ -204,7 +202,7 @@
public void testSetBottomWindowVisibility_setFalse_isGone() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window = mCarNavigationBar.getBottomWindow();
mCarNavigationBar.setBottomWindowVisibility(View.GONE);
@@ -216,7 +214,7 @@
public void testSetLeftWindowVisibility_setTrue_isVisible() {
mTestableResources.addOverride(R.bool.config_enableLeftNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window = mCarNavigationBar.getLeftWindow();
mCarNavigationBar.setLeftWindowVisibility(View.VISIBLE);
@@ -228,7 +226,7 @@
public void testSetLeftWindowVisibility_setFalse_isGone() {
mTestableResources.addOverride(R.bool.config_enableLeftNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window = mCarNavigationBar.getLeftWindow();
mCarNavigationBar.setLeftWindowVisibility(View.GONE);
@@ -240,7 +238,7 @@
public void testSetRightWindowVisibility_setTrue_isVisible() {
mTestableResources.addOverride(R.bool.config_enableRightNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window = mCarNavigationBar.getRightWindow();
mCarNavigationBar.setRightWindowVisibility(View.VISIBLE);
@@ -252,7 +250,7 @@
public void testSetRightWindowVisibility_setFalse_isGone() {
mTestableResources.addOverride(R.bool.config_enableRightNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
ViewGroup window = mCarNavigationBar.getRightWindow();
mCarNavigationBar.setRightWindowVisibility(View.GONE);
@@ -264,7 +262,7 @@
public void testRegisterBottomBarTouchListener_createViewFirst_registrationSuccessful() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
CarNavigationBarView bottomBar = mCarNavigationBar.getBottomBar(/* isSetUp= */ true);
View.OnTouchListener controller = bottomBar.getStatusBarWindowTouchListener();
@@ -279,7 +277,7 @@
public void testRegisterBottomBarTouchListener_registerFirst_registrationSuccessful() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
mCarNavigationBar.registerBottomBarTouchListener(mock(View.OnTouchListener.class));
CarNavigationBarView bottomBar = mCarNavigationBar.getBottomBar(/* isSetUp= */ true);
@@ -292,7 +290,7 @@
public void testRegisterNotificationController_createViewFirst_registrationSuccessful() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
CarNavigationBarView bottomBar = mCarNavigationBar.getBottomBar(/* isSetUp= */ true);
CarNavigationBarController.NotificationsShadeController controller =
@@ -309,7 +307,7 @@
public void testRegisterNotificationController_registerFirst_registrationSuccessful() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
mCarNavigationBar.registerNotificationController(
mock(CarNavigationBarController.NotificationsShadeController.class));
@@ -324,7 +322,7 @@
public void testShowAllKeyguardButtons_bottomEnabled_bottomKeyguardButtonsVisible() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
CarNavigationBarView bottomBar = mCarNavigationBar.getBottomBar(/* isSetUp= */ true);
View bottomKeyguardButtons = bottomBar.findViewById(R.id.lock_screen_nav_buttons);
@@ -337,7 +335,7 @@
public void testShowAllKeyguardButtons_bottomEnabled_bottomNavButtonsGone() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
CarNavigationBarView bottomBar = mCarNavigationBar.getBottomBar(/* isSetUp= */ true);
View bottomButtons = bottomBar.findViewById(R.id.nav_buttons);
@@ -350,7 +348,7 @@
public void testHideAllKeyguardButtons_bottomEnabled_bottomKeyguardButtonsGone() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
CarNavigationBarView bottomBar = mCarNavigationBar.getBottomBar(/* isSetUp= */ true);
View bottomKeyguardButtons = bottomBar.findViewById(R.id.lock_screen_nav_buttons);
@@ -365,7 +363,7 @@
public void testHideAllKeyguardButtons_bottomEnabled_bottomNavButtonsVisible() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
CarNavigationBarView bottomBar = mCarNavigationBar.getBottomBar(/* isSetUp= */ true);
View bottomButtons = bottomBar.findViewById(R.id.nav_buttons);
@@ -380,7 +378,7 @@
public void testToggleAllNotificationsUnseenIndicator_bottomEnabled_hasUnseen_setCorrectly() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
CarNavigationBarView bottomBar = mCarNavigationBar.getBottomBar(/* isSetUp= */ true);
CarNavigationButton notifications = bottomBar.findViewById(R.id.notifications);
@@ -395,7 +393,7 @@
public void testToggleAllNotificationsUnseenIndicator_bottomEnabled_noUnseen_setCorrectly() {
mTestableResources.addOverride(R.bool.config_enableBottomNavigationBar, true);
mCarNavigationBar = new CarNavigationBarController(mContext, mNavigationBarViewFactory,
- mHvacControllerLazy);
+ () -> mCarFacetButtonController, () -> mHvacController);
CarNavigationBarView bottomBar = mCarNavigationBar.getBottomBar(/* isSetUp= */ true);
CarNavigationButton notifications = bottomBar.findViewById(R.id.notifications);