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 | |
| 17 | package com.android.server.status; |
| 18 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | import android.app.PendingIntent; |
| 20 | import android.app.StatusBarManager; |
| 21 | import android.content.BroadcastReceiver; |
| 22 | import android.content.Context; |
| 23 | import android.content.Intent; |
| 24 | import android.content.IntentFilter; |
| 25 | import android.content.pm.PackageManager; |
| 26 | import android.content.res.Resources; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.net.Uri; |
| 28 | import android.os.IBinder; |
| 29 | import android.os.RemoteException; |
| 30 | import android.os.Binder; |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 31 | import android.os.Handler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | import android.os.SystemClock; |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 33 | import android.util.Slog; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 34 | |
| 35 | import com.android.internal.statusbar.IStatusBar; |
| 36 | import com.android.internal.statusbar.IStatusBarService; |
| 37 | import com.android.internal.statusbar.StatusBarIcon; |
| 38 | import com.android.internal.statusbar.StatusBarIconList; |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 39 | import com.android.internal.statusbar.StatusBarNotification; |
| 40 | import com.android.internal.statusbar.StatusBarNotificationList; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 41 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | import java.io.FileDescriptor; |
| 43 | import java.io.PrintWriter; |
| 44 | import java.util.ArrayList; |
| 45 | import java.util.HashMap; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | |
| 47 | |
| 48 | /** |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 49 | * A note on locking: We rely on the fact that calls onto mBar are oneway or |
| 50 | * 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] | 51 | */ |
Joe Onorato | 089de88 | 2010-04-12 08:18:45 -0700 | [diff] [blame] | 52 | public class StatusBarManagerService extends IStatusBarService.Stub |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | { |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 54 | static final String TAG = "StatusBarManagerService"; |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 55 | static final boolean SPEW = true; |
Joe Onorato | df7dbb6 | 2009-11-17 10:43:37 -0800 | [diff] [blame] | 56 | |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 57 | public static final String ACTION_STATUSBAR_START |
| 58 | = "com.android.internal.policy.statusbar.START"; |
| 59 | |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 60 | final Context mContext; |
| 61 | Handler mHandler = new Handler(); |
| 62 | NotificationCallbacks mNotificationCallbacks; |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 63 | volatile IStatusBar mBar; |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 64 | StatusBarIconList mIcons = new StatusBarIconList(); |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 65 | StatusBarNotificationList mNotifications = new StatusBarNotificationList(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 66 | |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 67 | // for disabling the status bar |
| 68 | ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>(); |
| 69 | int mDisabled = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 70 | |
| 71 | private class DisableRecord implements IBinder.DeathRecipient { |
| 72 | String pkg; |
| 73 | int what; |
| 74 | IBinder token; |
| 75 | |
| 76 | public void binderDied() { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 77 | Slog.i(TAG, "binder died for pkg=" + pkg); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | disable(0, token, pkg); |
Suchi Amalapurapu | fff2fda | 2009-06-30 21:36:16 -0700 | [diff] [blame] | 79 | token.unlinkToDeath(this, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | } |
| 81 | } |
| 82 | |
| 83 | public interface NotificationCallbacks { |
| 84 | void onSetDisabled(int status); |
| 85 | void onClearAll(); |
Fred Quintana | 6ecaff1 | 2009-09-25 14:23:13 -0700 | [diff] [blame] | 86 | void onNotificationClick(String pkg, String tag, int id); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | void onPanelRevealed(); |
| 88 | } |
| 89 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | /** |
| 91 | * Construct the service, add the status bar view to the window manager |
| 92 | */ |
Joe Onorato | 089de88 | 2010-04-12 08:18:45 -0700 | [diff] [blame] | 93 | public StatusBarManagerService(Context context) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | mContext = context; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 95 | |
| 96 | final Resources res = context.getResources(); |
| 97 | mIcons.defineSlots(res.getStringArray(com.android.internal.R.array.status_bar_icon_order)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | public void setNotificationCallbacks(NotificationCallbacks listener) { |
| 101 | mNotificationCallbacks = listener; |
| 102 | } |
| 103 | |
| 104 | // ================================================================================ |
| 105 | // Constructing the view |
| 106 | // ================================================================================ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 107 | |
| 108 | public void systemReady() { |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | public void systemReady2() { |
| 112 | // Start the status bar app |
| 113 | Intent intent = new Intent(ACTION_STATUSBAR_START); |
| 114 | mContext.sendBroadcast(intent /** permission **/); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 115 | } |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 116 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 117 | // ================================================================================ |
Joe Onorato | 25f95f9 | 2010-04-08 18:37:10 -0500 | [diff] [blame] | 118 | // From IStatusBarService |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 119 | // ================================================================================ |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 120 | public void expand() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 121 | enforceExpandStatusBar(); |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 122 | |
| 123 | if (mBar != null) { |
| 124 | try { |
| 125 | mBar.animateExpand(); |
| 126 | } catch (RemoteException ex) { |
| 127 | } |
| 128 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 129 | } |
| 130 | |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 131 | public void collapse() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 132 | enforceExpandStatusBar(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 133 | |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 134 | if (mBar != null) { |
| 135 | try { |
| 136 | mBar.animateCollapse(); |
| 137 | } catch (RemoteException ex) { |
| 138 | } |
| 139 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | public void disable(int what, IBinder token, String pkg) { |
| 143 | enforceStatusBar(); |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 144 | |
| 145 | // It's important that the the callback and the call to mBar get done |
| 146 | // in the same order when multiple threads are calling this function |
| 147 | // so they are paired correctly. The messages on the handler will be |
| 148 | // handled in the order they were enqueued, but will be outside the lock. |
| 149 | synchronized (mDisableRecords) { |
| 150 | manageDisableListLocked(what, token, pkg); |
| 151 | final int net = gatherDisableActionsLocked(); |
| 152 | Slog.d(TAG, "disable... net=0x" + Integer.toHexString(net)); |
| 153 | if (net != mDisabled) { |
| 154 | mDisabled = net; |
| 155 | mHandler.post(new Runnable() { |
| 156 | public void run() { |
| 157 | mNotificationCallbacks.onSetDisabled(net); |
| 158 | } |
| 159 | }); |
| 160 | if (mBar != null) { |
| 161 | try { |
| 162 | mBar.disable(net); |
| 163 | } catch (RemoteException ex) { |
| 164 | } |
| 165 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 166 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 167 | } |
| 168 | } |
| 169 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 170 | public void setIcon(String slot, String iconPackage, int iconId, int iconLevel) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 171 | enforceStatusBar(); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 172 | |
| 173 | synchronized (mIcons) { |
| 174 | int index = mIcons.getSlotIndex(slot); |
| 175 | if (index < 0) { |
| 176 | throw new SecurityException("invalid status bar icon slot: " + slot); |
| 177 | } |
| 178 | |
| 179 | StatusBarIcon icon = new StatusBarIcon(iconPackage, iconId, iconLevel); |
Joe Onorato | 66d7d01 | 2010-05-14 10:05:10 -0700 | [diff] [blame] | 180 | //Slog.d(TAG, "setIcon slot=" + slot + " index=" + index + " icon=" + icon); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 181 | mIcons.setIcon(index, icon); |
| 182 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 183 | if (mBar != null) { |
| 184 | try { |
| 185 | mBar.setIcon(index, icon); |
| 186 | } catch (RemoteException ex) { |
| 187 | } |
| 188 | } |
| 189 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 190 | } |
| 191 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 192 | public void setIconVisibility(String slot, boolean visible) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 193 | enforceStatusBar(); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 194 | |
Joe Onorato | 514ad663 | 2010-05-13 18:49:00 -0700 | [diff] [blame] | 195 | synchronized (mIcons) { |
| 196 | int index = mIcons.getSlotIndex(slot); |
| 197 | if (index < 0) { |
| 198 | throw new SecurityException("invalid status bar icon slot: " + slot); |
| 199 | } |
| 200 | |
| 201 | StatusBarIcon icon = mIcons.getIcon(index); |
| 202 | if (icon == null) { |
| 203 | return; |
| 204 | } |
| 205 | |
| 206 | if (icon.visible != visible) { |
| 207 | icon.visible = visible; |
| 208 | |
Joe Onorato | 514ad663 | 2010-05-13 18:49:00 -0700 | [diff] [blame] | 209 | if (mBar != null) { |
| 210 | try { |
| 211 | mBar.setIcon(index, icon); |
| 212 | } catch (RemoteException ex) { |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | public void removeIcon(String slot) { |
| 220 | enforceStatusBar(); |
| 221 | |
| 222 | synchronized (mIcons) { |
| 223 | int index = mIcons.getSlotIndex(slot); |
| 224 | if (index < 0) { |
| 225 | throw new SecurityException("invalid status bar icon slot: " + slot); |
| 226 | } |
| 227 | |
| 228 | mIcons.removeIcon(index); |
| 229 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 230 | if (mBar != null) { |
| 231 | try { |
| 232 | mBar.removeIcon(index); |
| 233 | } catch (RemoteException ex) { |
| 234 | } |
| 235 | } |
| 236 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | private void enforceStatusBar() { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 240 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR, |
Joe Onorato | 089de88 | 2010-04-12 08:18:45 -0700 | [diff] [blame] | 241 | "StatusBarManagerService"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | private void enforceExpandStatusBar() { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 245 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.EXPAND_STATUS_BAR, |
Joe Onorato | 089de88 | 2010-04-12 08:18:45 -0700 | [diff] [blame] | 246 | "StatusBarManagerService"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 247 | } |
| 248 | |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 249 | |
| 250 | // ================================================================================ |
| 251 | // Callbacks from the status bar service. |
| 252 | // ================================================================================ |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 253 | public void registerStatusBar(IStatusBar bar, StatusBarIconList iconList) { |
| 254 | Slog.i(TAG, "registerStatusBar bar=" + bar); |
| 255 | mBar = bar; |
| 256 | iconList.copyFrom(mIcons); |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 257 | } |
Joe Onorato | aaba60b | 2010-05-23 15:18:41 -0400 | [diff] [blame^] | 258 | |
Joe Onorato | 4762c2d | 2010-05-17 15:42:59 -0700 | [diff] [blame] | 259 | /** |
| 260 | * The status bar service should call this when the user changes whether |
| 261 | * the status bar is visible or not. |
| 262 | */ |
| 263 | public void visibilityChanged(boolean visible) { |
| 264 | Slog.d(TAG, "visibilityChanged visible=" + visible); |
| 265 | } |
| 266 | |
Joe Onorato | aaba60b | 2010-05-23 15:18:41 -0400 | [diff] [blame^] | 267 | public void onNotificationClick(String pkg, String tag, int id) { |
| 268 | mNotificationCallbacks.onNotificationClick(pkg, tag, id); |
| 269 | } |
| 270 | |
| 271 | public void onClearAllNotifications() { |
| 272 | mNotificationCallbacks.onClearAll(); |
| 273 | } |
| 274 | |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 275 | // ================================================================================ |
| 276 | // Callbacks for NotificationManagerService. |
| 277 | // ================================================================================ |
| 278 | public IBinder addNotification(StatusBarNotification notification) { |
| 279 | synchronized (mNotifications) { |
Joe Onorato | a0c56fe | 2010-05-20 10:21:52 -0700 | [diff] [blame] | 280 | IBinder key = new Binder(); |
| 281 | mNotifications.add(key, notification); |
Joe Onorato | e345fff | 2010-05-23 15:18:27 -0400 | [diff] [blame] | 282 | if (mBar != null) { |
| 283 | try { |
| 284 | mBar.addNotification(key, notification); |
| 285 | } catch (RemoteException ex) { |
| 286 | } |
| 287 | } |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 288 | return key; |
| 289 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 290 | } |
| 291 | |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 292 | public void updateNotification(IBinder key, StatusBarNotification notification) { |
| 293 | synchronized (mNotifications) { |
| 294 | mNotifications.update(key, notification); |
Joe Onorato | e345fff | 2010-05-23 15:18:27 -0400 | [diff] [blame] | 295 | if (mBar != null) { |
| 296 | try { |
| 297 | mBar.updateNotification(key, notification); |
| 298 | } catch (RemoteException ex) { |
| 299 | } |
| 300 | } |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 301 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | public void removeNotification(IBinder key) { |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 305 | synchronized (mNotifications) { |
| 306 | mNotifications.remove(key); |
Joe Onorato | e345fff | 2010-05-23 15:18:27 -0400 | [diff] [blame] | 307 | if (mBar != null) { |
| 308 | try { |
| 309 | mBar.removeNotification(key); |
| 310 | } catch (RemoteException ex) { |
| 311 | } |
| 312 | } |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 313 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 314 | } |
Joe Onorato | 2314aab | 2010-04-08 16:41:23 -0500 | [diff] [blame] | 315 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 316 | // ================================================================================ |
| 317 | // Can be called from any thread |
| 318 | // ================================================================================ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 319 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 320 | // lock on mDisableRecords |
| 321 | void manageDisableListLocked(int what, IBinder token, String pkg) { |
| 322 | if (SPEW) { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 323 | Slog.d(TAG, "manageDisableList what=0x" + Integer.toHexString(what) + " pkg=" + pkg); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 324 | } |
| 325 | // update the list |
| 326 | synchronized (mDisableRecords) { |
| 327 | final int N = mDisableRecords.size(); |
| 328 | DisableRecord tok = null; |
| 329 | int i; |
| 330 | for (i=0; i<N; i++) { |
| 331 | DisableRecord t = mDisableRecords.get(i); |
| 332 | if (t.token == token) { |
| 333 | tok = t; |
| 334 | break; |
| 335 | } |
| 336 | } |
| 337 | if (what == 0 || !token.isBinderAlive()) { |
| 338 | if (tok != null) { |
| 339 | mDisableRecords.remove(i); |
Suchi Amalapurapu | fff2fda | 2009-06-30 21:36:16 -0700 | [diff] [blame] | 340 | tok.token.unlinkToDeath(tok, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 341 | } |
| 342 | } else { |
| 343 | if (tok == null) { |
| 344 | tok = new DisableRecord(); |
| 345 | try { |
| 346 | token.linkToDeath(tok, 0); |
| 347 | } |
| 348 | catch (RemoteException ex) { |
| 349 | return; // give up |
| 350 | } |
| 351 | mDisableRecords.add(tok); |
| 352 | } |
| 353 | tok.what = what; |
| 354 | tok.token = token; |
| 355 | tok.pkg = pkg; |
| 356 | } |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | // lock on mDisableRecords |
| 361 | int gatherDisableActionsLocked() { |
| 362 | final int N = mDisableRecords.size(); |
| 363 | // gather the new net flags |
| 364 | int net = 0; |
| 365 | for (int i=0; i<N; i++) { |
| 366 | net |= mDisableRecords.get(i).what; |
| 367 | } |
| 368 | return net; |
| 369 | } |
| 370 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 371 | // ================================================================================ |
| 372 | // Always called from UI thread |
| 373 | // ================================================================================ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 374 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 375 | protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 376 | if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) |
| 377 | != PackageManager.PERMISSION_GRANTED) { |
| 378 | pw.println("Permission Denial: can't dump StatusBar from from pid=" |
| 379 | + Binder.getCallingPid() |
| 380 | + ", uid=" + Binder.getCallingUid()); |
| 381 | return; |
| 382 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 383 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 384 | synchronized (mIcons) { |
| 385 | mIcons.dump(pw); |
| 386 | } |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 387 | |
| 388 | synchronized (mNotifications) { |
| 389 | mNotifications.dump(pw); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 390 | } |
Joe Onorato | 18e69df | 2010-05-17 22:26:12 -0700 | [diff] [blame] | 391 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 392 | synchronized (mDisableRecords) { |
| 393 | final int N = mDisableRecords.size(); |
| 394 | pw.println(" mDisableRecords.size=" + N |
| 395 | + " mDisabled=0x" + Integer.toHexString(mDisabled)); |
| 396 | for (int i=0; i<N; i++) { |
| 397 | DisableRecord tok = mDisableRecords.get(i); |
| 398 | pw.println(" [" + i + "] what=0x" + Integer.toHexString(tok.what) |
| 399 | + " pkg=" + tok.pkg + " token=" + tok.token); |
| 400 | } |
| 401 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | /** |
| 405 | * The LEDs are turned o)ff when the notification panel is shown, even just a little bit. |
| 406 | * This was added last-minute and is inconsistent with the way the rest of the notifications |
| 407 | * are handled, because the notification isn't really cancelled. The lights are just |
| 408 | * turned off. If any other notifications happen, the lights will turn back on. Steve says |
| 409 | * this is what he wants. (see bug 1131461) |
| 410 | */ |
| 411 | private boolean mPanelSlightlyVisible; |
| 412 | void panelSlightlyVisible(boolean visible) { |
| 413 | if (mPanelSlightlyVisible != visible) { |
| 414 | mPanelSlightlyVisible = visible; |
| 415 | if (visible) { |
| 416 | // tell the notification manager to turn off the lights. |
| 417 | mNotificationCallbacks.onPanelRevealed(); |
| 418 | } |
| 419 | } |
| 420 | } |
| 421 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 422 | private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 423 | public void onReceive(Context context, Intent intent) { |
| 424 | String action = intent.getAction(); |
Joe Onorato | f9e0e6b | 2009-09-08 16:24:36 -0400 | [diff] [blame] | 425 | if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action) |
| 426 | || Intent.ACTION_SCREEN_OFF.equals(action)) { |
Joe Onorato | f3f0e05 | 2010-05-14 18:49:29 -0700 | [diff] [blame] | 427 | collapse(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 428 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 429 | /* |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 430 | else if (Telephony.Intents.SPN_STRINGS_UPDATED_ACTION.equals(action)) { |
| 431 | updateNetworkName(intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_SPN, false), |
| 432 | intent.getStringExtra(Telephony.Intents.EXTRA_SPN), |
| 433 | intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_PLMN, false), |
| 434 | intent.getStringExtra(Telephony.Intents.EXTRA_PLMN)); |
| 435 | } |
| 436 | else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { |
| 437 | updateResources(); |
| 438 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 439 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 440 | } |
| 441 | }; |
| 442 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 443 | } |