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 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | import android.app.StatusBarManager; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 20 | import android.os.Binder; |
| 21 | import android.os.Handler; |
| 22 | import android.os.IBinder; |
| 23 | import android.os.RemoteException; |
| 24 | import android.os.UserHandle; |
Daniel Sandler | 5feceeb | 2013-03-22 18:29:23 -0700 | [diff] [blame] | 25 | import android.service.notification.StatusBarNotification; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.content.Context; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.content.pm.PackageManager; |
| 28 | import android.content.res.Resources; |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 29 | import android.util.Slog; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 30 | |
| 31 | import com.android.internal.statusbar.IStatusBar; |
| 32 | import com.android.internal.statusbar.IStatusBarService; |
| 33 | import com.android.internal.statusbar.StatusBarIcon; |
| 34 | import com.android.internal.statusbar.StatusBarIconList; |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 35 | import com.android.server.LocalServices; |
| 36 | import com.android.server.notification.NotificationDelegate; |
Dianne Hackborn | a924dc0d | 2011-02-17 14:22:17 -0800 | [diff] [blame] | 37 | import com.android.server.wm.WindowManagerService; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 38 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | import java.io.FileDescriptor; |
| 40 | import java.io.PrintWriter; |
| 41 | import java.util.ArrayList; |
| 42 | import java.util.HashMap; |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 43 | import java.util.List; |
| 44 | import java.util.Map; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | |
| 46 | |
| 47 | /** |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 48 | * A note on locking: We rely on the fact that calls onto mBar are oneway or |
| 49 | * 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] | 50 | */ |
Joe Onorato | 089de88 | 2010-04-12 08:18:45 -0700 | [diff] [blame] | 51 | public class StatusBarManagerService extends IStatusBarService.Stub |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 52 | implements WindowManagerService.OnHardKeyboardStatusChangeListener |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | { |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 54 | private static final String TAG = "StatusBarManagerService"; |
| 55 | private static final boolean SPEW = false; |
Joe Onorato | df7dbb6 | 2009-11-17 10:43:37 -0800 | [diff] [blame] | 56 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 57 | private final Context mContext; |
| 58 | private final WindowManagerService mWindowManager; |
| 59 | private Handler mHandler = new Handler(); |
| 60 | private NotificationDelegate mNotificationDelegate; |
| 61 | private volatile IStatusBar mBar; |
| 62 | private StatusBarIconList mIcons = new StatusBarIconList(); |
| 63 | private HashMap<IBinder,StatusBarNotification> mNotifications |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 64 | = new HashMap<IBinder,StatusBarNotification>(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 66 | // for disabling the status bar |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 67 | private final ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>(); |
| 68 | private IBinder mSysUiVisToken = new Binder(); |
| 69 | private int mDisabled = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 70 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 71 | private Object mLock = new Object(); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 72 | // encompasses lights-out mode and other flags defined on View |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 73 | private int mSystemUiVisibility = 0; |
| 74 | private boolean mMenuVisible = false; |
| 75 | private int mImeWindowVis = 0; |
| 76 | private int mImeBackDisposition; |
| 77 | private IBinder mImeToken = null; |
| 78 | private int mCurrentUserId; |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 79 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | private class DisableRecord implements IBinder.DeathRecipient { |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 81 | int userId; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | String pkg; |
| 83 | int what; |
| 84 | IBinder token; |
| 85 | |
| 86 | public void binderDied() { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 87 | Slog.i(TAG, "binder died for pkg=" + pkg); |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 88 | disableInternal(userId, 0, token, pkg); |
Suchi Amalapurapu | fff2fda | 2009-06-30 21:36:16 -0700 | [diff] [blame] | 89 | token.unlinkToDeath(this, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | } |
| 91 | } |
| 92 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | /** |
| 94 | * Construct the service, add the status bar view to the window manager |
| 95 | */ |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 96 | public StatusBarManagerService(Context context, WindowManagerService windowManager) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 97 | mContext = context; |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 98 | mWindowManager = windowManager; |
| 99 | mWindowManager.setOnHardKeyboardStatusChangeListener(this); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 100 | |
| 101 | final Resources res = context.getResources(); |
Joe Onorato | 75144ea | 2010-06-07 12:36:25 -0700 | [diff] [blame] | 102 | mIcons.defineSlots(res.getStringArray(com.android.internal.R.array.config_statusBarIcons)); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 103 | |
| 104 | LocalServices.addService(StatusBarManagerInternal.class, mInternalService); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | } |
| 106 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 107 | /** |
| 108 | * Private API used by NotificationManagerService. |
| 109 | */ |
| 110 | private final StatusBarManagerInternal mInternalService = new StatusBarManagerInternal() { |
| 111 | @Override |
| 112 | public void setNotificationDelegate(NotificationDelegate delegate) { |
| 113 | synchronized (mNotifications) { |
| 114 | mNotificationDelegate = delegate; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | @Override |
| 119 | public IBinder addNotification(StatusBarNotification notification) { |
| 120 | synchronized (mNotifications) { |
| 121 | IBinder key = new Binder(); |
| 122 | mNotifications.put(key, notification); |
| 123 | if (mBar != null) { |
| 124 | try { |
| 125 | mBar.addNotification(key, notification); |
| 126 | } catch (RemoteException ex) { |
| 127 | } |
| 128 | } |
| 129 | return key; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | @Override |
| 134 | public void updateNotification(IBinder key, StatusBarNotification notification) { |
| 135 | synchronized (mNotifications) { |
| 136 | if (!mNotifications.containsKey(key)) { |
| 137 | throw new IllegalArgumentException("updateNotification key not found: " + key); |
| 138 | } |
| 139 | mNotifications.put(key, notification); |
| 140 | if (mBar != null) { |
| 141 | try { |
| 142 | mBar.updateNotification(key, notification); |
| 143 | } catch (RemoteException ex) { |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | @Override |
| 150 | public void removeNotification(IBinder key) { |
| 151 | synchronized (mNotifications) { |
| 152 | final StatusBarNotification n = mNotifications.remove(key); |
| 153 | if (n == null) { |
| 154 | Slog.e(TAG, "removeNotification key not found: " + key); |
| 155 | return; |
| 156 | } |
| 157 | if (mBar != null) { |
| 158 | try { |
| 159 | mBar.removeNotification(key); |
| 160 | } catch (RemoteException ex) { |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 166 | |
| 167 | // ================================================================================ |
Joe Onorato | 25f95f9 | 2010-04-08 18:37:10 -0500 | [diff] [blame] | 168 | // From IStatusBarService |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 169 | // ================================================================================ |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 170 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 171 | public void expandNotificationsPanel() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 172 | enforceExpandStatusBar(); |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 173 | |
| 174 | if (mBar != null) { |
| 175 | try { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 176 | mBar.animateExpandNotificationsPanel(); |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 177 | } catch (RemoteException ex) { |
| 178 | } |
| 179 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 180 | } |
| 181 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 182 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 183 | public void collapsePanels() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 184 | enforceExpandStatusBar(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 185 | |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 186 | if (mBar != null) { |
| 187 | try { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 188 | mBar.animateCollapsePanels(); |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 189 | } catch (RemoteException ex) { |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 194 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 195 | public void expandSettingsPanel() { |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 196 | enforceExpandStatusBar(); |
| 197 | |
| 198 | if (mBar != null) { |
| 199 | try { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 200 | mBar.animateExpandSettingsPanel(); |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 201 | } catch (RemoteException ex) { |
| 202 | } |
| 203 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 204 | } |
| 205 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 206 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 207 | public void disable(int what, IBinder token, String pkg) { |
John Spurlock | e677d71 | 2014-02-13 12:52:19 -0500 | [diff] [blame] | 208 | if (!mNotificationDelegate.allowDisable(what, token, pkg)) { |
| 209 | if (SPEW) Slog.d(TAG, "Blocking disable request from " + pkg); |
| 210 | return; |
| 211 | } |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 212 | disableInternal(mCurrentUserId, what, token, pkg); |
| 213 | } |
| 214 | |
| 215 | private void disableInternal(int userId, int what, IBinder token, String pkg) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 216 | enforceStatusBar(); |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 217 | |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 218 | synchronized (mLock) { |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 219 | disableLocked(userId, what, token, pkg); |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 220 | } |
| 221 | } |
| 222 | |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 223 | private void disableLocked(int userId, int what, IBinder token, String pkg) { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 224 | // It's important that the the callback and the call to mBar get done |
| 225 | // in the same order when multiple threads are calling this function |
| 226 | // so they are paired correctly. The messages on the handler will be |
| 227 | // handled in the order they were enqueued, but will be outside the lock. |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 228 | manageDisableListLocked(userId, what, token, pkg); |
John Spurlock | 8f3e6d5 | 2012-11-29 13:56:24 -0500 | [diff] [blame] | 229 | |
| 230 | // Ensure state for the current user is applied, even if passed a non-current user. |
| 231 | final int net = gatherDisableActionsLocked(mCurrentUserId); |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 232 | if (net != mDisabled) { |
| 233 | mDisabled = net; |
| 234 | mHandler.post(new Runnable() { |
| 235 | public void run() { |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 236 | mNotificationDelegate.onSetDisabled(net); |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 237 | } |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 238 | }); |
| 239 | if (mBar != null) { |
| 240 | try { |
| 241 | mBar.disable(net); |
| 242 | } catch (RemoteException ex) { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 243 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 244 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 245 | } |
| 246 | } |
| 247 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 248 | @Override |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 249 | public void setIcon(String slot, String iconPackage, int iconId, int iconLevel, |
| 250 | String contentDescription) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 251 | enforceStatusBar(); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 252 | |
| 253 | synchronized (mIcons) { |
| 254 | int index = mIcons.getSlotIndex(slot); |
| 255 | if (index < 0) { |
| 256 | throw new SecurityException("invalid status bar icon slot: " + slot); |
| 257 | } |
| 258 | |
Amith Yamasani | 98edc95 | 2012-09-25 14:09:27 -0700 | [diff] [blame] | 259 | StatusBarIcon icon = new StatusBarIcon(iconPackage, UserHandle.OWNER, iconId, |
| 260 | iconLevel, 0, |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 261 | contentDescription); |
Joe Onorato | 66d7d01 | 2010-05-14 10:05:10 -0700 | [diff] [blame] | 262 | //Slog.d(TAG, "setIcon slot=" + slot + " index=" + index + " icon=" + icon); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 263 | mIcons.setIcon(index, icon); |
| 264 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 265 | if (mBar != null) { |
| 266 | try { |
| 267 | mBar.setIcon(index, icon); |
| 268 | } catch (RemoteException ex) { |
| 269 | } |
| 270 | } |
| 271 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 272 | } |
| 273 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 274 | @Override |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 275 | public void setIconVisibility(String slot, boolean visible) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 276 | enforceStatusBar(); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 277 | |
Joe Onorato | 514ad663 | 2010-05-13 18:49:00 -0700 | [diff] [blame] | 278 | synchronized (mIcons) { |
| 279 | int index = mIcons.getSlotIndex(slot); |
| 280 | if (index < 0) { |
| 281 | throw new SecurityException("invalid status bar icon slot: " + slot); |
| 282 | } |
| 283 | |
| 284 | StatusBarIcon icon = mIcons.getIcon(index); |
| 285 | if (icon == null) { |
| 286 | return; |
| 287 | } |
| 288 | |
| 289 | if (icon.visible != visible) { |
| 290 | icon.visible = visible; |
| 291 | |
Joe Onorato | 514ad663 | 2010-05-13 18:49:00 -0700 | [diff] [blame] | 292 | if (mBar != null) { |
| 293 | try { |
| 294 | mBar.setIcon(index, icon); |
| 295 | } catch (RemoteException ex) { |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 300 | } |
| 301 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 302 | @Override |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 303 | public void removeIcon(String slot) { |
| 304 | enforceStatusBar(); |
| 305 | |
| 306 | synchronized (mIcons) { |
| 307 | int index = mIcons.getSlotIndex(slot); |
| 308 | if (index < 0) { |
| 309 | throw new SecurityException("invalid status bar icon slot: " + slot); |
| 310 | } |
| 311 | |
| 312 | mIcons.removeIcon(index); |
| 313 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 314 | if (mBar != null) { |
| 315 | try { |
| 316 | mBar.removeIcon(index); |
| 317 | } catch (RemoteException ex) { |
| 318 | } |
| 319 | } |
| 320 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 321 | } |
| 322 | |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 323 | /** |
| 324 | * Hide or show the on-screen Menu key. Only call this from the window manager, typically in |
| 325 | * response to a window with FLAG_NEEDS_MENU_KEY set. |
| 326 | */ |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 327 | @Override |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 328 | public void topAppWindowChanged(final boolean menuVisible) { |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 329 | enforceStatusBar(); |
| 330 | |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 331 | if (SPEW) Slog.d(TAG, (menuVisible?"showing":"hiding") + " MENU key"); |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 332 | |
| 333 | synchronized(mLock) { |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 334 | mMenuVisible = menuVisible; |
| 335 | mHandler.post(new Runnable() { |
| 336 | public void run() { |
| 337 | if (mBar != null) { |
| 338 | try { |
| 339 | mBar.topAppWindowChanged(menuVisible); |
| 340 | } catch (RemoteException ex) { |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 341 | } |
| 342 | } |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 343 | } |
| 344 | }); |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 345 | } |
| 346 | } |
| 347 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 348 | @Override |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 349 | public void setImeWindowStatus(final IBinder token, final int vis, final int backDisposition) { |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 350 | enforceStatusBar(); |
| 351 | |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 352 | if (SPEW) { |
| 353 | Slog.d(TAG, "swetImeWindowStatus vis=" + vis + " backDisposition=" + backDisposition); |
| 354 | } |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 355 | |
| 356 | synchronized(mLock) { |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 357 | // In case of IME change, we need to call up setImeWindowStatus() regardless of |
| 358 | // mImeWindowVis because mImeWindowVis may not have been set to false when the |
satok | 06e0744 | 2010-11-02 19:46:55 +0900 | [diff] [blame] | 359 | // previous IME was destroyed. |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 360 | mImeWindowVis = vis; |
| 361 | mImeBackDisposition = backDisposition; |
| 362 | mImeToken = token; |
satok | 06e0744 | 2010-11-02 19:46:55 +0900 | [diff] [blame] | 363 | mHandler.post(new Runnable() { |
| 364 | public void run() { |
| 365 | if (mBar != null) { |
| 366 | try { |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 367 | mBar.setImeWindowStatus(token, vis, backDisposition); |
satok | 06e0744 | 2010-11-02 19:46:55 +0900 | [diff] [blame] | 368 | } catch (RemoteException ex) { |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 369 | } |
| 370 | } |
satok | 06e0744 | 2010-11-02 19:46:55 +0900 | [diff] [blame] | 371 | } |
| 372 | }); |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 373 | } |
| 374 | } |
| 375 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 376 | @Override |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 377 | public void setSystemUiVisibility(int vis, int mask) { |
Joe Onorato | 55bf380 | 2011-01-25 13:42:10 -0800 | [diff] [blame] | 378 | // also allows calls from window manager which is in this process. |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 379 | enforceStatusBarService(); |
| 380 | |
Jeff Sharkey | 4519a02 | 2011-09-07 23:24:53 -0700 | [diff] [blame] | 381 | if (SPEW) Slog.d(TAG, "setSystemUiVisibility(0x" + Integer.toHexString(vis) + ")"); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 382 | |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 383 | synchronized (mLock) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 384 | updateUiVisibilityLocked(vis, mask); |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 385 | disableLocked( |
| 386 | mCurrentUserId, |
| 387 | vis & StatusBarManager.DISABLE_MASK, |
| 388 | mSysUiVisToken, |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 389 | "WindowManager.LayoutParams"); |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 390 | } |
| 391 | } |
| 392 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 393 | private void updateUiVisibilityLocked(final int vis, final int mask) { |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 394 | if (mSystemUiVisibility != vis) { |
| 395 | mSystemUiVisibility = vis; |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 396 | mHandler.post(new Runnable() { |
| 397 | public void run() { |
| 398 | if (mBar != null) { |
| 399 | try { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 400 | mBar.setSystemUiVisibility(vis, mask); |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 401 | } catch (RemoteException ex) { |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 402 | } |
| 403 | } |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 404 | } |
| 405 | }); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 406 | } |
| 407 | } |
| 408 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 409 | @Override |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 410 | public void setHardKeyboardEnabled(final boolean enabled) { |
| 411 | mHandler.post(new Runnable() { |
| 412 | public void run() { |
| 413 | mWindowManager.setHardKeyboardEnabled(enabled); |
| 414 | } |
| 415 | }); |
| 416 | } |
| 417 | |
| 418 | @Override |
| 419 | public void onHardKeyboardStatusChange(final boolean available, final boolean enabled) { |
| 420 | mHandler.post(new Runnable() { |
| 421 | public void run() { |
| 422 | if (mBar != null) { |
| 423 | try { |
| 424 | mBar.setHardKeyboardStatus(available, enabled); |
| 425 | } catch (RemoteException ex) { |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | }); |
| 430 | } |
| 431 | |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 432 | @Override |
| 433 | public void toggleRecentApps() { |
| 434 | if (mBar != null) { |
| 435 | try { |
| 436 | mBar.toggleRecentApps(); |
| 437 | } catch (RemoteException ex) {} |
| 438 | } |
| 439 | } |
| 440 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 441 | @Override |
| 442 | public void preloadRecentApps() { |
| 443 | if (mBar != null) { |
| 444 | try { |
| 445 | mBar.preloadRecentApps(); |
| 446 | } catch (RemoteException ex) {} |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | @Override |
| 451 | public void cancelPreloadRecentApps() { |
| 452 | if (mBar != null) { |
| 453 | try { |
| 454 | mBar.cancelPreloadRecentApps(); |
| 455 | } catch (RemoteException ex) {} |
| 456 | } |
| 457 | } |
| 458 | |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 459 | @Override |
| 460 | public void setCurrentUser(int newUserId) { |
| 461 | if (SPEW) Slog.d(TAG, "Setting current user to user " + newUserId); |
| 462 | mCurrentUserId = newUserId; |
| 463 | } |
| 464 | |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 465 | @Override |
| 466 | public void setWindowState(int window, int state) { |
| 467 | if (mBar != null) { |
| 468 | try { |
| 469 | mBar.setWindowState(window, state); |
| 470 | } catch (RemoteException ex) {} |
| 471 | } |
| 472 | } |
| 473 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 474 | private void enforceStatusBar() { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 475 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR, |
Joe Onorato | 089de88 | 2010-04-12 08:18:45 -0700 | [diff] [blame] | 476 | "StatusBarManagerService"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | private void enforceExpandStatusBar() { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 480 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.EXPAND_STATUS_BAR, |
Joe Onorato | 089de88 | 2010-04-12 08:18:45 -0700 | [diff] [blame] | 481 | "StatusBarManagerService"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 482 | } |
| 483 | |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 484 | private void enforceStatusBarService() { |
| 485 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR_SERVICE, |
| 486 | "StatusBarManagerService"); |
| 487 | } |
| 488 | |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 489 | // ================================================================================ |
| 490 | // Callbacks from the status bar service. |
| 491 | // ================================================================================ |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 492 | @Override |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 493 | public void registerStatusBar(IStatusBar bar, StatusBarIconList iconList, |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 494 | List<IBinder> notificationKeys, List<StatusBarNotification> notifications, |
satok | cd7cd29 | 2010-11-20 15:46:23 +0900 | [diff] [blame] | 495 | int switches[], List<IBinder> binders) { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 496 | enforceStatusBarService(); |
| 497 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 498 | Slog.i(TAG, "registerStatusBar bar=" + bar); |
| 499 | mBar = bar; |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 500 | synchronized (mIcons) { |
| 501 | iconList.copyFrom(mIcons); |
| 502 | } |
| 503 | synchronized (mNotifications) { |
| 504 | for (Map.Entry<IBinder,StatusBarNotification> e: mNotifications.entrySet()) { |
| 505 | notificationKeys.add(e.getKey()); |
| 506 | notifications.add(e.getValue()); |
| 507 | } |
| 508 | } |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 509 | synchronized (mLock) { |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 510 | switches[0] = gatherDisableActionsLocked(mCurrentUserId); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 511 | switches[1] = mSystemUiVisibility; |
Joe Onorato | e4c7b3f | 2010-10-30 12:15:03 -0700 | [diff] [blame] | 512 | switches[2] = mMenuVisible ? 1 : 0; |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 513 | switches[3] = mImeWindowVis; |
| 514 | switches[4] = mImeBackDisposition; |
| 515 | binders.add(mImeToken); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 516 | } |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 517 | switches[5] = mWindowManager.isHardKeyboardAvailable() ? 1 : 0; |
| 518 | switches[6] = mWindowManager.isHardKeyboardEnabled() ? 1 : 0; |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 519 | } |
Joe Onorato | aaba60b | 2010-05-23 15:18:41 -0400 | [diff] [blame] | 520 | |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 521 | /** |
Joe Onorato | f1f2591 | 2010-06-07 11:52:41 -0700 | [diff] [blame] | 522 | * The status bar service should call this each time the user brings the panel from |
| 523 | * invisible to visible in order to clear the notification light. |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 524 | */ |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 525 | @Override |
Joe Onorato | f1f2591 | 2010-06-07 11:52:41 -0700 | [diff] [blame] | 526 | public void onPanelRevealed() { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 527 | enforceStatusBarService(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 528 | long identity = Binder.clearCallingIdentity(); |
| 529 | try { |
| 530 | // tell the notification manager to turn off the lights. |
| 531 | mNotificationDelegate.onPanelRevealed(); |
| 532 | } finally { |
| 533 | Binder.restoreCallingIdentity(identity); |
| 534 | } |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 535 | } |
| 536 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 537 | @Override |
Christoph Studer | 760ea55 | 2014-03-21 13:10:21 +0100 | [diff] [blame^] | 538 | public void onPanelHidden() throws RemoteException { |
| 539 | enforceStatusBarService(); |
| 540 | long identity = Binder.clearCallingIdentity(); |
| 541 | try { |
| 542 | mNotificationDelegate.onPanelHidden(); |
| 543 | } finally { |
| 544 | Binder.restoreCallingIdentity(identity); |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | @Override |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 549 | public void onNotificationClick(String pkg, String tag, int id, int userId) { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 550 | enforceStatusBarService(); |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 551 | final int callingUid = Binder.getCallingUid(); |
| 552 | final int callingPid = Binder.getCallingPid(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 553 | long identity = Binder.clearCallingIdentity(); |
| 554 | try { |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 555 | mNotificationDelegate.onNotificationClick(callingUid, callingPid, pkg, tag, id, userId); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 556 | } finally { |
| 557 | Binder.restoreCallingIdentity(identity); |
| 558 | } |
Joe Onorato | aaba60b | 2010-05-23 15:18:41 -0400 | [diff] [blame] | 559 | } |
| 560 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 561 | @Override |
Dianne Hackborn | 9d39d0c | 2010-06-24 15:57:42 -0700 | [diff] [blame] | 562 | public void onNotificationError(String pkg, String tag, int id, |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 563 | int uid, int initialPid, String message, int userId) { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 564 | enforceStatusBarService(); |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 565 | final int callingUid = Binder.getCallingUid(); |
| 566 | final int callingPid = Binder.getCallingPid(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 567 | long identity = Binder.clearCallingIdentity(); |
| 568 | try { |
| 569 | // 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] | 570 | mNotificationDelegate.onNotificationError(callingUid, callingPid, |
| 571 | pkg, tag, id, uid, initialPid, message, userId); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 572 | } finally { |
| 573 | Binder.restoreCallingIdentity(identity); |
| 574 | } |
Joe Onorato | 005847b | 2010-06-04 16:08:02 -0400 | [diff] [blame] | 575 | } |
| 576 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 577 | @Override |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 578 | public void onNotificationClear(String pkg, String tag, int id, int userId) { |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 579 | enforceStatusBarService(); |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 580 | final int callingUid = Binder.getCallingUid(); |
| 581 | final int callingPid = Binder.getCallingPid(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 582 | long identity = Binder.clearCallingIdentity(); |
| 583 | try { |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 584 | mNotificationDelegate.onNotificationClear(callingUid, callingPid, pkg, tag, id, userId); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 585 | } finally { |
| 586 | Binder.restoreCallingIdentity(identity); |
| 587 | } |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 588 | } |
| 589 | |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 590 | @Override |
Kenny Guy | 3a7c4a5 | 2014-03-03 18:24:03 +0000 | [diff] [blame] | 591 | public void onClearAllNotifications(int userId) { |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 592 | enforceStatusBarService(); |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 593 | final int callingUid = Binder.getCallingUid(); |
| 594 | final int callingPid = Binder.getCallingPid(); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 595 | long identity = Binder.clearCallingIdentity(); |
| 596 | try { |
John Spurlock | e6a7d93 | 2014-03-13 12:29:00 -0400 | [diff] [blame] | 597 | mNotificationDelegate.onClearAll(callingUid, callingPid, userId); |
Adam Lesinski | 182f73f | 2013-12-05 16:48:06 -0800 | [diff] [blame] | 598 | } finally { |
| 599 | Binder.restoreCallingIdentity(identity); |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 600 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 601 | } |
| 602 | |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 603 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 604 | // ================================================================================ |
| 605 | // Can be called from any thread |
| 606 | // ================================================================================ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 607 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 608 | // lock on mDisableRecords |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 609 | void manageDisableListLocked(int userId, int what, IBinder token, String pkg) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 610 | if (SPEW) { |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 611 | Slog.d(TAG, "manageDisableList userId=" + userId |
| 612 | + " what=0x" + Integer.toHexString(what) + " pkg=" + pkg); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 613 | } |
| 614 | // update the list |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 615 | final int N = mDisableRecords.size(); |
| 616 | DisableRecord tok = null; |
| 617 | int i; |
| 618 | for (i=0; i<N; i++) { |
| 619 | DisableRecord t = mDisableRecords.get(i); |
John Spurlock | 4e6922d | 2012-10-04 14:51:51 -0400 | [diff] [blame] | 620 | if (t.token == token && t.userId == userId) { |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 621 | tok = t; |
| 622 | break; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 623 | } |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 624 | } |
| 625 | if (what == 0 || !token.isBinderAlive()) { |
| 626 | if (tok != null) { |
| 627 | mDisableRecords.remove(i); |
| 628 | tok.token.unlinkToDeath(tok, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 629 | } |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 630 | } else { |
| 631 | if (tok == null) { |
| 632 | tok = new DisableRecord(); |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 633 | tok.userId = userId; |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 634 | try { |
| 635 | token.linkToDeath(tok, 0); |
| 636 | } |
| 637 | catch (RemoteException ex) { |
| 638 | return; // give up |
| 639 | } |
| 640 | mDisableRecords.add(tok); |
| 641 | } |
| 642 | tok.what = what; |
| 643 | tok.token = token; |
| 644 | tok.pkg = pkg; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 645 | } |
| 646 | } |
| 647 | |
| 648 | // lock on mDisableRecords |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 649 | int gatherDisableActionsLocked(int userId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 650 | final int N = mDisableRecords.size(); |
| 651 | // gather the new net flags |
| 652 | int net = 0; |
| 653 | for (int i=0; i<N; i++) { |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 654 | final DisableRecord rec = mDisableRecords.get(i); |
| 655 | if (rec.userId == userId) { |
| 656 | net |= rec.what; |
| 657 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 658 | } |
| 659 | return net; |
| 660 | } |
| 661 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 662 | // ================================================================================ |
| 663 | // Always called from UI thread |
| 664 | // ================================================================================ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 665 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 666 | protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 667 | if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) |
| 668 | != PackageManager.PERMISSION_GRANTED) { |
| 669 | pw.println("Permission Denial: can't dump StatusBar from from pid=" |
| 670 | + Binder.getCallingPid() |
| 671 | + ", uid=" + Binder.getCallingUid()); |
| 672 | return; |
| 673 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 674 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 675 | synchronized (mIcons) { |
| 676 | mIcons.dump(pw); |
| 677 | } |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 678 | |
| 679 | synchronized (mNotifications) { |
Joe Onorato | 75199e3 | 2010-05-29 17:22:51 -0400 | [diff] [blame] | 680 | int i=0; |
| 681 | pw.println("Notification list:"); |
| 682 | for (Map.Entry<IBinder,StatusBarNotification> e: mNotifications.entrySet()) { |
| 683 | pw.printf(" %2d: %s\n", i, e.getValue().toString()); |
| 684 | i++; |
| 685 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 686 | } |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 687 | |
Joe Onorato | 7bb8eeb | 2011-01-27 16:00:58 -0800 | [diff] [blame] | 688 | synchronized (mLock) { |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 689 | pw.println(" mDisabled=0x" + Integer.toHexString(mDisabled)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 690 | final int N = mDisableRecords.size(); |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 691 | pw.println(" mDisableRecords.size=" + N); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 692 | for (int i=0; i<N; i++) { |
| 693 | DisableRecord tok = mDisableRecords.get(i); |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 694 | pw.println(" [" + i + "] userId=" + tok.userId |
| 695 | + " what=0x" + Integer.toHexString(tok.what) |
| 696 | + " pkg=" + tok.pkg |
| 697 | + " token=" + tok.token); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 698 | } |
| 699 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 700 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 701 | } |