Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -21238,6 +21238,7 @@ package android.service.notification { ctor public NotificationListenerService(); method public final void clearAllNotifications(); method public final void clearNotification(java.lang.String, java.lang.String, int); method public android.service.notification.StatusBarNotification[] getActiveNotifications(); method public android.os.IBinder onBind(android.content.Intent); method public abstract void onNotificationPosted(android.service.notification.StatusBarNotification); method public abstract void onNotificationRemoved(android.service.notification.StatusBarNotification); core/java/android/app/INotificationManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -46,4 +46,6 @@ interface INotificationManager void clearNotificationFromListener(in INotificationListener token, String pkg, String tag, int id); void clearAllNotificationsFromListener(in INotificationListener token); StatusBarNotification[] getActiveNotificationsFromListener(in INotificationListener token); } No newline at end of file core/java/android/service/notification/NotificationListenerService.java +15 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,21 @@ public abstract class NotificationListenerService extends Service { } } /** * Request the list of outstanding notifications (that is, those that are visible to the * current user). Useful when starting up and you don't know what's already been posted. * * @return An array of active notifications. */ public StatusBarNotification[] getActiveNotifications() { try { return getNotificationInterface().getActiveNotificationsFromListener(mWrapper); } catch (android.os.RemoteException ex) { Log.v(TAG, "Unable to contact notification manager", ex); } return null; } @Override public IBinder onBind(Intent intent) { if (mWrapper == null) { Loading services/java/com/android/server/NotificationManagerService.java +24 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -21238,6 +21238,7 @@ package android.service.notification { ctor public NotificationListenerService(); method public final void clearAllNotifications(); method public final void clearNotification(java.lang.String, java.lang.String, int); method public android.service.notification.StatusBarNotification[] getActiveNotifications(); method public android.os.IBinder onBind(android.content.Intent); method public abstract void onNotificationPosted(android.service.notification.StatusBarNotification); method public abstract void onNotificationRemoved(android.service.notification.StatusBarNotification);
core/java/android/app/INotificationManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -46,4 +46,6 @@ interface INotificationManager void clearNotificationFromListener(in INotificationListener token, String pkg, String tag, int id); void clearAllNotificationsFromListener(in INotificationListener token); StatusBarNotification[] getActiveNotificationsFromListener(in INotificationListener token); } No newline at end of file
core/java/android/service/notification/NotificationListenerService.java +15 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,21 @@ public abstract class NotificationListenerService extends Service { } } /** * Request the list of outstanding notifications (that is, those that are visible to the * current user). Useful when starting up and you don't know what's already been posted. * * @return An array of active notifications. */ public StatusBarNotification[] getActiveNotifications() { try { return getNotificationInterface().getActiveNotificationsFromListener(mWrapper); } catch (android.os.RemoteException ex) { Log.v(TAG, "Unable to contact notification manager", ex); } return null; } @Override public IBinder onBind(Intent intent) { if (mWrapper == null) { Loading
services/java/com/android/server/NotificationManagerService.java +24 −0 Original line number Diff line number Diff line Loading @@ -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 Loading