Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 1 | /* |
Brad Stenning | 8d1a51c | 2018-11-20 17:34:16 -0800 | [diff] [blame] | 2 | * Copyright (C) 2018 The Android Open Source Project |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.statusbar.car; |
| 18 | |
Wale Ogunwale | 04d9cb5 | 2018-04-30 13:55:07 -0700 | [diff] [blame] | 19 | import android.app.ActivityTaskManager; |
jovanak | edba98c | 2018-09-14 15:46:24 -0700 | [diff] [blame] | 20 | import android.car.drivingstate.CarDrivingStateEvent; |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 21 | import android.graphics.PixelFormat; |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 22 | import android.graphics.drawable.Drawable; |
Rakesh Iyer | 74ebabe | 2016-03-11 10:10:43 -0800 | [diff] [blame] | 23 | import android.util.Log; |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 24 | import android.view.Gravity; |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 25 | import android.view.View; |
Anthony Chen | 0801a5c | 2017-03-22 09:54:37 -0700 | [diff] [blame] | 26 | import android.view.ViewGroup; |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 27 | import android.view.ViewGroup.LayoutParams; |
| 28 | import android.view.WindowManager; |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 29 | |
Winson Chung | 2db3557 | 2017-10-09 15:08:30 -0700 | [diff] [blame] | 30 | import com.android.keyguard.KeyguardUpdateMonitor; |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 31 | import com.android.systemui.BatteryMeterView; |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 32 | import com.android.systemui.CarSystemUIFactory; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 33 | import com.android.systemui.Dependency; |
Winson Chung | 2db3557 | 2017-10-09 15:08:30 -0700 | [diff] [blame] | 34 | import com.android.systemui.Prefs; |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 35 | import com.android.systemui.R; |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 36 | import com.android.systemui.SystemUIFactory; |
Winson Chung | 2db3557 | 2017-10-09 15:08:30 -0700 | [diff] [blame] | 37 | import com.android.systemui.classifier.FalsingLog; |
| 38 | import com.android.systemui.classifier.FalsingManager; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 39 | import com.android.systemui.fragments.FragmentHostManager; |
Brad Stenning | 19f236a | 2018-12-11 14:12:30 -0800 | [diff] [blame] | 40 | import com.android.systemui.notifications.NotificationsUI; |
Brad Stenning | 8d1a51c | 2018-11-20 17:34:16 -0800 | [diff] [blame] | 41 | import com.android.systemui.plugins.qs.QS; |
| 42 | import com.android.systemui.qs.car.CarQSFragment; |
Winson Chung | b05b398 | 2017-11-01 18:02:43 -0700 | [diff] [blame] | 43 | import com.android.systemui.shared.system.ActivityManagerWrapper; |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 44 | import com.android.systemui.shared.system.TaskStackChangeListener; |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 45 | import com.android.systemui.statusbar.StatusBarState; |
Brad Stenning | 38b46f8 | 2018-03-27 13:57:29 -0700 | [diff] [blame] | 46 | import com.android.systemui.statusbar.car.hvac.HvacController; |
Brad Stenning | f084d88 | 2018-08-08 13:34:21 -0700 | [diff] [blame] | 47 | import com.android.systemui.statusbar.car.hvac.TemperatureView; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 48 | import com.android.systemui.statusbar.phone.CollapsedStatusBarFragment; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 49 | import com.android.systemui.statusbar.phone.StatusBar; |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 50 | import com.android.systemui.statusbar.policy.BatteryController; |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 51 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 52 | import com.android.systemui.statusbar.policy.UserSwitcherController; |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 53 | |
Qiming Shi | b9dfb92 | 2017-04-13 16:23:18 +0800 | [diff] [blame] | 54 | import java.io.FileDescriptor; |
| 55 | import java.io.PrintWriter; |
| 56 | import java.util.Map; |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 57 | |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 58 | /** |
| 59 | * A status bar (and navigation bar) tailored for the automotive use case. |
| 60 | */ |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 61 | public class CarStatusBar extends StatusBar implements |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 62 | CarBatteryController.BatteryViewHandler { |
Rakesh Iyer | 74ebabe | 2016-03-11 10:10:43 -0800 | [diff] [blame] | 63 | private static final String TAG = "CarStatusBar"; |
| 64 | |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 65 | private TaskStackListenerImpl mTaskStackListener; |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 66 | |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 67 | private FullscreenUserSwitcher mFullscreenUserSwitcher; |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 68 | |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 69 | private CarBatteryController mCarBatteryController; |
| 70 | private BatteryMeterView mBatteryMeterView; |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 71 | private Drawable mNotificationPanelBackground; |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 72 | |
Anthony Chen | 1c59e9f | 2016-04-11 11:05:48 -0700 | [diff] [blame] | 73 | private ConnectedDeviceSignalController mConnectedDeviceSignalController; |
Scott Randolph | f408582 | 2017-06-27 15:23:01 -0700 | [diff] [blame] | 74 | private ViewGroup mNavigationBarWindow; |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 75 | private ViewGroup mLeftNavigationBarWindow; |
| 76 | private ViewGroup mRightNavigationBarWindow; |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 77 | private CarNavigationBarView mNavigationBarView; |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 78 | private CarNavigationBarView mLeftNavigationBarView; |
| 79 | private CarNavigationBarView mRightNavigationBarView; |
Anthony Chen | 1c59e9f | 2016-04-11 11:05:48 -0700 | [diff] [blame] | 80 | |
Qiming Shi | b9dfb92 | 2017-04-13 16:23:18 +0800 | [diff] [blame] | 81 | private final Object mQueueLock = new Object(); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 82 | private boolean mShowLeft; |
| 83 | private boolean mShowRight; |
| 84 | private boolean mShowBottom; |
| 85 | private CarFacetButtonController mCarFacetButtonController; |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 86 | private ActivityManagerWrapper mActivityManagerWrapper; |
| 87 | private DeviceProvisionedController mDeviceProvisionedController; |
| 88 | private boolean mDeviceIsProvisioned = true; |
Brad Stenning | f084d88 | 2018-08-08 13:34:21 -0700 | [diff] [blame] | 89 | private HvacController mHvacController; |
jovanak | edba98c | 2018-09-14 15:46:24 -0700 | [diff] [blame] | 90 | private DrivingStateHelper mDrivingStateHelper; |
| 91 | private SwitchToGuestTimer mSwitchToGuestTimer; |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 92 | |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 93 | @Override |
| 94 | public void start() { |
| 95 | super.start(); |
Jaewan Kim | 938a50b | 2016-03-14 17:35:43 +0900 | [diff] [blame] | 96 | mTaskStackListener = new TaskStackListenerImpl(); |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 97 | mActivityManagerWrapper = ActivityManagerWrapper.getInstance(); |
| 98 | mActivityManagerWrapper.registerTaskStackListener(mTaskStackListener); |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 99 | |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 100 | mNotificationPanel.setScrollingEnabled(true); |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 101 | |
Rakesh Iyer | 545e47d | 2017-01-23 18:10:21 -0800 | [diff] [blame] | 102 | createBatteryController(); |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 103 | mCarBatteryController.startListening(); |
Brad Stenning | 38b46f8 | 2018-03-27 13:57:29 -0700 | [diff] [blame] | 104 | |
Brad Stenning | f084d88 | 2018-08-08 13:34:21 -0700 | [diff] [blame] | 105 | mHvacController.connectToCarService(); |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 106 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 107 | CarSystemUIFactory factory = SystemUIFactory.getInstance(); |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 108 | mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class); |
| 109 | mDeviceIsProvisioned = mDeviceProvisionedController.isDeviceProvisioned(); |
| 110 | if (!mDeviceIsProvisioned) { |
| 111 | mDeviceProvisionedController.addCallback( |
| 112 | new DeviceProvisionedController.DeviceProvisionedListener() { |
| 113 | @Override |
| 114 | public void onDeviceProvisionedChanged() { |
Brad Stenning | a2d87d8 | 2019-01-24 12:33:10 -0800 | [diff] [blame] | 115 | mHandler.post(() -> { |
| 116 | // on initial boot we are getting a call even though the value |
| 117 | // is the same so we are confirming the reset is needed |
| 118 | boolean deviceProvisioned = |
| 119 | mDeviceProvisionedController.isDeviceProvisioned(); |
| 120 | if (mDeviceIsProvisioned != deviceProvisioned) { |
| 121 | mDeviceIsProvisioned = deviceProvisioned; |
| 122 | restartNavBars(); |
| 123 | } |
| 124 | }); |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 125 | } |
| 126 | }); |
| 127 | } |
jovanak | edba98c | 2018-09-14 15:46:24 -0700 | [diff] [blame] | 128 | |
| 129 | // Register a listener for driving state changes. |
| 130 | mDrivingStateHelper = new DrivingStateHelper(mContext, this::onDrivingStateChanged); |
| 131 | mDrivingStateHelper.connectToCarService(); |
| 132 | |
| 133 | mSwitchToGuestTimer = new SwitchToGuestTimer(mContext); |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 134 | } |
| 135 | |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 136 | /** |
| 137 | * Remove all content from navbars and rebuild them. Used to allow for different nav bars |
Guobin Zhang | eef0e0c | 2019-02-01 11:54:24 -0800 | [diff] [blame] | 138 | * before and after the device is provisioned. . Also for change of density and font size. |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 139 | */ |
| 140 | private void restartNavBars() { |
Brad Stenning | f084d88 | 2018-08-08 13:34:21 -0700 | [diff] [blame] | 141 | // remove and reattach all hvac components such that we don't keep a reference to unused |
| 142 | // ui elements |
| 143 | mHvacController.removeAllComponents(); |
| 144 | addTemperatureViewToController(mStatusBarWindow); |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 145 | mCarFacetButtonController.removeAll(); |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 146 | if (mNavigationBarWindow != null) { |
| 147 | mNavigationBarWindow.removeAllViews(); |
| 148 | mNavigationBarView = null; |
| 149 | } |
| 150 | |
| 151 | if (mLeftNavigationBarWindow != null) { |
| 152 | mLeftNavigationBarWindow.removeAllViews(); |
| 153 | mLeftNavigationBarView = null; |
| 154 | } |
| 155 | |
| 156 | if (mRightNavigationBarWindow != null) { |
| 157 | mRightNavigationBarWindow.removeAllViews(); |
| 158 | mRightNavigationBarView = null; |
| 159 | } |
Brad Stenning | f084d88 | 2018-08-08 13:34:21 -0700 | [diff] [blame] | 160 | |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 161 | buildNavBarContent(); |
| 162 | } |
| 163 | |
Brad Stenning | f084d88 | 2018-08-08 13:34:21 -0700 | [diff] [blame] | 164 | private void addTemperatureViewToController(View v) { |
| 165 | if (v instanceof TemperatureView) { |
| 166 | Log.d(TAG, "addTemperatureViewToController: found "); |
| 167 | mHvacController.addHvacTextView((TemperatureView) v); |
| 168 | } else if (v instanceof ViewGroup) { |
| 169 | ViewGroup viewGroup = (ViewGroup) v; |
| 170 | for (int i = 0; i < viewGroup.getChildCount(); i++) { |
| 171 | addTemperatureViewToController(viewGroup.getChildAt(i)); |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
Brad Stenning | 7e41181 | 2018-04-13 22:52:39 -0700 | [diff] [blame] | 176 | /** |
| 177 | * Allows for showing or hiding just the navigation bars. This is indented to be used when |
| 178 | * the full screen user selector is shown. |
| 179 | */ |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 180 | void setNavBarVisibility(@View.Visibility int visibility) { |
Brad Stenning | 7e41181 | 2018-04-13 22:52:39 -0700 | [diff] [blame] | 181 | if (mNavigationBarWindow != null) { |
| 182 | mNavigationBarWindow.setVisibility(visibility); |
| 183 | } |
| 184 | if (mLeftNavigationBarWindow != null) { |
| 185 | mLeftNavigationBarWindow.setVisibility(visibility); |
| 186 | } |
| 187 | if (mRightNavigationBarWindow != null) { |
| 188 | mRightNavigationBarWindow.setVisibility(visibility); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | |
| 193 | @Override |
| 194 | public boolean hideKeyguard() { |
| 195 | boolean result = super.hideKeyguard(); |
| 196 | if (mNavigationBarView != null) { |
| 197 | mNavigationBarView.hideKeyguardButtons(); |
| 198 | } |
| 199 | if (mLeftNavigationBarView != null) { |
| 200 | mLeftNavigationBarView.hideKeyguardButtons(); |
| 201 | } |
| 202 | if (mRightNavigationBarView != null) { |
| 203 | mRightNavigationBarView.hideKeyguardButtons(); |
| 204 | } |
| 205 | return result; |
| 206 | } |
| 207 | |
| 208 | |
| 209 | @Override |
| 210 | public void showKeyguard() { |
| 211 | super.showKeyguard(); |
Brad Stenning | c622f1d | 2019-01-29 11:24:11 -0800 | [diff] [blame] | 212 | getComponent(NotificationsUI.class).closeCarNotifications(0); |
Brad Stenning | 7e41181 | 2018-04-13 22:52:39 -0700 | [diff] [blame] | 213 | if (mNavigationBarView != null) { |
| 214 | mNavigationBarView.showKeyguardButtons(); |
| 215 | } |
| 216 | if (mLeftNavigationBarView != null) { |
| 217 | mLeftNavigationBarView.showKeyguardButtons(); |
| 218 | } |
| 219 | if (mRightNavigationBarView != null) { |
| 220 | mRightNavigationBarView.showKeyguardButtons(); |
| 221 | } |
| 222 | } |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 223 | |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 224 | |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 225 | @Override |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 226 | protected void makeStatusBarView() { |
| 227 | super.makeStatusBarView(); |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 228 | mHvacController = new HvacController(mContext); |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 229 | |
Guobin Zhang | eef0e0c | 2019-02-01 11:54:24 -0800 | [diff] [blame] | 230 | CarSystemUIFactory factory = SystemUIFactory.getInstance(); |
| 231 | mCarFacetButtonController = factory.getCarDependencyComponent() |
| 232 | .getCarFacetButtonController(); |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 233 | mNotificationPanelBackground = getDefaultWallpaper(); |
| 234 | mScrimController.setScrimBehindDrawable(mNotificationPanelBackground); |
| 235 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 236 | FragmentHostManager manager = FragmentHostManager.get(mStatusBarWindow); |
| 237 | manager.addTagListener(CollapsedStatusBarFragment.TAG, (tag, fragment) -> { |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 238 | mBatteryMeterView = fragment.getView().findViewById(R.id.battery); |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 239 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 240 | // By default, the BatteryMeterView should not be visible. It will be toggled |
| 241 | // when a device has connected by bluetooth. |
| 242 | mBatteryMeterView.setVisibility(View.GONE); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 243 | }); |
Brad Stenning | f084d88 | 2018-08-08 13:34:21 -0700 | [diff] [blame] | 244 | addTemperatureViewToController(mStatusBarWindow); |
Brad Stenning | c622f1d | 2019-01-29 11:24:11 -0800 | [diff] [blame] | 245 | // The following are the ui elements that the user would call the status bar. |
| 246 | // This will set the status bar so it they can make call backs. |
| 247 | CarNavigationBarView topBar = mStatusBarWindow.findViewById(R.id.car_top_bar); |
| 248 | topBar.setStatusBar(this); |
| 249 | CarNavigationBarView qsTopBar = mStatusBarWindow.findViewById(R.id.qs_car_top_bar); |
| 250 | qsTopBar.setStatusBar(this); |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 251 | } |
| 252 | |
Brad Stenning | 8d1a51c | 2018-11-20 17:34:16 -0800 | [diff] [blame] | 253 | @Override |
| 254 | protected QS createDefaultQSFragment() { |
| 255 | return new CarQSFragment(); |
| 256 | } |
| 257 | |
Rakesh Iyer | 545e47d | 2017-01-23 18:10:21 -0800 | [diff] [blame] | 258 | private BatteryController createBatteryController() { |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 259 | mCarBatteryController = new CarBatteryController(mContext); |
| 260 | mCarBatteryController.addBatteryViewHandler(this); |
| 261 | return mCarBatteryController; |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 262 | } |
| 263 | |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 264 | @Override |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 265 | protected void createNavigationBar() { |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 266 | mShowBottom = mContext.getResources().getBoolean(R.bool.config_enableBottomNavigationBar); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 267 | mShowLeft = mContext.getResources().getBoolean(R.bool.config_enableLeftNavigationBar); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 268 | mShowRight = mContext.getResources().getBoolean(R.bool.config_enableRightNavigationBar); |
| 269 | |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 270 | buildNavBarWindows(); |
| 271 | buildNavBarContent(); |
| 272 | attachNavBarWindows(); |
Andrii Kulian | 3ddd7de | 2018-10-10 00:33:19 -0700 | [diff] [blame] | 273 | |
Charles Chen | 10ca70b | 2018-11-28 00:03:38 +0800 | [diff] [blame] | 274 | // There has been a car customized nav bar on the default display, so just create nav bars |
| 275 | // on external displays. |
| 276 | mNavigationBarController.createNavigationBars(false /* includeDefaultDisplay */); |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | private void buildNavBarContent() { |
| 280 | if (mShowBottom) { |
| 281 | buildBottomBar((mDeviceIsProvisioned) ? R.layout.car_navigation_bar : |
| 282 | R.layout.car_navigation_bar_unprovisioned); |
| 283 | } |
| 284 | |
| 285 | if (mShowLeft) { |
| 286 | buildLeft((mDeviceIsProvisioned) ? R.layout.car_left_navigation_bar : |
| 287 | R.layout.car_left_navigation_bar_unprovisioned); |
| 288 | } |
| 289 | |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 290 | if (mShowRight) { |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 291 | buildRight((mDeviceIsProvisioned) ? R.layout.car_right_navigation_bar : |
| 292 | R.layout.car_right_navigation_bar_unprovisioned); |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | private void buildNavBarWindows() { |
| 297 | if (mShowBottom) { |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 298 | mNavigationBarWindow = (ViewGroup) View.inflate(mContext, |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 299 | R.layout.navigation_bar_window, null); |
| 300 | } |
| 301 | if (mShowLeft) { |
| 302 | mLeftNavigationBarWindow = (ViewGroup) View.inflate(mContext, |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 303 | R.layout.navigation_bar_window, null); |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 304 | } |
| 305 | if (mShowRight) { |
| 306 | mRightNavigationBarWindow = (ViewGroup) View.inflate(mContext, |
| 307 | R.layout.navigation_bar_window, null); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | } |
| 311 | |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 312 | private void attachNavBarWindows() { |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 313 | |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 314 | if (mShowBottom) { |
| 315 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 316 | LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, |
| 317 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR, |
| 318 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 319 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 320 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
| 321 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
| 322 | PixelFormat.TRANSLUCENT); |
| 323 | lp.setTitle("CarNavigationBar"); |
| 324 | lp.windowAnimations = 0; |
| 325 | mWindowManager.addView(mNavigationBarWindow, lp); |
Brad Stenning | c622f1d | 2019-01-29 11:24:11 -0800 | [diff] [blame] | 326 | mNavigationBarWindow.setOnTouchListener(getStatusBarWindowTouchListener()); |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 327 | } |
| 328 | if (mShowLeft) { |
| 329 | int width = mContext.getResources().getDimensionPixelSize( |
| 330 | R.dimen.car_left_navigation_bar_width); |
| 331 | WindowManager.LayoutParams leftlp = new WindowManager.LayoutParams( |
| 332 | width, LayoutParams.MATCH_PARENT, |
| 333 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, |
| 334 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 335 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 336 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
| 337 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
| 338 | PixelFormat.TRANSLUCENT); |
| 339 | leftlp.setTitle("LeftCarNavigationBar"); |
| 340 | leftlp.windowAnimations = 0; |
| 341 | leftlp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR; |
| 342 | leftlp.gravity = Gravity.LEFT; |
| 343 | mWindowManager.addView(mLeftNavigationBarWindow, leftlp); |
| 344 | } |
| 345 | if (mShowRight) { |
| 346 | int width = mContext.getResources().getDimensionPixelSize( |
| 347 | R.dimen.car_right_navigation_bar_width); |
| 348 | WindowManager.LayoutParams rightlp = new WindowManager.LayoutParams( |
| 349 | width, LayoutParams.MATCH_PARENT, |
| 350 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, |
| 351 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 352 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 353 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
| 354 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
| 355 | PixelFormat.TRANSLUCENT); |
| 356 | rightlp.setTitle("RightCarNavigationBar"); |
| 357 | rightlp.windowAnimations = 0; |
| 358 | rightlp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR; |
| 359 | rightlp.gravity = Gravity.RIGHT; |
| 360 | mWindowManager.addView(mRightNavigationBarWindow, rightlp); |
| 361 | } |
| 362 | |
| 363 | } |
| 364 | |
| 365 | private void buildBottomBar(int layout) { |
Anthony Chen | 0801a5c | 2017-03-22 09:54:37 -0700 | [diff] [blame] | 366 | // SystemUI requires that the navigation bar view have a parent. Since the regular |
| 367 | // StatusBar inflates navigation_bar_window as this parent view, use the same view for the |
| 368 | // CarNavigationBarView. |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 369 | View.inflate(mContext, layout, mNavigationBarWindow); |
Scott Randolph | f408582 | 2017-06-27 15:23:01 -0700 | [diff] [blame] | 370 | mNavigationBarView = (CarNavigationBarView) mNavigationBarWindow.getChildAt(0); |
| 371 | if (mNavigationBarView == null) { |
| 372 | Log.e(TAG, "CarStatusBar failed inflate for R.layout.car_navigation_bar"); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 373 | throw new RuntimeException("Unable to build botom nav bar due to missing layout"); |
Scott Randolph | f408582 | 2017-06-27 15:23:01 -0700 | [diff] [blame] | 374 | } |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 375 | mNavigationBarView.setStatusBar(this); |
Brad Stenning | f084d88 | 2018-08-08 13:34:21 -0700 | [diff] [blame] | 376 | addTemperatureViewToController(mNavigationBarView); |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 377 | } |
| 378 | |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 379 | private void buildLeft(int layout) { |
| 380 | View.inflate(mContext, layout, mLeftNavigationBarWindow); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 381 | mLeftNavigationBarView = (CarNavigationBarView) mLeftNavigationBarWindow.getChildAt(0); |
| 382 | if (mLeftNavigationBarView == null) { |
| 383 | Log.e(TAG, "CarStatusBar failed inflate for R.layout.car_navigation_bar"); |
| 384 | throw new RuntimeException("Unable to build left nav bar due to missing layout"); |
| 385 | } |
| 386 | mLeftNavigationBarView.setStatusBar(this); |
Brad Stenning | f084d88 | 2018-08-08 13:34:21 -0700 | [diff] [blame] | 387 | addTemperatureViewToController(mLeftNavigationBarView); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 391 | private void buildRight(int layout) { |
| 392 | View.inflate(mContext, layout, mRightNavigationBarWindow); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 393 | mRightNavigationBarView = (CarNavigationBarView) mRightNavigationBarWindow.getChildAt(0); |
| 394 | if (mRightNavigationBarView == null) { |
| 395 | Log.e(TAG, "CarStatusBar failed inflate for R.layout.car_navigation_bar"); |
| 396 | throw new RuntimeException("Unable to build right nav bar due to missing layout"); |
| 397 | } |
Brad Stenning | f084d88 | 2018-08-08 13:34:21 -0700 | [diff] [blame] | 398 | mRightNavigationBarView.setStatusBar(this); |
| 399 | addTemperatureViewToController(mRightNavigationBarView); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 400 | } |
| 401 | |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 402 | @Override |
Qiming Shi | b9dfb92 | 2017-04-13 16:23:18 +0800 | [diff] [blame] | 403 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 404 | //When executing dump() funciton simultaneously, we need to serialize them |
| 405 | //to get mStackScroller's position correctly. |
| 406 | synchronized (mQueueLock) { |
| 407 | pw.println(" mStackScroller: " + viewInfo(mStackScroller)); |
| 408 | pw.println(" mStackScroller: " + viewInfo(mStackScroller) |
| 409 | + " scroll " + mStackScroller.getScrollX() |
| 410 | + "," + mStackScroller.getScrollY()); |
| 411 | } |
| 412 | |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 413 | pw.print(" mTaskStackListener="); |
| 414 | pw.println(mTaskStackListener); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 415 | pw.print(" mCarFacetButtonController="); |
| 416 | pw.println(mCarFacetButtonController); |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 417 | pw.print(" mFullscreenUserSwitcher="); |
| 418 | pw.println(mFullscreenUserSwitcher); |
Qiming Shi | b9dfb92 | 2017-04-13 16:23:18 +0800 | [diff] [blame] | 419 | pw.print(" mCarBatteryController="); |
| 420 | pw.println(mCarBatteryController); |
| 421 | pw.print(" mBatteryMeterView="); |
| 422 | pw.println(mBatteryMeterView); |
| 423 | pw.print(" mConnectedDeviceSignalController="); |
| 424 | pw.println(mConnectedDeviceSignalController); |
| 425 | pw.print(" mNavigationBarView="); |
| 426 | pw.println(mNavigationBarView); |
| 427 | |
| 428 | if (KeyguardUpdateMonitor.getInstance(mContext) != null) { |
| 429 | KeyguardUpdateMonitor.getInstance(mContext).dump(fd, pw, args); |
| 430 | } |
| 431 | |
| 432 | FalsingManager.getInstance(mContext).dump(pw); |
| 433 | FalsingLog.dump(pw); |
| 434 | |
| 435 | pw.println("SharedPreferences:"); |
| 436 | for (Map.Entry<String, ?> entry : Prefs.getAll(mContext).entrySet()) { |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 437 | pw.print(" "); |
| 438 | pw.print(entry.getKey()); |
| 439 | pw.print("="); |
| 440 | pw.println(entry.getValue()); |
Qiming Shi | b9dfb92 | 2017-04-13 16:23:18 +0800 | [diff] [blame] | 441 | } |
| 442 | } |
| 443 | |
Scott Randolph | f408582 | 2017-06-27 15:23:01 -0700 | [diff] [blame] | 444 | @Override |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 445 | protected View.OnTouchListener getStatusBarWindowTouchListener() { |
Brad Stenning | c622f1d | 2019-01-29 11:24:11 -0800 | [diff] [blame] | 446 | // Gets the car specific notification touch listener |
| 447 | return getComponent(NotificationsUI.class).getDragDownListener(); |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 448 | } |
| 449 | |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 450 | @Override |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 451 | public void showBatteryView() { |
| 452 | if (Log.isLoggable(TAG, Log.DEBUG)) { |
| 453 | Log.d(TAG, "showBatteryView(). mBatteryMeterView: " + mBatteryMeterView); |
| 454 | } |
| 455 | |
| 456 | if (mBatteryMeterView != null) { |
| 457 | mBatteryMeterView.setVisibility(View.VISIBLE); |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | @Override |
| 462 | public void hideBatteryView() { |
| 463 | if (Log.isLoggable(TAG, Log.DEBUG)) { |
| 464 | Log.d(TAG, "hideBatteryView(). mBatteryMeterView: " + mBatteryMeterView); |
| 465 | } |
| 466 | |
| 467 | if (mBatteryMeterView != null) { |
| 468 | mBatteryMeterView.setVisibility(View.GONE); |
| 469 | } |
| 470 | } |
| 471 | |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 472 | /** |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 473 | * An implementation of TaskStackChangeListener, that listens for changes in the system |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 474 | * task stack and notifies the navigation bar. |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 475 | */ |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 476 | private class TaskStackListenerImpl extends TaskStackChangeListener { |
Wale Ogunwale | 480dca0 | 2016-02-06 13:58:29 -0800 | [diff] [blame] | 477 | @Override |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 478 | public void onTaskStackChanged() { |
Brad Stenning | a5e714c | 2018-04-12 19:23:39 -0700 | [diff] [blame] | 479 | try { |
| 480 | mCarFacetButtonController.taskChanged( |
Wale Ogunwale | 04d9cb5 | 2018-04-30 13:55:07 -0700 | [diff] [blame] | 481 | ActivityTaskManager.getService().getAllStackInfos()); |
Brad Stenning | a5e714c | 2018-04-12 19:23:39 -0700 | [diff] [blame] | 482 | } catch (Exception e) { |
| 483 | Log.e(TAG, "Getting StackInfo from activity manager failed", e); |
| 484 | } |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 485 | } |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 486 | } |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 487 | |
jovanak | edba98c | 2018-09-14 15:46:24 -0700 | [diff] [blame] | 488 | private void onDrivingStateChanged(CarDrivingStateEvent notUsed) { |
| 489 | // Check if we need to start the timer every time driving state changes. |
| 490 | startSwitchToGuestTimerIfDrivingOnKeyguard(); |
| 491 | } |
| 492 | |
| 493 | private void startSwitchToGuestTimerIfDrivingOnKeyguard() { |
| 494 | if (mDrivingStateHelper.isCurrentlyDriving() && mState != StatusBarState.SHADE) { |
| 495 | // We're driving while keyguard is up. |
| 496 | mSwitchToGuestTimer.start(); |
| 497 | } else { |
| 498 | mSwitchToGuestTimer.cancel(); |
| 499 | } |
| 500 | } |
| 501 | |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 502 | @Override |
| 503 | protected void createUserSwitcher() { |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 504 | UserSwitcherController userSwitcherController = |
| 505 | Dependency.get(UserSwitcherController.class); |
| 506 | if (userSwitcherController.useFullscreenUserSwitcher()) { |
| 507 | mFullscreenUserSwitcher = new FullscreenUserSwitcher(this, |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 508 | mStatusBarWindow.findViewById(R.id.fullscreen_user_switcher_stub), mContext); |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 509 | } else { |
| 510 | super.createUserSwitcher(); |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | @Override |
jovanak | 168dbdb | 2019-02-18 01:00:43 -0800 | [diff] [blame] | 515 | public void setLockscreenUser(int newUserId) { |
| 516 | super.setLockscreenUser(newUserId); |
| 517 | // Try to dismiss the keyguard after every user switch. |
| 518 | dismissKeyguardWhenUserSwitcherNotDisplayed(); |
| 519 | } |
| 520 | |
| 521 | @Override |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 522 | public void onStateChanged(int newState) { |
| 523 | super.onStateChanged(newState); |
jovanak | edba98c | 2018-09-14 15:46:24 -0700 | [diff] [blame] | 524 | |
| 525 | startSwitchToGuestTimerIfDrivingOnKeyguard(); |
| 526 | |
jovanak | 168dbdb | 2019-02-18 01:00:43 -0800 | [diff] [blame] | 527 | if (newState != StatusBarState.FULLSCREEN_USER_SWITCHER) { |
| 528 | hideUserSwitcher(); |
jovanak | 604ad51 | 2018-08-14 18:41:27 -0700 | [diff] [blame] | 529 | } else { |
jovanak | 168dbdb | 2019-02-18 01:00:43 -0800 | [diff] [blame] | 530 | dismissKeyguardWhenUserSwitcherNotDisplayed(); |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | /** Makes the full screen user switcher visible, if applicable. */ |
| 535 | public void showUserSwitcher() { |
| 536 | if (mFullscreenUserSwitcher != null && mState == StatusBarState.FULLSCREEN_USER_SWITCHER) { |
| 537 | mFullscreenUserSwitcher.show(); // Makes the switcher visible. |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | private void hideUserSwitcher() { |
| 542 | if (mFullscreenUserSwitcher != null) { |
jovanak | 604ad51 | 2018-08-14 18:41:27 -0700 | [diff] [blame] | 543 | mFullscreenUserSwitcher.hide(); |
Aarthi Balachander | 0a427ef | 2018-07-13 15:00:58 -0700 | [diff] [blame] | 544 | } |
| 545 | } |
| 546 | |
jovanak | 168dbdb | 2019-02-18 01:00:43 -0800 | [diff] [blame] | 547 | // We automatically dismiss keyguard unless user switcher is being shown on the keyguard. |
| 548 | private void dismissKeyguardWhenUserSwitcherNotDisplayed() { |
| 549 | if (mFullscreenUserSwitcher == null) { |
| 550 | return; // Not using the full screen user switcher. |
| 551 | } |
| 552 | |
| 553 | if (mState == StatusBarState.FULLSCREEN_USER_SWITCHER |
| 554 | && !mFullscreenUserSwitcher.isVisible()) { |
| 555 | // Current execution path continues to set state after this, thus we deffer the |
| 556 | // dismissal to the next execution cycle. |
| 557 | postDismissKeyguard(); // Dismiss the keyguard if switcher is not visible. |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 558 | } |
| 559 | } |
Rakesh Iyer | 74ebabe | 2016-03-11 10:10:43 -0800 | [diff] [blame] | 560 | |
jovanak | 604ad51 | 2018-08-14 18:41:27 -0700 | [diff] [blame] | 561 | public void postDismissKeyguard() { |
| 562 | mHandler.post(this::dismissKeyguard); |
| 563 | } |
| 564 | |
| 565 | /** |
| 566 | * Dismisses the keyguard and shows bouncer if authentication is necessary. |
| 567 | */ |
| 568 | public void dismissKeyguard() { |
| 569 | executeRunnableDismissingKeyguard(null/* runnable */, null /* cancelAction */, |
Brad Stenning | 8d1a51c | 2018-11-20 17:34:16 -0800 | [diff] [blame] | 570 | true /* dismissShade */, true /* afterKeyguardGone */, true /* deferred */); |
jovanak | 604ad51 | 2018-08-14 18:41:27 -0700 | [diff] [blame] | 571 | } |
| 572 | |
Victor Chan | c87554c | 2016-08-24 14:58:14 -0700 | [diff] [blame] | 573 | @Override |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 574 | public void animateExpandNotificationsPanel() { |
| 575 | // Because space is usually constrained in the auto use-case, there should not be a |
| 576 | // pinned notification when the shade has been expanded. Ensure this by removing all heads- |
| 577 | // up notifications. |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 578 | mHeadsUpManager.releaseAllImmediately(); |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 579 | super.animateExpandNotificationsPanel(); |
| 580 | } |
| 581 | |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 582 | /** |
| 583 | * Ensures that relevant child views are appropriately recreated when the device's density |
| 584 | * changes. |
| 585 | */ |
| 586 | @Override |
Jason Monk | 9cac5ff | 2017-06-02 11:35:50 -0400 | [diff] [blame] | 587 | public void onDensityOrFontScaleChanged() { |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 588 | super.onDensityOrFontScaleChanged(); |
Guobin Zhang | eef0e0c | 2019-02-01 11:54:24 -0800 | [diff] [blame] | 589 | restartNavBars(); |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 590 | // Need to update the background on density changed in case the change was due to night |
| 591 | // mode. |
| 592 | mNotificationPanelBackground = getDefaultWallpaper(); |
| 593 | mScrimController.setScrimBehindDrawable(mNotificationPanelBackground); |
| 594 | } |
| 595 | |
| 596 | /** |
| 597 | * Returns the {@link Drawable} that represents the wallpaper that the user has currently set. |
| 598 | */ |
| 599 | private Drawable getDefaultWallpaper() { |
| 600 | return mContext.getDrawable(com.android.internal.R.drawable.default_wallpaper); |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 601 | } |
Brad Stenning | 19f236a | 2018-12-11 14:12:30 -0800 | [diff] [blame] | 602 | |
| 603 | public void toggleCarNotifications() { |
| 604 | getComponent(NotificationsUI.class).toggleShowingCarNotifications(); |
| 605 | } |
| 606 | |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 607 | } |