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