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