blob: 66e021463f4c71bdb3399b8bd1732723e9edba3a [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 Onoratof3f0e052010-05-14 18:49:29 -070057 static final boolean SPEW = true;
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;
74
Daniel Sandlere02d8082010-10-08 15:13:22 -040075 boolean mMenuVisible = 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 // ================================================================================
114 // Constructing the view
115 // ================================================================================
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800116
117 public void systemReady() {
Joe Onorato2314aab2010-04-08 16:41:23 -0500118 }
119
120 public void systemReady2() {
Joe Onorato9e875fc2010-06-07 11:12:11 -0700121 ComponentName cn = ComponentName.unflattenFromString(
122 mContext.getString(com.android.internal.R.string.config_statusBarComponent));
123 Intent intent = new Intent();
124 intent.setComponent(cn);
125 Slog.i(TAG, "Starting service: " + cn);
126 mContext.startService(intent);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800127 }
Joe Onorato4762c2d2010-05-17 15:42:59 -0700128
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800129 // ================================================================================
Joe Onorato25f95f92010-04-08 18:37:10 -0500130 // From IStatusBarService
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800131 // ================================================================================
Joe Onoratof3f0e052010-05-14 18:49:29 -0700132 public void expand() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800133 enforceExpandStatusBar();
Joe Onorato4762c2d2010-05-17 15:42:59 -0700134
135 if (mBar != null) {
136 try {
137 mBar.animateExpand();
138 } catch (RemoteException ex) {
139 }
140 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800141 }
142
Joe Onoratof3f0e052010-05-14 18:49:29 -0700143 public void collapse() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800144 enforceExpandStatusBar();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800145
Joe Onorato4762c2d2010-05-17 15:42:59 -0700146 if (mBar != null) {
147 try {
148 mBar.animateCollapse();
149 } catch (RemoteException ex) {
150 }
151 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800152 }
153
154 public void disable(int what, IBinder token, String pkg) {
155 enforceStatusBar();
Joe Onoratof3f0e052010-05-14 18:49:29 -0700156
157 // It's important that the the callback and the call to mBar get done
158 // in the same order when multiple threads are calling this function
159 // so they are paired correctly. The messages on the handler will be
160 // handled in the order they were enqueued, but will be outside the lock.
161 synchronized (mDisableRecords) {
162 manageDisableListLocked(what, token, pkg);
163 final int net = gatherDisableActionsLocked();
164 Slog.d(TAG, "disable... net=0x" + Integer.toHexString(net));
165 if (net != mDisabled) {
166 mDisabled = net;
167 mHandler.post(new Runnable() {
168 public void run() {
169 mNotificationCallbacks.onSetDisabled(net);
170 }
171 });
172 if (mBar != null) {
173 try {
174 mBar.disable(net);
175 } catch (RemoteException ex) {
176 }
177 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800178 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800179 }
180 }
181
Joe Onorato0cbda992010-05-02 16:28:15 -0700182 public void setIcon(String slot, String iconPackage, int iconId, int iconLevel) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800183 enforceStatusBar();
Joe Onorato0cbda992010-05-02 16:28:15 -0700184
185 synchronized (mIcons) {
186 int index = mIcons.getSlotIndex(slot);
187 if (index < 0) {
188 throw new SecurityException("invalid status bar icon slot: " + slot);
189 }
190
191 StatusBarIcon icon = new StatusBarIcon(iconPackage, iconId, iconLevel);
Joe Onorato66d7d012010-05-14 10:05:10 -0700192 //Slog.d(TAG, "setIcon slot=" + slot + " index=" + index + " icon=" + icon);
Joe Onorato0cbda992010-05-02 16:28:15 -0700193 mIcons.setIcon(index, icon);
194
Joe Onorato0cbda992010-05-02 16:28:15 -0700195 if (mBar != null) {
196 try {
197 mBar.setIcon(index, icon);
198 } catch (RemoteException ex) {
199 }
200 }
201 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800202 }
203
Joe Onorato0cbda992010-05-02 16:28:15 -0700204 public void setIconVisibility(String slot, boolean visible) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800205 enforceStatusBar();
Joe Onorato0cbda992010-05-02 16:28:15 -0700206
Joe Onorato514ad6632010-05-13 18:49:00 -0700207 synchronized (mIcons) {
208 int index = mIcons.getSlotIndex(slot);
209 if (index < 0) {
210 throw new SecurityException("invalid status bar icon slot: " + slot);
211 }
212
213 StatusBarIcon icon = mIcons.getIcon(index);
214 if (icon == null) {
215 return;
216 }
217
218 if (icon.visible != visible) {
219 icon.visible = visible;
220
Joe Onorato514ad6632010-05-13 18:49:00 -0700221 if (mBar != null) {
222 try {
223 mBar.setIcon(index, icon);
224 } catch (RemoteException ex) {
225 }
226 }
227 }
228 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700229 }
230
231 public void removeIcon(String slot) {
232 enforceStatusBar();
233
234 synchronized (mIcons) {
235 int index = mIcons.getSlotIndex(slot);
236 if (index < 0) {
237 throw new SecurityException("invalid status bar icon slot: " + slot);
238 }
239
240 mIcons.removeIcon(index);
241
Joe Onorato0cbda992010-05-02 16:28:15 -0700242 if (mBar != null) {
243 try {
244 mBar.removeIcon(index);
245 } catch (RemoteException ex) {
246 }
247 }
248 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800249 }
250
Daniel Sandlere02d8082010-10-08 15:13:22 -0400251 /**
252 * Hide or show the on-screen Menu key. Only call this from the window manager, typically in
253 * response to a window with FLAG_NEEDS_MENU_KEY set.
254 */
255 public void setMenuKeyVisible(final boolean visible) {
256 enforceStatusBar();
257
258 if (SPEW) Slog.d(TAG, (visible?"showing":"hiding") + " MENU key");
259
260 synchronized(mLock) {
261 if (mMenuVisible != visible) {
262 mMenuVisible = visible;
263 mHandler.post(new Runnable() {
264 public void run() {
265 if (mBar != null) {
266 try {
267 mBar.setMenuKeyVisible(visible);
268 } catch (RemoteException ex) {
269 }
270 }
271 }
272 });
273 }
274 }
275 }
276
Joe Onoratof63b0f42010-09-12 17:03:19 -0400277 /**
278 * This is used for the automatic version of lights-out mode. Only call this from
279 * the window manager.
280 *
281 * @see setLightsOn(boolean)
282 */
Joe Onorato93056472010-09-10 10:30:46 -0400283 public void setActiveWindowIsFullscreen(boolean fullscreen) {
284 // We could get away with a separate permission here, but STATUS_BAR is
285 // signatureOrSystem which is probably good enough. There is no public API
286 // for this, so the question is a security issue, not an API compatibility issue.
287 enforceStatusBar();
288
Joe Onorato93056472010-09-10 10:30:46 -0400289 synchronized (mLock) {
Joe Onoratof63b0f42010-09-12 17:03:19 -0400290 updateLightsOnLocked(!fullscreen);
291 }
292 }
293
294 /**
295 * This is used for the user-controlled version of lights-out mode. Only call this from
296 * the status bar itself.
297 *
298 * We have two different functions here, because I think we're going to want to
299 * tweak the behavior when the user keeps turning lights-out mode off and the
300 * app keeps trying to turn it on. For now they can just fight it out. Having
301 * these two separte inputs will allow us to keep that change local to here. --joeo
302 */
303 public void setLightsOn(boolean lightsOn) {
304 enforceStatusBarService();
305
306 synchronized (mLock) {
307 updateLightsOnLocked(lightsOn);
308 }
309 }
310
311 private void updateLightsOnLocked(final boolean lightsOn) {
312 if (mLightsOn != lightsOn) {
313 mLightsOn = lightsOn;
314 mHandler.post(new Runnable() {
315 public void run() {
316 if (mBar != null) {
317 try {
318 mBar.setLightsOn(lightsOn);
319 } catch (RemoteException ex) {
Joe Onorato93056472010-09-10 10:30:46 -0400320 }
321 }
Joe Onoratof63b0f42010-09-12 17:03:19 -0400322 }
323 });
Joe Onorato93056472010-09-10 10:30:46 -0400324 }
325 }
326
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800327 private void enforceStatusBar() {
Joe Onorato0cbda992010-05-02 16:28:15 -0700328 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR,
Joe Onorato089de882010-04-12 08:18:45 -0700329 "StatusBarManagerService");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800330 }
331
332 private void enforceExpandStatusBar() {
Joe Onorato0cbda992010-05-02 16:28:15 -0700333 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.EXPAND_STATUS_BAR,
Joe Onorato089de882010-04-12 08:18:45 -0700334 "StatusBarManagerService");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800335 }
336
Joe Onorato8bc6c512010-06-04 16:21:12 -0400337 private void enforceStatusBarService() {
338 mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR_SERVICE,
339 "StatusBarManagerService");
340 }
341
Joe Onorato4762c2d2010-05-17 15:42:59 -0700342
343 // ================================================================================
344 // Callbacks from the status bar service.
345 // ================================================================================
Joe Onorato75199e32010-05-29 17:22:51 -0400346 public void registerStatusBar(IStatusBar bar, StatusBarIconList iconList,
Joe Onorato93056472010-09-10 10:30:46 -0400347 List<IBinder> notificationKeys, List<StatusBarNotification> notifications,
Daniel Sandlere02d8082010-10-08 15:13:22 -0400348 boolean switches[]) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400349 enforceStatusBarService();
350
Joe Onorato0cbda992010-05-02 16:28:15 -0700351 Slog.i(TAG, "registerStatusBar bar=" + bar);
352 mBar = bar;
Joe Onorato75199e32010-05-29 17:22:51 -0400353 synchronized (mIcons) {
354 iconList.copyFrom(mIcons);
355 }
356 synchronized (mNotifications) {
357 for (Map.Entry<IBinder,StatusBarNotification> e: mNotifications.entrySet()) {
358 notificationKeys.add(e.getKey());
359 notifications.add(e.getValue());
360 }
361 }
Joe Onorato93056472010-09-10 10:30:46 -0400362 synchronized (mLock) {
Daniel Sandlere02d8082010-10-08 15:13:22 -0400363 switches[0] = mLightsOn;
364 switches[1] = mMenuVisible;
Joe Onorato93056472010-09-10 10:30:46 -0400365 }
Joe Onorato2314aab2010-04-08 16:41:23 -0500366 }
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400367
Joe Onorato4762c2d2010-05-17 15:42:59 -0700368 /**
Joe Onoratof1f25912010-06-07 11:52:41 -0700369 * The status bar service should call this each time the user brings the panel from
370 * invisible to visible in order to clear the notification light.
Joe Onorato4762c2d2010-05-17 15:42:59 -0700371 */
Joe Onoratof1f25912010-06-07 11:52:41 -0700372 public void onPanelRevealed() {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400373 enforceStatusBarService();
374
Joe Onoratof1f25912010-06-07 11:52:41 -0700375 // tell the notification manager to turn off the lights.
376 mNotificationCallbacks.onPanelRevealed();
Joe Onorato4762c2d2010-05-17 15:42:59 -0700377 }
378
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400379 public void onNotificationClick(String pkg, String tag, int id) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400380 enforceStatusBarService();
381
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400382 mNotificationCallbacks.onNotificationClick(pkg, tag, id);
383 }
384
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -0700385 public void onNotificationError(String pkg, String tag, int id,
386 int uid, int initialPid, String message) {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400387 enforceStatusBarService();
388
Joe Onorato005847b2010-06-04 16:08:02 -0400389 // WARNING: this will call back into us to do the remove. Don't hold any locks.
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -0700390 mNotificationCallbacks.onNotificationError(pkg, tag, id, uid, initialPid, message);
Joe Onorato005847b2010-06-04 16:08:02 -0400391 }
392
Daniel Sandler0f0b11c2010-08-04 15:54:58 -0400393 public void onNotificationClear(String pkg, String tag, int id) {
394 enforceStatusBarService();
395
396 mNotificationCallbacks.onNotificationClear(pkg, tag, id);
397 }
398
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400399 public void onClearAllNotifications() {
Joe Onorato8bc6c512010-06-04 16:21:12 -0400400 enforceStatusBarService();
401
Joe Onoratoaaba60b2010-05-23 15:18:41 -0400402 mNotificationCallbacks.onClearAll();
403 }
404
Joe Onorato18e69df2010-05-17 22:26:12 -0700405 // ================================================================================
406 // Callbacks for NotificationManagerService.
407 // ================================================================================
408 public IBinder addNotification(StatusBarNotification notification) {
409 synchronized (mNotifications) {
Joe Onoratoa0c56fe2010-05-20 10:21:52 -0700410 IBinder key = new Binder();
Joe Onorato75199e32010-05-29 17:22:51 -0400411 mNotifications.put(key, notification);
Joe Onoratoe345fff2010-05-23 15:18:27 -0400412 if (mBar != null) {
413 try {
414 mBar.addNotification(key, notification);
415 } catch (RemoteException ex) {
416 }
417 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700418 return key;
419 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700420 }
421
Joe Onorato18e69df2010-05-17 22:26:12 -0700422 public void updateNotification(IBinder key, StatusBarNotification notification) {
423 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400424 if (!mNotifications.containsKey(key)) {
425 throw new IllegalArgumentException("updateNotification key not found: " + key);
426 }
427 mNotifications.put(key, notification);
Joe Onoratoe345fff2010-05-23 15:18:27 -0400428 if (mBar != null) {
429 try {
430 mBar.updateNotification(key, notification);
431 } catch (RemoteException ex) {
432 }
433 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700434 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700435 }
436
437 public void removeNotification(IBinder key) {
Joe Onorato18e69df2010-05-17 22:26:12 -0700438 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400439 final StatusBarNotification n = mNotifications.remove(key);
440 if (n == null) {
441 throw new IllegalArgumentException("removeNotification key not found: " + key);
442 }
Joe Onoratoe345fff2010-05-23 15:18:27 -0400443 if (mBar != null) {
444 try {
445 mBar.removeNotification(key);
446 } catch (RemoteException ex) {
447 }
448 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700449 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700450 }
Joe Onorato2314aab2010-04-08 16:41:23 -0500451
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800452 // ================================================================================
453 // Can be called from any thread
454 // ================================================================================
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800455
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800456 // lock on mDisableRecords
457 void manageDisableListLocked(int what, IBinder token, String pkg) {
458 if (SPEW) {
Joe Onoratof3f0e052010-05-14 18:49:29 -0700459 Slog.d(TAG, "manageDisableList what=0x" + Integer.toHexString(what) + " pkg=" + pkg);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800460 }
461 // update the list
462 synchronized (mDisableRecords) {
463 final int N = mDisableRecords.size();
464 DisableRecord tok = null;
465 int i;
466 for (i=0; i<N; i++) {
467 DisableRecord t = mDisableRecords.get(i);
468 if (t.token == token) {
469 tok = t;
470 break;
471 }
472 }
473 if (what == 0 || !token.isBinderAlive()) {
474 if (tok != null) {
475 mDisableRecords.remove(i);
Suchi Amalapurapufff2fda2009-06-30 21:36:16 -0700476 tok.token.unlinkToDeath(tok, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800477 }
478 } else {
479 if (tok == null) {
480 tok = new DisableRecord();
481 try {
482 token.linkToDeath(tok, 0);
483 }
484 catch (RemoteException ex) {
485 return; // give up
486 }
487 mDisableRecords.add(tok);
488 }
489 tok.what = what;
490 tok.token = token;
491 tok.pkg = pkg;
492 }
493 }
494 }
495
496 // lock on mDisableRecords
497 int gatherDisableActionsLocked() {
498 final int N = mDisableRecords.size();
499 // gather the new net flags
500 int net = 0;
501 for (int i=0; i<N; i++) {
502 net |= mDisableRecords.get(i).what;
503 }
504 return net;
505 }
506
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800507 // ================================================================================
508 // Always called from UI thread
509 // ================================================================================
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800510
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800511 protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
512 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
513 != PackageManager.PERMISSION_GRANTED) {
514 pw.println("Permission Denial: can't dump StatusBar from from pid="
515 + Binder.getCallingPid()
516 + ", uid=" + Binder.getCallingUid());
517 return;
518 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700519
Joe Onorato0cbda992010-05-02 16:28:15 -0700520 synchronized (mIcons) {
521 mIcons.dump(pw);
522 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700523
524 synchronized (mNotifications) {
Joe Onorato75199e32010-05-29 17:22:51 -0400525 int i=0;
526 pw.println("Notification list:");
527 for (Map.Entry<IBinder,StatusBarNotification> e: mNotifications.entrySet()) {
528 pw.printf(" %2d: %s\n", i, e.getValue().toString());
529 i++;
530 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800531 }
Joe Onorato18e69df2010-05-17 22:26:12 -0700532
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800533 synchronized (mDisableRecords) {
534 final int N = mDisableRecords.size();
535 pw.println(" mDisableRecords.size=" + N
536 + " mDisabled=0x" + Integer.toHexString(mDisabled));
537 for (int i=0; i<N; i++) {
538 DisableRecord tok = mDisableRecords.get(i);
539 pw.println(" [" + i + "] what=0x" + Integer.toHexString(tok.what)
540 + " pkg=" + tok.pkg + " token=" + tok.token);
541 }
542 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800543 }
544
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800545 private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
546 public void onReceive(Context context, Intent intent) {
547 String action = intent.getAction();
Joe Onoratof9e0e6b2009-09-08 16:24:36 -0400548 if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)
549 || Intent.ACTION_SCREEN_OFF.equals(action)) {
Joe Onoratof3f0e052010-05-14 18:49:29 -0700550 collapse();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800551 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700552 /*
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800553 else if (Telephony.Intents.SPN_STRINGS_UPDATED_ACTION.equals(action)) {
554 updateNetworkName(intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_SPN, false),
555 intent.getStringExtra(Telephony.Intents.EXTRA_SPN),
556 intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_PLMN, false),
557 intent.getStringExtra(Telephony.Intents.EXTRA_PLMN));
558 }
559 else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
560 updateResources();
561 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700562 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800563 }
564 };
565
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800566}