Package org.robolectric.shadows
Class ShadowNotificationManager
- java.lang.Object
-
- org.robolectric.shadows.ShadowNotificationManager
-
@Implements(value=android.app.NotificationManager.class, looseSignatures=true) public class ShadowNotificationManager extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ShadowNotificationManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringaddAutomaticZenRule(android.app.AutomaticZenRule automaticZenRule)protected booleanareNotificationsEnabled()protected voidcancel(int id)protected voidcancel(java.lang.String tag, int id)protected voidcancelAll()protected booleancanNotifyAsPackage(java.lang.String pkg)protected voidcreateNotificationChannel(java.lang.Object channel)protected voidcreateNotificationChannelGroup(java.lang.Object group)protected voidcreateNotificationChannelGroups(java.util.List<java.lang.Object> groupList)protected voidcreateNotificationChannels(java.util.List<java.lang.Object> channelList)protected voiddeleteNotificationChannel(java.lang.String channelId)protected voiddeleteNotificationChannelGroup(java.lang.String channelGroupId)Delete a notification channel group and all notification channels associated with the group.android.service.notification.StatusBarNotification[]getActiveNotifications()java.util.List<android.app.Notification>getAllNotifications()protected android.app.AutomaticZenRulegetAutomaticZenRule(java.lang.String id)protected java.util.Map<java.lang.String,android.app.AutomaticZenRule>getAutomaticZenRules()protected intgetCurrentInterruptionFilter()android.app.NotificationgetNotification(int id)android.app.NotificationgetNotification(java.lang.String tag, int id)protected java.lang.ObjectgetNotificationChannel(java.lang.String channelId)java.lang.ObjectgetNotificationChannelGroup(java.lang.String id)protected java.util.List<java.lang.Object>getNotificationChannelGroups()java.util.List<java.lang.Object>getNotificationChannels()protected java.lang.StringgetNotificationDelegate()protected android.app.NotificationManager.PolicygetNotificationPolicy()booleanisChannelDeleted(java.lang.String channelId)Checks whether a channel is considered a "deleted" channel by Android.protected booleanisNotificationPolicyAccessGranted()protected voidnotify(int id, android.app.Notification notification)protected voidnotify(java.lang.String tag, int id, android.app.Notification notification)protected booleanremoveAutomaticZenRule(java.lang.String id)voidsetCanNotifyAsPackage(java.lang.String otherPackage, boolean canNotify)Sets notification delegate for the package provided.voidsetEnforceMaxNotificationLimit(boolean enforceMaxNotificationLimit)Ensures a notification limit is applied before posting the notification.protected voidsetInterruptionFilter(int interruptionFilter)Currently does not support checking for granted policy access.protected voidsetNotificationDelegate(java.lang.String delegate)protected voidsetNotificationPolicy(android.app.NotificationManager.Policy policy)Currently does not support checking for granted policy access.voidsetNotificationPolicyAccessGranted(boolean granted)Sets the value returned byNotificationManager.isNotificationPolicyAccessGranted().voidsetNotificationsEnabled(boolean areNotificationsEnabled)intsize()protected booleanupdateAutomaticZenRule(java.lang.String id, android.app.AutomaticZenRule automaticZenRule)
-
-
-
Method Detail
-
notify
@Implementation protected void notify(int id, android.app.Notification notification)
-
notify
@Implementation protected void notify(java.lang.String tag, int id, android.app.Notification notification)
-
cancel
@Implementation protected void cancel(int id)
-
cancel
@Implementation protected void cancel(java.lang.String tag, int id)
-
cancelAll
@Implementation protected void cancelAll()
-
areNotificationsEnabled
@Implementation(minSdk=24) protected boolean areNotificationsEnabled()
-
setNotificationsEnabled
public void setNotificationsEnabled(boolean areNotificationsEnabled)
-
getActiveNotifications
@Implementation(minSdk=23) public android.service.notification.StatusBarNotification[] getActiveNotifications()
-
getNotificationChannel
@Implementation(minSdk=26) protected java.lang.Object getNotificationChannel(java.lang.String channelId)
-
createNotificationChannelGroup
@Implementation(minSdk=26) protected void createNotificationChannelGroup(java.lang.Object group)
-
createNotificationChannelGroups
@Implementation(minSdk=26) protected void createNotificationChannelGroups(java.util.List<java.lang.Object> groupList)
-
getNotificationChannelGroups
@Implementation(minSdk=26) protected java.util.List<java.lang.Object> getNotificationChannelGroups()
-
createNotificationChannel
@Implementation(minSdk=26) protected void createNotificationChannel(java.lang.Object channel)
-
createNotificationChannels
@Implementation(minSdk=26) protected void createNotificationChannels(java.util.List<java.lang.Object> channelList)
-
getNotificationChannels
@Implementation(minSdk=26) public java.util.List<java.lang.Object> getNotificationChannels()
-
deleteNotificationChannel
@Implementation(minSdk=26) protected void deleteNotificationChannel(java.lang.String channelId)
-
deleteNotificationChannelGroup
@Implementation(minSdk=26) protected void deleteNotificationChannelGroup(java.lang.String channelGroupId)
Delete a notification channel group and all notification channels associated with the group. This method will not notify any NotificationListenerService of resulting changes to notification channel groups nor to notification channels.
-
getCurrentInterruptionFilter
@Implementation(minSdk=23) protected final int getCurrentInterruptionFilter()
- Returns:
NotificationManager.INTERRUPTION_FILTER_ALLby default, or the value specified viasetInterruptionFilter(int)
-
setInterruptionFilter
@Implementation(minSdk=23) protected final void setInterruptionFilter(int interruptionFilter)
Currently does not support checking for granted policy access.- See Also:
NotificationManager.getCurrentInterruptionFilter()
-
getNotificationPolicy
@Implementation(minSdk=23) protected final android.app.NotificationManager.Policy getNotificationPolicy()
- Returns:
- the value specified via
setNotificationPolicy(Policy)
-
isNotificationPolicyAccessGranted
@Implementation(minSdk=23) protected final boolean isNotificationPolicyAccessGranted()
- Returns:
- the value specified via
setNotificationPolicyAccessGranted(boolean)
-
setNotificationPolicy
@Implementation(minSdk=23) protected final void setNotificationPolicy(android.app.NotificationManager.Policy policy)
Currently does not support checking for granted policy access.- See Also:
NotificationManager.getNotificationPolicy()
-
setNotificationPolicyAccessGranted
public void setNotificationPolicyAccessGranted(boolean granted)
Sets the value returned byNotificationManager.isNotificationPolicyAccessGranted(). Ifgrantedis false, this also deletes allAutomaticZenRules.- See Also:
NotificationManager.isNotificationPolicyAccessGranted()
-
getAutomaticZenRule
@Implementation(minSdk=24) protected android.app.AutomaticZenRule getAutomaticZenRule(java.lang.String id)
-
getAutomaticZenRules
@Implementation(minSdk=24) protected java.util.Map<java.lang.String,android.app.AutomaticZenRule> getAutomaticZenRules()
-
addAutomaticZenRule
@Implementation(minSdk=24) protected java.lang.String addAutomaticZenRule(android.app.AutomaticZenRule automaticZenRule)
-
updateAutomaticZenRule
@Implementation(minSdk=24) protected boolean updateAutomaticZenRule(java.lang.String id, android.app.AutomaticZenRule automaticZenRule)
-
removeAutomaticZenRule
@Implementation(minSdk=24) protected boolean removeAutomaticZenRule(java.lang.String id)
-
getNotificationDelegate
@Implementation(minSdk=29) protected java.lang.String getNotificationDelegate()
-
canNotifyAsPackage
@Implementation(minSdk=29) protected boolean canNotifyAsPackage(@NonNull java.lang.String pkg)
-
setCanNotifyAsPackage
public void setCanNotifyAsPackage(@NonNull java.lang.String otherPackage, boolean canNotify)Sets notification delegate for the package provided.canNotifyAsPackage(String)will be returned based on this value.- Parameters:
otherPackage- the package for which the current package can notify on behalfcanNotify- whether the current package is set as notification delegate for 'otherPackage'
-
setNotificationDelegate
@Implementation(minSdk=29) protected void setNotificationDelegate(java.lang.String delegate)
-
setEnforceMaxNotificationLimit
public void setEnforceMaxNotificationLimit(boolean enforceMaxNotificationLimit)
Ensures a notification limit is applied before posting the notification.When set to true a maximum notification limit of 25 is applied. Notifications past this limit are dropped and are not posted or enqueued.
When set to false no limit is applied and all notifications are posted or enqueued. This is the default behavior.
-
isChannelDeleted
public boolean isChannelDeleted(java.lang.String channelId)
Checks whether a channel is considered a "deleted" channel by Android. This is a channel that was created but later deleted. If a channel is created that was deleted before, it recreates the channel with the old settings.
-
getNotificationChannelGroup
public java.lang.Object getNotificationChannelGroup(java.lang.String id)
-
size
public int size()
-
getNotification
public android.app.Notification getNotification(int id)
-
getNotification
public android.app.Notification getNotification(java.lang.String tag, int id)
-
getAllNotifications
public java.util.List<android.app.Notification> getAllNotifications()
-
-