blob: 596db572475a8e0c14c6887a5bcbab25ac4fb4ca [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
Joe Onorato7a0f36b2010-06-07 10:24:36 -070017package com.android.server;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080018
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080019import android.app.PendingIntent;
20import android.app.StatusBarManager;
21import android.content.BroadcastReceiver;
Joe Onorato9e875fc2010-06-07 11:12:11 -070022import android.content.ComponentName;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023import android.content.Context;
24import android.content.Intent;
25import android.content.IntentFilter;
26import android.content.pm.PackageManager;
27import android.content.res.Resources;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028import android.net.Uri;
29import android.os.IBinder;
30import android.os.RemoteException;
31import android.os.Binder;
Joe Onoratof3f0e052010-05-14 18:49:29 -070032import android.os.Handler;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033import android.os.SystemClock;
Joe Onorato8a9b2202010-02-26 18:56:32 -080034import android.util.Slog;
Joe Onorato0cbda992010-05-02 16:28:15 -070035
36import com.android.internal.statusbar.IStatusBar;
37import com.android.internal.statusbar.IStatusBarService;
38import com.android.internal.statusbar.StatusBarIcon;
39import com.android.internal.statusbar.StatusBarIconList;
Joe Onorato18e69df2010-05-17 22:26:12 -070040import com.android.internal.statusbar.StatusBarNotification;
The Android Open Source Project10592532009-03-18 17:39:46 -070041
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080042import java.io.FileDescriptor;
43import java.io.PrintWriter;
44import java.util.ArrayList;
45import java.util.HashMap;
Joe Onorato75199e32010-05-29 17:22:51 -040046import java.util.List;
47import java.util.Map;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080048
49
50/**
Joe Onoratof3f0e052010-05-14 18:49:29 -070051 * A note on locking: We rely on the fact that calls onto mBar are oneway or
52 * if they are local, that they just enqueue messages to not deadlock.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080053 */
Joe Onorato089de882010-04-12 08:18:45 -070054public class StatusBarManagerService extends IStatusBarService.Stub
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055{
Joe Onorato4762c2d2010-05-17 15:42:59 -070056 static final String TAG = "StatusBarManagerService";
Joe Onorato431bb222010-10-18 19:13:23 -040057 static final boolean SPEW = false;
Joe Onoratodf7dbb62009-11-17 10:43:37 -080058
Joe Onoratof3f0e052010-05-14 18:49:29 -070059 final Context mContext;
60 Handler mHandler = new Handler();
61 NotificationCallbacks mNotificationCallbacks;
Joe Onorato4762c2d2010-05-17 15:42:59 -070062 volatile IStatusBar mBar;
Joe Onoratof3f0e052010-05-14 18:49:29 -070063 StatusBarIconList mIcons = new StatusBarIconList();
Joe Onorato75199e32010-05-29 17:22:51 -040064 HashMap<IBinder,StatusBarNotification> mNotifications
65 = new HashMap<IBinder,StatusBarNotification>();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080066
Joe Onoratof3f0e052010-05-14 18:49:29 -070067 // for disabling the status bar
68 ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>();
69 int mDisabled = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080070
Joe Onorato93056472010-09-10 10:30:46 -040071 Object mLock = new Object();
72 // We usually call it lights out mode, but double negatives are annoying
73 boolean mLightsOn = true;
Daniel Sandlere02d8082010-10-08 15:13:22 -040074 boolean mMenuVisible = false;
satok06487a52010-10-29 11:37:18 +090075 boolean mIMEButtonVisible = false;
76
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080077 private class DisableRecord implements IBinder.DeathRecipient {
78 String pkg;
79 int what;
80 IBinder token;
81
82 public void binderDied() {
Joe Onorato8a9b2202010-02-26 18:56:32 -080083 Slog.i(TAG, "binder died for pkg=" + pkg);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080084 disable(0, token, pkg);
Suchi Amalapurapufff2fda2009-06-30 21:36:16 -070085 token.unlinkToDeath(this, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080086 }
87 }
88
89 public interface NotificationCallbacks {
90 void onSetDisabled(int status);
91 void onClearAll();
Fred Quintana6ecaff12009-09-25 14:23:13 -070092 void onNotificationClick(String pkg, String tag, int id);
Daniel Sandler0f0b11c2010-08-04 15:54:58 -040093 void onNotificationClear(String pkg, String tag, int id);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080094 void onPanelRevealed();
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -070095 void onNotificationError(String pkg, String tag, int id,
96 int uid, int initialPid, String message);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080097 }
98
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080099 /**
100 * Construct the service, add the status bar view to the window manager
101 */
Joe Onorato089de882010-04-12 08:18:45 -0700102 public StatusBarManagerService(Context context) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800103 mContext = context;
Joe Onorato0cbda992010-05-02 16:28:15 -0700104
105 final Resources res = context.getResources();
Joe Onorato75144ea2010-06-07 12:36:25 -0700106 mIcons.defineSlots(res.getStringArray(com.android.internal.R.array.config_statusBarIcons));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800107 }
108
109 public void setNotificationCallbacks(NotificationCallbacks listener) {
110 mNotificationCallbacks = listener;
111 }
112
113 // ================================================================================
Joe Onorato25f95f92010-04-08 18:37:10 -0500114 // From IStatusBarService
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800115 // ================================================================================
Joe Onoratof3f0e052010-05-14 18:49:29 -0700116 public void expand() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800117 enforceExpandStatusBar();
Joe Onorato4762c2d2010-05-17 15:42:59 -0700118
119 if (mBar != null) {
120 try {
121 mBar.animateExpand();
122 } catch (RemoteException ex) {
123 }
124 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800125 }
126
Joe Onoratof3f0e052010-05-14 18:49:29 -0700127 public void collapse() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800128 enforceExpandStatusBar();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800129
Joe Onorato4762c2d2010-05-17 15:42:59 -0700130 if (mBar != null) {
131 try {
132 mBar.animateCollapse();
133 } catch (RemoteException ex) {
134 }
135 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800136 }
137
138 public void disable(int what, IBinder token, String pkg) {
139 enforceStatusBar();
Joe Onoratof3f0e052010-05-14 18:49:29 -0700140
141 // It's important that the the callback and the call to mBar get done
142 // in the same order when multiple threads are calling this function
143 // so they are paired correctly. The messages on the handler will be
144 // handled in the order they were enqueued, but will be outside the lock.
145 synchronized (mDisableRecords) {
146 manageDisableListLocked(what, token, pkg);
147 final int net = gatherDisableActionsLocked();
Joe Onoratof3f0e052010-05-14 18:49:29 -0700148 if (net != mDisabled) {
149 mDisabled = net;
150 mHandler.post(new Runnable() {
151 public void run() {
152 mNotificationCallbacks.onSetDisabled(net);
153 }
154 });
155 if (mBar != null) {
156 try {
157 mBar.disable(net);
158 } catch (RemoteException ex) {
159 }
160 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800161 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800162 }
163 }
164
Joe Onorato0cbda992010-05-02 16:28:15 -0700165 public void setIcon(String slot, String iconPackage, int iconId, int iconLevel) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800166 enforceStatusBar();
Joe Onorato0cbda992010-05-02 16:28:15 -0700167
168 synchronized (mIcons) {
169 int index = mIcons.getSlotIndex(slot);
170 if (index < 0) {
171 throw new SecurityException("invalid status bar icon slot: " + slot);
172 }
173
174 StatusBarIcon icon = new StatusBarIcon(iconPackage, iconId, iconLevel);
Joe Onorato66d7d012010-05-14 10:05:10 -0700175 //Slog.d(TAG, "setIcon slot=" + slot + " index=" + index + " icon=" + icon);
Joe Onorato0cbda992010-05-02 16:28:15 -0700176 mIcons.setIcon(index, icon);
177
Joe Onorato0cbda992010-05-02 16:28:15 -0700178 if (mBar != null) {
179 try {
180 mBar.setIcon(index, icon);
181 } catch (RemoteException ex) {
182 }
183 }
184 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800185 }
186
Joe Onorato0cbda992010-05-02 16:28:15 -0700187 public void setIconVisibility(String slot, boolean visible) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800188 enforceStatusBar();
Joe Onorato0cbda992010-05-02 16:28:15 -0700189
Joe Onorato514ad6632010-05-13 18:49:00 -0700190 synchronized (mIcons) {
191 int index = mIcons.getSlotIndex(slot);
192 if (index < 0) {
193 throw new SecurityException("invalid status bar icon slot: " + slot);
194 }
195
196 StatusBarIcon icon = mIcons.getIcon(index);
197 if (icon == null) {
198 return;
199 }
200
201 if (icon.visible != visible) {
202 icon.visible = visible;
203
Joe Onorato514ad6632010-05-13 18:49:00 -0700204 if (mBar != null) {
205 try {
206 mBar.setIcon(index, icon);
207 } catch (RemoteException ex) {
208 }
209 }
210 }
211 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700212 }
213
214 public void removeIcon(String slot) {
215 enforceStatusBar();
216
217 synchronized (mIcons) {
218 int index = mIcons.getSlotIndex(slot);
219 if (index < 0) {
220 throw new SecurityException("invalid status bar icon slot: " + slot);
221 }
222
223 mIcons.removeIcon(index);
224
Joe Onorato0cbda992010-05-02 16:28:15 -0700225 if (mBar != null) {
226 try {
227 mBar.removeIcon(index);
228 } catch (RemoteException ex) {
229 }
230 }
231 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800232 }
233
Daniel Sandlere02d8082010-10-08 15:13:22 -0400234 /**
235 * Hide or show the on-screen Menu key. Only call this from the window manager, typically in
236 * response to a window with FLAG_NEEDS_MENU_KEY set.
237 */
238 public void setMenuKeyVisible(final boolean visible) {
239 enforceStatusBar();
240
241 if (SPEW) Slog.d(TAG, (visible?"showing":"hiding") + " MENU key");
242
243 synchronized(mLock) {
244 if (mMenuVisible != visible) {
245 mMenuVisible = visible;
246 mHandler.post(new Runnable() {
247 public void run() {
248 if (mBar != null) {
249 try {
250 mBar.setMenuKeyVisible(visible);
251 } catch (RemoteException ex) {
252 }
253 }
254 }
255 });
256 }
257 }
258 }
259
satok06487a52010-10-29 11:37:18 +0900260 public void setIMEButtonVisible(final boolean visible) {
261 enforceStatusBar();
262
263 if (SPEW) Slog.d(TAG, (visible?"showing":"hiding") + " IME Button");
264
265 synchronized(mLock) {
satok06e07442010-11-02 19:46:55 +0900266 // In case of IME change, we need to call up setIMEButtonVisible() regardless of
267 // mIMEButtonVisible because mIMEButtonVisible may not have been set to false when the
268 // previous IME was destroyed.
269 mIMEButtonVisible = visible;
270 mHandler.post(new Runnable() {
271 public void run() {
272 if (mBar != null) {
273 try {
274 mBar.setIMEButtonVisible(visible);
275 } catch (RemoteException ex) {
satok06487a52010-10-29 11:37:18 +0900276 }
277 }
satok06e07442010-11-02 19:46:55 +0900278 }
279 });
satok06487a52010-10-29 11:37:18 +0900280 }
281 }
282
Joe Onoratof63b0f42010-09-12 17:03:19 -0400283 /**
284 * This is used for the automatic version of lights-out mode. Only call this from
285 * the window manager.
286 *
287 * @see setLightsOn(boolean)
288 */
Joe Onorato93056472010-09-10 10:30:46 -0400289 public void setActiveWindowIsFullscreen(boolean fullscreen) {
290 // We could get away with a separate permission here, but STATUS_BAR is
291 // signatureOrSystem which is probably good enough. There is no public API
292 // for this, so the question is a security issue, not an API compatibility issue.
293 enforceStatusBar();
294
Joe Onorato93056472010-09-10 10:30:46 -0400295 synchronized (mLock) {
Joe Onoratof63b0f42010-09-12 17:03:19 -0400296 updateLightsOnLocked(!fullscreen);
297 }
298 }
299
300 /**
301 * This is used for the user-controlled version of lights-out mode. Only call this from
302 * the status bar itself.
303 *
304 * We have two different functions here, because I think we're going to want to
305 * tweak the behavior when the user keeps turning lights-out mode off and the
306 * app keeps trying to turn it on. For now they can just fight it out. Having
307 * these two separte inputs will allow us to keep that change local to here. --joeo
308 */
309 public void setLightsOn(boolean lightsOn) {
310 enforceStatusBarService();
311
312 synchronized (mLock) {
313 updateLightsOnLocked(lightsOn);
314 }
315 }
316
317 private void updateLightsOnLocked(final boolean lightsOn) {
318 if (mLightsOn != lightsOn) {
319 mLightsOn = lightsOn;
320 mHandler.post(new Runnable() {
321 public void run() {
322 if (mBar != null) {
323 try {
324 mBar.setLightsOn(lightsOn);
325 } catch (RemoteException ex) {
Joe Onorato93056472010-09-10 10:30:46 -0400326 }
327 }
Joe Onoratof63b0f42010-09-12 17:03:19 -0400328 }
329 });
Joe Onorato93056472010-09-10 10:30:46 -0400330 }
331 }
332
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800333 private void enforceStatusBar() {
Joe Onorato0cbda992010-05-02 16:28:15 -0700334 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR,
Joe Onorato089de882010-04-12 08:18:45 -0700335 "StatusBarManagerService");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800336 }
337
338 private void enforceExpandStatusBar() {
Joe Onorato0cbda992010-05-02 16:28:15 -0700339 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.EXPAND_STATUS_BAR,
Joe Onorato089de882010-04-12 08:18:45 -0700340 "StatusBarManagerService");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800341 }
342
Joe Onorato8bc6c512010-06-04 16:21:12 -0400343 private void enforceStatusBarService() {
344 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR_SERVICE,
345 "StatusBarManagerService");
346 }
347
Joe Onorato4762c2d2010-05-17 15:42:59 -0700348
349 // ================================================================================
350 // Callbacks from the status bar service.
351 // ================================================================================
Joe Onorato75199e32010-05-29 17:22:51 -0400352 public void registerStatusBar(IStatusBar bar, StatusBarIconList iconList,
Joe Onorato93056472010-09-10 10:30:46 -0400353 List<IBinder> notificationKeys, List<StatusBarNotification> notifications,
Joe Onoratoe4c7b3f2010-10-30 12:15:03 -0700354 int switches[]) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400355 enforceStatusBarService();
356
Joe Onorato0cbda992010-05-02 16:28:15 -0700357 Slog.i(TAG, "registerStatusBar bar=" + bar);
358 mBar = bar;
Joe Onorato75199e32010-05-29 17:22:51 -0400359 synchronized (mIcons) {
360 iconList.copyFrom(mIcons);
361 }
362 synchronized (mNotifications) {
363 for (Map.Entry<IBinder,StatusBarNotification> e: mNotifications.entrySet()) {
364 notificationKeys.add(e.getKey());
365 notifications.add(e.getValue());
366 }
367 }
Joe Onorato93056472010-09-10 10:30:46 -0400368 synchronized (mLock) {
Joe Onoratoe4c7b3f2010-10-30 12:15:03 -0700369 switches[0] = gatherDisableActionsLocked();
370 switches[1] = mLightsOn ? 1 : 0;
371 switches[2] = mMenuVisible ? 1 : 0;
372 switches[3] = mIMEButtonVisible ? 1 : 0;
Joe Onorato93056472010-09-10 10:30:46 -0400373 }
Joe Onorato2314aab2010-04-08 16:41:23 -0500374 }
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400375
Joe Onorato4762c2d2010-05-17 15:42:59 -0700376 /**
Joe Onoratof1f25912010-06-07 11:52:41 -0700377 * The status bar service should call this each time the user brings the panel from
378 * invisible to visible in order to clear the notification light.
Joe Onorato4762c2d2010-05-17 15:42:59 -0700379 */
Joe Onoratof1f25912010-06-07 11:52:41 -0700380 public void onPanelRevealed() {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400381 enforceStatusBarService();
382
Joe Onoratof1f25912010-06-07 11:52:41 -0700383 // tell the notification manager to turn off the lights.
384 mNotificationCallbacks.onPanelRevealed();
Joe Onorato4762c2d2010-05-17 15:42:59 -0700385 }
386
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400387 public void onNotificationClick(String pkg, String tag, int id) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400388 enforceStatusBarService();
389
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400390 mNotificationCallbacks.onNotificationClick(pkg, tag, id);
391 }
392
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -0700393 public void onNotificationError(String pkg, String tag, int id,
394 int uid, int initialPid, String message) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400395 enforceStatusBarService();
396
Joe Onorato005847b2010-06-04 16:08:02 -0400397 // WARNING: this will call back into us to do the remove. Don't hold any locks.
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -0700398 mNotificationCallbacks.onNotificationError(pkg, tag, id, uid, initialPid, message);
Joe Onorato005847b2010-06-04 16:08:02 -0400399 }
400
Daniel Sandler0f0b11c2010-08-04 15:54:58 -0400401 public void onNotificationClear(String pkg, String tag, int id) {
402 enforceStatusBarService();
403
404 mNotificationCallbacks.onNotificationClear(pkg, tag, id);
405 }
406
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400407 public void onClearAllNotifications() {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400408 enforceStatusBarService();
409
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400410 mNotificationCallbacks.onClearAll();
411 }
412
Joe Onorato18e69df2010-05-17 22:26:12 -0700413 // ================================================================================
414 // Callbacks for NotificationManagerService.
415 // ================================================================================
416 public IBinder addNotification(StatusBarNotification notification) {
417 synchronized (mNotifications) {
Joe Onoratoa0c56fe2010-05-20 10:21:52 -0700418 IBinder key = new Binder();
Joe Onorato75199e32010-05-29 17:22:51 -0400419 mNotifications.put(key, notification);
Joe Onoratoe345fff2010-05-23 15:18:27 -0400420 if (mBar != null) {
421 try {
422 mBar.addNotification(key, notification);
423 } catch (RemoteException ex) {
424 }
425 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700426 return key;
427 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700428 }
429
Joe Onorato18e69df2010-05-17 22:26:12 -0700430 public void updateNotification(IBinder key, StatusBarNotification notification) {
431 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400432 if (!mNotifications.containsKey(key)) {
433 throw new IllegalArgumentException("updateNotification key not found: " + key);
434 }
435 mNotifications.put(key, notification);
Joe Onoratoe345fff2010-05-23 15:18:27 -0400436 if (mBar != null) {
437 try {
438 mBar.updateNotification(key, notification);
439 } catch (RemoteException ex) {
440 }
441 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700442 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700443 }
444
445 public void removeNotification(IBinder key) {
Joe Onorato18e69df2010-05-17 22:26:12 -0700446 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400447 final StatusBarNotification n = mNotifications.remove(key);
448 if (n == null) {
449 throw new IllegalArgumentException("removeNotification key not found: " + key);
450 }
Joe Onoratoe345fff2010-05-23 15:18:27 -0400451 if (mBar != null) {
452 try {
453 mBar.removeNotification(key);
454 } catch (RemoteException ex) {
455 }
456 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700457 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700458 }
Joe Onorato2314aab2010-04-08 16:41:23 -0500459
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800460 // ================================================================================
461 // Can be called from any thread
462 // ================================================================================
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800463
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800464 // lock on mDisableRecords
465 void manageDisableListLocked(int what, IBinder token, String pkg) {
466 if (SPEW) {
Joe Onoratof3f0e052010-05-14 18:49:29 -0700467 Slog.d(TAG, "manageDisableList what=0x" + Integer.toHexString(what) + " pkg=" + pkg);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800468 }
469 // update the list
470 synchronized (mDisableRecords) {
471 final int N = mDisableRecords.size();
472 DisableRecord tok = null;
473 int i;
474 for (i=0; i<N; i++) {
475 DisableRecord t = mDisableRecords.get(i);
476 if (t.token == token) {
477 tok = t;
478 break;
479 }
480 }
481 if (what == 0 || !token.isBinderAlive()) {
482 if (tok != null) {
483 mDisableRecords.remove(i);
Suchi Amalapurapufff2fda2009-06-30 21:36:16 -0700484 tok.token.unlinkToDeath(tok, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800485 }
486 } else {
487 if (tok == null) {
488 tok = new DisableRecord();
489 try {
490 token.linkToDeath(tok, 0);
491 }
492 catch (RemoteException ex) {
493 return; // give up
494 }
495 mDisableRecords.add(tok);
496 }
497 tok.what = what;
498 tok.token = token;
499 tok.pkg = pkg;
500 }
501 }
502 }
503
504 // lock on mDisableRecords
505 int gatherDisableActionsLocked() {
506 final int N = mDisableRecords.size();
507 // gather the new net flags
508 int net = 0;
509 for (int i=0; i<N; i++) {
510 net |= mDisableRecords.get(i).what;
511 }
512 return net;
513 }
514
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800515 // ================================================================================
516 // Always called from UI thread
517 // ================================================================================
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800518
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800519 protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
520 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
521 != PackageManager.PERMISSION_GRANTED) {
522 pw.println("Permission Denial: can't dump StatusBar from from pid="
523 + Binder.getCallingPid()
524 + ", uid=" + Binder.getCallingUid());
525 return;
526 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700527
Joe Onorato0cbda992010-05-02 16:28:15 -0700528 synchronized (mIcons) {
529 mIcons.dump(pw);
530 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700531
532 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400533 int i=0;
534 pw.println("Notification list:");
535 for (Map.Entry<IBinder,StatusBarNotification> e: mNotifications.entrySet()) {
536 pw.printf(" %2d: %s\n", i, e.getValue().toString());
537 i++;
538 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800539 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700540
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800541 synchronized (mDisableRecords) {
542 final int N = mDisableRecords.size();
543 pw.println(" mDisableRecords.size=" + N
544 + " mDisabled=0x" + Integer.toHexString(mDisabled));
545 for (int i=0; i<N; i++) {
546 DisableRecord tok = mDisableRecords.get(i);
547 pw.println(" [" + i + "] what=0x" + Integer.toHexString(tok.what)
548 + " pkg=" + tok.pkg + " token=" + tok.token);
549 }
550 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800551 }
552
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800553 private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
554 public void onReceive(Context context, Intent intent) {
555 String action = intent.getAction();
Joe Onoratof9e0e6b2009-09-08 16:24:36 -0400556 if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)
557 || Intent.ACTION_SCREEN_OFF.equals(action)) {
Joe Onoratof3f0e052010-05-14 18:49:29 -0700558 collapse();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800559 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700560 /*
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800561 else if (Telephony.Intents.SPN_STRINGS_UPDATED_ACTION.equals(action)) {
562 updateNetworkName(intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_SPN, false),
563 intent.getStringExtra(Telephony.Intents.EXTRA_SPN),
564 intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_PLMN, false),
565 intent.getStringExtra(Telephony.Intents.EXTRA_PLMN));
566 }
567 else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
568 updateResources();
569 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700570 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800571 }
572 };
573
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800574}