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 String
addActiveNotification(StatusBarNotification statusBarNotification)
Adds the givenStatusBarNotification
to the list of active Notifications.String
addActiveNotification(String packageName, int id, Notification notification)
Adds the givenNotification
to the list of active Notifications.protected void
cancelAllNotifications()
protected void
cancelNotification(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 int
getCurrentInterruptionFilter()
protected int
getCurrentListenerHints()
protected NotificationListenerService.RankingMap
getCurrentRanking()
static int
getRebindRequestCount()
Returns the number of times rebind was requested.int
getUnbindRequestCount()
Returns the number of times unbind was requested.protected void
requestInterruptionFilter(int interruptionFilter)
protected void
requestListenerHints(int hint)
protected static void
requestRebind(ComponentName componentName)
protected void
requestUnbind()
static void
reset()
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 givenNotification
to the list of active Notifications. A correspondingStatusBarNotification
will 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 givenStatusBarNotification
to the list of active Notifications. The givenStatusBarNotification
will 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.
-
-