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 | |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 224 | @Override |
| 225 | public void destroy() { |
| 226 | mCarBatteryController.stopListening(); |
Anthony Chen | 1c59e9f | 2016-04-11 11:05:48 -0700 | [diff] [blame] | 227 | mConnectedDeviceSignalController.stopListening(); |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 228 | mActivityManagerWrapper.unregisterTaskStackListener(mTaskStackListener); |
jovanak | edba98c | 2018-09-14 15:46:24 -0700 | [diff] [blame] | 229 | mDrivingStateHelper.disconnectFromCarService(); |
Anthony Chen | 1c59e9f | 2016-04-11 11:05:48 -0700 | [diff] [blame] | 230 | |
Scott Randolph | f408582 | 2017-06-27 15:23:01 -0700 | [diff] [blame] | 231 | if (mNavigationBarWindow != null) { |
| 232 | mWindowManager.removeViewImmediate(mNavigationBarWindow); |
| 233 | mNavigationBarView = null; |
| 234 | } |
| 235 | |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 236 | if (mLeftNavigationBarWindow != null) { |
| 237 | mWindowManager.removeViewImmediate(mLeftNavigationBarWindow); |
| 238 | mLeftNavigationBarView = null; |
| 239 | } |
| 240 | |
| 241 | if (mRightNavigationBarWindow != null) { |
| 242 | mWindowManager.removeViewImmediate(mRightNavigationBarWindow); |
| 243 | mRightNavigationBarView = null; |
| 244 | } |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 245 | super.destroy(); |
| 246 | } |
| 247 | |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 248 | |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 249 | @Override |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 250 | protected void makeStatusBarView() { |
| 251 | super.makeStatusBarView(); |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 252 | mHvacController = new HvacController(mContext); |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 253 | |
Guobin Zhang | eef0e0c | 2019-02-01 11:54:24 -0800 | [diff] [blame^] | 254 | CarSystemUIFactory factory = SystemUIFactory.getInstance(); |
| 255 | mCarFacetButtonController = factory.getCarDependencyComponent() |
| 256 | .getCarFacetButtonController(); |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 257 | mNotificationPanelBackground = getDefaultWallpaper(); |
| 258 | mScrimController.setScrimBehindDrawable(mNotificationPanelBackground); |
| 259 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 260 | FragmentHostManager manager = FragmentHostManager.get(mStatusBarWindow); |
| 261 | manager.addTagListener(CollapsedStatusBarFragment.TAG, (tag, fragment) -> { |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 262 | mBatteryMeterView = fragment.getView().findViewById(R.id.battery); |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 263 | |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 264 | // By default, the BatteryMeterView should not be visible. It will be toggled |
| 265 | // when a device has connected by bluetooth. |
| 266 | mBatteryMeterView.setVisibility(View.GONE); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 267 | }); |
Brad Stenning | f084d88 | 2018-08-08 13:34:21 -0700 | [diff] [blame] | 268 | addTemperatureViewToController(mStatusBarWindow); |
Brad Stenning | c622f1d | 2019-01-29 11:24:11 -0800 | [diff] [blame] | 269 | // The following are the ui elements that the user would call the status bar. |
| 270 | // This will set the status bar so it they can make call backs. |
| 271 | CarNavigationBarView topBar = mStatusBarWindow.findViewById(R.id.car_top_bar); |
| 272 | topBar.setStatusBar(this); |
| 273 | CarNavigationBarView qsTopBar = mStatusBarWindow.findViewById(R.id.qs_car_top_bar); |
| 274 | qsTopBar.setStatusBar(this); |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Brad Stenning | 8d1a51c | 2018-11-20 17:34:16 -0800 | [diff] [blame] | 277 | @Override |
| 278 | protected QS createDefaultQSFragment() { |
| 279 | return new CarQSFragment(); |
| 280 | } |
| 281 | |
Rakesh Iyer | 545e47d | 2017-01-23 18:10:21 -0800 | [diff] [blame] | 282 | private BatteryController createBatteryController() { |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 283 | mCarBatteryController = new CarBatteryController(mContext); |
| 284 | mCarBatteryController.addBatteryViewHandler(this); |
| 285 | return mCarBatteryController; |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 286 | } |
| 287 | |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 288 | @Override |
Jason Monk | 49fa016 | 2017-01-11 09:21:56 -0500 | [diff] [blame] | 289 | protected void createNavigationBar() { |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 290 | mShowBottom = mContext.getResources().getBoolean(R.bool.config_enableBottomNavigationBar); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 291 | mShowLeft = mContext.getResources().getBoolean(R.bool.config_enableLeftNavigationBar); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 292 | mShowRight = mContext.getResources().getBoolean(R.bool.config_enableRightNavigationBar); |
| 293 | |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 294 | buildNavBarWindows(); |
| 295 | buildNavBarContent(); |
| 296 | attachNavBarWindows(); |
Andrii Kulian | 3ddd7de | 2018-10-10 00:33:19 -0700 | [diff] [blame] | 297 | |
Charles Chen | 10ca70b | 2018-11-28 00:03:38 +0800 | [diff] [blame] | 298 | // There has been a car customized nav bar on the default display, so just create nav bars |
| 299 | // on external displays. |
| 300 | mNavigationBarController.createNavigationBars(false /* includeDefaultDisplay */); |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | private void buildNavBarContent() { |
| 304 | if (mShowBottom) { |
| 305 | buildBottomBar((mDeviceIsProvisioned) ? R.layout.car_navigation_bar : |
| 306 | R.layout.car_navigation_bar_unprovisioned); |
| 307 | } |
| 308 | |
| 309 | if (mShowLeft) { |
| 310 | buildLeft((mDeviceIsProvisioned) ? R.layout.car_left_navigation_bar : |
| 311 | R.layout.car_left_navigation_bar_unprovisioned); |
| 312 | } |
| 313 | |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 314 | if (mShowRight) { |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 315 | buildRight((mDeviceIsProvisioned) ? R.layout.car_right_navigation_bar : |
| 316 | R.layout.car_right_navigation_bar_unprovisioned); |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | private void buildNavBarWindows() { |
| 321 | if (mShowBottom) { |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 322 | mNavigationBarWindow = (ViewGroup) View.inflate(mContext, |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 323 | R.layout.navigation_bar_window, null); |
| 324 | } |
| 325 | if (mShowLeft) { |
| 326 | mLeftNavigationBarWindow = (ViewGroup) View.inflate(mContext, |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 327 | R.layout.navigation_bar_window, null); |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 328 | } |
| 329 | if (mShowRight) { |
| 330 | mRightNavigationBarWindow = (ViewGroup) View.inflate(mContext, |
| 331 | R.layout.navigation_bar_window, null); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | } |
| 335 | |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 336 | private void attachNavBarWindows() { |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 337 | |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 338 | if (mShowBottom) { |
| 339 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 340 | LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, |
| 341 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR, |
| 342 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 343 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 344 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
| 345 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
| 346 | PixelFormat.TRANSLUCENT); |
| 347 | lp.setTitle("CarNavigationBar"); |
| 348 | lp.windowAnimations = 0; |
| 349 | mWindowManager.addView(mNavigationBarWindow, lp); |
Brad Stenning | c622f1d | 2019-01-29 11:24:11 -0800 | [diff] [blame] | 350 | mNavigationBarWindow.setOnTouchListener(getStatusBarWindowTouchListener()); |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 351 | } |
| 352 | if (mShowLeft) { |
| 353 | int width = mContext.getResources().getDimensionPixelSize( |
| 354 | R.dimen.car_left_navigation_bar_width); |
| 355 | WindowManager.LayoutParams leftlp = new WindowManager.LayoutParams( |
| 356 | width, LayoutParams.MATCH_PARENT, |
| 357 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, |
| 358 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 359 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 360 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
| 361 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
| 362 | PixelFormat.TRANSLUCENT); |
| 363 | leftlp.setTitle("LeftCarNavigationBar"); |
| 364 | leftlp.windowAnimations = 0; |
| 365 | leftlp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR; |
| 366 | leftlp.gravity = Gravity.LEFT; |
| 367 | mWindowManager.addView(mLeftNavigationBarWindow, leftlp); |
| 368 | } |
| 369 | if (mShowRight) { |
| 370 | int width = mContext.getResources().getDimensionPixelSize( |
| 371 | R.dimen.car_right_navigation_bar_width); |
| 372 | WindowManager.LayoutParams rightlp = new WindowManager.LayoutParams( |
| 373 | width, LayoutParams.MATCH_PARENT, |
| 374 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, |
| 375 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 376 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 377 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
| 378 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
| 379 | PixelFormat.TRANSLUCENT); |
| 380 | rightlp.setTitle("RightCarNavigationBar"); |
| 381 | rightlp.windowAnimations = 0; |
| 382 | rightlp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR; |
| 383 | rightlp.gravity = Gravity.RIGHT; |
| 384 | mWindowManager.addView(mRightNavigationBarWindow, rightlp); |
| 385 | } |
| 386 | |
| 387 | } |
| 388 | |
| 389 | private void buildBottomBar(int layout) { |
Anthony Chen | 0801a5c | 2017-03-22 09:54:37 -0700 | [diff] [blame] | 390 | // SystemUI requires that the navigation bar view have a parent. Since the regular |
| 391 | // StatusBar inflates navigation_bar_window as this parent view, use the same view for the |
| 392 | // CarNavigationBarView. |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 393 | View.inflate(mContext, layout, mNavigationBarWindow); |
Scott Randolph | f408582 | 2017-06-27 15:23:01 -0700 | [diff] [blame] | 394 | mNavigationBarView = (CarNavigationBarView) mNavigationBarWindow.getChildAt(0); |
| 395 | if (mNavigationBarView == null) { |
| 396 | Log.e(TAG, "CarStatusBar failed inflate for R.layout.car_navigation_bar"); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 397 | 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] | 398 | } |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 399 | mNavigationBarView.setStatusBar(this); |
Brad Stenning | f084d88 | 2018-08-08 13:34:21 -0700 | [diff] [blame] | 400 | addTemperatureViewToController(mNavigationBarView); |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 401 | } |
| 402 | |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 403 | private void buildLeft(int layout) { |
| 404 | View.inflate(mContext, layout, mLeftNavigationBarWindow); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 405 | mLeftNavigationBarView = (CarNavigationBarView) mLeftNavigationBarWindow.getChildAt(0); |
| 406 | if (mLeftNavigationBarView == null) { |
| 407 | Log.e(TAG, "CarStatusBar failed inflate for R.layout.car_navigation_bar"); |
| 408 | throw new RuntimeException("Unable to build left nav bar due to missing layout"); |
| 409 | } |
| 410 | mLeftNavigationBarView.setStatusBar(this); |
Brad Stenning | f084d88 | 2018-08-08 13:34:21 -0700 | [diff] [blame] | 411 | addTemperatureViewToController(mLeftNavigationBarView); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | |
Brad Stenning | 224b5b3 | 2018-03-28 21:26:57 -0700 | [diff] [blame] | 415 | private void buildRight(int layout) { |
| 416 | View.inflate(mContext, layout, mRightNavigationBarWindow); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 417 | mRightNavigationBarView = (CarNavigationBarView) mRightNavigationBarWindow.getChildAt(0); |
| 418 | if (mRightNavigationBarView == null) { |
| 419 | Log.e(TAG, "CarStatusBar failed inflate for R.layout.car_navigation_bar"); |
| 420 | throw new RuntimeException("Unable to build right nav bar due to missing layout"); |
| 421 | } |
Brad Stenning | f084d88 | 2018-08-08 13:34:21 -0700 | [diff] [blame] | 422 | mRightNavigationBarView.setStatusBar(this); |
| 423 | addTemperatureViewToController(mRightNavigationBarView); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 424 | } |
| 425 | |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 426 | @Override |
Qiming Shi | b9dfb92 | 2017-04-13 16:23:18 +0800 | [diff] [blame] | 427 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 428 | //When executing dump() funciton simultaneously, we need to serialize them |
| 429 | //to get mStackScroller's position correctly. |
| 430 | synchronized (mQueueLock) { |
| 431 | pw.println(" mStackScroller: " + viewInfo(mStackScroller)); |
| 432 | pw.println(" mStackScroller: " + viewInfo(mStackScroller) |
| 433 | + " scroll " + mStackScroller.getScrollX() |
| 434 | + "," + mStackScroller.getScrollY()); |
| 435 | } |
| 436 | |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 437 | pw.print(" mTaskStackListener="); |
| 438 | pw.println(mTaskStackListener); |
Brad Stenning | 078235b | 2017-12-18 08:25:10 -0800 | [diff] [blame] | 439 | pw.print(" mCarFacetButtonController="); |
| 440 | pw.println(mCarFacetButtonController); |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 441 | pw.print(" mFullscreenUserSwitcher="); |
| 442 | pw.println(mFullscreenUserSwitcher); |
Qiming Shi | b9dfb92 | 2017-04-13 16:23:18 +0800 | [diff] [blame] | 443 | pw.print(" mCarBatteryController="); |
| 444 | pw.println(mCarBatteryController); |
| 445 | pw.print(" mBatteryMeterView="); |
| 446 | pw.println(mBatteryMeterView); |
| 447 | pw.print(" mConnectedDeviceSignalController="); |
| 448 | pw.println(mConnectedDeviceSignalController); |
| 449 | pw.print(" mNavigationBarView="); |
| 450 | pw.println(mNavigationBarView); |
| 451 | |
| 452 | if (KeyguardUpdateMonitor.getInstance(mContext) != null) { |
| 453 | KeyguardUpdateMonitor.getInstance(mContext).dump(fd, pw, args); |
| 454 | } |
| 455 | |
| 456 | FalsingManager.getInstance(mContext).dump(pw); |
| 457 | FalsingLog.dump(pw); |
| 458 | |
| 459 | pw.println("SharedPreferences:"); |
| 460 | for (Map.Entry<String, ?> entry : Prefs.getAll(mContext).entrySet()) { |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 461 | pw.print(" "); |
| 462 | pw.print(entry.getKey()); |
| 463 | pw.print("="); |
| 464 | pw.println(entry.getValue()); |
Qiming Shi | b9dfb92 | 2017-04-13 16:23:18 +0800 | [diff] [blame] | 465 | } |
| 466 | } |
| 467 | |
Scott Randolph | f408582 | 2017-06-27 15:23:01 -0700 | [diff] [blame] | 468 | @Override |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 469 | protected View.OnTouchListener getStatusBarWindowTouchListener() { |
Brad Stenning | c622f1d | 2019-01-29 11:24:11 -0800 | [diff] [blame] | 470 | // Gets the car specific notification touch listener |
| 471 | return getComponent(NotificationsUI.class).getDragDownListener(); |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 472 | } |
| 473 | |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 474 | @Override |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 475 | public void showBatteryView() { |
| 476 | if (Log.isLoggable(TAG, Log.DEBUG)) { |
| 477 | Log.d(TAG, "showBatteryView(). mBatteryMeterView: " + mBatteryMeterView); |
| 478 | } |
| 479 | |
| 480 | if (mBatteryMeterView != null) { |
| 481 | mBatteryMeterView.setVisibility(View.VISIBLE); |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | @Override |
| 486 | public void hideBatteryView() { |
| 487 | if (Log.isLoggable(TAG, Log.DEBUG)) { |
| 488 | Log.d(TAG, "hideBatteryView(). mBatteryMeterView: " + mBatteryMeterView); |
| 489 | } |
| 490 | |
| 491 | if (mBatteryMeterView != null) { |
| 492 | mBatteryMeterView.setVisibility(View.GONE); |
| 493 | } |
| 494 | } |
| 495 | |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 496 | /** |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 497 | * An implementation of TaskStackChangeListener, that listens for changes in the system |
davidln | 5473915 | 2018-07-02 13:25:44 -0700 | [diff] [blame] | 498 | * task stack and notifies the navigation bar. |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 499 | */ |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 500 | private class TaskStackListenerImpl extends TaskStackChangeListener { |
Wale Ogunwale | 480dca0 | 2016-02-06 13:58:29 -0800 | [diff] [blame] | 501 | @Override |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 502 | public void onTaskStackChanged() { |
Brad Stenning | a5e714c | 2018-04-12 19:23:39 -0700 | [diff] [blame] | 503 | try { |
| 504 | mCarFacetButtonController.taskChanged( |
Wale Ogunwale | 04d9cb5 | 2018-04-30 13:55:07 -0700 | [diff] [blame] | 505 | ActivityTaskManager.getService().getAllStackInfos()); |
Brad Stenning | a5e714c | 2018-04-12 19:23:39 -0700 | [diff] [blame] | 506 | } catch (Exception e) { |
| 507 | Log.e(TAG, "Getting StackInfo from activity manager failed", e); |
| 508 | } |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 509 | } |
Victor Chan | 1c6d058 | 2016-01-09 16:26:37 -0800 | [diff] [blame] | 510 | } |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 511 | |
jovanak | edba98c | 2018-09-14 15:46:24 -0700 | [diff] [blame] | 512 | private void onDrivingStateChanged(CarDrivingStateEvent notUsed) { |
| 513 | // Check if we need to start the timer every time driving state changes. |
| 514 | startSwitchToGuestTimerIfDrivingOnKeyguard(); |
| 515 | } |
| 516 | |
| 517 | private void startSwitchToGuestTimerIfDrivingOnKeyguard() { |
| 518 | if (mDrivingStateHelper.isCurrentlyDriving() && mState != StatusBarState.SHADE) { |
| 519 | // We're driving while keyguard is up. |
| 520 | mSwitchToGuestTimer.start(); |
| 521 | } else { |
| 522 | mSwitchToGuestTimer.cancel(); |
| 523 | } |
| 524 | } |
| 525 | |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 526 | @Override |
| 527 | protected void createUserSwitcher() { |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 528 | UserSwitcherController userSwitcherController = |
| 529 | Dependency.get(UserSwitcherController.class); |
| 530 | if (userSwitcherController.useFullscreenUserSwitcher()) { |
| 531 | mFullscreenUserSwitcher = new FullscreenUserSwitcher(this, |
Aarthi Balachander | d8bf249 | 2018-03-30 11:15:59 -0700 | [diff] [blame] | 532 | mStatusBarWindow.findViewById(R.id.fullscreen_user_switcher_stub), mContext); |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 533 | } else { |
| 534 | super.createUserSwitcher(); |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | @Override |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 539 | public void onStateChanged(int newState) { |
| 540 | super.onStateChanged(newState); |
jovanak | edba98c | 2018-09-14 15:46:24 -0700 | [diff] [blame] | 541 | |
| 542 | startSwitchToGuestTimerIfDrivingOnKeyguard(); |
| 543 | |
jovanak | 1aa629c | 2018-08-29 09:58:58 -0700 | [diff] [blame] | 544 | if (mFullscreenUserSwitcher == null) { |
| 545 | return; // Not using the full screen user switcher. |
| 546 | } |
| 547 | |
jovanak | 604ad51 | 2018-08-14 18:41:27 -0700 | [diff] [blame] | 548 | if (newState == StatusBarState.FULLSCREEN_USER_SWITCHER) { |
| 549 | if (!mFullscreenUserSwitcher.isVisible()) { |
| 550 | // Current execution path continues to set state after this, thus we deffer the |
| 551 | // dismissal to the next execution cycle. |
| 552 | postDismissKeyguard(); // Dismiss the keyguard if switcher is not visible. |
| 553 | } |
| 554 | } else { |
| 555 | mFullscreenUserSwitcher.hide(); |
Aarthi Balachander | 0a427ef | 2018-07-13 15:00:58 -0700 | [diff] [blame] | 556 | } |
| 557 | } |
| 558 | |
| 559 | public void showUserSwitcher() { |
jovanak | 604ad51 | 2018-08-14 18:41:27 -0700 | [diff] [blame] | 560 | if (mFullscreenUserSwitcher != null && mState == StatusBarState.FULLSCREEN_USER_SWITCHER) { |
| 561 | mFullscreenUserSwitcher.show(); // Makes the switcher visible. |
Rakesh Iyer | 2790a37 | 2016-01-22 15:33:39 -0800 | [diff] [blame] | 562 | } |
| 563 | } |
Rakesh Iyer | 74ebabe | 2016-03-11 10:10:43 -0800 | [diff] [blame] | 564 | |
jovanak | 604ad51 | 2018-08-14 18:41:27 -0700 | [diff] [blame] | 565 | public void postDismissKeyguard() { |
| 566 | mHandler.post(this::dismissKeyguard); |
| 567 | } |
| 568 | |
| 569 | /** |
| 570 | * Dismisses the keyguard and shows bouncer if authentication is necessary. |
| 571 | */ |
| 572 | public void dismissKeyguard() { |
| 573 | executeRunnableDismissingKeyguard(null/* runnable */, null /* cancelAction */, |
Brad Stenning | 8d1a51c | 2018-11-20 17:34:16 -0800 | [diff] [blame] | 574 | true /* dismissShade */, true /* afterKeyguardGone */, true /* deferred */); |
jovanak | 604ad51 | 2018-08-14 18:41:27 -0700 | [diff] [blame] | 575 | } |
| 576 | |
Victor Chan | c87554c | 2016-08-24 14:58:14 -0700 | [diff] [blame] | 577 | @Override |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 578 | public void animateExpandNotificationsPanel() { |
| 579 | // Because space is usually constrained in the auto use-case, there should not be a |
| 580 | // pinned notification when the shade has been expanded. Ensure this by removing all heads- |
| 581 | // up notifications. |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 582 | mHeadsUpManager.releaseAllImmediately(); |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 583 | super.animateExpandNotificationsPanel(); |
| 584 | } |
| 585 | |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 586 | /** |
| 587 | * Ensures that relevant child views are appropriately recreated when the device's density |
| 588 | * changes. |
| 589 | */ |
| 590 | @Override |
Jason Monk | 9cac5ff | 2017-06-02 11:35:50 -0400 | [diff] [blame] | 591 | public void onDensityOrFontScaleChanged() { |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 592 | super.onDensityOrFontScaleChanged(); |
Guobin Zhang | eef0e0c | 2019-02-01 11:54:24 -0800 | [diff] [blame^] | 593 | restartNavBars(); |
Anthony Chen | e658cc2 | 2017-04-27 11:17:35 -0700 | [diff] [blame] | 594 | // Need to update the background on density changed in case the change was due to night |
| 595 | // mode. |
| 596 | mNotificationPanelBackground = getDefaultWallpaper(); |
| 597 | mScrimController.setScrimBehindDrawable(mNotificationPanelBackground); |
| 598 | } |
| 599 | |
| 600 | /** |
| 601 | * Returns the {@link Drawable} that represents the wallpaper that the user has currently set. |
| 602 | */ |
| 603 | private Drawable getDefaultWallpaper() { |
| 604 | return mContext.getDrawable(com.android.internal.R.drawable.default_wallpaper); |
Anthony Chen | 3cb3ad9 | 2016-12-01 10:58:47 -0800 | [diff] [blame] | 605 | } |
Brad Stenning | 19f236a | 2018-12-11 14:12:30 -0800 | [diff] [blame] | 606 | |
| 607 | public void toggleCarNotifications() { |
| 608 | getComponent(NotificationsUI.class).toggleShowingCarNotifications(); |
| 609 | } |
| 610 | |
Rakesh Iyer | 1186faa | 2015-12-07 16:48:46 -0800 | [diff] [blame] | 611 | } |