blob: 86b8bc619dc2e19b2774677c81661a57ef30e1d6 [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 Onorato664644d2011-01-23 17:53:23 -080035import android.view.View;
Joe Onorato0cbda992010-05-02 16:28:15 -070036
37import com.android.internal.statusbar.IStatusBar;
38import com.android.internal.statusbar.IStatusBarService;
39import com.android.internal.statusbar.StatusBarIcon;
40import com.android.internal.statusbar.StatusBarIconList;
Joe Onorato18e69df2010-05-17 22:26:12 -070041import com.android.internal.statusbar.StatusBarNotification;
The Android Open Source Project10592532009-03-18 17:39:46 -070042
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043import java.io.FileDescriptor;
44import java.io.PrintWriter;
45import java.util.ArrayList;
46import java.util.HashMap;
Joe Onorato75199e32010-05-29 17:22:51 -040047import java.util.List;
48import java.util.Map;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080049
50
51/**
Joe Onoratof3f0e052010-05-14 18:49:29 -070052 * A note on locking: We rely on the fact that calls onto mBar are oneway or
53 * if they are local, that they just enqueue messages to not deadlock.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080054 */
Joe Onorato089de882010-04-12 08:18:45 -070055public class StatusBarManagerService extends IStatusBarService.Stub
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056{
Joe Onorato4762c2d2010-05-17 15:42:59 -070057 static final String TAG = "StatusBarManagerService";
Joe Onorato431bb222010-10-18 19:13:23 -040058 static final boolean SPEW = false;
Joe Onoratodf7dbb62009-11-17 10:43:37 -080059
Joe Onoratof3f0e052010-05-14 18:49:29 -070060 final Context mContext;
61 Handler mHandler = new Handler();
62 NotificationCallbacks mNotificationCallbacks;
Joe Onorato4762c2d2010-05-17 15:42:59 -070063 volatile IStatusBar mBar;
Joe Onoratof3f0e052010-05-14 18:49:29 -070064 StatusBarIconList mIcons = new StatusBarIconList();
Joe Onorato75199e32010-05-29 17:22:51 -040065 HashMap<IBinder,StatusBarNotification> mNotifications
66 = new HashMap<IBinder,StatusBarNotification>();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080067
Joe Onoratof3f0e052010-05-14 18:49:29 -070068 // for disabling the status bar
69 ArrayList<DisableRecord> mDisableRecords = new ArrayList<DisableRecord>();
70 int mDisabled = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080071
Joe Onorato93056472010-09-10 10:30:46 -040072 Object mLock = new Object();
73 // We usually call it lights out mode, but double negatives are annoying
74 boolean mLightsOn = true;
Daniel Sandlere02d8082010-10-08 15:13:22 -040075 boolean mMenuVisible = false;
satok06487a52010-10-29 11:37:18 +090076 boolean mIMEButtonVisible = false;
satokcd7cd292010-11-20 15:46:23 +090077 IBinder mIMEToken = null;
satok06487a52010-10-29 11:37:18 +090078
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080079 private class DisableRecord implements IBinder.DeathRecipient {
80 String pkg;
81 int what;
82 IBinder token;
83
84 public void binderDied() {
Joe Onorato8a9b2202010-02-26 18:56:32 -080085 Slog.i(TAG, "binder died for pkg=" + pkg);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080086 disable(0, token, pkg);
Suchi Amalapurapufff2fda2009-06-30 21:36:16 -070087 token.unlinkToDeath(this, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 }
89 }
90
91 public interface NotificationCallbacks {
92 void onSetDisabled(int status);
93 void onClearAll();
Fred Quintana6ecaff12009-09-25 14:23:13 -070094 void onNotificationClick(String pkg, String tag, int id);
Daniel Sandler0f0b11c2010-08-04 15:54:58 -040095 void onNotificationClear(String pkg, String tag, int id);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080096 void onPanelRevealed();
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -070097 void onNotificationError(String pkg, String tag, int id,
98 int uid, int initialPid, String message);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080099 }
100
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800101 /**
102 * Construct the service, add the status bar view to the window manager
103 */
Joe Onorato089de882010-04-12 08:18:45 -0700104 public StatusBarManagerService(Context context) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800105 mContext = context;
Joe Onorato0cbda992010-05-02 16:28:15 -0700106
107 final Resources res = context.getResources();
Joe Onorato75144ea2010-06-07 12:36:25 -0700108 mIcons.defineSlots(res.getStringArray(com.android.internal.R.array.config_statusBarIcons));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800109 }
110
111 public void setNotificationCallbacks(NotificationCallbacks listener) {
112 mNotificationCallbacks = listener;
113 }
114
115 // ================================================================================
Joe Onorato25f95f92010-04-08 18:37:10 -0500116 // From IStatusBarService
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800117 // ================================================================================
Joe Onoratof3f0e052010-05-14 18:49:29 -0700118 public void expand() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800119 enforceExpandStatusBar();
Joe Onorato4762c2d2010-05-17 15:42:59 -0700120
121 if (mBar != null) {
122 try {
123 mBar.animateExpand();
124 } catch (RemoteException ex) {
125 }
126 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800127 }
128
Joe Onoratof3f0e052010-05-14 18:49:29 -0700129 public void collapse() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800130 enforceExpandStatusBar();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800131
Joe Onorato4762c2d2010-05-17 15:42:59 -0700132 if (mBar != null) {
133 try {
134 mBar.animateCollapse();
135 } catch (RemoteException ex) {
136 }
137 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800138 }
139
140 public void disable(int what, IBinder token, String pkg) {
141 enforceStatusBar();
Joe Onoratof3f0e052010-05-14 18:49:29 -0700142
143 // It's important that the the callback and the call to mBar get done
144 // in the same order when multiple threads are calling this function
145 // so they are paired correctly. The messages on the handler will be
146 // handled in the order they were enqueued, but will be outside the lock.
147 synchronized (mDisableRecords) {
148 manageDisableListLocked(what, token, pkg);
149 final int net = gatherDisableActionsLocked();
Joe Onoratof3f0e052010-05-14 18:49:29 -0700150 if (net != mDisabled) {
151 mDisabled = net;
152 mHandler.post(new Runnable() {
153 public void run() {
154 mNotificationCallbacks.onSetDisabled(net);
155 }
156 });
157 if (mBar != null) {
158 try {
159 mBar.disable(net);
160 } catch (RemoteException ex) {
161 }
162 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800163 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800164 }
165 }
166
Joe Onorato0cbda992010-05-02 16:28:15 -0700167 public void setIcon(String slot, String iconPackage, int iconId, int iconLevel) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800168 enforceStatusBar();
Joe Onorato0cbda992010-05-02 16:28:15 -0700169
170 synchronized (mIcons) {
171 int index = mIcons.getSlotIndex(slot);
172 if (index < 0) {
173 throw new SecurityException("invalid status bar icon slot: " + slot);
174 }
175
176 StatusBarIcon icon = new StatusBarIcon(iconPackage, iconId, iconLevel);
Joe Onorato66d7d012010-05-14 10:05:10 -0700177 //Slog.d(TAG, "setIcon slot=" + slot + " index=" + index + " icon=" + icon);
Joe Onorato0cbda992010-05-02 16:28:15 -0700178 mIcons.setIcon(index, icon);
179
Joe Onorato0cbda992010-05-02 16:28:15 -0700180 if (mBar != null) {
181 try {
182 mBar.setIcon(index, icon);
183 } catch (RemoteException ex) {
184 }
185 }
186 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800187 }
188
Joe Onorato0cbda992010-05-02 16:28:15 -0700189 public void setIconVisibility(String slot, boolean visible) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800190 enforceStatusBar();
Joe Onorato0cbda992010-05-02 16:28:15 -0700191
Joe Onorato514ad6632010-05-13 18:49:00 -0700192 synchronized (mIcons) {
193 int index = mIcons.getSlotIndex(slot);
194 if (index < 0) {
195 throw new SecurityException("invalid status bar icon slot: " + slot);
196 }
197
198 StatusBarIcon icon = mIcons.getIcon(index);
199 if (icon == null) {
200 return;
201 }
202
203 if (icon.visible != visible) {
204 icon.visible = visible;
205
Joe Onorato514ad6632010-05-13 18:49:00 -0700206 if (mBar != null) {
207 try {
208 mBar.setIcon(index, icon);
209 } catch (RemoteException ex) {
210 }
211 }
212 }
213 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700214 }
215
216 public void removeIcon(String slot) {
217 enforceStatusBar();
218
219 synchronized (mIcons) {
220 int index = mIcons.getSlotIndex(slot);
221 if (index < 0) {
222 throw new SecurityException("invalid status bar icon slot: " + slot);
223 }
224
225 mIcons.removeIcon(index);
226
Joe Onorato0cbda992010-05-02 16:28:15 -0700227 if (mBar != null) {
228 try {
229 mBar.removeIcon(index);
230 } catch (RemoteException ex) {
231 }
232 }
233 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800234 }
235
Daniel Sandlere02d8082010-10-08 15:13:22 -0400236 /**
237 * Hide or show the on-screen Menu key. Only call this from the window manager, typically in
238 * response to a window with FLAG_NEEDS_MENU_KEY set.
239 */
240 public void setMenuKeyVisible(final boolean visible) {
241 enforceStatusBar();
242
243 if (SPEW) Slog.d(TAG, (visible?"showing":"hiding") + " MENU key");
244
245 synchronized(mLock) {
246 if (mMenuVisible != visible) {
247 mMenuVisible = visible;
248 mHandler.post(new Runnable() {
249 public void run() {
250 if (mBar != null) {
251 try {
252 mBar.setMenuKeyVisible(visible);
253 } catch (RemoteException ex) {
254 }
255 }
256 }
257 });
258 }
259 }
260 }
261
satokcd7cd292010-11-20 15:46:23 +0900262 public void setIMEButtonVisible(final IBinder token, final boolean visible) {
satok06487a52010-10-29 11:37:18 +0900263 enforceStatusBar();
264
265 if (SPEW) Slog.d(TAG, (visible?"showing":"hiding") + " IME Button");
266
267 synchronized(mLock) {
satok06e07442010-11-02 19:46:55 +0900268 // In case of IME change, we need to call up setIMEButtonVisible() regardless of
269 // mIMEButtonVisible because mIMEButtonVisible may not have been set to false when the
270 // previous IME was destroyed.
271 mIMEButtonVisible = visible;
satokcd7cd292010-11-20 15:46:23 +0900272 mIMEToken = token;
satok06e07442010-11-02 19:46:55 +0900273 mHandler.post(new Runnable() {
274 public void run() {
275 if (mBar != null) {
276 try {
satokcd7cd292010-11-20 15:46:23 +0900277 mBar.setIMEButtonVisible(token, visible);
satok06e07442010-11-02 19:46:55 +0900278 } catch (RemoteException ex) {
satok06487a52010-10-29 11:37:18 +0900279 }
280 }
satok06e07442010-11-02 19:46:55 +0900281 }
282 });
satok06487a52010-10-29 11:37:18 +0900283 }
284 }
285
Joe Onoratof63b0f42010-09-12 17:03:19 -0400286 /**
Joe Onoratof63b0f42010-09-12 17:03:19 -0400287 * This is used for the user-controlled version of lights-out mode. Only call this from
288 * the status bar itself.
289 *
290 * We have two different functions here, because I think we're going to want to
291 * tweak the behavior when the user keeps turning lights-out mode off and the
292 * app keeps trying to turn it on. For now they can just fight it out. Having
293 * these two separte inputs will allow us to keep that change local to here. --joeo
294 */
Joe Onorato664644d2011-01-23 17:53:23 -0800295 public void setSystemUiVisibility(int vis) {
Joe Onoratof63b0f42010-09-12 17:03:19 -0400296 enforceStatusBarService();
297
298 synchronized (mLock) {
Joe Onorato664644d2011-01-23 17:53:23 -0800299 final boolean lightsOn = (vis & View.STATUS_BAR_HIDDEN) == 0;
Joe Onoratof63b0f42010-09-12 17:03:19 -0400300 updateLightsOnLocked(lightsOn);
301 }
302 }
303
304 private void updateLightsOnLocked(final boolean lightsOn) {
305 if (mLightsOn != lightsOn) {
306 mLightsOn = lightsOn;
307 mHandler.post(new Runnable() {
308 public void run() {
309 if (mBar != null) {
310 try {
311 mBar.setLightsOn(lightsOn);
312 } catch (RemoteException ex) {
Joe Onorato93056472010-09-10 10:30:46 -0400313 }
314 }
Joe Onoratof63b0f42010-09-12 17:03:19 -0400315 }
316 });
Joe Onorato93056472010-09-10 10:30:46 -0400317 }
318 }
319
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800320 private void enforceStatusBar() {
Joe Onorato0cbda992010-05-02 16:28:15 -0700321 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR,
Joe Onorato089de882010-04-12 08:18:45 -0700322 "StatusBarManagerService");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800323 }
324
325 private void enforceExpandStatusBar() {
Joe Onorato0cbda992010-05-02 16:28:15 -0700326 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.EXPAND_STATUS_BAR,
Joe Onorato089de882010-04-12 08:18:45 -0700327 "StatusBarManagerService");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800328 }
329
Joe Onorato8bc6c512010-06-04 16:21:12 -0400330 private void enforceStatusBarService() {
331 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR_SERVICE,
332 "StatusBarManagerService");
333 }
334
Joe Onorato4762c2d2010-05-17 15:42:59 -0700335
336 // ================================================================================
337 // Callbacks from the status bar service.
338 // ================================================================================
Joe Onorato75199e32010-05-29 17:22:51 -0400339 public void registerStatusBar(IStatusBar bar, StatusBarIconList iconList,
Joe Onorato93056472010-09-10 10:30:46 -0400340 List<IBinder> notificationKeys, List<StatusBarNotification> notifications,
satokcd7cd292010-11-20 15:46:23 +0900341 int switches[], List<IBinder> binders) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400342 enforceStatusBarService();
343
Joe Onorato0cbda992010-05-02 16:28:15 -0700344 Slog.i(TAG, "registerStatusBar bar=" + bar);
345 mBar = bar;
Joe Onorato75199e32010-05-29 17:22:51 -0400346 synchronized (mIcons) {
347 iconList.copyFrom(mIcons);
348 }
349 synchronized (mNotifications) {
350 for (Map.Entry<IBinder,StatusBarNotification> e: mNotifications.entrySet()) {
351 notificationKeys.add(e.getKey());
352 notifications.add(e.getValue());
353 }
354 }
Joe Onorato93056472010-09-10 10:30:46 -0400355 synchronized (mLock) {
Joe Onoratoe4c7b3f2010-10-30 12:15:03 -0700356 switches[0] = gatherDisableActionsLocked();
357 switches[1] = mLightsOn ? 1 : 0;
358 switches[2] = mMenuVisible ? 1 : 0;
359 switches[3] = mIMEButtonVisible ? 1 : 0;
satokcd7cd292010-11-20 15:46:23 +0900360 binders.add(mIMEToken);
Joe Onorato93056472010-09-10 10:30:46 -0400361 }
Joe Onorato2314aab2010-04-08 16:41:23 -0500362 }
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400363
Joe Onorato4762c2d2010-05-17 15:42:59 -0700364 /**
Joe Onoratof1f25912010-06-07 11:52:41 -0700365 * The status bar service should call this each time the user brings the panel from
366 * invisible to visible in order to clear the notification light.
Joe Onorato4762c2d2010-05-17 15:42:59 -0700367 */
Joe Onoratof1f25912010-06-07 11:52:41 -0700368 public void onPanelRevealed() {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400369 enforceStatusBarService();
370
Joe Onoratof1f25912010-06-07 11:52:41 -0700371 // tell the notification manager to turn off the lights.
372 mNotificationCallbacks.onPanelRevealed();
Joe Onorato4762c2d2010-05-17 15:42:59 -0700373 }
374
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400375 public void onNotificationClick(String pkg, String tag, int id) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400376 enforceStatusBarService();
377
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400378 mNotificationCallbacks.onNotificationClick(pkg, tag, id);
379 }
380
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -0700381 public void onNotificationError(String pkg, String tag, int id,
382 int uid, int initialPid, String message) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400383 enforceStatusBarService();
384
Joe Onorato005847b2010-06-04 16:08:02 -0400385 // WARNING: this will call back into us to do the remove. Don't hold any locks.
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -0700386 mNotificationCallbacks.onNotificationError(pkg, tag, id, uid, initialPid, message);
Joe Onorato005847b2010-06-04 16:08:02 -0400387 }
388
Daniel Sandler0f0b11c2010-08-04 15:54:58 -0400389 public void onNotificationClear(String pkg, String tag, int id) {
390 enforceStatusBarService();
391
392 mNotificationCallbacks.onNotificationClear(pkg, tag, id);
393 }
394
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400395 public void onClearAllNotifications() {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400396 enforceStatusBarService();
397
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400398 mNotificationCallbacks.onClearAll();
399 }
400
Joe Onorato18e69df2010-05-17 22:26:12 -0700401 // ================================================================================
402 // Callbacks for NotificationManagerService.
403 // ================================================================================
404 public IBinder addNotification(StatusBarNotification notification) {
405 synchronized (mNotifications) {
Joe Onoratoa0c56fe2010-05-20 10:21:52 -0700406 IBinder key = new Binder();
Joe Onorato75199e32010-05-29 17:22:51 -0400407 mNotifications.put(key, notification);
Joe Onoratoe345fff2010-05-23 15:18:27 -0400408 if (mBar != null) {
409 try {
410 mBar.addNotification(key, notification);
411 } catch (RemoteException ex) {
412 }
413 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700414 return key;
415 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700416 }
417
Joe Onorato18e69df2010-05-17 22:26:12 -0700418 public void updateNotification(IBinder key, StatusBarNotification notification) {
419 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400420 if (!mNotifications.containsKey(key)) {
421 throw new IllegalArgumentException("updateNotification key not found: " + key);
422 }
423 mNotifications.put(key, notification);
Joe Onoratoe345fff2010-05-23 15:18:27 -0400424 if (mBar != null) {
425 try {
426 mBar.updateNotification(key, notification);
427 } catch (RemoteException ex) {
428 }
429 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700430 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700431 }
432
433 public void removeNotification(IBinder key) {
Joe Onorato18e69df2010-05-17 22:26:12 -0700434 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400435 final StatusBarNotification n = mNotifications.remove(key);
436 if (n == null) {
437 throw new IllegalArgumentException("removeNotification key not found: " + key);
438 }
Joe Onoratoe345fff2010-05-23 15:18:27 -0400439 if (mBar != null) {
440 try {
441 mBar.removeNotification(key);
442 } catch (RemoteException ex) {
443 }
444 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700445 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700446 }
Joe Onorato2314aab2010-04-08 16:41:23 -0500447
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800448 // ================================================================================
449 // Can be called from any thread
450 // ================================================================================
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800451
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800452 // lock on mDisableRecords
453 void manageDisableListLocked(int what, IBinder token, String pkg) {
454 if (SPEW) {
Joe Onoratof3f0e052010-05-14 18:49:29 -0700455 Slog.d(TAG, "manageDisableList what=0x" + Integer.toHexString(what) + " pkg=" + pkg);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800456 }
457 // update the list
458 synchronized (mDisableRecords) {
459 final int N = mDisableRecords.size();
460 DisableRecord tok = null;
461 int i;
462 for (i=0; i<N; i++) {
463 DisableRecord t = mDisableRecords.get(i);
464 if (t.token == token) {
465 tok = t;
466 break;
467 }
468 }
469 if (what == 0 || !token.isBinderAlive()) {
470 if (tok != null) {
471 mDisableRecords.remove(i);
Suchi Amalapurapufff2fda2009-06-30 21:36:16 -0700472 tok.token.unlinkToDeath(tok, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800473 }
474 } else {
475 if (tok == null) {
476 tok = new DisableRecord();
477 try {
478 token.linkToDeath(tok, 0);
479 }
480 catch (RemoteException ex) {
481 return; // give up
482 }
483 mDisableRecords.add(tok);
484 }
485 tok.what = what;
486 tok.token = token;
487 tok.pkg = pkg;
488 }
489 }
490 }
491
492 // lock on mDisableRecords
493 int gatherDisableActionsLocked() {
494 final int N = mDisableRecords.size();
495 // gather the new net flags
496 int net = 0;
497 for (int i=0; i<N; i++) {
498 net |= mDisableRecords.get(i).what;
499 }
500 return net;
501 }
502
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800503 // ================================================================================
504 // Always called from UI thread
505 // ================================================================================
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800506
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800507 protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
508 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
509 != PackageManager.PERMISSION_GRANTED) {
510 pw.println("Permission Denial: can't dump StatusBar from from pid="
511 + Binder.getCallingPid()
512 + ", uid=" + Binder.getCallingUid());
513 return;
514 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700515
Joe Onorato0cbda992010-05-02 16:28:15 -0700516 synchronized (mIcons) {
517 mIcons.dump(pw);
518 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700519
520 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400521 int i=0;
522 pw.println("Notification list:");
523 for (Map.Entry<IBinder,StatusBarNotification> e: mNotifications.entrySet()) {
524 pw.printf(" %2d: %s\n", i, e.getValue().toString());
525 i++;
526 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800527 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700528
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800529 synchronized (mDisableRecords) {
530 final int N = mDisableRecords.size();
531 pw.println(" mDisableRecords.size=" + N
532 + " mDisabled=0x" + Integer.toHexString(mDisabled));
533 for (int i=0; i<N; i++) {
534 DisableRecord tok = mDisableRecords.get(i);
535 pw.println(" [" + i + "] what=0x" + Integer.toHexString(tok.what)
536 + " pkg=" + tok.pkg + " token=" + tok.token);
537 }
538 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800539 }
540
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800541 private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
542 public void onReceive(Context context, Intent intent) {
543 String action = intent.getAction();
Joe Onoratof9e0e6b2009-09-08 16:24:36 -0400544 if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)
545 || Intent.ACTION_SCREEN_OFF.equals(action)) {
Joe Onoratof3f0e052010-05-14 18:49:29 -0700546 collapse();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800547 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700548 /*
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800549 else if (Telephony.Intents.SPN_STRINGS_UPDATED_ACTION.equals(action)) {
550 updateNetworkName(intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_SPN, false),
551 intent.getStringExtra(Telephony.Intents.EXTRA_SPN),
552 intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_PLMN, false),
553 intent.getStringExtra(Telephony.Intents.EXTRA_PLMN));
554 }
555 else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
556 updateResources();
557 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700558 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800559 }
560 };
561
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800562}