Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 1 | /* |
Heemin Seog | 9b078d3 | 2020-04-21 15:07:32 -0700 | [diff] [blame] | 2 | * Copyright (C) 2020 The Android Open Source Project |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [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 | |
Heemin Seog | 9b078d3 | 2020-04-21 15:07:32 -0700 | [diff] [blame] | 17 | package com.android.systemui.car.navigationbar; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 18 | |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 19 | import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 20 | import static android.view.InsetsState.ITYPE_STATUS_BAR; |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 21 | import static android.view.InsetsState.containsType; |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 22 | import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS; |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 23 | |
| 24 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT; |
| 25 | import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT; |
| 26 | |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 27 | import android.content.Context; |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 28 | import android.content.res.Resources; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 29 | import android.graphics.PixelFormat; |
| 30 | import android.inputmethodservice.InputMethodService; |
| 31 | import android.os.Handler; |
| 32 | import android.os.IBinder; |
| 33 | import android.os.RemoteException; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 34 | import android.view.Display; |
| 35 | import android.view.Gravity; |
Heemin Seog | 8d6ec6a7 | 2019-10-25 14:34:11 -0700 | [diff] [blame] | 36 | import android.view.View; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 37 | import android.view.ViewGroup; |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 38 | import android.view.WindowInsetsController; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 39 | import android.view.WindowManager; |
| 40 | |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 41 | import androidx.annotation.VisibleForTesting; |
| 42 | |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 43 | import com.android.internal.statusbar.IStatusBarService; |
| 44 | import com.android.internal.statusbar.RegisterStatusBarResult; |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 45 | import com.android.internal.view.AppearanceRegion; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 46 | import com.android.systemui.R; |
| 47 | import com.android.systemui.SystemUI; |
Abhijoy Saha | ee51369 | 2019-12-10 13:52:26 -0800 | [diff] [blame] | 48 | import com.android.systemui.car.CarDeviceProvisionedController; |
| 49 | import com.android.systemui.car.CarDeviceProvisionedListener; |
Dave Mankoff | 00e8a2f | 2019-12-18 16:59:49 -0500 | [diff] [blame] | 50 | import com.android.systemui.dagger.qualifiers.Main; |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 51 | import com.android.systemui.dagger.qualifiers.UiBackground; |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 52 | import com.android.systemui.plugins.DarkIconDispatcher; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 53 | import com.android.systemui.shared.system.ActivityManagerWrapper; |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 54 | import com.android.systemui.statusbar.AutoHideUiElement; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 55 | import com.android.systemui.statusbar.CommandQueue; |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 56 | import com.android.systemui.statusbar.phone.AutoHideController; |
| 57 | import com.android.systemui.statusbar.phone.BarTransitions; |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 58 | import com.android.systemui.statusbar.phone.LightBarController; |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 59 | import com.android.systemui.statusbar.phone.PhoneStatusBarPolicy; |
| 60 | import com.android.systemui.statusbar.phone.StatusBarIconController; |
| 61 | import com.android.systemui.statusbar.phone.StatusBarSignalPolicy; |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 62 | import com.android.systemui.statusbar.phone.SysuiDarkIconDispatcher; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 63 | import com.android.systemui.statusbar.policy.KeyguardStateController; |
| 64 | |
| 65 | import java.io.FileDescriptor; |
| 66 | import java.io.PrintWriter; |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 67 | import java.util.concurrent.Executor; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 68 | |
| 69 | import javax.inject.Inject; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 70 | |
| 71 | import dagger.Lazy; |
| 72 | |
| 73 | /** Navigation bars customized for the automotive use case. */ |
| 74 | public class CarNavigationBar extends SystemUI implements CommandQueue.Callbacks { |
| 75 | |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 76 | private final Resources mResources; |
Heemin Seog | fcccab7 | 2019-10-22 08:30:23 -0700 | [diff] [blame] | 77 | private final CarNavigationBarController mCarNavigationBarController; |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 78 | private final SysuiDarkIconDispatcher mStatusBarIconController; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 79 | private final WindowManager mWindowManager; |
Abhijoy Saha | ee51369 | 2019-12-10 13:52:26 -0800 | [diff] [blame] | 80 | private final CarDeviceProvisionedController mCarDeviceProvisionedController; |
Heemin Seog | 4a68948 | 2019-11-04 10:37:43 -0800 | [diff] [blame] | 81 | private final CommandQueue mCommandQueue; |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 82 | private final AutoHideController mAutoHideController; |
kwaky | 77d81dc | 2019-12-12 16:23:59 -0800 | [diff] [blame] | 83 | private final ButtonSelectionStateListener mButtonSelectionStateListener; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 84 | private final Handler mMainHandler; |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 85 | private final Executor mUiBgExecutor; |
Heemin Seog | 23f18d0 | 2020-04-24 17:53:22 -0700 | [diff] [blame] | 86 | private final IStatusBarService mBarService; |
Heemin Seog | d59786b | 2019-11-08 09:20:26 -0800 | [diff] [blame] | 87 | private final Lazy<KeyguardStateController> mKeyguardStateControllerLazy; |
kwaky | 77d81dc | 2019-12-12 16:23:59 -0800 | [diff] [blame] | 88 | private final ButtonSelectionStateController mButtonSelectionStateController; |
Heemin Seog | a3d358f | 2020-04-28 22:31:03 -0700 | [diff] [blame] | 89 | private final Lazy<PhoneStatusBarPolicy> mIconPolicyLazy; |
| 90 | private final Lazy<StatusBarIconController> mIconControllerLazy; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 91 | |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 92 | private final int mDisplayId; |
| 93 | |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 94 | private StatusBarSignalPolicy mSignalPolicy; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 95 | private ActivityManagerWrapper mActivityManagerWrapper; |
| 96 | |
| 97 | // If the nav bar should be hidden when the soft keyboard is visible. |
| 98 | private boolean mHideNavBarForKeyboard; |
| 99 | private boolean mBottomNavBarVisible; |
| 100 | |
| 101 | // Nav bar views. |
Heemin Seog | d59786b | 2019-11-08 09:20:26 -0800 | [diff] [blame] | 102 | private ViewGroup mTopNavigationBarWindow; |
| 103 | private ViewGroup mBottomNavigationBarWindow; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 104 | private ViewGroup mLeftNavigationBarWindow; |
| 105 | private ViewGroup mRightNavigationBarWindow; |
Heemin Seog | d59786b | 2019-11-08 09:20:26 -0800 | [diff] [blame] | 106 | private CarNavigationBarView mTopNavigationBarView; |
| 107 | private CarNavigationBarView mBottomNavigationBarView; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 108 | private CarNavigationBarView mLeftNavigationBarView; |
| 109 | private CarNavigationBarView mRightNavigationBarView; |
| 110 | |
| 111 | // To be attached to the navigation bars such that they can close the notification panel if |
| 112 | // it's open. |
| 113 | private boolean mDeviceIsSetUpForUser = true; |
Abhijoy Saha | ee51369 | 2019-12-10 13:52:26 -0800 | [diff] [blame] | 114 | private boolean mIsUserSetupInProgress = false; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 115 | |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 116 | private AppearanceRegion[] mAppearanceRegions = new AppearanceRegion[0]; |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 117 | @BarTransitions.TransitionMode |
| 118 | private int mStatusBarMode; |
| 119 | @BarTransitions.TransitionMode |
| 120 | private int mNavigationBarMode; |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 121 | private boolean mStatusBarTransientShown; |
| 122 | private boolean mNavBarTransientShown; |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 123 | |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 124 | @Inject |
| 125 | public CarNavigationBar(Context context, |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 126 | @Main Resources resources, |
Heemin Seog | fcccab7 | 2019-10-22 08:30:23 -0700 | [diff] [blame] | 127 | CarNavigationBarController carNavigationBarController, |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 128 | // TODO(b/156052638): Should not need to inject LightBarController |
| 129 | LightBarController lightBarController, |
| 130 | DarkIconDispatcher darkIconDispatcher, |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 131 | WindowManager windowManager, |
Eric Berglund | 89edc87 | 2020-01-21 15:28:35 -0800 | [diff] [blame] | 132 | CarDeviceProvisionedController deviceProvisionedController, |
Heemin Seog | 4a68948 | 2019-11-04 10:37:43 -0800 | [diff] [blame] | 133 | CommandQueue commandQueue, |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 134 | AutoHideController autoHideController, |
kwaky | 77d81dc | 2019-12-12 16:23:59 -0800 | [diff] [blame] | 135 | ButtonSelectionStateListener buttonSelectionStateListener, |
Dave Mankoff | 00e8a2f | 2019-12-18 16:59:49 -0500 | [diff] [blame] | 136 | @Main Handler mainHandler, |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 137 | @UiBackground Executor uiBgExecutor, |
Heemin Seog | 23f18d0 | 2020-04-24 17:53:22 -0700 | [diff] [blame] | 138 | IStatusBarService barService, |
Heemin Seog | d59786b | 2019-11-08 09:20:26 -0800 | [diff] [blame] | 139 | Lazy<KeyguardStateController> keyguardStateControllerLazy, |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 140 | ButtonSelectionStateController buttonSelectionStateController, |
Heemin Seog | a3d358f | 2020-04-28 22:31:03 -0700 | [diff] [blame] | 141 | Lazy<PhoneStatusBarPolicy> iconPolicyLazy, |
| 142 | Lazy<StatusBarIconController> iconControllerLazy |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 143 | ) { |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 144 | super(context); |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 145 | mResources = resources; |
Heemin Seog | fcccab7 | 2019-10-22 08:30:23 -0700 | [diff] [blame] | 146 | mCarNavigationBarController = carNavigationBarController; |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 147 | mStatusBarIconController = (SysuiDarkIconDispatcher) darkIconDispatcher; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 148 | mWindowManager = windowManager; |
Eric Berglund | 89edc87 | 2020-01-21 15:28:35 -0800 | [diff] [blame] | 149 | mCarDeviceProvisionedController = deviceProvisionedController; |
Heemin Seog | 4a68948 | 2019-11-04 10:37:43 -0800 | [diff] [blame] | 150 | mCommandQueue = commandQueue; |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 151 | mAutoHideController = autoHideController; |
kwaky | 77d81dc | 2019-12-12 16:23:59 -0800 | [diff] [blame] | 152 | mButtonSelectionStateListener = buttonSelectionStateListener; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 153 | mMainHandler = mainHandler; |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 154 | mUiBgExecutor = uiBgExecutor; |
Heemin Seog | 23f18d0 | 2020-04-24 17:53:22 -0700 | [diff] [blame] | 155 | mBarService = barService; |
Heemin Seog | d59786b | 2019-11-08 09:20:26 -0800 | [diff] [blame] | 156 | mKeyguardStateControllerLazy = keyguardStateControllerLazy; |
kwaky | 77d81dc | 2019-12-12 16:23:59 -0800 | [diff] [blame] | 157 | mButtonSelectionStateController = buttonSelectionStateController; |
Heemin Seog | a3d358f | 2020-04-28 22:31:03 -0700 | [diff] [blame] | 158 | mIconPolicyLazy = iconPolicyLazy; |
| 159 | mIconControllerLazy = iconControllerLazy; |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 160 | |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 161 | mDisplayId = context.getDisplayId(); |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | @Override |
| 165 | public void start() { |
| 166 | // Set initial state. |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 167 | mHideNavBarForKeyboard = mResources.getBoolean( |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 168 | com.android.internal.R.bool.config_automotiveHideNavBarForKeyboard); |
| 169 | mBottomNavBarVisible = false; |
| 170 | |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 171 | // Connect into the status bar manager service |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 172 | mCommandQueue.addCallback(this); |
| 173 | |
| 174 | RegisterStatusBarResult result = null; |
| 175 | try { |
| 176 | result = mBarService.registerStatusBar(mCommandQueue); |
| 177 | } catch (RemoteException ex) { |
| 178 | ex.rethrowFromSystemServer(); |
| 179 | } |
| 180 | |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 181 | onSystemBarAppearanceChanged(mDisplayId, result.mAppearance, result.mAppearanceRegions, |
| 182 | result.mNavbarColorManagedByIme); |
| 183 | |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 184 | // StatusBarManagerService has a back up of IME token and it's restored here. |
| 185 | setImeWindowStatus(mDisplayId, result.mImeToken, result.mImeWindowVis, |
| 186 | result.mImeBackDisposition, result.mShowImeSwitcher); |
| 187 | |
| 188 | // Set up the initial icon state |
| 189 | int numIcons = result.mIcons.size(); |
| 190 | for (int i = 0; i < numIcons; i++) { |
| 191 | mCommandQueue.setIcon(result.mIcons.keyAt(i), result.mIcons.valueAt(i)); |
| 192 | } |
| 193 | |
| 194 | mAutoHideController.setStatusBar(new AutoHideUiElement() { |
| 195 | @Override |
| 196 | public void synchronizeState() { |
| 197 | // No op. |
| 198 | } |
| 199 | |
| 200 | @Override |
| 201 | public boolean isVisible() { |
| 202 | return mStatusBarTransientShown; |
| 203 | } |
| 204 | |
| 205 | @Override |
| 206 | public void hide() { |
| 207 | clearTransient(); |
| 208 | } |
| 209 | }); |
| 210 | |
Heemin Seog | a8983af | 2020-03-31 13:16:48 -0700 | [diff] [blame] | 211 | mAutoHideController.setNavigationBar(new AutoHideUiElement() { |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 212 | @Override |
| 213 | public void synchronizeState() { |
| 214 | // No op. |
| 215 | } |
| 216 | |
| 217 | @Override |
| 218 | public boolean isVisible() { |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 219 | return mNavBarTransientShown; |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | @Override |
| 223 | public void hide() { |
| 224 | clearTransient(); |
| 225 | } |
| 226 | }); |
| 227 | |
Abhijoy Saha | ee51369 | 2019-12-10 13:52:26 -0800 | [diff] [blame] | 228 | mDeviceIsSetUpForUser = mCarDeviceProvisionedController.isCurrentUserSetup(); |
| 229 | mIsUserSetupInProgress = mCarDeviceProvisionedController.isCurrentUserSetupInProgress(); |
| 230 | mCarDeviceProvisionedController.addCallback( |
| 231 | new CarDeviceProvisionedListener() { |
| 232 | @Override |
| 233 | public void onUserSetupInProgressChanged() { |
| 234 | mMainHandler.post(() -> restartNavBarsIfNecessary()); |
| 235 | } |
| 236 | |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 237 | @Override |
| 238 | public void onUserSetupChanged() { |
| 239 | mMainHandler.post(() -> restartNavBarsIfNecessary()); |
| 240 | } |
| 241 | |
| 242 | @Override |
| 243 | public void onUserSwitched() { |
| 244 | mMainHandler.post(() -> restartNavBarsIfNecessary()); |
| 245 | } |
| 246 | }); |
| 247 | |
| 248 | createNavigationBar(result); |
| 249 | |
| 250 | mActivityManagerWrapper = ActivityManagerWrapper.getInstance(); |
kwaky | 77d81dc | 2019-12-12 16:23:59 -0800 | [diff] [blame] | 251 | mActivityManagerWrapper.registerTaskStackListener(mButtonSelectionStateListener); |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 252 | |
Heemin Seog | 4860f80 | 2020-05-05 00:22:42 -0700 | [diff] [blame] | 253 | mUiBgExecutor.execute(mCarNavigationBarController::connectToHvac); |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 254 | |
| 255 | // Lastly, call to the icon policy to install/update all the icons. |
Heemin Seog | 23f18d0 | 2020-04-24 17:53:22 -0700 | [diff] [blame] | 256 | // Must be called on the main thread due to the use of observeForever() in |
| 257 | // mIconPolicy.init(). |
| 258 | mMainHandler.post(() -> { |
Heemin Seog | a3d358f | 2020-04-28 22:31:03 -0700 | [diff] [blame] | 259 | mIconPolicyLazy.get().init(); |
| 260 | mSignalPolicy = new StatusBarSignalPolicy(mContext, mIconControllerLazy.get()); |
Heemin Seog | 23f18d0 | 2020-04-24 17:53:22 -0700 | [diff] [blame] | 261 | }); |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | private void restartNavBarsIfNecessary() { |
Abhijoy Saha | ee51369 | 2019-12-10 13:52:26 -0800 | [diff] [blame] | 265 | boolean currentUserSetup = mCarDeviceProvisionedController.isCurrentUserSetup(); |
| 266 | boolean currentUserSetupInProgress = mCarDeviceProvisionedController |
| 267 | .isCurrentUserSetupInProgress(); |
| 268 | if (mIsUserSetupInProgress != currentUserSetupInProgress |
| 269 | || mDeviceIsSetUpForUser != currentUserSetup) { |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 270 | mDeviceIsSetUpForUser = currentUserSetup; |
Abhijoy Saha | ee51369 | 2019-12-10 13:52:26 -0800 | [diff] [blame] | 271 | mIsUserSetupInProgress = currentUserSetupInProgress; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 272 | restartNavBars(); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | /** |
| 277 | * Remove all content from navbars and rebuild them. Used to allow for different nav bars |
| 278 | * before and after the device is provisioned. . Also for change of density and font size. |
| 279 | */ |
| 280 | private void restartNavBars() { |
| 281 | // remove and reattach all hvac components such that we don't keep a reference to unused |
| 282 | // ui elements |
Heemin Seog | fcccab7 | 2019-10-22 08:30:23 -0700 | [diff] [blame] | 283 | mCarNavigationBarController.removeAllFromHvac(); |
kwaky | 77d81dc | 2019-12-12 16:23:59 -0800 | [diff] [blame] | 284 | mButtonSelectionStateController.removeAll(); |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 285 | |
Heemin Seog | d59786b | 2019-11-08 09:20:26 -0800 | [diff] [blame] | 286 | if (mTopNavigationBarWindow != null) { |
| 287 | mTopNavigationBarWindow.removeAllViews(); |
| 288 | mTopNavigationBarView = null; |
| 289 | } |
| 290 | |
| 291 | if (mBottomNavigationBarWindow != null) { |
| 292 | mBottomNavigationBarWindow.removeAllViews(); |
| 293 | mBottomNavigationBarView = null; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | if (mLeftNavigationBarWindow != null) { |
| 297 | mLeftNavigationBarWindow.removeAllViews(); |
| 298 | mLeftNavigationBarView = null; |
| 299 | } |
| 300 | |
| 301 | if (mRightNavigationBarWindow != null) { |
| 302 | mRightNavigationBarWindow.removeAllViews(); |
| 303 | mRightNavigationBarView = null; |
| 304 | } |
| 305 | |
| 306 | buildNavBarContent(); |
JianYang Liu | 4fbd981 | 2020-03-09 13:39:58 -0700 | [diff] [blame] | 307 | // If the UI was rebuilt (day/night change or user change) while the keyguard was up we need |
| 308 | // to correctly respect that state. |
Heemin Seog | d59786b | 2019-11-08 09:20:26 -0800 | [diff] [blame] | 309 | if (mKeyguardStateControllerLazy.get().isShowing()) { |
Abhijoy Saha | ee51369 | 2019-12-10 13:52:26 -0800 | [diff] [blame] | 310 | mCarNavigationBarController.showAllKeyguardButtons(isDeviceSetupForUser()); |
JianYang Liu | 4fbd981 | 2020-03-09 13:39:58 -0700 | [diff] [blame] | 311 | } else { |
| 312 | mCarNavigationBarController.hideAllKeyguardButtons(isDeviceSetupForUser()); |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 313 | } |
kwaky | 371e621 | 2020-02-19 13:45:22 -0800 | [diff] [blame] | 314 | |
| 315 | // Upon restarting the Navigation Bar, CarFacetButtonController should immediately apply the |
| 316 | // selection state that reflects the current task stack. |
| 317 | mButtonSelectionStateListener.onTaskStackChanged(); |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 318 | } |
| 319 | |
Abhijoy Saha | ee51369 | 2019-12-10 13:52:26 -0800 | [diff] [blame] | 320 | private boolean isDeviceSetupForUser() { |
| 321 | return mDeviceIsSetUpForUser && !mIsUserSetupInProgress; |
| 322 | } |
| 323 | |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 324 | private void createNavigationBar(RegisterStatusBarResult result) { |
| 325 | buildNavBarWindows(); |
| 326 | buildNavBarContent(); |
| 327 | attachNavBarWindows(); |
| 328 | |
| 329 | // Try setting up the initial state of the nav bar if applicable. |
| 330 | if (result != null) { |
| 331 | setImeWindowStatus(Display.DEFAULT_DISPLAY, result.mImeToken, |
| 332 | result.mImeWindowVis, result.mImeBackDisposition, |
| 333 | result.mShowImeSwitcher); |
| 334 | } |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | private void buildNavBarWindows() { |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 338 | mTopNavigationBarWindow = mCarNavigationBarController.getTopWindow(); |
Heemin Seog | d59786b | 2019-11-08 09:20:26 -0800 | [diff] [blame] | 339 | mBottomNavigationBarWindow = mCarNavigationBarController.getBottomWindow(); |
Heemin Seog | fcccab7 | 2019-10-22 08:30:23 -0700 | [diff] [blame] | 340 | mLeftNavigationBarWindow = mCarNavigationBarController.getLeftWindow(); |
| 341 | mRightNavigationBarWindow = mCarNavigationBarController.getRightWindow(); |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | private void buildNavBarContent() { |
Abhijoy Saha | ee51369 | 2019-12-10 13:52:26 -0800 | [diff] [blame] | 345 | mTopNavigationBarView = mCarNavigationBarController.getTopBar(isDeviceSetupForUser()); |
Heemin Seog | d59786b | 2019-11-08 09:20:26 -0800 | [diff] [blame] | 346 | if (mTopNavigationBarView != null) { |
| 347 | mTopNavigationBarWindow.addView(mTopNavigationBarView); |
| 348 | } |
| 349 | |
Abhijoy Saha | ee51369 | 2019-12-10 13:52:26 -0800 | [diff] [blame] | 350 | mBottomNavigationBarView = mCarNavigationBarController.getBottomBar(isDeviceSetupForUser()); |
Heemin Seog | d59786b | 2019-11-08 09:20:26 -0800 | [diff] [blame] | 351 | if (mBottomNavigationBarView != null) { |
| 352 | mBottomNavigationBarWindow.addView(mBottomNavigationBarView); |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 353 | } |
| 354 | |
Abhijoy Saha | ee51369 | 2019-12-10 13:52:26 -0800 | [diff] [blame] | 355 | mLeftNavigationBarView = mCarNavigationBarController.getLeftBar(isDeviceSetupForUser()); |
Heemin Seog | fcccab7 | 2019-10-22 08:30:23 -0700 | [diff] [blame] | 356 | if (mLeftNavigationBarView != null) { |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 357 | mLeftNavigationBarWindow.addView(mLeftNavigationBarView); |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 358 | } |
| 359 | |
Abhijoy Saha | ee51369 | 2019-12-10 13:52:26 -0800 | [diff] [blame] | 360 | mRightNavigationBarView = mCarNavigationBarController.getRightBar(isDeviceSetupForUser()); |
Heemin Seog | fcccab7 | 2019-10-22 08:30:23 -0700 | [diff] [blame] | 361 | if (mRightNavigationBarView != null) { |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 362 | mRightNavigationBarWindow.addView(mRightNavigationBarView); |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 363 | } |
| 364 | } |
| 365 | |
| 366 | private void attachNavBarWindows() { |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 367 | if (mTopNavigationBarWindow != null) { |
| 368 | int height = mResources.getDimensionPixelSize( |
| 369 | com.android.internal.R.dimen.status_bar_height); |
| 370 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 371 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 372 | height, |
Heemin Seog | 991711a | 2020-04-24 00:38:39 -0700 | [diff] [blame] | 373 | WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL, |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 374 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
Heemin Seog | 991711a | 2020-04-24 00:38:39 -0700 | [diff] [blame] | 375 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 376 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
| 377 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 378 | PixelFormat.TRANSLUCENT); |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 379 | lp.setTitle("TopCarNavigationBar"); |
Heemin Seog | 991711a | 2020-04-24 00:38:39 -0700 | [diff] [blame] | 380 | lp.providesInsetsTypes = new int[]{ITYPE_STATUS_BAR}; |
| 381 | lp.setFitInsetsTypes(0); |
| 382 | lp.windowAnimations = 0; |
| 383 | lp.gravity = Gravity.TOP; |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 384 | mWindowManager.addView(mTopNavigationBarWindow, lp); |
| 385 | } |
| 386 | |
Heemin Seog | d59786b | 2019-11-08 09:20:26 -0800 | [diff] [blame] | 387 | if (mBottomNavigationBarWindow != null && !mBottomNavBarVisible) { |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 388 | mBottomNavBarVisible = true; |
Heemin Seog | 991711a | 2020-04-24 00:38:39 -0700 | [diff] [blame] | 389 | int height = mResources.getDimensionPixelSize( |
| 390 | com.android.internal.R.dimen.navigation_bar_height); |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 391 | |
| 392 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
Heemin Seog | 991711a | 2020-04-24 00:38:39 -0700 | [diff] [blame] | 393 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 394 | height, |
| 395 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 396 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 397 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 398 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
| 399 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
| 400 | PixelFormat.TRANSLUCENT); |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 401 | lp.setTitle("BottomCarNavigationBar"); |
Heemin Seog | 991711a | 2020-04-24 00:38:39 -0700 | [diff] [blame] | 402 | lp.providesInsetsTypes = new int[]{ITYPE_NAVIGATION_BAR}; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 403 | lp.windowAnimations = 0; |
Heemin Seog | 991711a | 2020-04-24 00:38:39 -0700 | [diff] [blame] | 404 | lp.gravity = Gravity.BOTTOM; |
Heemin Seog | d59786b | 2019-11-08 09:20:26 -0800 | [diff] [blame] | 405 | mWindowManager.addView(mBottomNavigationBarWindow, lp); |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 406 | } |
| 407 | |
Heemin Seog | fcccab7 | 2019-10-22 08:30:23 -0700 | [diff] [blame] | 408 | if (mLeftNavigationBarWindow != null) { |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 409 | int width = mResources.getDimensionPixelSize( |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 410 | R.dimen.car_left_navigation_bar_width); |
| 411 | WindowManager.LayoutParams leftlp = new WindowManager.LayoutParams( |
| 412 | width, ViewGroup.LayoutParams.MATCH_PARENT, |
| 413 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, |
| 414 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 415 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 416 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
| 417 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
| 418 | PixelFormat.TRANSLUCENT); |
| 419 | leftlp.setTitle("LeftCarNavigationBar"); |
| 420 | leftlp.windowAnimations = 0; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 421 | leftlp.gravity = Gravity.LEFT; |
| 422 | mWindowManager.addView(mLeftNavigationBarWindow, leftlp); |
| 423 | } |
Heemin Seog | 991711a | 2020-04-24 00:38:39 -0700 | [diff] [blame] | 424 | |
Heemin Seog | fcccab7 | 2019-10-22 08:30:23 -0700 | [diff] [blame] | 425 | if (mRightNavigationBarWindow != null) { |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 426 | int width = mResources.getDimensionPixelSize( |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 427 | R.dimen.car_right_navigation_bar_width); |
| 428 | WindowManager.LayoutParams rightlp = new WindowManager.LayoutParams( |
| 429 | width, ViewGroup.LayoutParams.MATCH_PARENT, |
| 430 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, |
| 431 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 432 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 433 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
| 434 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
| 435 | PixelFormat.TRANSLUCENT); |
| 436 | rightlp.setTitle("RightCarNavigationBar"); |
| 437 | rightlp.windowAnimations = 0; |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 438 | rightlp.gravity = Gravity.RIGHT; |
| 439 | mWindowManager.addView(mRightNavigationBarWindow, rightlp); |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | /** |
| 444 | * We register for soft keyboard visibility events such that we can hide the navigation bar |
| 445 | * giving more screen space to the IME. Note: this is optional and controlled by |
| 446 | * {@code com.android.internal.R.bool.config_automotiveHideNavBarForKeyboard}. |
| 447 | */ |
| 448 | @Override |
| 449 | public void setImeWindowStatus(int displayId, IBinder token, int vis, int backDisposition, |
| 450 | boolean showImeSwitcher) { |
| 451 | if (!mHideNavBarForKeyboard) { |
| 452 | return; |
| 453 | } |
| 454 | |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 455 | if (mContext.getDisplayId() != displayId) { |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 456 | return; |
| 457 | } |
| 458 | |
| 459 | boolean isKeyboardVisible = (vis & InputMethodService.IME_VISIBLE) != 0; |
Heemin Seog | 8d6ec6a7 | 2019-10-25 14:34:11 -0700 | [diff] [blame] | 460 | mCarNavigationBarController.setBottomWindowVisibility( |
| 461 | isKeyboardVisible ? View.GONE : View.VISIBLE); |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 462 | } |
| 463 | |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 464 | @Override |
JianYang Liu | 0e3c478 | 2020-05-07 19:15:37 -0700 | [diff] [blame] | 465 | public void onSystemBarAppearanceChanged( |
| 466 | int displayId, |
| 467 | @WindowInsetsController.Appearance int appearance, |
| 468 | AppearanceRegion[] appearanceRegions, |
| 469 | boolean navbarColorManagedByIme) { |
| 470 | if (displayId != mDisplayId) { |
| 471 | return; |
| 472 | } |
| 473 | boolean barModeChanged = updateStatusBarMode( |
| 474 | mStatusBarTransientShown ? MODE_SEMI_TRANSPARENT : MODE_TRANSPARENT); |
| 475 | int numStacks = appearanceRegions.length; |
| 476 | boolean stackAppearancesChanged = mAppearanceRegions.length != numStacks; |
| 477 | for (int i = 0; i < numStacks && !stackAppearancesChanged; i++) { |
| 478 | stackAppearancesChanged |= !appearanceRegions[i].equals(mAppearanceRegions[i]); |
| 479 | } |
| 480 | if (stackAppearancesChanged || barModeChanged) { |
| 481 | mAppearanceRegions = appearanceRegions; |
| 482 | updateStatusBarAppearance(); |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | private void updateStatusBarAppearance() { |
| 487 | int numStacks = mAppearanceRegions.length; |
| 488 | int numLightStacks = 0; |
| 489 | |
| 490 | // We can only have maximum one light stack. |
| 491 | int indexLightStack = -1; |
| 492 | |
| 493 | for (int i = 0; i < numStacks; i++) { |
| 494 | if (isLight(mAppearanceRegions[i].getAppearance())) { |
| 495 | numLightStacks++; |
| 496 | indexLightStack = i; |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | // If all stacks are light, all icons become dark. |
| 501 | if (numLightStacks == numStacks) { |
| 502 | mStatusBarIconController.setIconsDarkArea(null); |
| 503 | mStatusBarIconController.getTransitionsController().setIconsDark( |
| 504 | /* dark= */ true, /* animate= */ false); |
| 505 | } else if (numLightStacks == 0) { |
| 506 | // If no one is light, all icons become white. |
| 507 | mStatusBarIconController.getTransitionsController().setIconsDark( |
| 508 | /* dark= */ false, /* animate= */ false); |
| 509 | } else { |
| 510 | // Not the same for every stack, update icons in area only. |
| 511 | mStatusBarIconController.setIconsDarkArea( |
| 512 | mAppearanceRegions[indexLightStack].getBounds()); |
| 513 | mStatusBarIconController.getTransitionsController().setIconsDark( |
| 514 | /* dark= */ true, /* animate= */ false); |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | private static boolean isLight(int appearance) { |
| 519 | return (appearance & APPEARANCE_LIGHT_STATUS_BARS) != 0; |
| 520 | } |
| 521 | |
| 522 | @Override |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 523 | public void showTransient(int displayId, int[] types) { |
| 524 | if (displayId != mDisplayId) { |
| 525 | return; |
| 526 | } |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 527 | if (containsType(types, ITYPE_STATUS_BAR)) { |
| 528 | if (!mStatusBarTransientShown) { |
| 529 | mStatusBarTransientShown = true; |
| 530 | handleTransientChanged(); |
| 531 | } |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 532 | } |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 533 | if (containsType(types, ITYPE_NAVIGATION_BAR)) { |
| 534 | if (!mNavBarTransientShown) { |
| 535 | mNavBarTransientShown = true; |
| 536 | handleTransientChanged(); |
| 537 | } |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 538 | } |
| 539 | } |
| 540 | |
| 541 | @Override |
| 542 | public void abortTransient(int displayId, int[] types) { |
| 543 | if (displayId != mDisplayId) { |
| 544 | return; |
| 545 | } |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 546 | if (!containsType(types, ITYPE_STATUS_BAR) && !containsType(types, ITYPE_NAVIGATION_BAR)) { |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 547 | return; |
| 548 | } |
| 549 | clearTransient(); |
| 550 | } |
| 551 | |
| 552 | private void clearTransient() { |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 553 | if (mStatusBarTransientShown) { |
| 554 | mStatusBarTransientShown = false; |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 555 | handleTransientChanged(); |
| 556 | } |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 557 | if (mNavBarTransientShown) { |
| 558 | mNavBarTransientShown = false; |
| 559 | handleTransientChanged(); |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | @VisibleForTesting |
| 564 | boolean isStatusBarTransientShown() { |
| 565 | return mStatusBarTransientShown; |
| 566 | } |
| 567 | |
| 568 | @VisibleForTesting |
| 569 | boolean isNavBarTransientShown() { |
| 570 | return mNavBarTransientShown; |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | @Override |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 574 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 575 | pw.print(" mTaskStackListener="); |
kwaky | 77d81dc | 2019-12-12 16:23:59 -0800 | [diff] [blame] | 576 | pw.println(mButtonSelectionStateListener); |
Heemin Seog | d59786b | 2019-11-08 09:20:26 -0800 | [diff] [blame] | 577 | pw.print(" mBottomNavigationBarView="); |
| 578 | pw.println(mBottomNavigationBarView); |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 579 | } |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 580 | |
| 581 | private void handleTransientChanged() { |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 582 | updateStatusBarMode(mStatusBarTransientShown ? MODE_SEMI_TRANSPARENT : MODE_TRANSPARENT); |
| 583 | updateNavBarMode(mNavBarTransientShown ? MODE_SEMI_TRANSPARENT : MODE_TRANSPARENT); |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 584 | } |
| 585 | |
Heemin Seog | 29ecf61 | 2020-04-14 22:47:01 -0700 | [diff] [blame] | 586 | // Returns true if the status bar mode has changed. |
| 587 | private boolean updateStatusBarMode(int barMode) { |
| 588 | if (mStatusBarMode != barMode) { |
| 589 | mStatusBarMode = barMode; |
| 590 | mAutoHideController.touchAutoHide(); |
| 591 | return true; |
| 592 | } |
| 593 | return false; |
| 594 | } |
| 595 | |
| 596 | // Returns true if the nav bar mode has changed. |
| 597 | private boolean updateNavBarMode(int barMode) { |
Heemin Seog | e67cefea | 2020-01-28 12:02:50 -0800 | [diff] [blame] | 598 | if (mNavigationBarMode != barMode) { |
| 599 | mNavigationBarMode = barMode; |
| 600 | mAutoHideController.touchAutoHide(); |
| 601 | return true; |
| 602 | } |
| 603 | return false; |
| 604 | } |
Heemin Seog | 1a39dea | 2019-10-16 15:58:21 -0700 | [diff] [blame] | 605 | } |