blob: cbfa4eed21db180c8e89ecc05a0a83be594a9f94 [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;
satokcd7cd292010-11-20 15:46:23 +090076 IBinder mIMEToken = null;
satok06487a52010-10-29 11:37:18 +090077
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080078 private class DisableRecord implements IBinder.DeathRecipient {
79 String pkg;
80 int what;
81 IBinder token;
82
83 public void binderDied() {
Joe Onorato8a9b2202010-02-26 18:56:32 -080084 Slog.i(TAG, "binder died for pkg=" + pkg);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080085 disable(0, token, pkg);
Suchi Amalapurapufff2fda2009-06-30 21:36:16 -070086 token.unlinkToDeath(this, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080087 }
88 }
89
90 public interface NotificationCallbacks {
91 void onSetDisabled(int status);
92 void onClearAll();
Fred Quintana6ecaff12009-09-25 14:23:13 -070093 void onNotificationClick(String pkg, String tag, int id);
Daniel Sandler0f0b11c2010-08-04 15:54:58 -040094 void onNotificationClear(String pkg, String tag, int id);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080095 void onPanelRevealed();
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -070096 void onNotificationError(String pkg, String tag, int id,
97 int uid, int initialPid, String message);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080098 }
99
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800100 /**
101 * Construct the service, add the status bar view to the window manager
102 */
Joe Onorato089de882010-04-12 08:18:45 -0700103 public StatusBarManagerService(Context context) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800104 mContext = context;
Joe Onorato0cbda992010-05-02 16:28:15 -0700105
106 final Resources res = context.getResources();
Joe Onorato75144ea2010-06-07 12:36:25 -0700107 mIcons.defineSlots(res.getStringArray(com.android.internal.R.array.config_statusBarIcons));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800108 }
109
110 public void setNotificationCallbacks(NotificationCallbacks listener) {
111 mNotificationCallbacks = listener;
112 }
113
114 // ================================================================================
Joe Onorato25f95f92010-04-08 18:37:10 -0500115 // From IStatusBarService
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800116 // ================================================================================
Joe Onoratof3f0e052010-05-14 18:49:29 -0700117 public void expand() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118 enforceExpandStatusBar();
Joe Onorato4762c2d2010-05-17 15:42:59 -0700119
120 if (mBar != null) {
121 try {
122 mBar.animateExpand();
123 } catch (RemoteException ex) {
124 }
125 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800126 }
127
Joe Onoratof3f0e052010-05-14 18:49:29 -0700128 public void collapse() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800129 enforceExpandStatusBar();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800130
Joe Onorato4762c2d2010-05-17 15:42:59 -0700131 if (mBar != null) {
132 try {
133 mBar.animateCollapse();
134 } catch (RemoteException ex) {
135 }
136 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800137 }
138
139 public void disable(int what, IBinder token, String pkg) {
140 enforceStatusBar();
Joe Onoratof3f0e052010-05-14 18:49:29 -0700141
142 // It's important that the the callback and the call to mBar get done
143 // in the same order when multiple threads are calling this function
144 // so they are paired correctly. The messages on the handler will be
145 // handled in the order they were enqueued, but will be outside the lock.
146 synchronized (mDisableRecords) {
147 manageDisableListLocked(what, token, pkg);
148 final int net = gatherDisableActionsLocked();
Joe Onoratof3f0e052010-05-14 18:49:29 -0700149 if (net != mDisabled) {
150 mDisabled = net;
151 mHandler.post(new Runnable() {
152 public void run() {
153 mNotificationCallbacks.onSetDisabled(net);
154 }
155 });
156 if (mBar != null) {
157 try {
158 mBar.disable(net);
159 } catch (RemoteException ex) {
160 }
161 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800162 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800163 }
164 }
165
Joe Onorato0cbda992010-05-02 16:28:15 -0700166 public void setIcon(String slot, String iconPackage, int iconId, int iconLevel) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800167 enforceStatusBar();
Joe Onorato0cbda992010-05-02 16:28:15 -0700168
169 synchronized (mIcons) {
170 int index = mIcons.getSlotIndex(slot);
171 if (index < 0) {
172 throw new SecurityException("invalid status bar icon slot: " + slot);
173 }
174
175 StatusBarIcon icon = new StatusBarIcon(iconPackage, iconId, iconLevel);
Joe Onorato66d7d012010-05-14 10:05:10 -0700176 //Slog.d(TAG, "setIcon slot=" + slot + " index=" + index + " icon=" + icon);
Joe Onorato0cbda992010-05-02 16:28:15 -0700177 mIcons.setIcon(index, icon);
178
Joe Onorato0cbda992010-05-02 16:28:15 -0700179 if (mBar != null) {
180 try {
181 mBar.setIcon(index, icon);
182 } catch (RemoteException ex) {
183 }
184 }
185 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800186 }
187
Joe Onorato0cbda992010-05-02 16:28:15 -0700188 public void setIconVisibility(String slot, boolean visible) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800189 enforceStatusBar();
Joe Onorato0cbda992010-05-02 16:28:15 -0700190
Joe Onorato514ad6632010-05-13 18:49:00 -0700191 synchronized (mIcons) {
192 int index = mIcons.getSlotIndex(slot);
193 if (index < 0) {
194 throw new SecurityException("invalid status bar icon slot: " + slot);
195 }
196
197 StatusBarIcon icon = mIcons.getIcon(index);
198 if (icon == null) {
199 return;
200 }
201
202 if (icon.visible != visible) {
203 icon.visible = visible;
204
Joe Onorato514ad6632010-05-13 18:49:00 -0700205 if (mBar != null) {
206 try {
207 mBar.setIcon(index, icon);
208 } catch (RemoteException ex) {
209 }
210 }
211 }
212 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700213 }
214
215 public void removeIcon(String slot) {
216 enforceStatusBar();
217
218 synchronized (mIcons) {
219 int index = mIcons.getSlotIndex(slot);
220 if (index < 0) {
221 throw new SecurityException("invalid status bar icon slot: " + slot);
222 }
223
224 mIcons.removeIcon(index);
225
Joe Onorato0cbda992010-05-02 16:28:15 -0700226 if (mBar != null) {
227 try {
228 mBar.removeIcon(index);
229 } catch (RemoteException ex) {
230 }
231 }
232 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800233 }
234
Daniel Sandlere02d8082010-10-08 15:13:22 -0400235 /**
236 * Hide or show the on-screen Menu key. Only call this from the window manager, typically in
237 * response to a window with FLAG_NEEDS_MENU_KEY set.
238 */
239 public void setMenuKeyVisible(final boolean visible) {
240 enforceStatusBar();
241
242 if (SPEW) Slog.d(TAG, (visible?"showing":"hiding") + " MENU key");
243
244 synchronized(mLock) {
245 if (mMenuVisible != visible) {
246 mMenuVisible = visible;
247 mHandler.post(new Runnable() {
248 public void run() {
249 if (mBar != null) {
250 try {
251 mBar.setMenuKeyVisible(visible);
252 } catch (RemoteException ex) {
253 }
254 }
255 }
256 });
257 }
258 }
259 }
260
satokcd7cd292010-11-20 15:46:23 +0900261 public void setIMEButtonVisible(final IBinder token, final boolean visible) {
satok06487a52010-10-29 11:37:18 +0900262 enforceStatusBar();
263
264 if (SPEW) Slog.d(TAG, (visible?"showing":"hiding") + " IME Button");
265
266 synchronized(mLock) {
satok06e07442010-11-02 19:46:55 +0900267 // In case of IME change, we need to call up setIMEButtonVisible() regardless of
268 // mIMEButtonVisible because mIMEButtonVisible may not have been set to false when the
269 // previous IME was destroyed.
270 mIMEButtonVisible = visible;
satokcd7cd292010-11-20 15:46:23 +0900271 mIMEToken = token;
satok06e07442010-11-02 19:46:55 +0900272 mHandler.post(new Runnable() {
273 public void run() {
274 if (mBar != null) {
275 try {
satokcd7cd292010-11-20 15:46:23 +0900276 mBar.setIMEButtonVisible(token, visible);
satok06e07442010-11-02 19:46:55 +0900277 } catch (RemoteException ex) {
satok06487a52010-10-29 11:37:18 +0900278 }
279 }
satok06e07442010-11-02 19:46:55 +0900280 }
281 });
satok06487a52010-10-29 11:37:18 +0900282 }
283 }
284
Joe Onoratof63b0f42010-09-12 17:03:19 -0400285 /**
286 * This is used for the automatic version of lights-out mode. Only call this from
287 * the window manager.
288 *
289 * @see setLightsOn(boolean)
290 */
Joe Onorato93056472010-09-10 10:30:46 -0400291 public void setActiveWindowIsFullscreen(boolean fullscreen) {
292 // We could get away with a separate permission here, but STATUS_BAR is
293 // signatureOrSystem which is probably good enough. There is no public API
294 // for this, so the question is a security issue, not an API compatibility issue.
295 enforceStatusBar();
296
Joe Onorato93056472010-09-10 10:30:46 -0400297 synchronized (mLock) {
Joe Onoratof63b0f42010-09-12 17:03:19 -0400298 updateLightsOnLocked(!fullscreen);
299 }
300 }
301
302 /**
303 * This is used for the user-controlled version of lights-out mode. Only call this from
304 * the status bar itself.
305 *
306 * We have two different functions here, because I think we're going to want to
307 * tweak the behavior when the user keeps turning lights-out mode off and the
308 * app keeps trying to turn it on. For now they can just fight it out. Having
309 * these two separte inputs will allow us to keep that change local to here. --joeo
310 */
311 public void setLightsOn(boolean lightsOn) {
312 enforceStatusBarService();
313
314 synchronized (mLock) {
315 updateLightsOnLocked(lightsOn);
316 }
317 }
318
319 private void updateLightsOnLocked(final boolean lightsOn) {
320 if (mLightsOn != lightsOn) {
321 mLightsOn = lightsOn;
322 mHandler.post(new Runnable() {
323 public void run() {
324 if (mBar != null) {
325 try {
326 mBar.setLightsOn(lightsOn);
327 } catch (RemoteException ex) {
Joe Onorato93056472010-09-10 10:30:46 -0400328 }
329 }
Joe Onoratof63b0f42010-09-12 17:03:19 -0400330 }
331 });
Joe Onorato93056472010-09-10 10:30:46 -0400332 }
333 }
334
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800335 private void enforceStatusBar() {
Joe Onorato0cbda992010-05-02 16:28:15 -0700336 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR,
Joe Onorato089de882010-04-12 08:18:45 -0700337 "StatusBarManagerService");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800338 }
339
340 private void enforceExpandStatusBar() {
Joe Onorato0cbda992010-05-02 16:28:15 -0700341 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.EXPAND_STATUS_BAR,
Joe Onorato089de882010-04-12 08:18:45 -0700342 "StatusBarManagerService");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800343 }
344
Joe Onorato8bc6c512010-06-04 16:21:12 -0400345 private void enforceStatusBarService() {
346 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR_SERVICE,
347 "StatusBarManagerService");
348 }
349
Joe Onorato4762c2d2010-05-17 15:42:59 -0700350
351 // ================================================================================
352 // Callbacks from the status bar service.
353 // ================================================================================
Joe Onorato75199e32010-05-29 17:22:51 -0400354 public void registerStatusBar(IStatusBar bar, StatusBarIconList iconList,
Joe Onorato93056472010-09-10 10:30:46 -0400355 List<IBinder> notificationKeys, List<StatusBarNotification> notifications,
satokcd7cd292010-11-20 15:46:23 +0900356 int switches[], List<IBinder> binders) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400357 enforceStatusBarService();
358
Joe Onorato0cbda992010-05-02 16:28:15 -0700359 Slog.i(TAG, "registerStatusBar bar=" + bar);
360 mBar = bar;
Joe Onorato75199e32010-05-29 17:22:51 -0400361 synchronized (mIcons) {
362 iconList.copyFrom(mIcons);
363 }
364 synchronized (mNotifications) {
365 for (Map.Entry<IBinder,StatusBarNotification> e: mNotifications.entrySet()) {
366 notificationKeys.add(e.getKey());
367 notifications.add(e.getValue());
368 }
369 }
Joe Onorato93056472010-09-10 10:30:46 -0400370 synchronized (mLock) {
Joe Onoratoe4c7b3f2010-10-30 12:15:03 -0700371 switches[0] = gatherDisableActionsLocked();
372 switches[1] = mLightsOn ? 1 : 0;
373 switches[2] = mMenuVisible ? 1 : 0;
374 switches[3] = mIMEButtonVisible ? 1 : 0;
satokcd7cd292010-11-20 15:46:23 +0900375 binders.add(mIMEToken);
Joe Onorato93056472010-09-10 10:30:46 -0400376 }
Joe Onorato2314aab2010-04-08 16:41:23 -0500377 }
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400378
Joe Onorato4762c2d2010-05-17 15:42:59 -0700379 /**
Joe Onoratof1f25912010-06-07 11:52:41 -0700380 * The status bar service should call this each time the user brings the panel from
381 * invisible to visible in order to clear the notification light.
Joe Onorato4762c2d2010-05-17 15:42:59 -0700382 */
Joe Onoratof1f25912010-06-07 11:52:41 -0700383 public void onPanelRevealed() {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400384 enforceStatusBarService();
385
Joe Onoratof1f25912010-06-07 11:52:41 -0700386 // tell the notification manager to turn off the lights.
387 mNotificationCallbacks.onPanelRevealed();
Joe Onorato4762c2d2010-05-17 15:42:59 -0700388 }
389
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400390 public void onNotificationClick(String pkg, String tag, int id) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400391 enforceStatusBarService();
392
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400393 mNotificationCallbacks.onNotificationClick(pkg, tag, id);
394 }
395
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -0700396 public void onNotificationError(String pkg, String tag, int id,
397 int uid, int initialPid, String message) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400398 enforceStatusBarService();
399
Joe Onorato005847b2010-06-04 16:08:02 -0400400 // WARNING: this will call back into us to do the remove. Don't hold any locks.
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -0700401 mNotificationCallbacks.onNotificationError(pkg, tag, id, uid, initialPid, message);
Joe Onorato005847b2010-06-04 16:08:02 -0400402 }
403
Daniel Sandler0f0b11c2010-08-04 15:54:58 -0400404 public void onNotificationClear(String pkg, String tag, int id) {
405 enforceStatusBarService();
406
407 mNotificationCallbacks.onNotificationClear(pkg, tag, id);
408 }
409
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400410 public void onClearAllNotifications() {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400411 enforceStatusBarService();
412
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400413 mNotificationCallbacks.onClearAll();
414 }
415
Joe Onorato18e69df2010-05-17 22:26:12 -0700416 // ================================================================================
417 // Callbacks for NotificationManagerService.
418 // ================================================================================
419 public IBinder addNotification(StatusBarNotification notification) {
420 synchronized (mNotifications) {
Joe Onoratoa0c56fe2010-05-20 10:21:52 -0700421 IBinder key = new Binder();
Joe Onorato75199e32010-05-29 17:22:51 -0400422 mNotifications.put(key, notification);
Joe Onoratoe345fff2010-05-23 15:18:27 -0400423 if (mBar != null) {
424 try {
425 mBar.addNotification(key, notification);
426 } catch (RemoteException ex) {
427 }
428 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700429 return key;
430 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700431 }
432
Joe Onorato18e69df2010-05-17 22:26:12 -0700433 public void updateNotification(IBinder key, StatusBarNotification notification) {
434 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400435 if (!mNotifications.containsKey(key)) {
436 throw new IllegalArgumentException("updateNotification key not found: " + key);
437 }
438 mNotifications.put(key, notification);
Joe Onoratoe345fff2010-05-23 15:18:27 -0400439 if (mBar != null) {
440 try {
441 mBar.updateNotification(key, notification);
442 } catch (RemoteException ex) {
443 }
444 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700445 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700446 }
447
448 public void removeNotification(IBinder key) {
Joe Onorato18e69df2010-05-17 22:26:12 -0700449 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400450 final StatusBarNotification n = mNotifications.remove(key);
451 if (n == null) {
452 throw new IllegalArgumentException("removeNotification key not found: " + key);
453 }
Joe Onoratoe345fff2010-05-23 15:18:27 -0400454 if (mBar != null) {
455 try {
456 mBar.removeNotification(key);
457 } catch (RemoteException ex) {
458 }
459 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700460 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700461 }
Joe Onorato2314aab2010-04-08 16:41:23 -0500462
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800463 // ================================================================================
464 // Can be called from any thread
465 // ================================================================================
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800466
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800467 // lock on mDisableRecords
468 void manageDisableListLocked(int what, IBinder token, String pkg) {
469 if (SPEW) {
Joe Onoratof3f0e052010-05-14 18:49:29 -0700470 Slog.d(TAG, "manageDisableList what=0x" + Integer.toHexString(what) + " pkg=" + pkg);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800471 }
472 // update the list
473 synchronized (mDisableRecords) {
474 final int N = mDisableRecords.size();
475 DisableRecord tok = null;
476 int i;
477 for (i=0; i<N; i++) {
478 DisableRecord t = mDisableRecords.get(i);
479 if (t.token == token) {
480 tok = t;
481 break;
482 }
483 }
484 if (what == 0 || !token.isBinderAlive()) {
485 if (tok != null) {
486 mDisableRecords.remove(i);
Suchi Amalapurapufff2fda2009-06-30 21:36:16 -0700487 tok.token.unlinkToDeath(tok, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800488 }
489 } else {
490 if (tok == null) {
491 tok = new DisableRecord();
492 try {
493 token.linkToDeath(tok, 0);
494 }
495 catch (RemoteException ex) {
496 return; // give up
497 }
498 mDisableRecords.add(tok);
499 }
500 tok.what = what;
501 tok.token = token;
502 tok.pkg = pkg;
503 }
504 }
505 }
506
507 // lock on mDisableRecords
508 int gatherDisableActionsLocked() {
509 final int N = mDisableRecords.size();
510 // gather the new net flags
511 int net = 0;
512 for (int i=0; i<N; i++) {
513 net |= mDisableRecords.get(i).what;
514 }
515 return net;
516 }
517
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800518 // ================================================================================
519 // Always called from UI thread
520 // ================================================================================
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800521
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800522 protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
523 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
524 != PackageManager.PERMISSION_GRANTED) {
525 pw.println("Permission Denial: can't dump StatusBar from from pid="
526 + Binder.getCallingPid()
527 + ", uid=" + Binder.getCallingUid());
528 return;
529 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700530
Joe Onorato0cbda992010-05-02 16:28:15 -0700531 synchronized (mIcons) {
532 mIcons.dump(pw);
533 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700534
535 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400536 int i=0;
537 pw.println("Notification list:");
538 for (Map.Entry<IBinder,StatusBarNotification> e: mNotifications.entrySet()) {
539 pw.printf(" %2d: %s\n", i, e.getValue().toString());
540 i++;
541 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800542 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700543
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800544 synchronized (mDisableRecords) {
545 final int N = mDisableRecords.size();
546 pw.println(" mDisableRecords.size=" + N
547 + " mDisabled=0x" + Integer.toHexString(mDisabled));
548 for (int i=0; i<N; i++) {
549 DisableRecord tok = mDisableRecords.get(i);
550 pw.println(" [" + i + "] what=0x" + Integer.toHexString(tok.what)
551 + " pkg=" + tok.pkg + " token=" + tok.token);
552 }
553 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800554 }
555
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800556 private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
557 public void onReceive(Context context, Intent intent) {
558 String action = intent.getAction();
Joe Onoratof9e0e6b2009-09-08 16:24:36 -0400559 if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)
560 || Intent.ACTION_SCREEN_OFF.equals(action)) {
Joe Onoratof3f0e052010-05-14 18:49:29 -0700561 collapse();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800562 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700563 /*
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800564 else if (Telephony.Intents.SPN_STRINGS_UPDATED_ACTION.equals(action)) {
565 updateNetworkName(intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_SPN, false),
566 intent.getStringExtra(Telephony.Intents.EXTRA_SPN),
567 intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_PLMN, false),
568 intent.getStringExtra(Telephony.Intents.EXTRA_PLMN));
569 }
570 else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
571 updateResources();
572 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700573 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800574 }
575 };
576
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800577}