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