Loading core/java/android/service/notification/NotificationListenerService.java +11 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ public abstract class NotificationListenerService extends Service { * {@link android.app.NotificationManager#notify(String, int, android.app.Notification)}. */ public final void cancelNotification(String pkg, String tag, int id) { if (!isBound()) return; try { getNotificationInterface().cancelNotificationFromListener(mWrapper, pkg, tag, id); } catch (android.os.RemoteException ex) { Loading @@ -131,6 +132,7 @@ public abstract class NotificationListenerService extends Service { * {@see #cancelNotification(String, String, int)} */ public final void cancelAllNotifications() { if (!isBound()) return; try { getNotificationInterface().cancelAllNotificationsFromListener(mWrapper); } catch (android.os.RemoteException ex) { Loading @@ -145,6 +147,7 @@ public abstract class NotificationListenerService extends Service { * @return An array of active notifications. */ public StatusBarNotification[] getActiveNotifications() { if (!isBound()) return null; try { return getNotificationInterface().getActiveNotificationsFromListener(mWrapper); } catch (android.os.RemoteException ex) { Loading @@ -161,6 +164,14 @@ public abstract class NotificationListenerService extends Service { return mWrapper; } private boolean isBound() { if (mWrapper == null) { Log.w(TAG, "Notification listener service not yet bound."); return false; } return true; } private class INotificationListenerWrapper extends INotificationListener.Stub { @Override public void onNotificationPosted(StatusBarNotification sbn) { Loading services/core/java/com/android/server/notification/NotificationManagerService.java +9 −0 Original line number Diff line number Diff line Loading @@ -725,7 +725,14 @@ public class NotificationManagerService extends SystemService { // -- APIs to support listeners clicking/clearing notifications -- private void checkNullListener(INotificationListener listener) { if (listener == null) { throw new IllegalArgumentException("Listener must not be null"); } } private NotificationListenerInfo checkListenerToken(INotificationListener listener) { checkNullListener(listener); final IBinder token = listener.asBinder(); final int N = mListeners.size(); for (int i=0; i<N; i++) { Loading Loading @@ -1469,6 +1476,7 @@ public class NotificationManagerService extends SystemService { public void registerListener(final INotificationListener listener, final ComponentName component, final int userid) { checkCallerIsSystem(); checkNullListener(listener); registerListenerImpl(listener, component, userid); } Loading @@ -1477,6 +1485,7 @@ public class NotificationManagerService extends SystemService { */ @Override public void unregisterListener(INotificationListener listener, int userid) { checkNullListener(listener); // no need to check permissions; if your listener binder is in the list, // that's proof that you had permission to add it in the first place unregisterListenerImpl(listener, userid); Loading Loading
core/java/android/service/notification/NotificationListenerService.java +11 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ public abstract class NotificationListenerService extends Service { * {@link android.app.NotificationManager#notify(String, int, android.app.Notification)}. */ public final void cancelNotification(String pkg, String tag, int id) { if (!isBound()) return; try { getNotificationInterface().cancelNotificationFromListener(mWrapper, pkg, tag, id); } catch (android.os.RemoteException ex) { Loading @@ -131,6 +132,7 @@ public abstract class NotificationListenerService extends Service { * {@see #cancelNotification(String, String, int)} */ public final void cancelAllNotifications() { if (!isBound()) return; try { getNotificationInterface().cancelAllNotificationsFromListener(mWrapper); } catch (android.os.RemoteException ex) { Loading @@ -145,6 +147,7 @@ public abstract class NotificationListenerService extends Service { * @return An array of active notifications. */ public StatusBarNotification[] getActiveNotifications() { if (!isBound()) return null; try { return getNotificationInterface().getActiveNotificationsFromListener(mWrapper); } catch (android.os.RemoteException ex) { Loading @@ -161,6 +164,14 @@ public abstract class NotificationListenerService extends Service { return mWrapper; } private boolean isBound() { if (mWrapper == null) { Log.w(TAG, "Notification listener service not yet bound."); return false; } return true; } private class INotificationListenerWrapper extends INotificationListener.Stub { @Override public void onNotificationPosted(StatusBarNotification sbn) { Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +9 −0 Original line number Diff line number Diff line Loading @@ -725,7 +725,14 @@ public class NotificationManagerService extends SystemService { // -- APIs to support listeners clicking/clearing notifications -- private void checkNullListener(INotificationListener listener) { if (listener == null) { throw new IllegalArgumentException("Listener must not be null"); } } private NotificationListenerInfo checkListenerToken(INotificationListener listener) { checkNullListener(listener); final IBinder token = listener.asBinder(); final int N = mListeners.size(); for (int i=0; i<N; i++) { Loading Loading @@ -1469,6 +1476,7 @@ public class NotificationManagerService extends SystemService { public void registerListener(final INotificationListener listener, final ComponentName component, final int userid) { checkCallerIsSystem(); checkNullListener(listener); registerListenerImpl(listener, component, userid); } Loading @@ -1477,6 +1485,7 @@ public class NotificationManagerService extends SystemService { */ @Override public void unregisterListener(INotificationListener listener, int userid) { checkNullListener(listener); // no need to check permissions; if your listener binder is in the list, // that's proof that you had permission to add it in the first place unregisterListenerImpl(listener, userid); Loading