Loading packages/CarSystemUI/src/com/android/systemui/car/CarServiceProvider.java 0 → 100644 +71 −0 Original line number Diff line number Diff line /* * 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); } } packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java +50 −39 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import com.android.systemui.dagger.qualifiers.MainHandler; 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; Loading @@ -54,10 +55,12 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks 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; Loading @@ -67,10 +70,12 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks 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; Loading @@ -84,19 +89,23 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks 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 Loading Loading @@ -137,7 +146,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks createNavigationBar(result); mActivityManagerWrapper = ActivityManagerWrapper.getInstance(); mActivityManagerWrapper.registerTaskStackListener(mFacetButtonTaskStackListener.get()); mActivityManagerWrapper.registerTaskStackListener(mFacetButtonTaskStackListenerLazy.get()); mCarNavigationBarController.connectToHvac(); } Loading @@ -158,10 +167,16 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks // 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) { Loading @@ -177,8 +192,8 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks buildNavBarContent(); // If the UI was rebuilt (day/night change) while the keyguard was up we need to // correctly respect that state. if (mKeyguardStateController.get().isShowing()) { updateNavBarForKeyguardContent(); if (mKeyguardStateControllerLazy.get().isShowing()) { mCarNavigationBarController.showAllKeyguardButtons(mDeviceIsSetUpForUser); } } Loading @@ -196,20 +211,28 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks // 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); Loading @@ -224,7 +247,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks } private void attachNavBarWindows() { if (mNavigationBarWindow != null && !mBottomNavBarVisible) { if (mBottomNavigationBarWindow != null && !mBottomNavBarVisible) { mBottomNavBarVisible = true; WindowManager.LayoutParams lp = new WindowManager.LayoutParams( Loading @@ -237,7 +260,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks PixelFormat.TRANSLUCENT); lp.setTitle("CarNavigationBar"); lp.windowAnimations = 0; mWindowManager.addView(mNavigationBarWindow, lp); mWindowManager.addView(mBottomNavigationBarWindow, lp); } if (mLeftNavigationBarWindow != null) { Loading Loading @@ -297,23 +320,11 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks 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); } } packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBarController.java +16 −25 Original line number Diff line number Diff line Loading @@ -24,8 +24,7 @@ import androidx.annotation.NonNull; 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; Loading @@ -38,6 +37,7 @@ public class CarNavigationBarController { private final Context mContext; private final NavigationBarViewFactory mNavigationBarViewFactory; private final Lazy<CarFacetButtonController> mCarFacetButtonControllerLazy; private final Lazy<HvacController> mHvacControllerLazy; private boolean mShowBottom; Loading @@ -58,9 +58,11 @@ public class CarNavigationBarController { @Inject public CarNavigationBarController(Context context, NavigationBarViewFactory navigationBarViewFactory, Lazy<CarFacetButtonController> carFacetButtonControllerLazy, Lazy<HvacController> hvacControllerLazy) { mContext = context; mNavigationBarViewFactory = navigationBarViewFactory; mCarFacetButtonControllerLazy = carFacetButtonControllerLazy; mHvacControllerLazy = hvacControllerLazy; // Read configuration. Loading Loading @@ -129,9 +131,7 @@ public class CarNavigationBarController { @NonNull public CarNavigationBarView getTopBar(boolean isSetUp) { mTopView = mNavigationBarViewFactory.getTopBar(isSetUp); mTopView.setStatusBarWindowTouchListener(mTopBarTouchListener); mTopView.setNotificationsPanelController(mNotificationsShadeController); addTemperatureViewToController(mTopView); setupBar(mTopView, mTopBarTouchListener, mNotificationsShadeController); return mTopView; } Loading @@ -143,9 +143,7 @@ public class CarNavigationBarController { } mBottomView = mNavigationBarViewFactory.getBottomBar(isSetUp); mBottomView.setStatusBarWindowTouchListener(mBottomBarTouchListener); mBottomView.setNotificationsPanelController(mNotificationsShadeController); addTemperatureViewToController(mBottomView); setupBar(mBottomView, mBottomBarTouchListener, mNotificationsShadeController); return mBottomView; } Loading @@ -157,9 +155,7 @@ public class CarNavigationBarController { } mLeftView = mNavigationBarViewFactory.getLeftBar(isSetUp); mLeftView.setStatusBarWindowTouchListener(mLeftBarTouchListener); mLeftView.setNotificationsPanelController(mNotificationsShadeController); addTemperatureViewToController(mLeftView); setupBar(mLeftView, mLeftBarTouchListener, mNotificationsShadeController); return mLeftView; } Loading @@ -171,12 +167,18 @@ public class CarNavigationBarController { } 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; Loading Loading @@ -290,17 +292,6 @@ public class CarNavigationBarController { 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); Loading packages/CarSystemUI/src/com/android/systemui/statusbar/car/hvac/HvacController.java→packages/CarSystemUI/src/com/android/systemui/navigationbar/car/hvac/HvacController.java +38 −27 Original line number Diff line number Diff line /* * 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. Loading @@ -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; Loading @@ -37,19 +38,18 @@ import java.util.Map; 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<>(); Loading Loading @@ -85,10 +85,8 @@ public class HvacController { } }; private final CarServiceLifecycleListener mCarServiceLifecycleListener = (car, ready) -> { if (!ready) { return; } private final CarServiceProvider.CarServiceOnConnectedListener mCarServiceLifecycleListener = car -> { try { mHvacManager = (CarHvacManager) car.getCarManager(Car.HVAC_SERVICE); mHvacManager.registerCallback(mHardwareCallback); Loading @@ -99,8 +97,8 @@ public class HvacController { }; @Inject public HvacController(Context context) { mContext = context; public HvacController(CarServiceProvider carServiceProvider) { mCarServiceProvider = carServiceProvider; } /** Loading @@ -108,9 +106,7 @@ public class HvacController { * ({@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); } /** Loading Loading @@ -171,6 +167,21 @@ public class HvacController { mTempComponents.clear(); } /** * 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 */ Loading packages/CarSystemUI/src/com/android/systemui/statusbar/car/hvac/TemperatureTextView.java→packages/CarSystemUI/src/com/android/systemui/navigationbar/car/hvac/TemperatureTextView.java +2 −2 Original line number Diff line number Diff line /* * 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. Loading @@ -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; Loading Loading
packages/CarSystemUI/src/com/android/systemui/car/CarServiceProvider.java 0 → 100644 +71 −0 Original line number Diff line number Diff line /* * 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); } }
packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java +50 −39 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import com.android.systemui.dagger.qualifiers.MainHandler; 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; Loading @@ -54,10 +55,12 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks 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; Loading @@ -67,10 +70,12 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks 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; Loading @@ -84,19 +89,23 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks 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 Loading Loading @@ -137,7 +146,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks createNavigationBar(result); mActivityManagerWrapper = ActivityManagerWrapper.getInstance(); mActivityManagerWrapper.registerTaskStackListener(mFacetButtonTaskStackListener.get()); mActivityManagerWrapper.registerTaskStackListener(mFacetButtonTaskStackListenerLazy.get()); mCarNavigationBarController.connectToHvac(); } Loading @@ -158,10 +167,16 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks // 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) { Loading @@ -177,8 +192,8 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks buildNavBarContent(); // If the UI was rebuilt (day/night change) while the keyguard was up we need to // correctly respect that state. if (mKeyguardStateController.get().isShowing()) { updateNavBarForKeyguardContent(); if (mKeyguardStateControllerLazy.get().isShowing()) { mCarNavigationBarController.showAllKeyguardButtons(mDeviceIsSetUpForUser); } } Loading @@ -196,20 +211,28 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks // 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); Loading @@ -224,7 +247,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks } private void attachNavBarWindows() { if (mNavigationBarWindow != null && !mBottomNavBarVisible) { if (mBottomNavigationBarWindow != null && !mBottomNavBarVisible) { mBottomNavBarVisible = true; WindowManager.LayoutParams lp = new WindowManager.LayoutParams( Loading @@ -237,7 +260,7 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks PixelFormat.TRANSLUCENT); lp.setTitle("CarNavigationBar"); lp.windowAnimations = 0; mWindowManager.addView(mNavigationBarWindow, lp); mWindowManager.addView(mBottomNavigationBarWindow, lp); } if (mLeftNavigationBarWindow != null) { Loading Loading @@ -297,23 +320,11 @@ public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks 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); } }
packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBarController.java +16 −25 Original line number Diff line number Diff line Loading @@ -24,8 +24,7 @@ import androidx.annotation.NonNull; 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; Loading @@ -38,6 +37,7 @@ public class CarNavigationBarController { private final Context mContext; private final NavigationBarViewFactory mNavigationBarViewFactory; private final Lazy<CarFacetButtonController> mCarFacetButtonControllerLazy; private final Lazy<HvacController> mHvacControllerLazy; private boolean mShowBottom; Loading @@ -58,9 +58,11 @@ public class CarNavigationBarController { @Inject public CarNavigationBarController(Context context, NavigationBarViewFactory navigationBarViewFactory, Lazy<CarFacetButtonController> carFacetButtonControllerLazy, Lazy<HvacController> hvacControllerLazy) { mContext = context; mNavigationBarViewFactory = navigationBarViewFactory; mCarFacetButtonControllerLazy = carFacetButtonControllerLazy; mHvacControllerLazy = hvacControllerLazy; // Read configuration. Loading Loading @@ -129,9 +131,7 @@ public class CarNavigationBarController { @NonNull public CarNavigationBarView getTopBar(boolean isSetUp) { mTopView = mNavigationBarViewFactory.getTopBar(isSetUp); mTopView.setStatusBarWindowTouchListener(mTopBarTouchListener); mTopView.setNotificationsPanelController(mNotificationsShadeController); addTemperatureViewToController(mTopView); setupBar(mTopView, mTopBarTouchListener, mNotificationsShadeController); return mTopView; } Loading @@ -143,9 +143,7 @@ public class CarNavigationBarController { } mBottomView = mNavigationBarViewFactory.getBottomBar(isSetUp); mBottomView.setStatusBarWindowTouchListener(mBottomBarTouchListener); mBottomView.setNotificationsPanelController(mNotificationsShadeController); addTemperatureViewToController(mBottomView); setupBar(mBottomView, mBottomBarTouchListener, mNotificationsShadeController); return mBottomView; } Loading @@ -157,9 +155,7 @@ public class CarNavigationBarController { } mLeftView = mNavigationBarViewFactory.getLeftBar(isSetUp); mLeftView.setStatusBarWindowTouchListener(mLeftBarTouchListener); mLeftView.setNotificationsPanelController(mNotificationsShadeController); addTemperatureViewToController(mLeftView); setupBar(mLeftView, mLeftBarTouchListener, mNotificationsShadeController); return mLeftView; } Loading @@ -171,12 +167,18 @@ public class CarNavigationBarController { } 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; Loading Loading @@ -290,17 +292,6 @@ public class CarNavigationBarController { 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); Loading
packages/CarSystemUI/src/com/android/systemui/statusbar/car/hvac/HvacController.java→packages/CarSystemUI/src/com/android/systemui/navigationbar/car/hvac/HvacController.java +38 −27 Original line number Diff line number Diff line /* * 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. Loading @@ -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; Loading @@ -37,19 +38,18 @@ import java.util.Map; 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<>(); Loading Loading @@ -85,10 +85,8 @@ public class HvacController { } }; private final CarServiceLifecycleListener mCarServiceLifecycleListener = (car, ready) -> { if (!ready) { return; } private final CarServiceProvider.CarServiceOnConnectedListener mCarServiceLifecycleListener = car -> { try { mHvacManager = (CarHvacManager) car.getCarManager(Car.HVAC_SERVICE); mHvacManager.registerCallback(mHardwareCallback); Loading @@ -99,8 +97,8 @@ public class HvacController { }; @Inject public HvacController(Context context) { mContext = context; public HvacController(CarServiceProvider carServiceProvider) { mCarServiceProvider = carServiceProvider; } /** Loading @@ -108,9 +106,7 @@ public class HvacController { * ({@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); } /** Loading Loading @@ -171,6 +167,21 @@ public class HvacController { mTempComponents.clear(); } /** * 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 */ Loading
packages/CarSystemUI/src/com/android/systemui/statusbar/car/hvac/TemperatureTextView.java→packages/CarSystemUI/src/com/android/systemui/navigationbar/car/hvac/TemperatureTextView.java +2 −2 Original line number Diff line number Diff line /* * 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. Loading @@ -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; Loading