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