Package org.robolectric.shadows
Class ShadowNotificationListenerService
- java.lang.Object
-
- org.robolectric.shadows.ShadowContextWrapper
-
- org.robolectric.shadows.ShadowService
-
- org.robolectric.shadows.ShadowNotificationListenerService
-
@Implements(value=android.service.notification.NotificationListenerService.class, minSdk=21) public class ShadowNotificationListenerService extends ShadowService
Shadow implementation ofNotificationListenerService.
-
-
Constructor Summary
Constructors Constructor Description ShadowNotificationListenerService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringaddActiveNotification(StatusBarNotification statusBarNotification)Adds the givenStatusBarNotificationto the list of active Notifications.StringaddActiveNotification(String packageName, int id, Notification notification)Adds the givenNotificationto the list of active Notifications.protected voidcancelAllNotifications()protected voidcancelNotification(String key)protected StatusBarNotification[]getActiveNotifications(String[] keys, int trim)Returns zero or more notifications, added byaddActiveNotification(java.lang.String, int, android.app.Notification), that match one of the provided keys.protected intgetCurrentInterruptionFilter()protected intgetCurrentListenerHints()protected NotificationListenerService.RankingMapgetCurrentRanking()static intgetRebindRequestCount()Returns the number of times rebind was requested.intgetUnbindRequestCount()Returns the number of times unbind was requested.protected voidrequestInterruptionFilter(int interruptionFilter)protected voidrequestListenerHints(int hint)protected static voidrequestRebind(ComponentName componentName)protected voidrequestUnbind()static voidreset()Resets this shadow instance.-
Methods inherited from class org.robolectric.shadows.ShadowService
getForegroundServiceType, getLastForegroundNotification, getLastForegroundNotificationId, getNotificationShouldRemoved, getStopSelfId, getStopSelfResultId, isForegroundStopped, isLastForegroundNotificationAttached, isStoppedBySelf, onDestroy, startForeground, startForeground, stopForeground, stopForeground, stopSelf, stopSelf, stopSelfResult
-
Methods inherited from class org.robolectric.shadows.ShadowContextWrapper
clearBroadcastIntents, clearNextStartedActivities, clearStartedServices, denyPermissions, denyPermissions, getAllStartedServices, getBroadcastIntents, getBroadcastIntentsForUser, getBroadcastOptions, getNextStartedActivity, getNextStartedActivityForResult, getNextStartedService, getNextStoppedService, grantPermissions, grantPermissions, peekNextStartedActivity, peekNextStartedActivityForResult, peekNextStartedService, removeSystemService
-
-
-
-
Method Detail
-
addActiveNotification
public String addActiveNotification(String packageName, int id, Notification notification)
Adds the givenNotificationto the list of active Notifications. A correspondingStatusBarNotificationwill be generated from this Notification, which will be included in the result ofNotificationListenerService.getActiveNotifications().- Returns:
- the key of the generated
StatusBarNotification
-
addActiveNotification
public String addActiveNotification(StatusBarNotification statusBarNotification)
Adds the givenStatusBarNotificationto the list of active Notifications. The givenStatusBarNotificationwill be included in the result ofNotificationListenerService.getActiveNotifications().- Returns:
- the key of the given
StatusBarNotification
-
requestRebind
@Implementation(minSdk=24) protected static void requestRebind(ComponentName componentName)
-
requestUnbind
@Implementation(minSdk=24) protected void requestUnbind()
-
cancelAllNotifications
@Implementation protected final void cancelAllNotifications()
-
cancelNotification
@Implementation protected final void cancelNotification(String key)
-
getActiveNotifications
@Implementation protected StatusBarNotification[] getActiveNotifications(String[] keys, int trim)
Returns zero or more notifications, added byaddActiveNotification(java.lang.String, int, android.app.Notification), that match one of the provided keys.- Parameters:
keys- the keys to matchtrim- ignored, trimming is not supported
-
requestInterruptionFilter
@Implementation protected void requestInterruptionFilter(int interruptionFilter)
-
getCurrentInterruptionFilter
@Implementation protected int getCurrentInterruptionFilter()
-
requestListenerHints
@Implementation protected void requestListenerHints(int hint)
-
getCurrentListenerHints
@Implementation protected int getCurrentListenerHints()
-
getCurrentRanking
@Implementation protected NotificationListenerService.RankingMap getCurrentRanking()
-
getRebindRequestCount
public static int getRebindRequestCount()
Returns the number of times rebind was requested.
-
getUnbindRequestCount
public int getUnbindRequestCount()
Returns the number of times unbind was requested.
-
reset
@Resetter public static void reset()
Resets this shadow instance.
-
-