• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_NOTIFICATION_H
17 #define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_NOTIFICATION_H
18 
19 #include <list>
20 
21 #include "ans_manager_death_recipient.h"
22 #include "ans_manager_interface.h"
23 #include "notification_subscriber.h"
24 
25 namespace OHOS {
26 namespace Notification {
27 class AnsNotification {
28 public:
29     /**
30      * @brief Creates a notification slot.
31      * @note You can call the NotificationRequest::SetSlotType(NotificationConstant::SlotType) method to bind the slot
32      * for publishing. A NotificationSlot instance cannot be used directly after being initialized. Instead, you have to
33      * call this method to create a notification slot and bind the slot ID to a NotificationRequest object so that the
34      * notification published can have all the characteristics set in the NotificationSlot. After a notification slot is
35      * created by using this method, only the name and description of the notification slot can be changed. Changes to
36      * the other attributes, such as the vibration status and notification tone, will no longer take effect.
37      *
38      * @param slot Indicates the notification slot to be created, which is set by NotificationSlot.
39      *             This parameter must be specified.
40      * @return Returns add notification slot result.
41      */
42     ErrCode AddNotificationSlot(const NotificationSlot &slot);
43 
44     /**
45      * @brief Adds a notification slot by type.
46      *
47      * @param slotType Indicates the notification slot type to be added.
48      * @return Returns add notification slot result.
49      */
50     ErrCode AddSlotByType(const NotificationConstant::SlotType &slotType);
51 
52     /**
53      * @brief Creates multiple notification slots.
54      *
55      * @param slots Indicates the notification slots to create.
56      * @return Returns add notification slots result.
57      */
58     ErrCode AddNotificationSlots(const std::vector<NotificationSlot> &slots);
59 
60     /**
61      * @brief Deletes a created notification slot based on the slot ID.
62      *
63      * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot
64      *                This parameter must be specified.
65      * @return Returns remove notification slot result.
66      */
67     ErrCode RemoveNotificationSlot(const NotificationConstant::SlotType &slotType);
68 
69     /**
70      * @brief Deletes all notification slots.
71      *
72      * @return Returns remove all slots result.
73      */
74     ErrCode RemoveAllSlots();
75 
76     /**
77      * @brief Queries a created notification slot.
78      *
79      * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This
80      *        parameter must be specified.
81      * @param slot Indicates the created NotificationSlot.
82      * @return Returns the get notification slot result.
83      */
84     ErrCode GetNotificationSlot(const NotificationConstant::SlotType &slotType, sptr<NotificationSlot> &slot);
85 
86     /**
87      * @brief Obtains all notification slots of this application.
88      *
89      * @param slots Indicates the created NotificationSlot.
90      * @return Returns all notification slots of this application.
91      */
92     ErrCode GetNotificationSlots(std::vector<sptr<NotificationSlot>> &slots);
93 
94     /**
95      * @brief Obtains number of slot.
96      *
97      * @param bundleOption Indicates the bundle name and uid of the application.
98      * @param num Indicates number of slot.
99      * @return Returns get slot number by bundle result.
100      */
101     ErrCode GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, uint64_t &num);
102 
103     /**
104      * @brief Publishes a notification.
105      * @note If a notification with the same ID has been published by the current application and has not been deleted,
106      * this method will update the notification.
107      *
108      * @param request Indicates the NotificationRequest object for setting the notification content.
109      *                This parameter must be specified.
110      * @return Returns publish notification result.
111      */
112     ErrCode PublishNotification(const NotificationRequest &request);
113 
114     /**
115      * @brief Publishes a notification with a specified label.
116      * @note If a notification with the same ID has been published by the current application and has not been deleted,
117      *       this method will update the notification.
118      *
119      * @param label Indicates the label of the notification to publish.
120      * @param request Indicates the NotificationRequest object for setting the notification content.
121      *                This parameter must be specified.
122      * @return Returns publish notification result.
123      */
124     ErrCode PublishNotification(const std::string &label, const NotificationRequest &request);
125 
126     /**
127      * @brief Cancels a published notification.
128      *
129      * @param notificationId Indicates the unique notification ID in the application.
130      *                       The value must be the ID of a published notification.
131      *                       Otherwise, this method does not take effect.
132      * @return Returns cancel notification result.
133      */
134     ErrCode CancelNotification(int32_t notificationId);
135 
136     /**
137      * @brief Cancels a published notification matching the specified label and notificationId.
138      *
139      * @param label Indicates the label of the notification to cancel.
140      * @param notificationId Indicates the ID of the notification to cancel.
141      * @return Returns cancel notification result.
142      */
143     ErrCode CancelNotification(const std::string &label, int32_t notificationId);
144 
145     /**
146      * @brief Cancels all the published notifications.
147      * @note To cancel a specified notification, see CancelNotification(int_32).
148      *
149      * @return Returns cancel all notifications result.
150      */
151     ErrCode CancelAllNotifications();
152 
153     /**
154      * @brief Cancels a published agent notification.
155      *
156      * @param notificationId Indicates the unique notification ID in the application.
157      *                       The value must be the ID of a published notification.
158      *                       Otherwise, this method does not take effect.
159      * @param representativeBundle Indicates the name of application bundle your application is representing.
160      * @param userId Indicates the specific user.
161      * @return Returns cancel notification result.
162      */
163     ErrCode CancelAsBundle(int32_t notificationId, const std::string &representativeBundle, int32_t userId);
164 
165     /**
166      * @brief Obtains the number of active notifications of the current application in the system.
167      *
168      * @param num Indicates the number of active notifications of the current application.
169      * @return Returns get active notification nums result.
170      */
171     ErrCode GetActiveNotificationNums(uint64_t &num);
172 
173     /**
174      * @brief Obtains active notifications of the current application in the system.
175      *
176      * @param  request Indicates active NotificationRequest objects of the current application.
177      * @return Returns get active notifications result.
178      */
179     ErrCode GetActiveNotifications(std::vector<sptr<NotificationRequest>> &request);
180 
181     /**
182      * @brief Allows another application to act as an agent to publish notifications in the name of your application
183      * bundle. You can revoke this authorization by passing null to this method.
184      *
185      * @param agent Indicates the name of the application bundle that can publish notifications for your application.
186      * @return Returns set notification agent result.
187      */
188     ErrCode SetNotificationAgent(const std::string &agent);
189 
190     /**
191      * @brief Obtains the name of the application bundle that can publish notifications in the name of your application.
192      *
193      * @param agent Indicates the name of the application bundle that can publish notifications for your application if
194      * any; returns null otherwise.
195      * @return Returns get notification agent result.
196      */
197     ErrCode GetNotificationAgent(std::string &agent);
198 
199     /**
200      * @brief Checks whether your application has permission to publish notifications by calling
201      * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the
202      * given representativeBundle.
203      *
204      * @param representativeBundle Indicates the name of application bundle your application is representing.
205      * @param canPublish Indicates whether your application has permission to publish notifications.
206      * @return Returns can publish notification as bundle result.
207      */
208     ErrCode CanPublishNotificationAsBundle(const std::string &representativeBundle, bool &canPublish);
209 
210     /**
211      * @brief Publishes a notification in the name of a specified application bundle.
212      * @note If the notification to be published has the same ID as a published notification that has not been canceled,
213      * the existing notification will be replaced by the new one.
214      *
215      * @param request Indicates the NotificationRequest object for setting the notification content.
216      *                This parameter must be specified.
217      * @param representativeBundle Indicates the name of the application bundle that allows your application to publish
218      *                             notifications for it by calling setNotificationAgent.
219      * @return Returns publish notification as bundle result.
220      */
221     ErrCode PublishNotificationAsBundle(const std::string &representativeBundle, const NotificationRequest &request);
222 
223     /**
224      * @brief Sets the number of active notifications of the current application as the number to be displayed on the
225      * notification badge.
226      *
227      * @return Returns set notification badge num result.
228      */
229     ErrCode SetNotificationBadgeNum();
230 
231     /**
232      * @brief Sets the number to be displayed on the notification badge of the application.
233      *
234      * @param num Indicates the number to display. A negative number indicates that the badge setting remains unchanged.
235      *            The value 0 indicates that no badge is displayed on the application icon.
236      *            If the value is greater than 99, 99+ will be displayed.
237      * @return Returns set notification badge num result.
238      */
239     ErrCode SetNotificationBadgeNum(int32_t num);
240 
241     /**
242      * @brief Checks whether this application has permission to publish notifications. The caller must have
243      * system permissions to call this method.
244      *
245      * @param  allowed True if this application has the permission; returns false otherwise
246      * @return Returns is allowed notify result.
247      */
248     ErrCode IsAllowedNotify(bool &allowed);
249 
250     /**
251      * @brief Checks whether this application has permission to publish notifications.
252      *
253      * @param  allowed True if this application has the permission; returns false otherwise
254      * @return Returns is allowed notify result.
255      */
256     ErrCode IsAllowedNotifySelf(bool &allowed);
257 
258     /**
259      * @brief Allows the current application to publish notifications on a specified device.
260      *
261      * @param deviceId Indicates the ID of the device running the application. At present, this parameter can
262      *                 only be null or an empty string, indicating the current device.
263      * @return Returns set notifications enabled for default bundle result.
264      */
265     ErrCode RequestEnableNotification(std::string &deviceId, sptr<IRemoteObject> &callerToken);
266 
267     /**
268      * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy.
269      *
270      * @param hasPermission True if this application is suspended; returns false otherwise.
271      * @return Returns has notification policy access permission.
272      */
273     ErrCode HasNotificationPolicyAccessPermission(bool &hasPermission);
274 
275     /**
276      * @brief Obtains the importance level of this application.
277      *
278      * @param  importance the importance level of this application, which can be LEVEL_NONE,
279                LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED.
280      * @return Returns get bundle importance result
281      */
282     ErrCode GetBundleImportance(NotificationSlot::NotificationLevel &importance);
283 
284     /**
285      * @brief Subscribes to notifications from all applications. This method can be called only by applications
286      * with required system permissions.
287      * @note  To subscribe to a notification, inherit the {NotificationSubscriber} class, override its
288      *        callback methods and create a subscriber. The subscriber will be used as a parameter of this method.
289      *        After the notification is published, subscribers that meet the filter criteria can receive the
290      * notification. To subscribe to notifications published only by specified sources, for example, notifications from
291      *        certain applications, call the {SubscribeNotification(NotificationSubscriber, NotificationSubscribeInfo)}
292      * method.
293      *
294      * @param subscriber Indicates the {NotificationSubscriber} to receive notifications.
295      *                   This parameter must be specified.
296      * @return Returns subscribe notification result.
297      */
298     ErrCode SubscribeNotification(const NotificationSubscriber &subscriber);
299 
300     /**
301      * @brief Subscribes to all notifications based on the filtering criteria. This method can be called only
302      * by applications with required system permissions.
303      * @note  After {subscribeInfo} is specified, a subscriber receives only the notifications that
304      *        meet the filter criteria specified by {subscribeInfo}.
305      *        To subscribe to a notification, inherit the {NotificationSubscriber} class, override its
306      *        callback methods and create a subscriber. The subscriber will be used as a parameter of this method.
307      *        After the notification is published, subscribers that meet the filter criteria can receive the
308      * notification. To subscribe to and receive all notifications, call the
309      * {SubscribeNotification(NotificationSubscriber)} method.
310      *
311      * @param subscriber Indicates the subscribers to receive notifications. This parameter must be specified.
312      *                   For details, see {NotificationSubscriber}.
313      * @param subscribeInfo Indicates the filters for specified notification sources, including application name,
314      *                      user ID, or device name. This parameter is optional.
315      * @return Returns subscribe notification result.
316      */
317     ErrCode SubscribeNotification(
318         const NotificationSubscriber &subscriber, const NotificationSubscribeInfo &subscribeInfo);
319 
320     /**
321      * @brief Unsubscribes from all notifications. This method can be called only by applications with required
322      * system permissions.
323      * @note Generally, you subscribe to a notification by calling the
324      *       {SubscribeNotification(NotificationSubscriber)} method. If you do not want your application
325      *       to receive a notification any longer, unsubscribe from that notification using this method.
326      *       You can unsubscribe from only those notifications that your application has subscribed to.
327      *        To unsubscribe from notifications published only by specified sources, for example,
328      *       notifications from certain applications, call the
329      *       {UnSubscribeNotification(NotificationSubscriber, NotificationSubscribeInfo)} method.
330      *
331      * @param subscriber Indicates the {NotificationSubscriber} to receive notifications.
332      *                   This parameter must be specified.
333      * @return Returns unsubscribe notification result.
334      */
335     ErrCode UnSubscribeNotification(NotificationSubscriber &subscriber);
336 
337     /**
338      * @brief Unsubscribes from all notifications based on the filtering criteria. This method can be called
339      * only by applications with required system permissions.
340      * @note A subscriber will no longer receive the notifications from specified notification sources.
341      *
342      * @param subscriber Indicates the {NotificationSubscriber} to receive notifications.
343      *                   This parameter must be specified.
344      * @param subscribeInfo Indicates the filters for , including application name,
345      *                      user ID, or device name. This parameter is optional.
346      * @return Returns unsubscribe notification result.
347      */
348     ErrCode UnSubscribeNotification(NotificationSubscriber &subscriber, NotificationSubscribeInfo subscribeInfo);
349 
350     /**
351      * @brief Removes a specified removable notification of other applications.
352      * @note Your application must have platform signature to use this method.
353      *
354      * @param key Indicates the key of the notification to remove.
355      * @param removeReason Indicates the reason of remove notification.
356      * @return Returns remove notification result.
357      */
358     ErrCode RemoveNotification(const std::string &key, int32_t removeReason);
359 
360     /**
361      * @brief Removes a specified removable notification of other applications.
362      * @note Your application must have platform signature to use this method.
363      *
364      * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed.
365      * @param notificationId Indicates the id of the notification to remove.
366      * @param label Indicates the label of the notification to remove.
367      * @param removeReason Indicates the reason of remove notification.
368      * @return Returns remove notification result.
369      */
370     ErrCode RemoveNotification(const NotificationBundleOption &bundleOption, const int32_t notificationId,
371         const std::string &label, int32_t removeReason);
372 
373     /**
374      * @brief Removes a specified removable notification of other applications.
375      * @note Your application must have platform signature to use this method.
376      *
377      * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed.
378      * @return Returns remove notification result.
379      */
380     ErrCode RemoveAllNotifications(const NotificationBundleOption &bundleOption);
381 
382     ErrCode RemoveNotifications(const std::vector<std::string> hashcodes, int32_t removeReason);
383 
384     /**
385      * @brief Removes all removable notifications of a specified bundle.
386      * @note Your application must have platform signature to use this method.
387      *
388      * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed.
389      * @return Returns remove notifications result.
390      */
391     ErrCode RemoveNotificationsByBundle(const NotificationBundleOption &bundleOption);
392 
393     /**
394      * @brief Removes all removable notifications in the system.
395      * @note Your application must have platform signature to use this method.
396      *
397      * @return Returns remove notifications result.
398      */
399     ErrCode RemoveNotifications();
400 
401     /**
402      * @brief Obtains all notification slots belonging to the specified bundle.
403      *
404      * @param bundleOption Indicates the bundle name and uid of the application.
405      * @param slots Indicates a list of notification slots.
406      * @return Returns get notification slots for bundle result.
407      */
408     ErrCode GetNotificationSlotsForBundle(
409         const NotificationBundleOption &bundleOption, std::vector<sptr<NotificationSlot>> &slots);
410 
411     /**
412      * @brief Updates all notification slots for the specified bundle.
413      *
414      * @param bundleOption Indicates the bundle name and uid of the application.
415      * @param slots Indicates a list of new notification slots.
416      * @return Returns update notification slots for bundle result.
417      */
418     ErrCode UpdateNotificationSlots(
419         const NotificationBundleOption &bundleOption, const std::vector<sptr<NotificationSlot>> &slots);
420 
421     /**
422      * @brief Obtains all active notifications in the current system. The caller must have system permissions to
423      * call this method.
424      *
425      * @param notification Indicates all active notifications of this application.
426      * @return Returns get all active notifications
427      */
428     ErrCode GetAllActiveNotifications(std::vector<sptr<Notification>> &notification);
429 
430     /**
431      * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method
432      * to obtain particular active notifications, you must have received the notifications and obtained the key
433      * via {Notification::GetKey()}.
434      *
435      * @param key Indicates the key array for querying corresponding active notifications.
436      *            If this parameter is null, this method returns all active notifications in the system.
437      * @param notification Indicates the set of active notifications corresponding to the specified key.
438      * @return Returns get all active notifications result.
439      */
440     ErrCode GetAllActiveNotifications(
441         const std::vector<std::string> key, std::vector<sptr<Notification>> &notification);
442 
443     /**
444      * @brief Checks whether a specified application has the permission to publish notifications. If bundle specifies
445      * the current application, no permission is required for calling this method. If bundle specifies another
446      * application, the caller must have system permissions.
447      *
448      * @param bundleOption Indicates the bundle name and uid of the application.
449      * @param allowed True if the application has permissions; returns false otherwise.
450      * @return Returns is allowed notify result.
451      */
452     ErrCode IsAllowedNotify(const NotificationBundleOption &bundleOption, bool &allowed);
453 
454     /**
455      * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must
456      * have system permissions to call this method.
457      *
458      * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only
459      *                 be null or an empty string, indicating the current device.
460      * @param enabled Specifies whether to allow all applications to publish notifications. The value true
461      *                indicates that notifications are allowed, and the value false indicates that notifications are not
462      *                allowed.
463      * @return Returns set notifications enabled for all bundles result.
464      */
465     ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled);
466 
467     /**
468      * @brief Sets whether to allow the current application to publish notifications on a specified device. The caller
469      * must have system permissions to call this method.
470      *
471      * @param deviceId Indicates the ID of the device running the application. At present, this parameter can
472      *                 only be null or an empty string, indicating the current device.
473      * @param enabled Specifies whether to allow the current application to publish notifications. The value
474      *                true indicates that notifications are allowed, and the value false indicates that
475      *                notifications are not allowed.
476      * @return Returns set notifications enabled for default bundle result.
477      */
478     ErrCode SetNotificationsEnabledForDefaultBundle(const std::string &deviceId, bool enabled);
479 
480     /**
481      * @brief Sets whether to allow a specified application to publish notifications on a specified device. The caller
482      * must have system permissions to call this method.
483      *
484      * @param bundleOption Indicates the bundle name and uid of the application.
485      * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only
486      *                 be null or an empty string, indicating the current device.
487      * @param enabled Specifies whether to allow the given application to publish notifications. The value
488      *                true indicates that notifications are allowed, and the value false indicates that notifications
489      *                are not allowed.
490      * @return Returns set notifications enabled for specified bundle result.
491      */
492     ErrCode SetNotificationsEnabledForSpecifiedBundle(
493         const NotificationBundleOption &bundleOption, const std::string &deviceId, bool enabled);
494 
495     /**
496      * @brief Sets whether to allow a specified application to to show badge.
497      *
498      * @param bundleOption Indicates the bundle name and uid of the application.
499      * @param enabled Specifies whether to allow the given application to show badge.
500      * @return Returns set result.
501      */
502     ErrCode SetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool enabled);
503 
504     /**
505      * @brief Obtains the flag that whether to allow a specified application to to show badge.
506      *
507      * @param bundleOption Indicates the bundle name and uid of the application.
508      * @param enabled Specifies whether to allow the given application to show badge.
509      * @return Returns get result.
510      */
511     ErrCode GetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool &enabled);
512 
513     /**
514      * @brief Obtains the flag that whether to allow the current application to to show badge.
515      *
516      * @param enabled Specifies whether to allow the given application to show badge.
517      * @return Returns get result.
518      */
519     ErrCode GetShowBadgeEnabled(bool &enabled);
520 
521     /**
522      * @brief Cancels the notification of the specified group of this application.
523      *
524      * @param groupName the specified group name.
525      * @return Returns cancel group result.
526      */
527     ErrCode CancelGroup(const std::string &groupName);
528 
529     /**
530      * @brief Removes the notification of the specified group of the specified application.
531      *
532      * @param bundleOption Indicates the bundle name and uid of the specified application.
533      * @param groupName Indicates the specified group name.
534      * @return Returns remove group by bundle result.
535      */
536     ErrCode RemoveGroupByBundle(const NotificationBundleOption &bundleOption, const std::string &groupName);
537 
538     /**
539      * @brief Sets the do not disturb time.
540      * @note Your application must have system signature to call this method.
541      *
542      * @param doNotDisturbDate Indicates the do not disturb time to set.
543      * @return Returns set do not disturb time result.
544      */
545     ErrCode SetDoNotDisturbDate(const NotificationDoNotDisturbDate &doNotDisturbDate);
546 
547     /**
548      * @brief Obtains the do not disturb time.
549      * @note Your application must have system signature to call this method.
550      *
551      * @param doNotDisturbDate Indicates the do not disturb time to get.
552      * @return Returns set do not disturb time result.
553      */
554     ErrCode GetDoNotDisturbDate(NotificationDoNotDisturbDate &doNotDisturbDate);
555 
556     /**
557      * @brief Obtains the flag that whether to support do not disturb mode.
558      *
559      * @param doesSupport Specifies whether to support do not disturb mode.
560      * @return Returns check result.
561      */
562     ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport);
563 
564     /**
565      * @brief Checks if the device supports distributed notification.
566      *
567      * @param enabled True if the device supports distributed notification; false otherwise.
568      * @return Returns is distributed enabled result.
569      */
570     ErrCode IsDistributedEnabled(bool &enabled);
571 
572     /**
573      * @brief Sets whether the device supports distributed notifications.
574      *
575      * @param enable Specifies whether to enable the device to support distributed notification.
576      *               The value true indicates that the device is enabled to support distributed notifications, and
577      *               the value false indicates that the device is forbidden to support distributed notifications.
578      * @return Returns enable distributed result.
579      */
580     ErrCode EnableDistributed(const bool enabled);
581 
582     /**
583      * @brief Sets whether an application supports distributed notifications.
584      *
585      * @param bundleOption Indicates the bundle name and uid of an application.
586      * @param enabled Specifies whether to enable an application to support distributed notification.
587      *                The value true indicates that the application is enabled to support distributed notifications,
588      *                and the value false indicates that the application is forbidden to support distributed
589      *                notifications.
590      * @return Returns enable distributed by bundle result.
591      */
592     ErrCode EnableDistributedByBundle(const NotificationBundleOption &bundleOption, const bool enabled);
593 
594     /**
595      * @brief Sets whether this application supports distributed notifications.
596      *
597      * @param enabled Specifies whether to enable this application to support distributed notification.
598      *                The value true indicates that this application is enabled to support distributed notifications,
599      *                and the value false indicates that this application is forbidden to support distributed
600      *                notifications.
601      * @return Returns enable distributed self result.
602      */
603     ErrCode EnableDistributedSelf(const bool enabled);
604 
605     /**
606      * @brief Checks whether an application supports distributed notifications.
607      *
608      * @param bundleOption Indicates the bundle name and uid of an application.
609      * @param enabled True if the application supports distributed notification; false otherwise.
610      * @return Returns is distributed enabled by bundle result.
611      */
612     ErrCode IsDistributedEnableByBundle(const NotificationBundleOption &bundleOption, bool &enabled);
613 
614     /**
615      * @brief Obtains the device remind type.
616      * @note Your application must have system signature to call this method.
617      *
618      * @param remindType Indicates the device remind type to get.
619      * @return Returns get device reminder type result.
620      */
621     ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType);
622 
623     /**
624      * @brief Publishes a continuous task notification.
625      *
626      * @param request Indicates the NotificationRequest object for setting the notification content.
627      *                This parameter must be specified.
628      * @return Returns publish continuous task notification result.
629      */
630     ErrCode PublishContinuousTaskNotification(const NotificationRequest &request);
631 
632     /**
633      * @brief Cancels a published continuous task notification matching the specified label and notificationId.
634      *
635      * @param label Indicates the label of the continuous task notification to cancel.
636      * @param notificationId Indicates the ID of the continuous task notification to cancel.
637      * @return Returns cancel continuous task notification result.
638      */
639     ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId);
640 
641     /**
642      * @brief Obtains whether the template is supported by the system.
643      *
644      * @param support whether is it a system supported template.
645      * @return Returns check result.
646      */
647     ErrCode IsSupportTemplate(const std::string &templateName, bool &support);
648 
649     /**
650      * @brief Resets ans manager proxy when OnRemoteDied called.
651      */
652     void ResetAnsManagerProxy();
653 
654     /**
655      * @brief Publishes a scheduled reminder.
656      *
657      * @param reminder Indicates a reminder.
658      * @return Returns publish result.
659      */
660     ErrCode PublishReminder(ReminderRequest &reminder);
661 
662     /**
663      * @brief Cancels a specified reminder.
664      *
665      * @param reminderId Indicates reminder Id.
666      * @return Returns cancel result.
667      */
668     ErrCode CancelReminder(const int32_t reminderId);
669 
670     /**
671      * @brief Cancels all reminders of current third part application.
672      *
673      * @return Returns cancel result.
674      */
675     ErrCode CancelAllReminders();
676 
677     /**
678      * @brief Obtains all valid reminder notifications set by the current application.
679      *
680      * @param[out] validReminders Indicates the vector to store the result.
681      * @return Returns get valid reminders result.
682      */
683     ErrCode GetValidReminders(std::vector<sptr<ReminderRequest>> &validReminders);
684 
685     /**
686      * @brief Checks whether this application has permission to publish notifications under the user.
687      *
688      * @param userId Indicates the userId of the application.
689      * @param allowed True if the application has permissions; returns false otherwise.
690      * @return Returns get allowed result.
691      */
692     ErrCode IsAllowedNotify(const int32_t &userId, bool &allowed);
693 
694     /**
695      * @brief Sets whether to allow all applications to publish notifications on a specified user.
696      * The caller must have system permissions to call this method.
697      *
698      * @param userId Indicates the ID of the user running the application.
699      * @param enabled Specifies whether to allow all applications to publish notifications. The value true
700      *                indicates that notifications are allowed, and the value false indicates that notifications
701      *                are not allowed.
702      * @return Returns set notifications enabled for all bundles result.
703      */
704     ErrCode SetNotificationsEnabledForAllBundles(const int32_t &userId, bool enabled);
705 
706     /**
707      * @brief Removes notifications under specified user.
708      * @note Your application must have platform signature to use this method.
709      *
710      * @param userId Indicates the ID of user whose notifications are to be removed.
711      * @return Returns remove notification result.
712      */
713     ErrCode RemoveNotifications(const int32_t &userId);
714 
715     /**
716      * @brief Sets the do not disturb time on a specified user.
717      * @note Your application must have system signature to call this method.
718      *
719      * @param userId Indicates the specific user.
720      * @param doNotDisturbDate Indicates the do not disturb time to set.
721      * @return Returns set do not disturb time result.
722      */
723     ErrCode SetDoNotDisturbDate(const int32_t &userId, const NotificationDoNotDisturbDate &doNotDisturbDate);
724 
725     /**
726      * @brief Obtains the do not disturb time on a specified user.
727      * @note Your application must have system signature to call this method.
728      *
729      * @param userId Indicates the specific user.
730      * @param doNotDisturbDate Indicates the do not disturb time to get.
731      * @return Returns set do not disturb time result.
732      */
733     ErrCode GetDoNotDisturbDate(const int32_t &userId, NotificationDoNotDisturbDate &doNotDisturbDate);
734 
735     /**
736      * Set whether the application slot is enabled.
737      *
738      * @param bundleOption Indicates the bundle name and uid of the application.
739      * @param slotType Indicates type of slot.
740      * @param enable the type of slot enabled.
741      * @return Returns get slot number by bundle result.
742      */
743     ErrCode SetEnabledForBundleSlot(
744         const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType, bool enabled);
745 
746     /**
747      * Obtains whether the application slot is enabled.
748      *
749      * @param bundleOption Indicates the bundle name and uid of the application.
750      * @param slotType Indicates type of slot.
751      * @param enable the type of slot enabled to get.
752      * @return Returns get slot number by bundle result.
753      */
754     ErrCode GetEnabledForBundleSlot(
755         const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType, bool &enabled);
756 
757     /**
758      * @brief Obtains specific datas via specified dump option.
759      *
760      * @param cmd Indicates the specified dump command.
761      * @param bundle Indicates the specified bundle name.
762      * @param userId Indicates the specified userId.
763      * @param dumpInfo Indicates the container containing datas.
764      * @return Returns check result.
765      */
766     ErrCode ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId,
767         std::vector<std::string> &dumpInfo);
768 
769     /**
770      * @brief Set whether to sync notifications to devices that do not have the app installed.
771      *
772      * @param userId Indicates the specific user.
773      * @param enabled Allow or disallow sync notifications.
774      * @return Returns set enabled result.
775      */
776     ErrCode SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled);
777 
778     /**
779      * @brief Obtains whether to sync notifications to devices that do not have the app installed.
780      *
781      * @param userId Indicates the specific user.
782      * @param enabled Allow or disallow sync notifications.
783      * @return Returns get enabled result.
784      */
785     ErrCode GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled);
786 
787     /**
788      * @brief Set badge number.
789      *
790      * @param badgeNumber The badge number.
791      * @return Returns set badge number result.
792      */
793     ErrCode SetBadgeNumber(int32_t badgeNumber);
794 
795     /**
796      * @brief Register Push Callback.
797      *
798      * @param pushCallback PushCallBack.
799      * @return Returns register PushCallback result.
800      */
801     ErrCode RegisterPushCallback(const sptr<IRemoteObject> &pushCallback);
802 
803     /**
804      * @brief Unregister Push Callback.
805      *
806      * @return Returns unregister push Callback result.
807      */
808     ErrCode UnregisterPushCallback();
809 
810 private:
811     /**
812      * @brief Gets Ans Manager proxy.
813      *
814      * @return Returns true if succeed; returns false otherwise.
815      */
816     bool GetAnsManagerProxy();
817 
818     /**
819      * @brief Checks if the MediaContent can be published.
820      *
821      * @param request Indicates the specified request.
822      * @return Returns true if the MediaContent can be published; returns false otherwise.
823      */
824     bool CanPublishMediaContent(const NotificationRequest &request) const;
825 
826     /**
827      * @brief Checks whether the picture size exceeds the limit in PixelMap.
828      *
829      * @param pixelMap Indicates the specified image.
830      * @param maxSize Indicates the limit size.
831      * @return Returns true if the limit size is exceeded; returns false otherwise.
832      */
833     bool CheckImageOverSizeForPixelMap(
834         const std::shared_ptr<Media::PixelMap> &pixelMap, uint32_t maxSize);
835 
836     /**
837      * @brief Checks whether the picture size exceeds the limit in NotificationRequest's content.
838      *
839      * @param request Indicates the specified request.
840      * @return Returns the ErrCode.
841      */
842     ErrCode CheckImageSizeForContent(const NotificationRequest &request);
843 
844     /**
845      * @brief Checks whether the picture size exceeds the limit.
846      *
847      * @param request Indicates the specified request.
848      * @return Returns the ErrCode.
849      */
850     ErrCode CheckImageSize(const NotificationRequest &request);
851 
852     /**
853      * @brief Checks whether the notification doesn't support distribution.
854      *
855      * @param type Indicates the specified NotificationContent::Type.
856      * @return Returns true if the notification doesn't support distribution; returns false otherwise.
857      */
858     bool IsNonDistributedNotificationType(const NotificationContent::Type &type);
859 
860 private:
861     std::mutex mutex_;
862     sptr<AnsManagerInterface> ansManagerProxy_;
863     sptr<AnsManagerDeathRecipient> recipient_;
864 };
865 }  // namespace Notification
866 }  // namespace OHOS
867 
868 #endif  // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_NOTIFICATION_H