Class ShadowNotificationManager


  • @Implements(value=android.app.NotificationManager.class,
                looseSignatures=true)
    public class ShadowNotificationManager
    extends java.lang.Object
    • Constructor Detail

      • ShadowNotificationManager

        public ShadowNotificationManager()
    • 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_ALL by default, or the value specified via setInterruptionFilter(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)
      • 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 by NotificationManager.isNotificationPolicyAccessGranted(). If granted is false, this also deletes all AutomaticZenRules.
        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 behalf
        canNotify - 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()