blob: bdaa3b02e2b91497cf2419c70d4f435ebc4805bd [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 Onorato664644d2011-01-23 17:53:23 -0800286 public void setSystemUiVisibility(int vis) {
Joe Onorato55bf3802011-01-25 13:42:10 -0800287 // also allows calls from window manager which is in this process.
Joe Onoratof63b0f42010-09-12 17:03:19 -0400288 enforceStatusBarService();
289
290 synchronized (mLock) {
Joe Onorato664644d2011-01-23 17:53:23 -0800291 final boolean lightsOn = (vis & View.STATUS_BAR_HIDDEN) == 0;
Joe Onoratof63b0f42010-09-12 17:03:19 -0400292 updateLightsOnLocked(lightsOn);
293 }
294 }
295
296 private void updateLightsOnLocked(final boolean lightsOn) {
297 if (mLightsOn != lightsOn) {
298 mLightsOn = lightsOn;
299 mHandler.post(new Runnable() {
300 public void run() {
301 if (mBar != null) {
302 try {
303 mBar.setLightsOn(lightsOn);
304 } catch (RemoteException ex) {
Joe Onorato93056472010-09-10 10:30:46 -0400305 }
306 }
Joe Onoratof63b0f42010-09-12 17:03:19 -0400307 }
308 });
Joe Onorato93056472010-09-10 10:30:46 -0400309 }
310 }
311
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800312 private void enforceStatusBar() {
Joe Onorato0cbda992010-05-02 16:28:15 -0700313 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR,
Joe Onorato089de882010-04-12 08:18:45 -0700314 "StatusBarManagerService");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800315 }
316
317 private void enforceExpandStatusBar() {
Joe Onorato0cbda992010-05-02 16:28:15 -0700318 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.EXPAND_STATUS_BAR,
Joe Onorato089de882010-04-12 08:18:45 -0700319 "StatusBarManagerService");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800320 }
321
Joe Onorato8bc6c512010-06-04 16:21:12 -0400322 private void enforceStatusBarService() {
323 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR_SERVICE,
324 "StatusBarManagerService");
325 }
326
Joe Onorato4762c2d2010-05-17 15:42:59 -0700327
328 // ================================================================================
329 // Callbacks from the status bar service.
330 // ================================================================================
Joe Onorato75199e32010-05-29 17:22:51 -0400331 public void registerStatusBar(IStatusBar bar, StatusBarIconList iconList,
Joe Onorato93056472010-09-10 10:30:46 -0400332 List<IBinder> notificationKeys, List<StatusBarNotification> notifications,
satokcd7cd292010-11-20 15:46:23 +0900333 int switches[], List<IBinder> binders) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400334 enforceStatusBarService();
335
Joe Onorato0cbda992010-05-02 16:28:15 -0700336 Slog.i(TAG, "registerStatusBar bar=" + bar);
337 mBar = bar;
Joe Onorato75199e32010-05-29 17:22:51 -0400338 synchronized (mIcons) {
339 iconList.copyFrom(mIcons);
340 }
341 synchronized (mNotifications) {
342 for (Map.Entry<IBinder,StatusBarNotification> e: mNotifications.entrySet()) {
343 notificationKeys.add(e.getKey());
344 notifications.add(e.getValue());
345 }
346 }
Joe Onorato93056472010-09-10 10:30:46 -0400347 synchronized (mLock) {
Joe Onoratoe4c7b3f2010-10-30 12:15:03 -0700348 switches[0] = gatherDisableActionsLocked();
349 switches[1] = mLightsOn ? 1 : 0;
350 switches[2] = mMenuVisible ? 1 : 0;
351 switches[3] = mIMEButtonVisible ? 1 : 0;
satokcd7cd292010-11-20 15:46:23 +0900352 binders.add(mIMEToken);
Joe Onorato93056472010-09-10 10:30:46 -0400353 }
Joe Onorato2314aab2010-04-08 16:41:23 -0500354 }
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400355
Joe Onorato4762c2d2010-05-17 15:42:59 -0700356 /**
Joe Onoratof1f25912010-06-07 11:52:41 -0700357 * The status bar service should call this each time the user brings the panel from
358 * invisible to visible in order to clear the notification light.
Joe Onorato4762c2d2010-05-17 15:42:59 -0700359 */
Joe Onoratof1f25912010-06-07 11:52:41 -0700360 public void onPanelRevealed() {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400361 enforceStatusBarService();
362
Joe Onoratof1f25912010-06-07 11:52:41 -0700363 // tell the notification manager to turn off the lights.
364 mNotificationCallbacks.onPanelRevealed();
Joe Onorato4762c2d2010-05-17 15:42:59 -0700365 }
366
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400367 public void onNotificationClick(String pkg, String tag, int id) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400368 enforceStatusBarService();
369
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400370 mNotificationCallbacks.onNotificationClick(pkg, tag, id);
371 }
372
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -0700373 public void onNotificationError(String pkg, String tag, int id,
374 int uid, int initialPid, String message) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400375 enforceStatusBarService();
376
Joe Onorato005847b2010-06-04 16:08:02 -0400377 // WARNING: this will call back into us to do the remove. Don't hold any locks.
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -0700378 mNotificationCallbacks.onNotificationError(pkg, tag, id, uid, initialPid, message);
Joe Onorato005847b2010-06-04 16:08:02 -0400379 }
380
Daniel Sandler0f0b11c2010-08-04 15:54:58 -0400381 public void onNotificationClear(String pkg, String tag, int id) {
382 enforceStatusBarService();
383
384 mNotificationCallbacks.onNotificationClear(pkg, tag, id);
385 }
386
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400387 public void onClearAllNotifications() {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400388 enforceStatusBarService();
389
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400390 mNotificationCallbacks.onClearAll();
391 }
392
Joe Onorato18e69df2010-05-17 22:26:12 -0700393 // ================================================================================
394 // Callbacks for NotificationManagerService.
395 // ================================================================================
396 public IBinder addNotification(StatusBarNotification notification) {
397 synchronized (mNotifications) {
Joe Onoratoa0c56fe2010-05-20 10:21:52 -0700398 IBinder key = new Binder();
Joe Onorato75199e32010-05-29 17:22:51 -0400399 mNotifications.put(key, notification);
Joe Onoratoe345fff2010-05-23 15:18:27 -0400400 if (mBar != null) {
401 try {
402 mBar.addNotification(key, notification);
403 } catch (RemoteException ex) {
404 }
405 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700406 return key;
407 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700408 }
409
Joe Onorato18e69df2010-05-17 22:26:12 -0700410 public void updateNotification(IBinder key, StatusBarNotification notification) {
411 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400412 if (!mNotifications.containsKey(key)) {
413 throw new IllegalArgumentException("updateNotification key not found: " + key);
414 }
415 mNotifications.put(key, notification);
Joe Onoratoe345fff2010-05-23 15:18:27 -0400416 if (mBar != null) {
417 try {
418 mBar.updateNotification(key, notification);
419 } catch (RemoteException ex) {
420 }
421 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700422 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700423 }
424
425 public void removeNotification(IBinder key) {
Joe Onorato18e69df2010-05-17 22:26:12 -0700426 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400427 final StatusBarNotification n = mNotifications.remove(key);
428 if (n == null) {
429 throw new IllegalArgumentException("removeNotification key not found: " + key);
430 }
Joe Onoratoe345fff2010-05-23 15:18:27 -0400431 if (mBar != null) {
432 try {
433 mBar.removeNotification(key);
434 } catch (RemoteException ex) {
435 }
436 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700437 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700438 }
Joe Onorato2314aab2010-04-08 16:41:23 -0500439
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800440 // ================================================================================
441 // Can be called from any thread
442 // ================================================================================
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800443
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800444 // lock on mDisableRecords
445 void manageDisableListLocked(int what, IBinder token, String pkg) {
446 if (SPEW) {
Joe Onoratof3f0e052010-05-14 18:49:29 -0700447 Slog.d(TAG, "manageDisableList what=0x" + Integer.toHexString(what) + " pkg=" + pkg);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800448 }
449 // update the list
450 synchronized (mDisableRecords) {
451 final int N = mDisableRecords.size();
452 DisableRecord tok = null;
453 int i;
454 for (i=0; i<N; i++) {
455 DisableRecord t = mDisableRecords.get(i);
456 if (t.token == token) {
457 tok = t;
458 break;
459 }
460 }
461 if (what == 0 || !token.isBinderAlive()) {
462 if (tok != null) {
463 mDisableRecords.remove(i);
Suchi Amalapurapufff2fda2009-06-30 21:36:16 -0700464 tok.token.unlinkToDeath(tok, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800465 }
466 } else {
467 if (tok == null) {
468 tok = new DisableRecord();
469 try {
470 token.linkToDeath(tok, 0);
471 }
472 catch (RemoteException ex) {
473 return; // give up
474 }
475 mDisableRecords.add(tok);
476 }
477 tok.what = what;
478 tok.token = token;
479 tok.pkg = pkg;
480 }
481 }
482 }
483
484 // lock on mDisableRecords
485 int gatherDisableActionsLocked() {
486 final int N = mDisableRecords.size();
487 // gather the new net flags
488 int net = 0;
489 for (int i=0; i<N; i++) {
490 net |= mDisableRecords.get(i).what;
491 }
492 return net;
493 }
494
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800495 // ================================================================================
496 // Always called from UI thread
497 // ================================================================================
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800498
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800499 protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
500 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
501 != PackageManager.PERMISSION_GRANTED) {
502 pw.println("Permission Denial: can't dump StatusBar from from pid="
503 + Binder.getCallingPid()
504 + ", uid=" + Binder.getCallingUid());
505 return;
506 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700507
Joe Onorato0cbda992010-05-02 16:28:15 -0700508 synchronized (mIcons) {
509 mIcons.dump(pw);
510 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700511
512 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400513 int i=0;
514 pw.println("Notification list:");
515 for (Map.Entry<IBinder,StatusBarNotification> e: mNotifications.entrySet()) {
516 pw.printf(" %2d: %s\n", i, e.getValue().toString());
517 i++;
518 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800519 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700520
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800521 synchronized (mDisableRecords) {
522 final int N = mDisableRecords.size();
523 pw.println(" mDisableRecords.size=" + N
524 + " mDisabled=0x" + Integer.toHexString(mDisabled));
525 for (int i=0; i<N; i++) {
526 DisableRecord tok = mDisableRecords.get(i);
527 pw.println(" [" + i + "] what=0x" + Integer.toHexString(tok.what)
528 + " pkg=" + tok.pkg + " token=" + tok.token);
529 }
530 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800531 }
532
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800533 private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
534 public void onReceive(Context context, Intent intent) {
535 String action = intent.getAction();
Joe Onoratof9e0e6b2009-09-08 16:24:36 -0400536 if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)
537 || Intent.ACTION_SCREEN_OFF.equals(action)) {
Joe Onoratof3f0e052010-05-14 18:49:29 -0700538 collapse();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800539 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700540 /*
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800541 else if (Telephony.Intents.SPN_STRINGS_UPDATED_ACTION.equals(action)) {
542 updateNetworkName(intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_SPN, false),
543 intent.getStringExtra(Telephony.Intents.EXTRA_SPN),
544 intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_PLMN, false),
545 intent.getStringExtra(Telephony.Intents.EXTRA_PLMN));
546 }
547 else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
548 updateResources();
549 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700550 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800551 }
552 };
553
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800554}