The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 17 | package com.android.server.statusbar; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 19 | import android.app.ActivityThread; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | import android.app.StatusBarManager; |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 21 | import android.content.ComponentName; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 22 | import android.content.Context; |
| 23 | import android.content.pm.PackageManager; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 24 | import android.graphics.Rect; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 25 | import android.os.Binder; |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 26 | import android.os.Bundle; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 27 | import android.os.Handler; |
| 28 | import android.os.IBinder; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 29 | import android.os.PowerManager; |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 30 | import android.os.Process; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 31 | import android.os.RemoteException; |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 32 | import android.os.ResultReceiver; |
Dianne Hackborn | 354736e | 2016-08-22 17:00:05 -0700 | [diff] [blame] | 33 | import android.os.ShellCallback; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 34 | import android.os.UserHandle; |
Dan Sandler | f3a1f2c | 2016-06-26 15:59:13 -0400 | [diff] [blame] | 35 | import android.text.TextUtils; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 36 | import android.util.ArrayMap; |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 37 | import android.util.Slog; |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 38 | |
Jason Monk | b430218 | 2017-08-04 13:39:17 -0400 | [diff] [blame] | 39 | import com.android.internal.R; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 40 | import com.android.internal.statusbar.IStatusBar; |
| 41 | import com.android.internal.statusbar.IStatusBarService; |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 42 | import com.android.internal.statusbar.NotificationVisibility; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 43 | import com.android.internal.statusbar.StatusBarIcon; |
Jeff Sharkey | fe9a53b | 2017-03-31 14:08:23 -0600 | [diff] [blame] | 44 | import com.android.internal.util.DumpUtils; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 45 | import com.android.server.LocalServices; |
| 46 | import com.android.server.notification.NotificationDelegate; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 47 | import com.android.server.power.ShutdownThread; |
| 48 | import com.android.server.statusbar.StatusBarManagerInternal.GlobalActionsListener; |
Dianne Hackborn | a924dc0d | 2011-02-17 14:22:17 -0800 | [diff] [blame] | 49 | import com.android.server.wm.WindowManagerService; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 50 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | import java.io.FileDescriptor; |
| 52 | import java.io.PrintWriter; |
| 53 | import java.util.ArrayList; |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 54 | import java.util.List; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | |
| 56 | |
| 57 | /** |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 58 | * A note on locking: We rely on the fact that calls onto mBar are oneway or |
| 59 | * if they are local, that they just enqueue messages to not deadlock. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | */ |
Michael Wright | 665366a | 2014-08-07 15:44:40 -0700 | [diff] [blame] | 61 | public class StatusBarManagerService extends IStatusBarService.Stub { |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 62 | private static final String TAG = "StatusBarManagerService"; |
| 63 | private static final boolean SPEW = false; |
Joe Onorato | df7dbb6 | 2009-11-17 10:43:37 -0800 | [diff] [blame] | 64 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 65 | private final Context mContext; |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 66 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 67 | private final WindowManagerService mWindowManager; |
| 68 | private Handler mHandler = new Handler(); |
| 69 | private NotificationDelegate mNotificationDelegate; |
| 70 | private volatile IStatusBar mBar; |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 71 | private ArrayMap<String, StatusBarIcon> mIcons = new ArrayMap<>(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 | |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 73 | // for disabling the status bar |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 74 | private final ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>(); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 75 | private GlobalActionsListener mGlobalActionListener; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 76 | private IBinder mSysUiVisToken = new Binder(); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 77 | private int mDisabled1 = 0; |
| 78 | private int mDisabled2 = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 79 | |
Adrian Roos | 2a62910 | 2016-04-15 16:28:03 -0700 | [diff] [blame] | 80 | private final Object mLock = new Object(); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 81 | // encompasses lights-out mode and other flags defined on View |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 82 | private int mSystemUiVisibility = 0; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 83 | private int mFullscreenStackSysUiVisibility; |
| 84 | private int mDockedStackSysUiVisibility; |
| 85 | private final Rect mFullscreenStackBounds = new Rect(); |
| 86 | private final Rect mDockedStackBounds = new Rect(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 87 | private boolean mMenuVisible = false; |
| 88 | private int mImeWindowVis = 0; |
| 89 | private int mImeBackDisposition; |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 90 | private boolean mShowImeSwitcher; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 91 | private IBinder mImeToken = null; |
| 92 | private int mCurrentUserId; |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 93 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | private class DisableRecord implements IBinder.DeathRecipient { |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 95 | int userId; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | String pkg; |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 97 | int what1; |
| 98 | int what2; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | IBinder token; |
| 100 | |
| 101 | public void binderDied() { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 102 | Slog.i(TAG, "binder died for pkg=" + pkg); |
Benjamin Franz | ea2ec97 | 2015-03-16 17:18:09 +0000 | [diff] [blame] | 103 | disableForUser(0, token, pkg, userId); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 104 | disable2ForUser(0, token, pkg, userId); |
Suchi Amalapurapu | fff2fda | 2009-06-30 21:36:16 -0700 | [diff] [blame] | 105 | token.unlinkToDeath(this, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 106 | } |
| 107 | } |
| 108 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 109 | /** |
| 110 | * Construct the service, add the status bar view to the window manager |
| 111 | */ |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 112 | public StatusBarManagerService(Context context, WindowManagerService windowManager) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 113 | mContext = context; |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 114 | mWindowManager = windowManager; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 115 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 116 | LocalServices.addService(StatusBarManagerInternal.class, mInternalService); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 117 | } |
| 118 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 119 | /** |
| 120 | * Private API used by NotificationManagerService. |
| 121 | */ |
| 122 | private final StatusBarManagerInternal mInternalService = new StatusBarManagerInternal() { |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 123 | private boolean mNotificationLightOn; |
| 124 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 125 | @Override |
| 126 | public void setNotificationDelegate(NotificationDelegate delegate) { |
Christoph Studer | e71fefc | 2014-06-24 16:16:49 +0200 | [diff] [blame] | 127 | mNotificationDelegate = delegate; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 128 | } |
John Spurlock | cb566aa | 2014-08-03 22:58:28 -0400 | [diff] [blame] | 129 | |
John Spurlock | cad5768 | 2014-07-26 17:09:56 -0400 | [diff] [blame] | 130 | @Override |
Andrii Kulian | 0f051f5 | 2016-04-14 00:41:51 -0700 | [diff] [blame] | 131 | public void showScreenPinningRequest(int taskId) { |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 132 | if (mBar != null) { |
| 133 | try { |
Andrii Kulian | 0f051f5 | 2016-04-14 00:41:51 -0700 | [diff] [blame] | 134 | mBar.showScreenPinningRequest(taskId); |
Jason Monk | 5565cb4 | 2014-09-12 10:59:21 -0400 | [diff] [blame] | 135 | } catch (RemoteException e) { |
| 136 | } |
| 137 | } |
| 138 | } |
Adrian Roos | 4f43dc0 | 2015-06-17 16:43:38 -0700 | [diff] [blame] | 139 | |
| 140 | @Override |
| 141 | public void showAssistDisclosure() { |
| 142 | if (mBar != null) { |
| 143 | try { |
| 144 | mBar.showAssistDisclosure(); |
| 145 | } catch (RemoteException e) { |
| 146 | } |
| 147 | } |
| 148 | } |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 149 | |
| 150 | @Override |
| 151 | public void startAssist(Bundle args) { |
| 152 | if (mBar != null) { |
| 153 | try { |
| 154 | mBar.startAssist(args); |
| 155 | } catch (RemoteException e) { |
| 156 | } |
| 157 | } |
| 158 | } |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 159 | |
| 160 | @Override |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 161 | public void onCameraLaunchGestureDetected(int source) { |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 162 | if (mBar != null) { |
| 163 | try { |
Jorim Jaggi | 40aa881 | 2015-09-23 12:59:22 -0700 | [diff] [blame] | 164 | mBar.onCameraLaunchGestureDetected(source); |
Selim Cinek | 372d1bd | 2015-08-14 13:19:37 -0700 | [diff] [blame] | 165 | } catch (RemoteException e) { |
| 166 | } |
| 167 | } |
| 168 | } |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 169 | |
| 170 | @Override |
| 171 | public void topAppWindowChanged(boolean menuVisible) { |
| 172 | StatusBarManagerService.this.topAppWindowChanged(menuVisible); |
| 173 | } |
| 174 | |
| 175 | @Override |
| 176 | public void setSystemUiVisibility(int vis, int fullscreenStackVis, int dockedStackVis, |
| 177 | int mask, |
| 178 | Rect fullscreenBounds, Rect dockedBounds, String cause) { |
| 179 | StatusBarManagerService.this.setSystemUiVisibility(vis, fullscreenStackVis, |
| 180 | dockedStackVis, mask, fullscreenBounds, dockedBounds, cause); |
| 181 | } |
Phil Weaver | 315c34e | 2016-02-19 15:12:29 -0800 | [diff] [blame] | 182 | |
| 183 | @Override |
| 184 | public void toggleSplitScreen() { |
| 185 | enforceStatusBarService(); |
| 186 | if (mBar != null) { |
| 187 | try { |
| 188 | mBar.toggleSplitScreen(); |
| 189 | } catch (RemoteException ex) {} |
| 190 | } |
| 191 | } |
Jorim Jaggi | 2adba07 | 2016-03-03 13:43:39 +0100 | [diff] [blame] | 192 | |
| 193 | public void appTransitionFinished() { |
| 194 | enforceStatusBarService(); |
| 195 | if (mBar != null) { |
| 196 | try { |
| 197 | mBar.appTransitionFinished(); |
| 198 | } catch (RemoteException ex) {} |
| 199 | } |
| 200 | } |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 201 | |
| 202 | @Override |
| 203 | public void toggleRecentApps() { |
| 204 | if (mBar != null) { |
| 205 | try { |
| 206 | mBar.toggleRecentApps(); |
| 207 | } catch (RemoteException ex) {} |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | @Override |
| 212 | public void setCurrentUser(int newUserId) { |
| 213 | if (SPEW) Slog.d(TAG, "Setting current user to user " + newUserId); |
| 214 | mCurrentUserId = newUserId; |
| 215 | } |
| 216 | |
| 217 | |
| 218 | @Override |
| 219 | public void preloadRecentApps() { |
| 220 | if (mBar != null) { |
| 221 | try { |
| 222 | mBar.preloadRecentApps(); |
| 223 | } catch (RemoteException ex) {} |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | @Override |
| 228 | public void cancelPreloadRecentApps() { |
| 229 | if (mBar != null) { |
| 230 | try { |
| 231 | mBar.cancelPreloadRecentApps(); |
| 232 | } catch (RemoteException ex) {} |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | @Override |
| 237 | public void showRecentApps(boolean triggeredFromAltTab, boolean fromHome) { |
| 238 | if (mBar != null) { |
| 239 | try { |
| 240 | mBar.showRecentApps(triggeredFromAltTab, fromHome); |
| 241 | } catch (RemoteException ex) {} |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | @Override |
| 246 | public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { |
| 247 | if (mBar != null) { |
| 248 | try { |
| 249 | mBar.hideRecentApps(triggeredFromAltTab, triggeredFromHomeKey); |
| 250 | } catch (RemoteException ex) {} |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | @Override |
Andrei Stingaceanu | 0bf096f | 2016-04-14 18:11:57 +0100 | [diff] [blame] | 255 | public void dismissKeyboardShortcutsMenu() { |
| 256 | if (mBar != null) { |
| 257 | try { |
| 258 | mBar.dismissKeyboardShortcutsMenu(); |
| 259 | } catch (RemoteException ex) {} |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | @Override |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 264 | public void toggleKeyboardShortcutsMenu(int deviceId) { |
| 265 | if (mBar != null) { |
| 266 | try { |
| 267 | mBar.toggleKeyboardShortcutsMenu(deviceId); |
| 268 | } catch (RemoteException ex) {} |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | @Override |
Winson Chung | ac52f28 | 2017-03-30 14:44:52 -0700 | [diff] [blame] | 273 | public void showPictureInPictureMenu() { |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 274 | if (mBar != null) { |
| 275 | try { |
Winson Chung | ac52f28 | 2017-03-30 14:44:52 -0700 | [diff] [blame] | 276 | mBar.showPictureInPictureMenu(); |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 277 | } catch (RemoteException ex) {} |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | @Override |
| 282 | public void setWindowState(int window, int state) { |
| 283 | if (mBar != null) { |
| 284 | try { |
| 285 | mBar.setWindowState(window, state); |
| 286 | } catch (RemoteException ex) {} |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | @Override |
| 291 | public void appTransitionPending() { |
| 292 | if (mBar != null) { |
| 293 | try { |
| 294 | mBar.appTransitionPending(); |
| 295 | } catch (RemoteException ex) {} |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | @Override |
| 300 | public void appTransitionCancelled() { |
| 301 | if (mBar != null) { |
| 302 | try { |
| 303 | mBar.appTransitionCancelled(); |
| 304 | } catch (RemoteException ex) {} |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | @Override |
| 309 | public void appTransitionStarting(long statusBarAnimationsStartTime, |
| 310 | long statusBarAnimationsDuration) { |
| 311 | if (mBar != null) { |
| 312 | try { |
| 313 | mBar.appTransitionStarting( |
| 314 | statusBarAnimationsStartTime, statusBarAnimationsDuration); |
| 315 | } catch (RemoteException ex) {} |
| 316 | } |
| 317 | } |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 318 | |
| 319 | @Override |
| 320 | public void setGlobalActionsListener(GlobalActionsListener listener) { |
| 321 | mGlobalActionListener = listener; |
| 322 | mGlobalActionListener.onStatusBarConnectedChanged(mBar != null); |
| 323 | } |
| 324 | |
| 325 | @Override |
| 326 | public void showGlobalActions() { |
| 327 | if (mBar != null) { |
| 328 | try { |
| 329 | mBar.showGlobalActionsMenu(); |
| 330 | } catch (RemoteException ex) {} |
| 331 | } |
| 332 | } |
Jason Monk | b430218 | 2017-08-04 13:39:17 -0400 | [diff] [blame] | 333 | |
| 334 | @Override |
| 335 | public boolean showShutdownUi(boolean isReboot, String reason) { |
| 336 | if (!mContext.getResources().getBoolean(R.bool.config_showSysuiShutdown)) { |
| 337 | return false; |
| 338 | } |
| 339 | if (mBar != null) { |
| 340 | try { |
| 341 | mBar.showShutdownUi(isReboot, reason); |
| 342 | return true; |
| 343 | } catch (RemoteException ex) {} |
| 344 | } |
| 345 | return false; |
| 346 | } |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 347 | }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 348 | |
| 349 | // ================================================================================ |
Joe Onorato | 25f95f9 | 2010-04-08 18:37:10 -0500 | [diff] [blame] | 350 | // From IStatusBarService |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 351 | // ================================================================================ |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 352 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 353 | public void expandNotificationsPanel() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 354 | enforceExpandStatusBar(); |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 355 | |
| 356 | if (mBar != null) { |
| 357 | try { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 358 | mBar.animateExpandNotificationsPanel(); |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 359 | } catch (RemoteException ex) { |
| 360 | } |
| 361 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 362 | } |
| 363 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 364 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 365 | public void collapsePanels() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 366 | enforceExpandStatusBar(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 367 | |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 368 | if (mBar != null) { |
| 369 | try { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 370 | mBar.animateCollapsePanels(); |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 371 | } catch (RemoteException ex) { |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 376 | @Override |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 377 | public void expandSettingsPanel(String subPanel) { |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 378 | enforceExpandStatusBar(); |
| 379 | |
| 380 | if (mBar != null) { |
| 381 | try { |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 382 | mBar.animateExpandSettingsPanel(subPanel); |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 383 | } catch (RemoteException ex) { |
| 384 | } |
| 385 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 386 | } |
| 387 | |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 388 | public void addTile(ComponentName component) { |
| 389 | enforceStatusBarOrShell(); |
| 390 | |
| 391 | if (mBar != null) { |
| 392 | try { |
| 393 | mBar.addQsTile(component); |
| 394 | } catch (RemoteException ex) { |
| 395 | } |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | public void remTile(ComponentName component) { |
| 400 | enforceStatusBarOrShell(); |
| 401 | |
| 402 | if (mBar != null) { |
| 403 | try { |
| 404 | mBar.remQsTile(component); |
| 405 | } catch (RemoteException ex) { |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | public void clickTile(ComponentName component) { |
| 411 | enforceStatusBarOrShell(); |
| 412 | |
| 413 | if (mBar != null) { |
| 414 | try { |
| 415 | mBar.clickQsTile(component); |
| 416 | } catch (RemoteException ex) { |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 421 | @Override |
Philip Quinn | c3a503d | 2017-07-18 23:23:41 -0700 | [diff] [blame] | 422 | public void handleSystemKey(int key) throws RemoteException { |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 423 | enforceExpandStatusBar(); |
| 424 | |
| 425 | if (mBar != null) { |
| 426 | try { |
Philip Quinn | c3a503d | 2017-07-18 23:23:41 -0700 | [diff] [blame] | 427 | mBar.handleSystemKey(key); |
Jim Miller | 07e0384 | 2016-06-22 15:18:13 -0700 | [diff] [blame] | 428 | } catch (RemoteException ex) { |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 434 | public void disable(int what, IBinder token, String pkg) { |
Benjamin Franz | ea2ec97 | 2015-03-16 17:18:09 +0000 | [diff] [blame] | 435 | disableForUser(what, token, pkg, mCurrentUserId); |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 436 | } |
| 437 | |
Benjamin Franz | ea2ec97 | 2015-03-16 17:18:09 +0000 | [diff] [blame] | 438 | @Override |
| 439 | public void disableForUser(int what, IBinder token, String pkg, int userId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 440 | enforceStatusBar(); |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 441 | |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 442 | synchronized (mLock) { |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 443 | disableLocked(userId, what, token, pkg, 1); |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 444 | } |
| 445 | } |
| 446 | |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 447 | /** |
| 448 | * Disable additional status bar features. Pass the bitwise-or of the DISABLE2_* flags. |
| 449 | * To re-enable everything, pass {@link #DISABLE_NONE}. |
| 450 | * |
| 451 | * Warning: Only pass DISABLE2_* flags into this function, do not use DISABLE_* flags. |
| 452 | */ |
| 453 | @Override |
| 454 | public void disable2(int what, IBinder token, String pkg) { |
Benjamin Franz | 292a0a9 | 2016-03-30 13:41:57 +0100 | [diff] [blame] | 455 | disable2ForUser(what, token, pkg, mCurrentUserId); |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | /** |
| 459 | * Disable additional status bar features for a given user. Pass the bitwise-or of the |
| 460 | * DISABLE2_* flags. To re-enable everything, pass {@link #DISABLE_NONE}. |
| 461 | * |
| 462 | * Warning: Only pass DISABLE2_* flags into this function, do not use DISABLE_* flags. |
| 463 | */ |
| 464 | @Override |
| 465 | public void disable2ForUser(int what, IBinder token, String pkg, int userId) { |
| 466 | enforceStatusBar(); |
| 467 | |
| 468 | synchronized (mLock) { |
| 469 | disableLocked(userId, what, token, pkg, 2); |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | private void disableLocked(int userId, int what, IBinder token, String pkg, int whichFlag) { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 474 | // It's important that the the callback and the call to mBar get done |
| 475 | // in the same order when multiple threads are calling this function |
| 476 | // so they are paired correctly. The messages on the handler will be |
| 477 | // handled in the order they were enqueued, but will be outside the lock. |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 478 | manageDisableListLocked(userId, what, token, pkg, whichFlag); |
John Spurlock | 8f3e6d5 | 2012-11-29 13:56:24 -0500 | [diff] [blame] | 479 | |
| 480 | // Ensure state for the current user is applied, even if passed a non-current user. |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 481 | final int net1 = gatherDisableActionsLocked(mCurrentUserId, 1); |
| 482 | final int net2 = gatherDisableActionsLocked(mCurrentUserId, 2); |
| 483 | if (net1 != mDisabled1 || net2 != mDisabled2) { |
| 484 | mDisabled1 = net1; |
| 485 | mDisabled2 = net2; |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 486 | mHandler.post(new Runnable() { |
| 487 | public void run() { |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 488 | mNotificationDelegate.onSetDisabled(net1); |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 489 | } |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 490 | }); |
| 491 | if (mBar != null) { |
| 492 | try { |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 493 | mBar.disable(net1, net2); |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 494 | } catch (RemoteException ex) { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 495 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 496 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 497 | } |
| 498 | } |
| 499 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 500 | @Override |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 501 | public void setIcon(String slot, String iconPackage, int iconId, int iconLevel, |
| 502 | String contentDescription) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 503 | enforceStatusBar(); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 504 | |
| 505 | synchronized (mIcons) { |
Xiaohui Chen | e4de5a0 | 2015-09-22 15:33:31 -0700 | [diff] [blame] | 506 | StatusBarIcon icon = new StatusBarIcon(iconPackage, UserHandle.SYSTEM, iconId, |
| 507 | iconLevel, 0, contentDescription); |
Joe Onorato | 66d7d01 | 2010-05-14 10:05:10 -0700 | [diff] [blame] | 508 | //Slog.d(TAG, "setIcon slot=" + slot + " index=" + index + " icon=" + icon); |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 509 | mIcons.put(slot, icon); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 510 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 511 | if (mBar != null) { |
| 512 | try { |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 513 | mBar.setIcon(slot, icon); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 514 | } catch (RemoteException ex) { |
| 515 | } |
| 516 | } |
| 517 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 518 | } |
| 519 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 520 | @Override |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 521 | public void setIconVisibility(String slot, boolean visibility) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 522 | enforceStatusBar(); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 523 | |
Joe Onorato | 514ad663 | 2010-05-13 18:49:00 -0700 | [diff] [blame] | 524 | synchronized (mIcons) { |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 525 | StatusBarIcon icon = mIcons.get(slot); |
Joe Onorato | 514ad663 | 2010-05-13 18:49:00 -0700 | [diff] [blame] | 526 | if (icon == null) { |
| 527 | return; |
| 528 | } |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 529 | if (icon.visible != visibility) { |
| 530 | icon.visible = visibility; |
Joe Onorato | 514ad663 | 2010-05-13 18:49:00 -0700 | [diff] [blame] | 531 | |
Joe Onorato | 514ad663 | 2010-05-13 18:49:00 -0700 | [diff] [blame] | 532 | if (mBar != null) { |
| 533 | try { |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 534 | mBar.setIcon(slot, icon); |
Joe Onorato | 514ad663 | 2010-05-13 18:49:00 -0700 | [diff] [blame] | 535 | } catch (RemoteException ex) { |
| 536 | } |
| 537 | } |
| 538 | } |
| 539 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 540 | } |
| 541 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 542 | @Override |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 543 | public void removeIcon(String slot) { |
| 544 | enforceStatusBar(); |
| 545 | |
| 546 | synchronized (mIcons) { |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 547 | mIcons.remove(slot); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 548 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 549 | if (mBar != null) { |
| 550 | try { |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 551 | mBar.removeIcon(slot); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 552 | } catch (RemoteException ex) { |
| 553 | } |
| 554 | } |
| 555 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 556 | } |
| 557 | |
Wale Ogunwale | 393b1c1 | 2014-10-18 16:22:01 -0700 | [diff] [blame] | 558 | /** |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 559 | * Hide or show the on-screen Menu key. Only call this from the window manager, typically in |
Wale Ogunwale | 393b1c1 | 2014-10-18 16:22:01 -0700 | [diff] [blame] | 560 | * response to a window with {@link android.view.WindowManager.LayoutParams#needsMenuKey} set |
| 561 | * to {@link android.view.WindowManager.LayoutParams#NEEDS_MENU_SET_TRUE}. |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 562 | */ |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 563 | private void topAppWindowChanged(final boolean menuVisible) { |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 564 | enforceStatusBar(); |
| 565 | |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 566 | if (SPEW) Slog.d(TAG, (menuVisible?"showing":"hiding") + " MENU key"); |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 567 | |
| 568 | synchronized(mLock) { |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 569 | mMenuVisible = menuVisible; |
| 570 | mHandler.post(new Runnable() { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 571 | public void run() { |
| 572 | if (mBar != null) { |
| 573 | try { |
| 574 | mBar.topAppWindowChanged(menuVisible); |
| 575 | } catch (RemoteException ex) { |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 576 | } |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 577 | } |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 578 | } |
| 579 | }); |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 580 | } |
| 581 | } |
| 582 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 583 | @Override |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 584 | public void setImeWindowStatus(final IBinder token, final int vis, final int backDisposition, |
| 585 | final boolean showImeSwitcher) { |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 586 | enforceStatusBar(); |
| 587 | |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 588 | if (SPEW) { |
| 589 | Slog.d(TAG, "swetImeWindowStatus vis=" + vis + " backDisposition=" + backDisposition); |
| 590 | } |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 591 | |
| 592 | synchronized(mLock) { |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 593 | // In case of IME change, we need to call up setImeWindowStatus() regardless of |
| 594 | // mImeWindowVis because mImeWindowVis may not have been set to false when the |
satok | 06e0744 | 2010-11-02 19:46:55 +0900 | [diff] [blame] | 595 | // previous IME was destroyed. |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 596 | mImeWindowVis = vis; |
| 597 | mImeBackDisposition = backDisposition; |
| 598 | mImeToken = token; |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 599 | mShowImeSwitcher = showImeSwitcher; |
satok | 06e0744 | 2010-11-02 19:46:55 +0900 | [diff] [blame] | 600 | mHandler.post(new Runnable() { |
| 601 | public void run() { |
| 602 | if (mBar != null) { |
| 603 | try { |
Jason Monk | b605fec | 2014-05-02 17:04:10 -0400 | [diff] [blame] | 604 | mBar.setImeWindowStatus(token, vis, backDisposition, showImeSwitcher); |
satok | 06e0744 | 2010-11-02 19:46:55 +0900 | [diff] [blame] | 605 | } catch (RemoteException ex) { |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 606 | } |
| 607 | } |
satok | 06e0744 | 2010-11-02 19:46:55 +0900 | [diff] [blame] | 608 | } |
| 609 | }); |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 610 | } |
| 611 | } |
| 612 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 613 | @Override |
Adrian Roos | 53f28ec | 2014-10-29 17:26:12 +0100 | [diff] [blame] | 614 | public void setSystemUiVisibility(int vis, int mask, String cause) { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 615 | setSystemUiVisibility(vis, 0, 0, mask, mFullscreenStackBounds, mDockedStackBounds, cause); |
| 616 | } |
| 617 | |
| 618 | private void setSystemUiVisibility(int vis, int fullscreenStackVis, int dockedStackVis, int mask, |
| 619 | Rect fullscreenBounds, Rect dockedBounds, String cause) { |
Joe Onorato | 55bf380 | 2011-01-25 13:42:10 -0800 | [diff] [blame] | 620 | // also allows calls from window manager which is in this process. |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 621 | enforceStatusBarService(); |
| 622 | |
Jeff Sharkey | 4519a02 | 2011-09-07 23:24:53 -0700 | [diff] [blame] | 623 | if (SPEW) Slog.d(TAG, "setSystemUiVisibility(0x" + Integer.toHexString(vis) + ")"); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 624 | |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 625 | synchronized (mLock) { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 626 | updateUiVisibilityLocked(vis, fullscreenStackVis, dockedStackVis, mask, |
| 627 | fullscreenBounds, dockedBounds); |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 628 | disableLocked( |
| 629 | mCurrentUserId, |
| 630 | vis & StatusBarManager.DISABLE_MASK, |
| 631 | mSysUiVisToken, |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 632 | cause, 1); |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 633 | } |
| 634 | } |
| 635 | |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 636 | private void updateUiVisibilityLocked(final int vis, |
| 637 | final int fullscreenStackVis, final int dockedStackVis, final int mask, |
| 638 | final Rect fullscreenBounds, final Rect dockedBounds) { |
| 639 | if (mSystemUiVisibility != vis |
| 640 | || mFullscreenStackSysUiVisibility != fullscreenStackVis |
| 641 | || mDockedStackSysUiVisibility != dockedStackVis |
| 642 | || !mFullscreenStackBounds.equals(fullscreenBounds) |
| 643 | || !mDockedStackBounds.equals(dockedBounds)) { |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 644 | mSystemUiVisibility = vis; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 645 | mFullscreenStackSysUiVisibility = fullscreenStackVis; |
| 646 | mDockedStackSysUiVisibility = dockedStackVis; |
| 647 | mFullscreenStackBounds.set(fullscreenBounds); |
| 648 | mDockedStackBounds.set(dockedBounds); |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 649 | mHandler.post(new Runnable() { |
| 650 | public void run() { |
| 651 | if (mBar != null) { |
| 652 | try { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 653 | mBar.setSystemUiVisibility(vis, fullscreenStackVis, dockedStackVis, |
| 654 | mask, fullscreenBounds, dockedBounds); |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 655 | } catch (RemoteException ex) { |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 656 | } |
| 657 | } |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 658 | } |
| 659 | }); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 660 | } |
| 661 | } |
| 662 | |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 663 | private void enforceStatusBarOrShell() { |
| 664 | if (Binder.getCallingUid() == Process.SHELL_UID) { |
| 665 | return; |
| 666 | } |
| 667 | enforceStatusBar(); |
| 668 | } |
| 669 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 670 | private void enforceStatusBar() { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 671 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR, |
Joe Onorato | 089de88 | 2010-04-12 08:18:45 -0700 | [diff] [blame] | 672 | "StatusBarManagerService"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | private void enforceExpandStatusBar() { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 676 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.EXPAND_STATUS_BAR, |
Joe Onorato | 089de88 | 2010-04-12 08:18:45 -0700 | [diff] [blame] | 677 | "StatusBarManagerService"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 678 | } |
| 679 | |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 680 | private void enforceStatusBarService() { |
| 681 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR_SERVICE, |
| 682 | "StatusBarManagerService"); |
| 683 | } |
| 684 | |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 685 | // ================================================================================ |
| 686 | // Callbacks from the status bar service. |
| 687 | // ================================================================================ |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 688 | @Override |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 689 | public void registerStatusBar(IStatusBar bar, List<String> iconSlots, |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 690 | List<StatusBarIcon> iconList, int switches[], List<IBinder> binders, |
| 691 | Rect fullscreenStackBounds, Rect dockedStackBounds) { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 692 | enforceStatusBarService(); |
| 693 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 694 | Slog.i(TAG, "registerStatusBar bar=" + bar); |
| 695 | mBar = bar; |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 696 | try { |
| 697 | mBar.asBinder().linkToDeath(new DeathRecipient() { |
| 698 | @Override |
| 699 | public void binderDied() { |
| 700 | mBar = null; |
| 701 | notifyBarAttachChanged(); |
| 702 | } |
| 703 | }, 0); |
| 704 | } catch (RemoteException e) { |
| 705 | } |
| 706 | notifyBarAttachChanged(); |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 707 | synchronized (mIcons) { |
Jason Monk | 07473ce | 2016-01-05 14:59:19 -0500 | [diff] [blame] | 708 | for (String slot : mIcons.keySet()) { |
| 709 | iconSlots.add(slot); |
| 710 | iconList.add(mIcons.get(slot)); |
| 711 | } |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 712 | } |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 713 | synchronized (mLock) { |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 714 | switches[0] = gatherDisableActionsLocked(mCurrentUserId, 1); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 715 | switches[1] = mSystemUiVisibility; |
Joe Onorato | e4c7b3f | 2010-10-30 12:15:03 -0700 | [diff] [blame] | 716 | switches[2] = mMenuVisible ? 1 : 0; |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 717 | switches[3] = mImeWindowVis; |
| 718 | switches[4] = mImeBackDisposition; |
Michael Wright | 665366a | 2014-08-07 15:44:40 -0700 | [diff] [blame] | 719 | switches[5] = mShowImeSwitcher ? 1 : 0; |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 720 | switches[6] = gatherDisableActionsLocked(mCurrentUserId, 2); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 721 | switches[7] = mFullscreenStackSysUiVisibility; |
| 722 | switches[8] = mDockedStackSysUiVisibility; |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 723 | binders.add(mImeToken); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 724 | fullscreenStackBounds.set(mFullscreenStackBounds); |
| 725 | dockedStackBounds.set(mDockedStackBounds); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 726 | } |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 727 | } |
Joe Onorato | aaba60b | 2010-05-23 15:18:41 -0400 | [diff] [blame] | 728 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 729 | private void notifyBarAttachChanged() { |
| 730 | mHandler.post(() -> { |
| 731 | if (mGlobalActionListener == null) return; |
| 732 | mGlobalActionListener.onStatusBarConnectedChanged(mBar != null); |
| 733 | }); |
| 734 | } |
| 735 | |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 736 | /** |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 737 | * @param clearNotificationEffects whether to consider notifications as "shown" and stop |
| 738 | * LED, vibration, and ringing |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 739 | */ |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 740 | @Override |
Chris Wren | b659c4f | 2015-06-25 17:12:27 -0400 | [diff] [blame] | 741 | public void onPanelRevealed(boolean clearNotificationEffects, int numItems) { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 742 | enforceStatusBarService(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 743 | long identity = Binder.clearCallingIdentity(); |
| 744 | try { |
Chris Wren | b659c4f | 2015-06-25 17:12:27 -0400 | [diff] [blame] | 745 | mNotificationDelegate.onPanelRevealed(clearNotificationEffects, numItems); |
Christoph Studer | 1f32c65 | 2014-11-26 15:32:20 +0100 | [diff] [blame] | 746 | } finally { |
| 747 | Binder.restoreCallingIdentity(identity); |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | @Override |
| 752 | public void clearNotificationEffects() throws RemoteException { |
| 753 | enforceStatusBarService(); |
| 754 | long identity = Binder.clearCallingIdentity(); |
| 755 | try { |
| 756 | mNotificationDelegate.clearEffects(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 757 | } finally { |
| 758 | Binder.restoreCallingIdentity(identity); |
| 759 | } |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 760 | } |
| 761 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 762 | @Override |
Christoph Studer | 760ea55 | 2014-03-21 13:10:21 +0100 | [diff] [blame] | 763 | public void onPanelHidden() throws RemoteException { |
| 764 | enforceStatusBarService(); |
| 765 | long identity = Binder.clearCallingIdentity(); |
| 766 | try { |
| 767 | mNotificationDelegate.onPanelHidden(); |
| 768 | } finally { |
| 769 | Binder.restoreCallingIdentity(identity); |
| 770 | } |
| 771 | } |
| 772 | |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 773 | /** |
| 774 | * Allows the status bar to shutdown the device. |
| 775 | */ |
| 776 | @Override |
| 777 | public void shutdown() { |
| 778 | enforceStatusBarService(); |
| 779 | long identity = Binder.clearCallingIdentity(); |
| 780 | try { |
Michael Wright | 6cd1026 | 2017-04-04 17:44:56 +0100 | [diff] [blame] | 781 | // ShutdownThread displays UI, so give it a UI context. |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 782 | mHandler.post(() -> |
Michael Wright | 6cd1026 | 2017-04-04 17:44:56 +0100 | [diff] [blame] | 783 | ShutdownThread.shutdown(getUiContext(), |
| 784 | PowerManager.SHUTDOWN_USER_REQUESTED, false)); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 785 | } finally { |
| 786 | Binder.restoreCallingIdentity(identity); |
| 787 | } |
| 788 | } |
| 789 | |
| 790 | /** |
| 791 | * Allows the status bar to reboot the device. |
| 792 | */ |
| 793 | @Override |
| 794 | public void reboot(boolean safeMode) { |
| 795 | enforceStatusBarService(); |
| 796 | long identity = Binder.clearCallingIdentity(); |
| 797 | try { |
| 798 | mHandler.post(() -> { |
Adam Lesinski | a82b626 | 2017-03-21 16:56:17 -0700 | [diff] [blame] | 799 | // ShutdownThread displays UI, so give it a UI context. |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 800 | if (safeMode) { |
Shunta Sato | bdb0e49 | 2017-04-14 16:01:54 +0900 | [diff] [blame] | 801 | ShutdownThread.rebootSafeMode(getUiContext(), true); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 802 | } else { |
Michael Wright | 6cd1026 | 2017-04-04 17:44:56 +0100 | [diff] [blame] | 803 | ShutdownThread.reboot(getUiContext(), |
| 804 | PowerManager.SHUTDOWN_USER_REQUESTED, false); |
Jason Monk | 361915c | 2017-03-21 20:33:59 -0400 | [diff] [blame] | 805 | } |
| 806 | }); |
| 807 | } finally { |
| 808 | Binder.restoreCallingIdentity(identity); |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | @Override |
| 813 | public void onGlobalActionsShown() { |
| 814 | enforceStatusBarService(); |
| 815 | long identity = Binder.clearCallingIdentity(); |
| 816 | try { |
| 817 | if (mGlobalActionListener == null) return; |
| 818 | mGlobalActionListener.onGlobalActionsShown(); |
| 819 | } finally { |
| 820 | Binder.restoreCallingIdentity(identity); |
| 821 | } |
| 822 | } |
| 823 | |
| 824 | @Override |
| 825 | public void onGlobalActionsHidden() { |
| 826 | enforceStatusBarService(); |
| 827 | long identity = Binder.clearCallingIdentity(); |
| 828 | try { |
| 829 | if (mGlobalActionListener == null) return; |
| 830 | mGlobalActionListener.onGlobalActionsDismissed(); |
| 831 | } finally { |
| 832 | Binder.restoreCallingIdentity(identity); |
| 833 | } |
| 834 | } |
| 835 | |
Christoph Studer | 760ea55 | 2014-03-21 13:10:21 +0100 | [diff] [blame] | 836 | @Override |
Christoph Studer | 03b87a2 | 2014-04-30 17:33:27 +0200 | [diff] [blame] | 837 | public void onNotificationClick(String key) { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 838 | enforceStatusBarService(); |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 839 | final int callingUid = Binder.getCallingUid(); |
| 840 | final int callingPid = Binder.getCallingPid(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 841 | long identity = Binder.clearCallingIdentity(); |
| 842 | try { |
Christoph Studer | 03b87a2 | 2014-04-30 17:33:27 +0200 | [diff] [blame] | 843 | mNotificationDelegate.onNotificationClick(callingUid, callingPid, key); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 844 | } finally { |
| 845 | Binder.restoreCallingIdentity(identity); |
| 846 | } |
Joe Onorato | aaba60b | 2010-05-23 15:18:41 -0400 | [diff] [blame] | 847 | } |
| 848 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 849 | @Override |
Christoph Studer | 4da84cd | 2014-10-21 17:24:20 +0200 | [diff] [blame] | 850 | public void onNotificationActionClick(String key, int actionIndex) { |
| 851 | enforceStatusBarService(); |
| 852 | final int callingUid = Binder.getCallingUid(); |
| 853 | final int callingPid = Binder.getCallingPid(); |
| 854 | long identity = Binder.clearCallingIdentity(); |
| 855 | try { |
| 856 | mNotificationDelegate.onNotificationActionClick(callingUid, callingPid, key, |
| 857 | actionIndex); |
| 858 | } finally { |
| 859 | Binder.restoreCallingIdentity(identity); |
| 860 | } |
| 861 | } |
| 862 | |
| 863 | @Override |
Dianne Hackborn | 9d39d0c | 2010-06-24 15:57:42 -0700 | [diff] [blame] | 864 | public void onNotificationError(String pkg, String tag, int id, |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 865 | int uid, int initialPid, String message, int userId) { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 866 | enforceStatusBarService(); |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 867 | final int callingUid = Binder.getCallingUid(); |
| 868 | final int callingPid = Binder.getCallingPid(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 869 | long identity = Binder.clearCallingIdentity(); |
| 870 | try { |
| 871 | // WARNING: this will call back into us to do the remove. Don't hold any locks. |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 872 | mNotificationDelegate.onNotificationError(callingUid, callingPid, |
| 873 | pkg, tag, id, uid, initialPid, message, userId); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 874 | } finally { |
| 875 | Binder.restoreCallingIdentity(identity); |
| 876 | } |
Joe Onorato | 005847b | 2010-06-04 16:08:02 -0400 | [diff] [blame] | 877 | } |
| 878 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 879 | @Override |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 880 | public void onNotificationClear(String pkg, String tag, int id, int userId) { |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 881 | enforceStatusBarService(); |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 882 | final int callingUid = Binder.getCallingUid(); |
| 883 | final int callingPid = Binder.getCallingPid(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 884 | long identity = Binder.clearCallingIdentity(); |
| 885 | try { |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 886 | mNotificationDelegate.onNotificationClear(callingUid, callingPid, pkg, tag, id, userId); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 887 | } finally { |
| 888 | Binder.restoreCallingIdentity(identity); |
| 889 | } |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 890 | } |
| 891 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 892 | @Override |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 893 | public void onNotificationVisibilityChanged( |
Chris Wren | d1dbc92 | 2015-06-19 17:51:16 -0400 | [diff] [blame] | 894 | NotificationVisibility[] newlyVisibleKeys, NotificationVisibility[] noLongerVisibleKeys) |
| 895 | throws RemoteException { |
Christoph Studer | 92b389d | 2014-04-01 18:44:40 +0200 | [diff] [blame] | 896 | enforceStatusBarService(); |
| 897 | long identity = Binder.clearCallingIdentity(); |
| 898 | try { |
| 899 | mNotificationDelegate.onNotificationVisibilityChanged( |
| 900 | newlyVisibleKeys, noLongerVisibleKeys); |
| 901 | } finally { |
| 902 | Binder.restoreCallingIdentity(identity); |
| 903 | } |
| 904 | } |
| 905 | |
| 906 | @Override |
Chris Wren | 78403d7 | 2014-07-28 10:23:24 +0100 | [diff] [blame] | 907 | public void onNotificationExpansionChanged(String key, boolean userAction, |
| 908 | boolean expanded) throws RemoteException { |
| 909 | enforceStatusBarService(); |
| 910 | long identity = Binder.clearCallingIdentity(); |
| 911 | try { |
| 912 | mNotificationDelegate.onNotificationExpansionChanged( |
| 913 | key, userAction, expanded); |
| 914 | } finally { |
| 915 | Binder.restoreCallingIdentity(identity); |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | @Override |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 920 | public void onClearAllNotifications(int userId) { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 921 | enforceStatusBarService(); |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 922 | final int callingUid = Binder.getCallingUid(); |
| 923 | final int callingPid = Binder.getCallingPid(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 924 | long identity = Binder.clearCallingIdentity(); |
| 925 | try { |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 926 | mNotificationDelegate.onClearAll(callingUid, callingPid, userId); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 927 | } finally { |
| 928 | Binder.restoreCallingIdentity(identity); |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 929 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 930 | } |
| 931 | |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 932 | @Override |
| 933 | public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err, |
Dianne Hackborn | 354736e | 2016-08-22 17:00:05 -0700 | [diff] [blame] | 934 | String[] args, ShellCallback callback, ResultReceiver resultReceiver) { |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 935 | (new StatusBarShellCommand(this)).exec( |
Dianne Hackborn | 354736e | 2016-08-22 17:00:05 -0700 | [diff] [blame] | 936 | this, in, out, err, args, callback, resultReceiver); |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 937 | } |
| 938 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 939 | // ================================================================================ |
| 940 | // Can be called from any thread |
| 941 | // ================================================================================ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 942 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 943 | // lock on mDisableRecords |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 944 | void manageDisableListLocked(int userId, int what, IBinder token, String pkg, int which) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 945 | if (SPEW) { |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 946 | Slog.d(TAG, "manageDisableList userId=" + userId |
| 947 | + " what=0x" + Integer.toHexString(what) + " pkg=" + pkg); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 948 | } |
| 949 | // update the list |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 950 | final int N = mDisableRecords.size(); |
| 951 | DisableRecord tok = null; |
| 952 | int i; |
| 953 | for (i=0; i<N; i++) { |
| 954 | DisableRecord t = mDisableRecords.get(i); |
John Spurlock | 4e6922d | 2012-10-04 14:51:51 -0400 | [diff] [blame] | 955 | if (t.token == token && t.userId == userId) { |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 956 | tok = t; |
| 957 | break; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 958 | } |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 959 | } |
| 960 | if (what == 0 || !token.isBinderAlive()) { |
| 961 | if (tok != null) { |
| 962 | mDisableRecords.remove(i); |
| 963 | tok.token.unlinkToDeath(tok, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 964 | } |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 965 | } else { |
| 966 | if (tok == null) { |
| 967 | tok = new DisableRecord(); |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 968 | tok.userId = userId; |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 969 | try { |
| 970 | token.linkToDeath(tok, 0); |
| 971 | } |
| 972 | catch (RemoteException ex) { |
| 973 | return; // give up |
| 974 | } |
| 975 | mDisableRecords.add(tok); |
| 976 | } |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 977 | if (which == 1) { |
| 978 | tok.what1 = what; |
| 979 | } else { |
| 980 | tok.what2 = what; |
| 981 | } |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 982 | tok.token = token; |
| 983 | tok.pkg = pkg; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 984 | } |
| 985 | } |
| 986 | |
| 987 | // lock on mDisableRecords |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 988 | int gatherDisableActionsLocked(int userId, int which) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 989 | final int N = mDisableRecords.size(); |
| 990 | // gather the new net flags |
| 991 | int net = 0; |
| 992 | for (int i=0; i<N; i++) { |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 993 | final DisableRecord rec = mDisableRecords.get(i); |
| 994 | if (rec.userId == userId) { |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 995 | net |= (which == 1) ? rec.what1 : rec.what2; |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 996 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 997 | } |
| 998 | return net; |
| 999 | } |
| 1000 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1001 | // ================================================================================ |
| 1002 | // Always called from UI thread |
| 1003 | // ================================================================================ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1004 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1005 | protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
Jeff Sharkey | fe9a53b | 2017-03-31 14:08:23 -0600 | [diff] [blame] | 1006 | if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1007 | |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 1008 | synchronized (mLock) { |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 1009 | pw.println(" mDisabled1=0x" + Integer.toHexString(mDisabled1)); |
| 1010 | pw.println(" mDisabled2=0x" + Integer.toHexString(mDisabled2)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1011 | final int N = mDisableRecords.size(); |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 1012 | pw.println(" mDisableRecords.size=" + N); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1013 | for (int i=0; i<N; i++) { |
| 1014 | DisableRecord tok = mDisableRecords.get(i); |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 1015 | pw.println(" [" + i + "] userId=" + tok.userId |
Benjamin Franz | cde0a2a | 2015-04-23 17:19:48 +0100 | [diff] [blame] | 1016 | + " what1=0x" + Integer.toHexString(tok.what1) |
| 1017 | + " what2=0x" + Integer.toHexString(tok.what2) |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 1018 | + " pkg=" + tok.pkg |
| 1019 | + " token=" + tok.token); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1020 | } |
Adrian Roos | 2a62910 | 2016-04-15 16:28:03 -0700 | [diff] [blame] | 1021 | pw.println(" mCurrentUserId=" + mCurrentUserId); |
Dan Sandler | f3a1f2c | 2016-06-26 15:59:13 -0400 | [diff] [blame] | 1022 | pw.println(" mIcons="); |
| 1023 | for (String slot : mIcons.keySet()) { |
| 1024 | pw.println(" "); |
| 1025 | pw.print(slot); |
| 1026 | pw.print(" -> "); |
| 1027 | final StatusBarIcon icon = mIcons.get(slot); |
| 1028 | pw.print(icon); |
| 1029 | if (!TextUtils.isEmpty(icon.contentDescription)) { |
| 1030 | pw.print(" \""); |
| 1031 | pw.print(icon.contentDescription); |
| 1032 | pw.print("\""); |
| 1033 | } |
| 1034 | pw.println(); |
| 1035 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1036 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1037 | } |
Michael Wright | 6cd1026 | 2017-04-04 17:44:56 +0100 | [diff] [blame] | 1038 | |
| 1039 | private static final Context getUiContext() { |
| 1040 | return ActivityThread.currentActivityThread().getSystemUiContext(); |
| 1041 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1042 | } |