Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 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.phone; |
| 18 | |
Adrian Roos | 7b54b07 | 2018-03-08 12:52:22 +0100 | [diff] [blame] | 19 | import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; |
| 20 | |
Eliot Courtney | e77edea | 2017-11-15 14:25:21 +0900 | [diff] [blame] | 21 | import static com.android.systemui.statusbar.NotificationRemoteInputManager.ENABLE_REMOTE_INPUT; |
| 22 | |
Sudheer Shanka | dc589ac | 2016-11-10 15:30:17 -0800 | [diff] [blame] | 23 | import android.app.ActivityManager; |
Jorim Jaggi | f6782ee | 2016-07-22 11:40:00 +0200 | [diff] [blame] | 24 | import android.app.IActivityManager; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 25 | import android.app.WallpaperManager; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 26 | import android.content.Context; |
| 27 | import android.content.pm.ActivityInfo; |
| 28 | import android.content.res.Resources; |
| 29 | import android.graphics.PixelFormat; |
Wale Ogunwale | 6ce0fb8 | 2016-12-13 14:24:00 -0800 | [diff] [blame] | 30 | import android.os.Binder; |
Jorim Jaggi | f6782ee | 2016-07-22 11:40:00 +0200 | [diff] [blame] | 31 | import android.os.RemoteException; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 32 | import android.os.SystemProperties; |
Jorim Jaggi | f6782ee | 2016-07-22 11:40:00 +0200 | [diff] [blame] | 33 | import android.util.Log; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 34 | import android.view.Gravity; |
| 35 | import android.view.View; |
| 36 | import android.view.ViewGroup; |
| 37 | import android.view.WindowManager; |
Jorim Jaggi | f12ec0f | 2017-08-23 16:14:10 +0200 | [diff] [blame] | 38 | import android.view.WindowManager.LayoutParams; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 39 | |
Lucas Dupin | a3e3627 | 2018-08-21 13:22:33 -0700 | [diff] [blame] | 40 | import com.android.internal.annotations.VisibleForTesting; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 41 | import com.android.keyguard.R; |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 42 | import com.android.systemui.Dependency; |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 43 | import com.android.systemui.Dumpable; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 44 | import com.android.systemui.colorextraction.SysuiColorExtractor; |
Jorim Jaggi | 6b88cdf | 2014-12-22 20:56:50 +0100 | [diff] [blame] | 45 | import com.android.systemui.keyguard.KeyguardViewMediator; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 46 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
| 47 | import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 48 | import com.android.systemui.statusbar.RemoteInputController.Callback; |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 49 | import com.android.systemui.statusbar.StatusBarState; |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 50 | import com.android.systemui.statusbar.SysuiStatusBarStateController; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 51 | import com.android.systemui.statusbar.policy.ConfigurationController; |
| 52 | import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 53 | |
Selim Cinek | 7025f26 | 2015-07-13 16:22:48 -0700 | [diff] [blame] | 54 | import java.io.FileDescriptor; |
| 55 | import java.io.PrintWriter; |
Selim Cinek | 6a1bd2b | 2015-06-02 16:02:41 +0200 | [diff] [blame] | 56 | import java.lang.reflect.Field; |
| 57 | |
Jason Monk | 196d639 | 2018-12-20 13:25:34 -0500 | [diff] [blame] | 58 | import javax.inject.Inject; |
| 59 | import javax.inject.Singleton; |
| 60 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 61 | /** |
| 62 | * Encapsulates all logic for the status bar window state management. |
| 63 | */ |
Jason Monk | 196d639 | 2018-12-20 13:25:34 -0500 | [diff] [blame] | 64 | @Singleton |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 65 | public class StatusBarWindowController implements Callback, Dumpable, ConfigurationListener { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 66 | |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 67 | private static final String TAG = "StatusBarWindowController"; |
Jorim Jaggi | f6782ee | 2016-07-22 11:40:00 +0200 | [diff] [blame] | 68 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 69 | private final Context mContext; |
| 70 | private final WindowManager mWindowManager; |
Jorim Jaggi | f6782ee | 2016-07-22 11:40:00 +0200 | [diff] [blame] | 71 | private final IActivityManager mActivityManager; |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 72 | private final DozeParameters mDozeParameters; |
Lucas Dupin | 42ebe54 | 2019-01-22 09:45:09 -0800 | [diff] [blame] | 73 | private final WindowManager.LayoutParams mLpChanged; |
| 74 | private final boolean mKeyguardScreenRotation; |
Mady Mellor | d1c78b26 | 2018-11-06 18:04:40 -0800 | [diff] [blame] | 75 | private ViewGroup mStatusBarView; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 76 | private WindowManager.LayoutParams mLp; |
Jorim Jaggi | f6782ee | 2016-07-22 11:40:00 +0200 | [diff] [blame] | 77 | private boolean mHasTopUi; |
| 78 | private boolean mHasTopUiChanged; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 79 | private int mBarHeight; |
Adrian Roos | 3e23eb5 | 2017-07-07 15:58:57 +0200 | [diff] [blame] | 80 | private float mScreenBrightnessDoze; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 81 | private final State mCurrentState = new State(); |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 82 | private OtherwisedCollapsedListener mListener; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 83 | |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 84 | private final SysuiColorExtractor mColorExtractor = Dependency.get(SysuiColorExtractor.class); |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 85 | |
Jason Monk | 196d639 | 2018-12-20 13:25:34 -0500 | [diff] [blame] | 86 | @Inject |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 87 | public StatusBarWindowController(Context context) { |
Lucas Dupin | a3e3627 | 2018-08-21 13:22:33 -0700 | [diff] [blame] | 88 | this(context, context.getSystemService(WindowManager.class), ActivityManager.getService(), |
| 89 | DozeParameters.getInstance(context)); |
| 90 | } |
| 91 | |
| 92 | @VisibleForTesting |
Mady Mellor | ebdbbb9 | 2018-11-15 14:36:48 -0800 | [diff] [blame] | 93 | public StatusBarWindowController(Context context, WindowManager windowManager, |
Lucas Dupin | a3e3627 | 2018-08-21 13:22:33 -0700 | [diff] [blame] | 94 | IActivityManager activityManager, DozeParameters dozeParameters) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 95 | mContext = context; |
Lucas Dupin | a3e3627 | 2018-08-21 13:22:33 -0700 | [diff] [blame] | 96 | mWindowManager = windowManager; |
| 97 | mActivityManager = activityManager; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 98 | mKeyguardScreenRotation = shouldEnableKeyguardScreenRotation(); |
Lucas Dupin | a3e3627 | 2018-08-21 13:22:33 -0700 | [diff] [blame] | 99 | mDozeParameters = dozeParameters; |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 100 | mScreenBrightnessDoze = mDozeParameters.getScreenBrightnessDoze(); |
Lucas Dupin | 42ebe54 | 2019-01-22 09:45:09 -0800 | [diff] [blame] | 101 | mLpChanged = new WindowManager.LayoutParams(); |
Beverly | 8fdb533 | 2019-02-04 14:29:49 -0500 | [diff] [blame] | 102 | ((SysuiStatusBarStateController) Dependency.get(StatusBarStateController.class)) |
| 103 | .addCallback(mStateListener, |
| 104 | SysuiStatusBarStateController.RANK_STATUS_BAR_WINDOW_CONTROLLER); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 105 | Dependency.get(ConfigurationController.class).addCallback(this); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | private boolean shouldEnableKeyguardScreenRotation() { |
| 109 | Resources res = mContext.getResources(); |
| 110 | return SystemProperties.getBoolean("lockscreen.rot_override", false) |
| 111 | || res.getBoolean(R.bool.config_enableLockScreenRotation); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Adds the status bar view to the window manager. |
| 116 | * |
| 117 | * @param statusBarView The view to add. |
| 118 | * @param barHeight The height of the status bar in collapsed state. |
| 119 | */ |
Mady Mellor | d1c78b26 | 2018-11-06 18:04:40 -0800 | [diff] [blame] | 120 | public void add(ViewGroup statusBarView, int barHeight) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 121 | |
| 122 | // Now that the status bar window encompasses the sliding panel and its |
| 123 | // translucent backdrop, the entire thing is made TRANSLUCENT and is |
| 124 | // hardware-accelerated. |
| 125 | mLp = new WindowManager.LayoutParams( |
| 126 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 127 | barHeight, |
| 128 | WindowManager.LayoutParams.TYPE_STATUS_BAR, |
| 129 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 130 | | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING |
| 131 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH |
| 132 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 133 | | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 134 | PixelFormat.TRANSLUCENT); |
Wale Ogunwale | 6ce0fb8 | 2016-12-13 14:24:00 -0800 | [diff] [blame] | 135 | mLp.token = new Binder(); |
Jorim Jaggi | 76aaef5 | 2014-05-08 19:16:49 +0200 | [diff] [blame] | 136 | mLp.gravity = Gravity.TOP; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 137 | mLp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 138 | mLp.setTitle("StatusBar"); |
| 139 | mLp.packageName = mContext.getPackageName(); |
Adrian Roos | 7b54b07 | 2018-03-08 12:52:22 +0100 | [diff] [blame] | 140 | mLp.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 141 | mStatusBarView = statusBarView; |
| 142 | mBarHeight = barHeight; |
| 143 | mWindowManager.addView(mStatusBarView, mLp); |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 144 | mLpChanged.copyFrom(mLp); |
Lucas Dupin | fdbfc54 | 2018-09-17 15:56:09 -0700 | [diff] [blame] | 145 | onThemeChanged(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 146 | } |
| 147 | |
Mady Mellor | d1c78b26 | 2018-11-06 18:04:40 -0800 | [diff] [blame] | 148 | public ViewGroup getStatusBarView() { |
Mady Mellor | c3d6f7d | 2018-11-07 09:36:56 -0800 | [diff] [blame] | 149 | return mStatusBarView; |
| 150 | } |
| 151 | |
Adrian Roos | 3e23eb5 | 2017-07-07 15:58:57 +0200 | [diff] [blame] | 152 | public void setDozeScreenBrightness(int value) { |
| 153 | mScreenBrightnessDoze = value / 255f; |
| 154 | } |
| 155 | |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 156 | private void setKeyguardDark(boolean dark) { |
Lucas Dupin | 987f193 | 2017-05-13 21:02:52 -0700 | [diff] [blame] | 157 | int vis = mStatusBarView.getSystemUiVisibility(); |
| 158 | if (dark) { |
| 159 | vis = vis | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; |
| 160 | vis = vis | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; |
| 161 | } else { |
| 162 | vis = vis & ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; |
| 163 | vis = vis & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; |
| 164 | } |
| 165 | mStatusBarView.setSystemUiVisibility(vis); |
| 166 | } |
| 167 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 168 | private void applyKeyguardFlags(State state) { |
| 169 | if (state.keyguardShowing) { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 170 | mLpChanged.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 171 | } else { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 172 | mLpChanged.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 173 | } |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 174 | |
Lucas Dupin | 16cfe45 | 2018-02-08 13:14:50 -0800 | [diff] [blame] | 175 | final boolean scrimsOccludingWallpaper = |
| 176 | state.scrimsVisibility == ScrimController.VISIBILITY_FULLY_OPAQUE; |
Lucas Dupin | 47a65c7 | 2018-02-15 14:16:18 -0800 | [diff] [blame] | 177 | final boolean keyguardOrAod = state.keyguardShowing |
| 178 | || (state.dozing && mDozeParameters.getAlwaysOn()); |
Selim Cinek | dbf172e | 2018-08-08 18:31:45 +0000 | [diff] [blame] | 179 | if (keyguardOrAod && !state.backdropShowing && !scrimsOccludingWallpaper) { |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 180 | mLpChanged.flags |= WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
| 181 | } else { |
| 182 | mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
| 183 | } |
Lucas Dupin | a3e3627 | 2018-08-21 13:22:33 -0700 | [diff] [blame] | 184 | |
| 185 | if (state.dozing) { |
Philip P. Moltmann | 66ce238 | 2018-10-09 13:46:11 -0700 | [diff] [blame] | 186 | mLpChanged.privateFlags |= LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; |
Lucas Dupin | a3e3627 | 2018-08-21 13:22:33 -0700 | [diff] [blame] | 187 | } else { |
Philip P. Moltmann | 66ce238 | 2018-10-09 13:46:11 -0700 | [diff] [blame] | 188 | mLpChanged.privateFlags &= ~LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; |
Lucas Dupin | a3e3627 | 2018-08-21 13:22:33 -0700 | [diff] [blame] | 189 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | private void adjustScreenOrientation(State state) { |
Adrian Roos | 8206944 | 2017-06-28 19:37:24 +0200 | [diff] [blame] | 193 | if (state.isKeyguardShowingAndNotOccluded() || state.dozing) { |
Jorim Jaggi | ca36cf7 | 2014-04-17 20:36:15 +0200 | [diff] [blame] | 194 | if (mKeyguardScreenRotation) { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 195 | mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER; |
Jorim Jaggi | ca36cf7 | 2014-04-17 20:36:15 +0200 | [diff] [blame] | 196 | } else { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 197 | mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; |
Jorim Jaggi | ca36cf7 | 2014-04-17 20:36:15 +0200 | [diff] [blame] | 198 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 199 | } else { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 200 | mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 201 | } |
| 202 | } |
| 203 | |
| 204 | private void applyFocusableFlag(State state) { |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 205 | boolean panelFocusable = state.statusBarFocusable && state.panelExpanded; |
Jorim Jaggi | bb33669 | 2016-11-15 15:24:26 -0800 | [diff] [blame] | 206 | if (state.bouncerShowing && (state.keyguardOccluded || state.keyguardNeedsInput) |
Issei Suzuki | ac9fcb7 | 2019-02-04 17:45:57 +0100 | [diff] [blame] | 207 | || ENABLE_REMOTE_INPUT && state.remoteInputActive |
| 208 | || state.bubbleExpanded) { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 209 | mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; |
| 210 | mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 211 | } else if (state.isKeyguardShowingAndNotOccluded() || panelFocusable) { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 212 | mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; |
| 213 | mLpChanged.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 214 | } else { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 215 | mLpChanged.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; |
| 216 | mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 217 | } |
Adrian Roos | dc5b453 | 2016-01-06 20:49:41 +0100 | [diff] [blame] | 218 | |
Adrian Roos | 5153d4a | 2016-03-22 10:01:56 -0700 | [diff] [blame] | 219 | mLpChanged.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 220 | } |
| 221 | |
Tiger Huang | a90dea4 | 2018-08-03 17:20:17 +0800 | [diff] [blame] | 222 | private void applyForceShowNavigationFlag(State state) { |
| 223 | if (state.panelExpanded || state.bouncerShowing |
Tiger Huang | 3404601 | 2018-06-29 15:26:52 +0800 | [diff] [blame] | 224 | || ENABLE_REMOTE_INPUT && state.remoteInputActive) { |
Tiger Huang | a90dea4 | 2018-08-03 17:20:17 +0800 | [diff] [blame] | 225 | mLpChanged.privateFlags |= LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION; |
Tiger Huang | 3404601 | 2018-06-29 15:26:52 +0800 | [diff] [blame] | 226 | } else { |
Tiger Huang | a90dea4 | 2018-08-03 17:20:17 +0800 | [diff] [blame] | 227 | mLpChanged.privateFlags &= ~LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION; |
Tiger Huang | 3404601 | 2018-06-29 15:26:52 +0800 | [diff] [blame] | 228 | } |
| 229 | } |
| 230 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 231 | private void applyHeight(State state) { |
Selim Cinek | 6a1bd2b | 2015-06-02 16:02:41 +0200 | [diff] [blame] | 232 | boolean expanded = isExpanded(state); |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 233 | if (state.forcePluginOpen) { |
Lucas Dupin | 42ebe54 | 2019-01-22 09:45:09 -0800 | [diff] [blame] | 234 | if (mListener != null) { |
| 235 | mListener.setWouldOtherwiseCollapse(expanded); |
| 236 | } |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 237 | expanded = true; |
| 238 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 239 | if (expanded) { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 240 | mLpChanged.height = ViewGroup.LayoutParams.MATCH_PARENT; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 241 | } else { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 242 | mLpChanged.height = mBarHeight; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 243 | } |
| 244 | } |
| 245 | |
Selim Cinek | 6a1bd2b | 2015-06-02 16:02:41 +0200 | [diff] [blame] | 246 | private boolean isExpanded(State state) { |
| 247 | return !state.forceCollapsed && (state.isKeyguardShowingAndNotOccluded() |
| 248 | || state.panelVisible || state.keyguardFadingAway || state.bouncerShowing |
James O'Leary | 4855f45 | 2019-02-25 12:29:50 -0500 | [diff] [blame] | 249 | || state.headsUpShowing || state.bubblesShowing || state.assistShowing |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 250 | || state.scrimsVisibility != ScrimController.VISIBILITY_FULLY_TRANSPARENT); |
Selim Cinek | 6a1bd2b | 2015-06-02 16:02:41 +0200 | [diff] [blame] | 251 | } |
| 252 | |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 253 | private void applyFitsSystemWindows(State state) { |
Adrian Roos | a5d6cd0 | 2016-07-27 15:12:40 -0700 | [diff] [blame] | 254 | boolean fitsSystemWindows = !state.isKeyguardShowingAndNotOccluded(); |
Lucas Dupin | 42ebe54 | 2019-01-22 09:45:09 -0800 | [diff] [blame] | 255 | if (mStatusBarView != null && mStatusBarView.getFitsSystemWindows() != fitsSystemWindows) { |
Adrian Roos | a5d6cd0 | 2016-07-27 15:12:40 -0700 | [diff] [blame] | 256 | mStatusBarView.setFitsSystemWindows(fitsSystemWindows); |
| 257 | mStatusBarView.requestApplyInsets(); |
| 258 | } |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 259 | } |
| 260 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 261 | private void applyUserActivityTimeout(State state) { |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 262 | if (state.isKeyguardShowingAndNotOccluded() |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 263 | && state.statusBarState == StatusBarState.KEYGUARD |
| 264 | && !state.qsExpanded) { |
Jorim Jaggi | 6b88cdf | 2014-12-22 20:56:50 +0100 | [diff] [blame] | 265 | mLpChanged.userActivityTimeout = KeyguardViewMediator.AWAKE_INTERVAL_DEFAULT_MS; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 266 | } else { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 267 | mLpChanged.userActivityTimeout = -1; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 271 | private void applyInputFeatures(State state) { |
Jorim Jaggi | 4222d9a | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 272 | if (state.isKeyguardShowingAndNotOccluded() |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 273 | && state.statusBarState == StatusBarState.KEYGUARD |
Vadim Tryshev | 6069c40 | 2016-03-09 14:24:29 -0800 | [diff] [blame] | 274 | && !state.qsExpanded && !state.forceUserActivity) { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 275 | mLpChanged.inputFeatures |= |
| 276 | WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 277 | } else { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 278 | mLpChanged.inputFeatures &= |
| 279 | ~WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY; |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 280 | } |
| 281 | } |
| 282 | |
Peiyong Lin | 7504538 | 2019-03-04 19:22:33 -0800 | [diff] [blame] | 283 | private void applyStatusBarColorSpaceAgnosticFlag(State state) { |
| 284 | if (!isExpanded(state)) { |
| 285 | mLpChanged.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC; |
| 286 | } else { |
| 287 | mLpChanged.privateFlags &= |
| 288 | ~WindowManager.LayoutParams.PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC; |
| 289 | } |
| 290 | } |
| 291 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 292 | private void apply(State state) { |
| 293 | applyKeyguardFlags(state); |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 294 | applyForceStatusBarVisibleFlag(state); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 295 | applyFocusableFlag(state); |
Tiger Huang | a90dea4 | 2018-08-03 17:20:17 +0800 | [diff] [blame] | 296 | applyForceShowNavigationFlag(state); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 297 | adjustScreenOrientation(state); |
| 298 | applyHeight(state); |
| 299 | applyUserActivityTimeout(state); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 300 | applyInputFeatures(state); |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 301 | applyFitsSystemWindows(state); |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 302 | applyModalFlag(state); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 303 | applyBrightness(state); |
Jorim Jaggi | f6782ee | 2016-07-22 11:40:00 +0200 | [diff] [blame] | 304 | applyHasTopUi(state); |
Hyunyoung Song | c1647ea | 2018-08-20 12:23:46 -0700 | [diff] [blame] | 305 | applyNotTouchable(state); |
Peiyong Lin | 7504538 | 2019-03-04 19:22:33 -0800 | [diff] [blame] | 306 | applyStatusBarColorSpaceAgnosticFlag(state); |
Lucas Dupin | 42ebe54 | 2019-01-22 09:45:09 -0800 | [diff] [blame] | 307 | if (mLp != null && mLp.copyFrom(mLpChanged) != 0) { |
Jorim Jaggi | 95e89ca | 2014-11-24 20:12:50 +0100 | [diff] [blame] | 308 | mWindowManager.updateViewLayout(mStatusBarView, mLp); |
| 309 | } |
Jorim Jaggi | f6782ee | 2016-07-22 11:40:00 +0200 | [diff] [blame] | 310 | if (mHasTopUi != mHasTopUiChanged) { |
| 311 | try { |
| 312 | mActivityManager.setHasTopUi(mHasTopUiChanged); |
| 313 | } catch (RemoteException e) { |
| 314 | Log.e(TAG, "Failed to call setHasTopUi", e); |
| 315 | } |
| 316 | mHasTopUi = mHasTopUiChanged; |
| 317 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 318 | } |
| 319 | |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 320 | private void applyForceStatusBarVisibleFlag(State state) { |
| 321 | if (state.forceStatusBarVisible) { |
| 322 | mLpChanged.privateFlags |= WindowManager |
| 323 | .LayoutParams.PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT; |
| 324 | } else { |
| 325 | mLpChanged.privateFlags &= ~WindowManager |
| 326 | .LayoutParams.PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT; |
| 327 | } |
| 328 | } |
| 329 | |
Selim Cinek | a59ecc3 | 2015-04-07 10:51:49 -0700 | [diff] [blame] | 330 | private void applyModalFlag(State state) { |
| 331 | if (state.headsUpShowing) { |
| 332 | mLpChanged.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; |
| 333 | } else { |
| 334 | mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; |
| 335 | } |
| 336 | } |
| 337 | |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 338 | private void applyBrightness(State state) { |
| 339 | if (state.forceDozeBrightness) { |
| 340 | mLpChanged.screenBrightness = mScreenBrightnessDoze; |
| 341 | } else { |
| 342 | mLpChanged.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE; |
| 343 | } |
| 344 | } |
| 345 | |
Jorim Jaggi | f6782ee | 2016-07-22 11:40:00 +0200 | [diff] [blame] | 346 | private void applyHasTopUi(State state) { |
| 347 | mHasTopUiChanged = isExpanded(state); |
| 348 | } |
| 349 | |
Hyunyoung Song | c1647ea | 2018-08-20 12:23:46 -0700 | [diff] [blame] | 350 | private void applyNotTouchable(State state) { |
| 351 | if (state.notTouchable) { |
| 352 | mLpChanged.flags |= LayoutParams.FLAG_NOT_TOUCHABLE; |
| 353 | } else { |
| 354 | mLpChanged.flags &= ~LayoutParams.FLAG_NOT_TOUCHABLE; |
| 355 | } |
| 356 | } |
| 357 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 358 | public void setKeyguardShowing(boolean showing) { |
| 359 | mCurrentState.keyguardShowing = showing; |
| 360 | apply(mCurrentState); |
| 361 | } |
| 362 | |
| 363 | public void setKeyguardOccluded(boolean occluded) { |
| 364 | mCurrentState.keyguardOccluded = occluded; |
| 365 | apply(mCurrentState); |
| 366 | } |
| 367 | |
| 368 | public void setKeyguardNeedsInput(boolean needsInput) { |
| 369 | mCurrentState.keyguardNeedsInput = needsInput; |
| 370 | apply(mCurrentState); |
| 371 | } |
| 372 | |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 373 | public void setPanelVisible(boolean visible) { |
| 374 | mCurrentState.panelVisible = visible; |
| 375 | mCurrentState.statusBarFocusable = visible; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 376 | apply(mCurrentState); |
| 377 | } |
| 378 | |
| 379 | public void setStatusBarFocusable(boolean focusable) { |
| 380 | mCurrentState.statusBarFocusable = focusable; |
| 381 | apply(mCurrentState); |
| 382 | } |
| 383 | |
Jorim Jaggi | 5fd4d05 | 2014-05-13 22:50:20 +0200 | [diff] [blame] | 384 | public void setBouncerShowing(boolean showing) { |
| 385 | mCurrentState.bouncerShowing = showing; |
| 386 | apply(mCurrentState); |
| 387 | } |
| 388 | |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 389 | public void setBackdropShowing(boolean showing) { |
| 390 | mCurrentState.backdropShowing = showing; |
| 391 | apply(mCurrentState); |
| 392 | } |
| 393 | |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 394 | public void setKeyguardFadingAway(boolean keyguardFadingAway) { |
| 395 | mCurrentState.keyguardFadingAway = keyguardFadingAway; |
| 396 | apply(mCurrentState); |
| 397 | } |
| 398 | |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 399 | public void setQsExpanded(boolean expanded) { |
| 400 | mCurrentState.qsExpanded = expanded; |
| 401 | apply(mCurrentState); |
| 402 | } |
| 403 | |
Vadim Tryshev | 6069c40 | 2016-03-09 14:24:29 -0800 | [diff] [blame] | 404 | public void setForceUserActivity(boolean forceUserActivity) { |
| 405 | mCurrentState.forceUserActivity = forceUserActivity; |
| 406 | apply(mCurrentState); |
| 407 | } |
| 408 | |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 409 | public void setScrimsVisibility(int scrimsVisibility) { |
| 410 | mCurrentState.scrimsVisibility = scrimsVisibility; |
Adrian Roos | a5c6322 | 2017-07-27 16:33:39 +0200 | [diff] [blame] | 411 | apply(mCurrentState); |
| 412 | } |
| 413 | |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 414 | public void setHeadsUpShowing(boolean showing) { |
| 415 | mCurrentState.headsUpShowing = showing; |
| 416 | apply(mCurrentState); |
| 417 | } |
| 418 | |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 419 | public void setWallpaperSupportsAmbientMode(boolean supportsAmbientMode) { |
| 420 | mCurrentState.wallpaperSupportsAmbientMode = supportsAmbientMode; |
| 421 | apply(mCurrentState); |
| 422 | } |
| 423 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 424 | /** |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 425 | * @param state The {@link StatusBarStateController} of the status bar. |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 426 | */ |
Jason Monk | 1fd3fc3 | 2018-08-14 17:20:09 -0400 | [diff] [blame] | 427 | private void setStatusBarState(int state) { |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 428 | mCurrentState.statusBarState = state; |
| 429 | apply(mCurrentState); |
| 430 | } |
| 431 | |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 432 | public void setForceStatusBarVisible(boolean forceStatusBarVisible) { |
| 433 | mCurrentState.forceStatusBarVisible = forceStatusBarVisible; |
| 434 | apply(mCurrentState); |
| 435 | } |
| 436 | |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 437 | /** |
| 438 | * Force the window to be collapsed, even if it should theoretically be expanded. |
| 439 | * Used for when a heads-up comes in but we still need to wait for the touchable regions to |
| 440 | * be computed. |
| 441 | */ |
| 442 | public void setForceWindowCollapsed(boolean force) { |
| 443 | mCurrentState.forceCollapsed = force; |
| 444 | apply(mCurrentState); |
| 445 | } |
| 446 | |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 447 | public void setPanelExpanded(boolean isExpanded) { |
| 448 | mCurrentState.panelExpanded = isExpanded; |
| 449 | apply(mCurrentState); |
| 450 | } |
| 451 | |
Adrian Roos | d28ccd7 | 2016-01-06 15:23:14 +0100 | [diff] [blame] | 452 | @Override |
| 453 | public void onRemoteInputActive(boolean remoteInputActive) { |
Adrian Roos | 1c0ca50 | 2015-10-07 12:20:42 -0700 | [diff] [blame] | 454 | mCurrentState.remoteInputActive = remoteInputActive; |
| 455 | apply(mCurrentState); |
| 456 | } |
| 457 | |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 458 | /** |
| 459 | * Set whether the screen brightness is forced to the value we use for doze mode by the status |
| 460 | * bar window. |
| 461 | */ |
| 462 | public void setForceDozeBrightness(boolean forceDozeBrightness) { |
| 463 | mCurrentState.forceDozeBrightness = forceDozeBrightness; |
| 464 | apply(mCurrentState); |
| 465 | } |
| 466 | |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 467 | public void setDozing(boolean dozing) { |
| 468 | mCurrentState.dozing = dozing; |
| 469 | apply(mCurrentState); |
| 470 | } |
| 471 | |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 472 | public void setBarHeight(int barHeight) { |
| 473 | mBarHeight = barHeight; |
| 474 | apply(mCurrentState); |
| 475 | } |
| 476 | |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 477 | public void setForcePluginOpen(boolean forcePluginOpen) { |
| 478 | mCurrentState.forcePluginOpen = forcePluginOpen; |
| 479 | apply(mCurrentState); |
| 480 | } |
| 481 | |
Hyunyoung Song | c1647ea | 2018-08-20 12:23:46 -0700 | [diff] [blame] | 482 | public void setNotTouchable(boolean notTouchable) { |
| 483 | mCurrentState.notTouchable = notTouchable; |
| 484 | apply(mCurrentState); |
| 485 | } |
| 486 | |
Mady Mellor | d1c78b26 | 2018-11-06 18:04:40 -0800 | [diff] [blame] | 487 | /** |
| 488 | * Sets whether there are bubbles showing on the screen. |
| 489 | */ |
| 490 | public void setBubblesShowing(boolean bubblesShowing) { |
| 491 | mCurrentState.bubblesShowing = bubblesShowing; |
| 492 | apply(mCurrentState); |
| 493 | } |
| 494 | |
| 495 | /** |
| 496 | * The bubbles showing state for the status bar. |
| 497 | */ |
| 498 | public boolean getBubblesShowing() { |
| 499 | return mCurrentState.bubblesShowing; |
| 500 | } |
| 501 | |
Issei Suzuki | ac9fcb7 | 2019-02-04 17:45:57 +0100 | [diff] [blame] | 502 | /** |
James O'Leary | 4855f45 | 2019-02-25 12:29:50 -0500 | [diff] [blame] | 503 | * Sets whether assist UI is showing on the screen. |
| 504 | */ |
| 505 | public void setAssistShowing(boolean assistShowing) { |
| 506 | mCurrentState.assistShowing = assistShowing; |
| 507 | apply(mCurrentState); |
| 508 | } |
| 509 | |
| 510 | /** |
| 511 | * The assist UI showing state for the status bar. |
| 512 | */ |
| 513 | public boolean getAssistShowing() { |
| 514 | return mCurrentState.assistShowing; |
| 515 | } |
| 516 | |
| 517 | /** |
Issei Suzuki | ac9fcb7 | 2019-02-04 17:45:57 +0100 | [diff] [blame] | 518 | * Sets if there is a bubble being expanded on the screen. |
| 519 | */ |
| 520 | public void setBubbleExpanded(boolean bubbleExpanded) { |
| 521 | mCurrentState.bubbleExpanded = bubbleExpanded; |
| 522 | apply(mCurrentState); |
| 523 | } |
| 524 | |
| 525 | /** |
| 526 | * The bubble is shown in expanded state for the status bar. |
| 527 | */ |
| 528 | public boolean getBubbleExpanded() { |
| 529 | return mCurrentState.bubbleExpanded; |
| 530 | } |
| 531 | |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 532 | public void setStateListener(OtherwisedCollapsedListener listener) { |
| 533 | mListener = listener; |
| 534 | } |
| 535 | |
Selim Cinek | 7025f26 | 2015-07-13 16:22:48 -0700 | [diff] [blame] | 536 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 537 | pw.println("StatusBarWindowController state:"); |
Selim Cinek | 7025f26 | 2015-07-13 16:22:48 -0700 | [diff] [blame] | 538 | pw.println(mCurrentState); |
Selim Cinek | 6a1bd2b | 2015-06-02 16:02:41 +0200 | [diff] [blame] | 539 | } |
| 540 | |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 541 | public boolean isShowingWallpaper() { |
| 542 | return !mCurrentState.backdropShowing; |
| 543 | } |
| 544 | |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 545 | @Override |
| 546 | public void onThemeChanged() { |
Lucas Dupin | fdbfc54 | 2018-09-17 15:56:09 -0700 | [diff] [blame] | 547 | if (mStatusBarView == null) { |
| 548 | return; |
| 549 | } |
| 550 | |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 551 | StatusBarStateController state = Dependency.get(StatusBarStateController.class); |
| 552 | int which; |
| 553 | if (state.getState() == StatusBarState.KEYGUARD |
| 554 | || state.getState() == StatusBarState.SHADE_LOCKED) { |
| 555 | which = WallpaperManager.FLAG_LOCK; |
| 556 | } else { |
| 557 | which = WallpaperManager.FLAG_SYSTEM; |
| 558 | } |
| 559 | final boolean useDarkText = mColorExtractor.getColors(which, |
| 560 | true /* ignoreVisibility */).supportsDarkText(); |
| 561 | |
| 562 | // Make sure we have the correct navbar/statusbar colors. |
| 563 | setKeyguardDark(useDarkText); |
| 564 | } |
| 565 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 566 | private static class State { |
| 567 | boolean keyguardShowing; |
| 568 | boolean keyguardOccluded; |
| 569 | boolean keyguardNeedsInput; |
Selim Cinek | 4a21a7f | 2015-05-19 11:00:38 -0700 | [diff] [blame] | 570 | boolean panelVisible; |
| 571 | boolean panelExpanded; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 572 | boolean statusBarFocusable; |
Jorim Jaggi | 5fd4d05 | 2014-05-13 22:50:20 +0200 | [diff] [blame] | 573 | boolean bouncerShowing; |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 574 | boolean keyguardFadingAway; |
Jorim Jaggi | b690f0d | 2014-07-03 23:25:44 +0200 | [diff] [blame] | 575 | boolean qsExpanded; |
Selim Cinek | b8f09cf | 2015-03-16 17:09:28 -0700 | [diff] [blame] | 576 | boolean headsUpShowing; |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 577 | boolean forceStatusBarVisible; |
Selim Cinek | 737bff3 | 2015-05-08 16:08:35 -0700 | [diff] [blame] | 578 | boolean forceCollapsed; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 579 | boolean forceDozeBrightness; |
Vadim Tryshev | 6069c40 | 2016-03-09 14:24:29 -0800 | [diff] [blame] | 580 | boolean forceUserActivity; |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 581 | boolean backdropShowing; |
Lucas Dupin | 7517b5d | 2017-08-22 12:51:25 -0700 | [diff] [blame] | 582 | boolean wallpaperSupportsAmbientMode; |
Hyunyoung Song | c1647ea | 2018-08-20 12:23:46 -0700 | [diff] [blame] | 583 | boolean notTouchable; |
Mady Mellor | d1c78b26 | 2018-11-06 18:04:40 -0800 | [diff] [blame] | 584 | boolean bubblesShowing; |
Issei Suzuki | ac9fcb7 | 2019-02-04 17:45:57 +0100 | [diff] [blame] | 585 | boolean bubbleExpanded; |
James O'Leary | 4855f45 | 2019-02-25 12:29:50 -0500 | [diff] [blame] | 586 | boolean assistShowing; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 587 | |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 588 | /** |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 589 | * The {@link StatusBar} state from the status bar. |
Jorim Jaggi | ecbab36 | 2014-04-23 16:13:15 +0200 | [diff] [blame] | 590 | */ |
| 591 | int statusBarState; |
| 592 | |
Adrian Roos | 1c0ca50 | 2015-10-07 12:20:42 -0700 | [diff] [blame] | 593 | boolean remoteInputActive; |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 594 | boolean forcePluginOpen; |
Adrian Roos | 67cca74 | 2017-04-13 16:52:51 -0700 | [diff] [blame] | 595 | boolean dozing; |
Lucas Dupin | 82aa163 | 2017-12-13 00:13:57 -0800 | [diff] [blame] | 596 | int scrimsVisibility; |
Adrian Roos | 1c0ca50 | 2015-10-07 12:20:42 -0700 | [diff] [blame] | 597 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 598 | private boolean isKeyguardShowingAndNotOccluded() { |
| 599 | return keyguardShowing && !keyguardOccluded; |
| 600 | } |
Selim Cinek | 6a1bd2b | 2015-06-02 16:02:41 +0200 | [diff] [blame] | 601 | |
| 602 | @Override |
| 603 | public String toString() { |
| 604 | StringBuilder result = new StringBuilder(); |
| 605 | String newLine = "\n"; |
| 606 | result.append("Window State {"); |
| 607 | result.append(newLine); |
| 608 | |
| 609 | Field[] fields = this.getClass().getDeclaredFields(); |
| 610 | |
| 611 | // Print field names paired with their values |
| 612 | for (Field field : fields) { |
| 613 | result.append(" "); |
| 614 | try { |
| 615 | result.append(field.getName()); |
| 616 | result.append(": "); |
| 617 | //requires access to private field: |
| 618 | result.append(field.get(this)); |
| 619 | } catch (IllegalAccessException ex) { |
| 620 | } |
| 621 | result.append(newLine); |
| 622 | } |
| 623 | result.append("}"); |
| 624 | |
| 625 | return result.toString(); |
| 626 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 627 | } |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 628 | |
Evan Laird | 878c853 | 2018-10-15 15:54:29 -0400 | [diff] [blame] | 629 | private final StateListener mStateListener = new StateListener() { |
| 630 | @Override |
| 631 | public void onStateChanged(int newState) { |
| 632 | setStatusBarState(newState); |
| 633 | } |
| 634 | |
| 635 | @Override |
| 636 | public void onDozingChanged(boolean isDozing) { |
| 637 | setDozing(isDozing); |
| 638 | } |
| 639 | }; |
| 640 | |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 641 | /** |
| 642 | * Custom listener to pipe data back to plugins about whether or not the status bar would be |
| 643 | * collapsed if not for the plugin. |
| 644 | * TODO: Find cleaner way to do this. |
| 645 | */ |
| 646 | public interface OtherwisedCollapsedListener { |
| 647 | void setWouldOtherwiseCollapse(boolean otherwiseCollapse); |
| 648 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 649 | } |