summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/NotificationManagerService.java
diff options
context:
space:
mode:
authorDaniel Sandler <dsandler@android.com>2013-04-24 15:34:57 -0400
committerDaniel Sandler <dsandler@android.com>2013-04-24 23:19:08 -0400
commit25cf8cee6f304a286d321204e448b18ce733a60c (patch)
tree07f36464efefd2890fd42ee7b7a8fb2303abb009 /services/java/com/android/server/NotificationManagerService.java
parent7395838d8e45cf39c34d2f2e18da2bedd3e4dc33 (diff)
New NotificationListener API: getActiveNotifications()
This allows a listener service to catch up on the current state of the notification panel at any time, including at startup. Bug: 8656860 Change-Id: I1a3d665d84576e17870929a63dda334afc696010
Diffstat (limited to 'services/java/com/android/server/NotificationManagerService.java')
-rw-r--r--services/java/com/android/server/NotificationManagerService.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index f0257ffe276d..6cac22736ffd 100644
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -816,6 +816,30 @@ public class NotificationManagerService extends INotificationManager.Stub
}
}
+ /**
+ * Allow an INotificationListener to request the list of outstanding notifications seen by
+ * the current user. Useful when starting up, after which point the listener callbacks should
+ * be used.
+ *
+ * @param token The binder for the listener, to check that the caller is allowed
+ */
+ public StatusBarNotification[] getActiveNotificationsFromListener(INotificationListener token) {
+ NotificationListenerInfo info = checkListenerToken(token);
+
+ StatusBarNotification[] result = new StatusBarNotification[0];
+ ArrayList<StatusBarNotification> list = new ArrayList<StatusBarNotification>();
+ synchronized (mNotificationList) {
+ final int N = mNotificationList.size();
+ for (int i=0; i<N; i++) {
+ StatusBarNotification sbn = mNotificationList.get(i).sbn;
+ if (info.enabledAndUserMatches(sbn)) {
+ list.add(sbn);
+ }
+ }
+ }
+ return list.toArray(result);
+ }
+
// -- end of listener APIs --
public static final class NotificationRecord