• 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_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_HELPER_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_HELPER_H
18 
19 #include "notification_bundle_option.h"
20 #include "notification_do_not_disturb_date.h"
21 #include "enabled_notification_callback_data.h"
22 #include "notification_request.h"
23 #include "notification_slot.h"
24 #include "notification_sorting_map.h"
25 #include "notification_subscriber.h"
26 
27 namespace OHOS {
28 namespace Notification {
29 class NotificationHelper {
30 public:
31     /**
32      * @brief Creates a notification slot.
33      * @note You can call the NotificationRequest::SetSlotType(NotificationConstant::SlotType) method to bind the slot
34      * for publishing. A NotificationSlot instance cannot be used directly after being initialized. Instead, you have to
35      * call this method to create a notification slot and bind the slot ID to a NotificationRequest object so that the
36      * notification published can have all the characteristics set in the NotificationSlot. After a notification slot is
37      * created by using this method, only the name and description of the notification slot can be changed. Changes to
38      * the other attributes, such as the vibration status and notification tone, will no longer take effect.
39      *
40      * @param slot Indicates the notification slot to be created, which is set by NotificationSlot.
41      *             This parameter must be specified.
42      * @return Returns add notification slot result.
43      */
44     static ErrCode AddNotificationSlot(const NotificationSlot &slot);
45 
46     /**
47      * @brief Adds a notification slot by type.
48      *
49      * @param slotType Indicates the notification slot type to be added.
50      * @return Returns add notification slot result.
51      */
52     static ErrCode AddSlotByType(const NotificationConstant::SlotType &slotType);
53 
54     /**
55      * @brief Creates multiple notification slots.
56      *
57      * @param slots Indicates the notification slots to create.
58      * @return Returns add notification slots result.
59      */
60     static ErrCode AddNotificationSlots(const std::vector<NotificationSlot> &slots);
61 
62     /**
63      * @brief Deletes a created notification slot based on the slot ID.
64      *
65      * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot
66      *                 This parameter must be specified.
67      * @return Returns remove notification slot result.
68      */
69     static ErrCode RemoveNotificationSlot(const NotificationConstant::SlotType &slotType);
70 
71     /**
72      * @brief Deletes all notification slots.
73      *
74      * @return Returns remove all slots result.
75      */
76     static ErrCode RemoveAllSlots();
77 
78     /**
79      * @brief Queries a created notification slot.
80      *
81      * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This
82      *        parameter must be specified.
83      * @param slot Indicates the created NotificationSlot.
84      * @return Returns the get notification slot result.
85      */
86     static ErrCode GetNotificationSlot(const NotificationConstant::SlotType &slotType, sptr<NotificationSlot> &slot);
87 
88     /**
89      * @brief Obtains all notification slots of this application.
90      * @param slots Indicates the created NotificationSlot.
91      * @return Returns all notification slots of this application.
92      */
93     static ErrCode GetNotificationSlots(std::vector<sptr<NotificationSlot>> &slots);
94 
95     /**
96      * @brief Obtains number of slot.
97      *
98      * @param bundleOption Indicates the bundle name and uid of the application.
99      * @param num Indicates number of slot.
100      * @return Returns get slot number by bundle result.
101      */
102     static ErrCode GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, uint64_t &num);
103 
104     /**
105      * @brief Publishes a notification.
106      * @note If a notification with the same ID has been published by the current application and has not been deleted,
107      * this method will update the notification.
108      *
109      * @param request Indicates the NotificationRequest object for setting the notification content.
110      *                This parameter must be specified.
111      * @return Returns publish notification result.
112      */
113     static ErrCode PublishNotification(const NotificationRequest &request);
114 
115     /**
116      * @brief Publishes a notification with a specified label.
117      * @note If a notification with the same ID has been published by the current application and has not been deleted,
118      *       this method will update the notification.
119      *
120      * @param label Indicates the label of the notification to publish.
121      * @param request Indicates the NotificationRequest object for setting the notification content.
122      *                This parameter must be specified.
123      * @return Returns publish notification result.
124      */
125     static ErrCode PublishNotification(const std::string &label, const NotificationRequest &request);
126 
127     /**
128      * @brief Cancels a published notification.
129      *
130      * @param notificationId Indicates the unique notification ID in the application.
131      *                       The value must be the ID of a published notification.
132      *                       Otherwise, this method does not take effect.
133      * @return Returns cancel notification result.
134      */
135     static ErrCode CancelNotification(int32_t notificationId);
136 
137     /**
138      * @brief Cancels a published notification matching the specified label and notificationId.
139      *
140      * @param label Indicates the label of the notification to cancel.
141      * @param notificationId Indicates the ID of the notification to cancel.
142      * @return Returns cancel notification result.
143      */
144     static ErrCode CancelNotification(const std::string &label, int32_t notificationId);
145 
146     /**
147      * @brief Cancels all the published notifications.
148      *
149      * @note To cancel a specified notification, see CancelNotification(int_32).
150      * @return Returns cancel all notifications result.
151      */
152     static ErrCode CancelAllNotifications();
153 
154     /**
155      * @brief Cancels a published agent notification.
156      *
157      * @param notificationId Indicates the unique notification ID in the application.
158      *                       The value must be the ID of a published notification.
159      *                       Otherwise, this method does not take effect.
160      * @param representativeBundle Indicates the name of application bundle your application is representing.
161      * @param userId Indicates the specific user.
162      * @return Returns cancel notification result.
163      */
164     static ErrCode CancelAsBundle(int32_t notificationId, const std::string &representativeBundle, int32_t userId);
165 
166     /**
167      * @brief Obtains the number of active notifications of the current application in the system.
168      *
169      * @param nums Indicates the number of active notifications of the current application.
170      * @return Returns get active notification nums result.
171      */
172     static ErrCode GetActiveNotificationNums(uint64_t &num);
173 
174     /**
175      * @brief Obtains active notifications of the current application in the system.
176      *
177      * @param  request Indicates active NotificationRequest objects of the current application.
178      * @return Returns get active notifications result.
179      */
180     static ErrCode GetActiveNotifications(std::vector<sptr<NotificationRequest>> &request);
181 
182     /**
183      * @brief Allows another application to act as an agent to publish notifications in the name of your application
184      * bundle.
185      *
186      * @param agent Indicates the name of the application bundle that can publish notifications for your application.
187      * @return Returns set notification agent result.
188      */
189     static ErrCode SetNotificationAgent(const std::string &agent);
190 
191     /**
192      * @brief Obtains the name of the application bundle that can publish notifications in the name of your application.
193      *
194      * @param agent Indicates the name of the application bundle that can publish notifications for your application if
195      * any; returns null otherwise.
196      * @return Returns get notification agent result.
197      */
198     static ErrCode GetNotificationAgent(std::string &agent);
199 
200     /**
201      * @brief Checks whether your application has permission to publish notifications by calling
202      * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the
203      * given representativeBundle.
204      *
205      * @param representativeBundle Indicates the name of application bundle your application is representing.
206      * @param canPublish Indicates whether your application has permission to publish notifications.
207      * @return Returns can publish notification as bundle result.
208      */
209     static ErrCode CanPublishNotificationAsBundle(const std::string &representativeBundle, bool &canPublish);
210 
211     /**
212      * @brief Publishes a notification in the name of a specified application bundle.
213      * @note If the notification to be published has the same ID as a published notification that has not been canceled,
214      * the existing notification will be replaced by the new one.
215      *
216      * @param request Indicates the NotificationRequest object for setting the notification content.
217      *                This parameter must be specified.
218      * @param representativeBundle Indicates the name of the application bundle that allows your application to publish
219      *                             notifications for it by calling setNotificationAgent.
220      * @return Returns publish notification as bundle result.
221      */
222     static ErrCode PublishNotificationAsBundle(
223         const std::string &representativeBundle, const NotificationRequest &request);
224 
225     /**
226      * @brief Sets the number of active notifications of the current application as the number to be displayed on the
227      * notification badge.
228      *
229      * @return Returns set notification badge num result.
230      */
231     static ErrCode SetNotificationBadgeNum();
232 
233     /**
234      * @brief Sets the number to be displayed on the notification badge of the application.
235      *
236      * @param num Indicates the number to display. A negative number indicates that the badge setting remains unchanged.
237      *            The value 0 indicates that no badge is displayed on the application icon.
238      *            If the value is greater than 99, 99+ will be displayed.
239      * @return Returns set notification badge num result.
240      */
241     static ErrCode SetNotificationBadgeNum(int32_t num);
242 
243     /**
244      * @brief Checks whether this application has permission to publish notifications. The caller must have
245      * system permissions to call this method.
246      *
247      * @param  allowed True if this application has the permission; returns false otherwise
248      * @return Returns is allowed notify result.
249      */
250     static ErrCode IsAllowedNotify(bool &allowed);
251 
252     /**
253      * @brief Checks whether this application has permission to publish notifications.
254      *
255      * @param  allowed True if this application has the permission; returns false otherwise
256      * @return Returns is allowed notify result.
257      */
258     static ErrCode IsAllowedNotifySelf(bool &allowed);
259 
260     /**
261      * @brief Allow the current application to publish notifications on a specified device.
262      *
263      * @param deviceId Indicates the ID of the device running the application. At present, this parameter can
264      *                 only be null or an empty string, indicating the current device.
265      * @return Returns set notifications enabled for default bundle result.
266      */
267     static ErrCode RequestEnableNotification(std::string &deviceId, sptr<IRemoteObject> &callerToken);
268 
269     /**
270      * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy.
271      *
272      * @param hasPermission True if this application is suspended; false otherwise.
273      * @return Returns has notification policy access permission.
274      */
275     static ErrCode HasNotificationPolicyAccessPermission(bool &hasPermission);
276 
277     /**
278      * @brief Obtains the importance level of this application.
279      *
280      * @param  importance Indicates the importance level of this application, which can be LEVEL_NONE,
281                LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED.
282      * @return Returns get bundle importance result
283      */
284     static ErrCode GetBundleImportance(NotificationSlot::NotificationLevel &importance);
285 
286     /**
287      * @brief Subscribes to notifications from all applications. This method can be called only by applications
288      * with required system permissions.
289      * @note  To subscribe to a notification, inherit the {NotificationSubscriber} class, override its
290      *        callback methods and create a subscriber. The subscriber will be used as a parameter of this method.
291      *        After the notification is published, subscribers that meet the filter criteria can receive the
292      *        notification. To subscribe to notifications published only by specified sources, for example,
293      *        notifications from certain applications,
294      *        call the {SubscribeNotification(NotificationSubscriber, NotificationSubscribeInfo)} method.
295      *
296      * @param subscriber Indicates the {NotificationSubscriber} to receive notifications.
297      *                   This parameter must be specified.
298      * @return Returns unsubscribe notification result.
299      */
300     static ErrCode SubscribeNotification(const NotificationSubscriber &subscriber);
301 
302     /**
303      * @brief Subscribes to all notifications based on the filtering criteria. This method can be called only
304      * by applications with required system permissions.
305      * @note  After {subscribeInfo} is specified, a subscriber receives only the notifications that
306      *        meet the filter criteria specified by {subscribeInfo}.
307      *        To subscribe to a notification, inherit the {NotificationSubscriber} class, override its
308      *        callback methods and create a subscriber. The subscriber will be used as a parameter of this method.
309      *        After the notification is published, subscribers that meet the filter criteria can receive the
310      *        notification. To subscribe to and receive all notifications, call the
311      *        {SubscribeNotification(NotificationSubscriber)} method.
312      *
313      * @param subscriber Indicates the subscribers to receive notifications. This parameter must be specified.
314      *                   For details, see {NotificationSubscriber}.
315      * @param subscribeInfo Indicates the filters for specified notification sources, including application name,
316      *                      user ID, or device name. This parameter is optional.
317      * @return Returns subscribe notification result.
318      */
319     static ErrCode SubscribeNotification(
320         const NotificationSubscriber &subscriber, const NotificationSubscribeInfo &subscribeInfo);
321 
322     /**
323      * @brief Unsubscribes from all notifications. This method can be called only by applications with required
324      * system permissions.
325      * @note Generally, you subscribe to a notification by calling the
326      *       {SubscribeNotification(NotificationSubscriber)} method. If you do not want your application
327      *       to receive a notification any longer, unsubscribe from that notification using this method.
328      *       You can unsubscribe from only those notifications that your application has subscribed to.
329      *        To unsubscribe from notifications published only by specified sources, for example,
330      *       notifications from certain applications, call the
331      *       {UnSubscribeNotification(NotificationSubscriber, NotificationSubscribeInfo)} method.
332      *
333      * @param subscriber Indicates the {NotificationSubscriber} to receive notifications.
334      *                   This parameter must be specified.
335      * @return Returns unsubscribe notification result.
336      */
337     static ErrCode UnSubscribeNotification(NotificationSubscriber &subscriber);
338 
339     /**
340      * @brief Unsubscribes from all notifications based on the filtering criteria. This method can be called
341      * only by applications with required system permissions.
342      * @note A subscriber will no longer receive the notifications from specified notification sources.
343      *
344      * @param subscriber Indicates the {NotificationSubscriber} to receive notifications.
345      *                   This parameter must be specified.
346      * @param subscribeInfo Indicates the filters for , including application name,
347      *                      user ID, or device name. This parameter is optional.
348      * @return Returns unsubscribe notification result.
349      */
350     static ErrCode UnSubscribeNotification(NotificationSubscriber &subscriber, NotificationSubscribeInfo subscribeInfo);
351 
352     /**
353      * @brief Removes a specified removable notification of other applications.
354      * @note Your application must have platform signature to use this method.
355      *
356      * @param key Indicates the key of the notification to remove.
357      * @param removeReason Indicates the reason of remove notification.
358      * @return Returns remove notification result.
359      */
360     static ErrCode RemoveNotification(const std::string &key, int32_t removeReason);
361 
362     /**
363      * @brief Removes a specified removable notification of other applications.
364      * @note Your application must have platform signature to use this method.
365      *
366      * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed.
367      * @param notificationId Indicates the id of the notification to remove.
368      * @param label Indicates the label of the notification to remove.
369      * @param removeReason Indicates the reason of remove notification.
370      * @return Returns remove notification result.
371      */
372     static ErrCode RemoveNotification(const NotificationBundleOption &bundleOption,
373         const int32_t notificationId, const std::string &label, int32_t removeReason);
374 
375     /**
376      * @brief Removes a specified removable notification of other applications.
377      * @note Your application must have platform signature to use this method.
378      *
379      * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed.
380      * @return Returns remove notification result.
381      */
382     static ErrCode RemoveAllNotifications(const NotificationBundleOption &bundleOption);
383 
384     static ErrCode RemoveNotifications(const std::vector<std::string> hashcodes, int32_t removeReason);
385 
386     /**
387      * @brief Removes all removable notifications of a specified bundle.
388      * @note Your application must have platform signature to use this method.
389      *
390      * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed.
391      * @return Returns remove notifications result.
392      */
393     static ErrCode RemoveNotificationsByBundle(const NotificationBundleOption &bundleOption);
394 
395     /**
396      * @brief Removes all removable notifications in the system.
397      * @note Your application must have platform signature to use this method.
398      * @return Returns remove notifications result.
399      */
400     static ErrCode RemoveNotifications();
401 
402     /**
403      * @brief Obtains all notification slots belonging to the specified bundle.
404      *
405      * @param bundleOption Indicates the bundle name and uid of the application.
406      * @param slots Indicates a list of notification slots.
407      * @return Returns get notification slots for bundle result.
408      */
409     static ErrCode GetNotificationSlotsForBundle(
410         const NotificationBundleOption &bundleOption, std::vector<sptr<NotificationSlot>> &slots);
411 
412     /**
413      * @brief Update all notification slots for the specified bundle.
414      *
415      * @param bundleOption Indicates the bundle name and uid of the application.
416      * @param slots Indicates a list of new notification slots.
417      * @return Returns update notification slots for bundle result.
418      */
419     static ErrCode UpdateNotificationSlots(
420         const NotificationBundleOption &bundleOption, const std::vector<sptr<NotificationSlot>> &slots);
421 
422     /**
423      * @brief Obtains all active notifications in the current system. The caller must have system permissions to
424      * call this method.
425      *
426      * @param notification Indicates all active notifications of this application.
427      * @return Returns get all active notifications
428      */
429     static ErrCode GetAllActiveNotifications(std::vector<sptr<Notification>> &notification);
430 
431     /**
432      * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method
433      * to obtain particular active notifications, you must have received the notifications and obtained the key
434      * via {Notification::GetKey()}.
435      *
436      * @param key Indicates the key array for querying corresponding active notifications.
437      *            If this parameter is null, this method returns all active notifications in the system.
438      * @param notification Indicates the set of active notifications corresponding to the specified key.
439      * @return Returns get all active notifications.
440      */
441     static ErrCode GetAllActiveNotifications(
442         const std::vector<std::string> key, std::vector<sptr<Notification>> &notification);
443 
444     /**
445      * @brief Checks whether a specified application has the permission to publish notifications. If bundle specifies
446      * the current application, no permission is required for calling this method. If bundle specifies another
447      * application, the caller must have system permissions.
448      *
449      * @param bundleOption Indicates the bundle name and uid of the application.
450      * @param allowed True if the application has permissions; false otherwise.
451      * @return Returns is allowed notify result.
452      */
453     static ErrCode IsAllowedNotify(const NotificationBundleOption &bundleOption, bool &allowed);
454 
455     /**
456      * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must
457      * have system permissions to call this method.
458      *
459      * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only
460      *                 be null or an empty string, indicating the current device.
461      * @param enabled Specifies whether to allow all applications to publish notifications. The value true
462      *                indicates that notifications are allowed, and the value false indicates that notifications
463      *                are not allowed.
464      * @return Returns set notifications enabled for all bundles result.
465      */
466     static ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled);
467 
468     /**
469      * @brief Sets whether to allow the current application to publish notifications on a specified device. The caller
470      * must have system permissions to call this method.
471      *
472      * @param deviceId Indicates the ID of the device running the application. At present, this parameter can
473      *                 only be null or an empty string, indicating the current device.
474      * @param enabled Specifies whether to allow the current application to publish notifications. The value
475      *                true indicates that notifications are allowed, and the value false indicates that
476      *                notifications are not allowed.
477      * @return Returns set notifications enabled for default bundle result.
478      */
479     static ErrCode SetNotificationsEnabledForDefaultBundle(const std::string &deviceId, bool enabled);
480 
481     /**
482      * @brief Sets whether to allow a specified application to publish notifications on a specified device. The caller
483      * must have system permissions to call this method.
484      *
485      * @param bundleOption Indicates the bundle name and uid of the application.
486      * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only
487      *                 be null or an empty string, indicating the current device.
488      * @param enabled Specifies whether to allow the given application to publish notifications. The value
489      *                true indicates that notifications are allowed, and the value false indicates that notifications
490      *                are not allowed.
491      * @return Returns set notifications enabled for specified bundle result.
492      */
493     static ErrCode SetNotificationsEnabledForSpecifiedBundle(
494         const NotificationBundleOption &bundleOption, std::string &deviceId, bool enabled);
495 
496     /**
497      * @brief Sets whether to allow a specified application to show badge.
498      *
499      * @param bundleOption Indicates the bundle name and uid of the application.
500      * @param enabled Specifies whether to allow the given application to show badge.
501      * @return Returns set result.
502      */
503     static ErrCode SetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool enabled);
504 
505     /**
506      * @brief Obtains the flag that whether to allow a specified application to show badge.
507      *
508      * @param bundleOption Indicates the bundle name and uid of the application.
509      * @param enabled Specifies whether to allow the given application to show badge.
510      * @return Returns get result.
511      */
512     static ErrCode GetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool &enabled);
513 
514     /**
515      * @brief Obtains the flag that whether to allow the current application to show badge.
516      *
517      * @param enabled Specifies whether to allow the given application to show badge.
518      * @return Returns get result.
519      */
520     static ErrCode GetShowBadgeEnabled(bool &enabled);
521 
522     /**
523      * @brief Cancel the notification of the specified group of this application.
524      *
525      * @param groupName Indicates the specified group name.
526      * @return Returns cancel group result.
527      */
528     static ErrCode CancelGroup(const std::string &groupName);
529 
530     /**
531      * @brief Remove the notification of the specified group of the specified application.
532      *
533      * @param bundleOption Indicates the bundle name and uid of the specified application.
534      * @param groupName Indicates the specified group name.
535      * @return Returns remove group by bundle result.
536      */
537     static ErrCode RemoveGroupByBundle(const NotificationBundleOption &bundleOption, const std::string &groupName);
538 
539     /**
540      * @brief Sets the do not disturb time.
541      * @note Your application must have system signature to call this method.
542      *
543      * @param doNotDisturbDate Indicates the do not disturb time to set.
544      * @return Returns set do not disturb time result.
545      */
546     static ErrCode SetDoNotDisturbDate(const NotificationDoNotDisturbDate &doNotDisturbDate);
547 
548     /**
549      * @brief Obtains the do not disturb time.
550      * @note Your application must have system signature to call this method.
551      *
552      * @param doNotDisturbDate Indicates the do not disturb time to get.
553      * @return Returns set do not disturb time result.
554      */
555     static ErrCode GetDoNotDisturbDate(NotificationDoNotDisturbDate &doNotDisturbDate);
556 
557     /**
558      * @brief Obtains the flag that whether to support do not disturb mode.
559      *
560      * @param doesSupport Specifies whether to support do not disturb mode.
561      * @return Returns check result.
562      */
563     static ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport);
564 
565     /**
566      * @brief Check if the device supports distributed notification.
567      *
568      * @param enabled True if the device supports distributed notification; false otherwise.
569      * @return Returns is distributed enabled result.
570      */
571     static ErrCode IsDistributedEnabled(bool &enabled);
572 
573     /**
574      * @brief Set whether the device supports distributed notifications.
575      *
576      * @param enable Specifies whether to enable the device to support distributed notification.
577      *               The value true indicates that the device is enabled to support distributed notifications, and
578      *               the value false indicates that the device is forbidden to support distributed notifications.
579      * @return Returns enable distributed result.
580      */
581     static ErrCode EnableDistributed(const bool enabled);
582 
583     /**
584      * @brief Set whether an application supports distributed notifications.
585      *
586      * @param bundleOption Indicates the bundle name and uid of an application.
587      * @param enabled Specifies whether to enable an application to support distributed notification.
588      *                The value true indicates that the application is enabled to support distributed notifications,
589      *                and the value false indicates that the application is forbidden to support distributed
590      *                notifications.
591      * @return Returns enable distributed by bundle result.
592      */
593     static ErrCode EnableDistributedByBundle(const NotificationBundleOption &bundleOption, const bool enabled);
594 
595     /**
596      * @brief Set whether this application supports distributed notifications.
597      *
598      * @param enabled Specifies whether to enable this application to support distributed notification.
599      *                The value true indicates that this application is enabled to support distributed notifications,
600      *                and the value false indicates that this application is forbidden to support distributed
601      *                notifications.
602      * @return Returns enable distributed self result.
603      */
604     static ErrCode EnableDistributedSelf(const bool enabled);
605 
606     /**
607      * @brief Check whether an application supports distributed notifications.
608      *
609      * @param bundleOption Indicates the bundle name and uid of an application.
610      * @param enabled True if the application supports distributed notification; false otherwise.
611      * @return Returns is distributed enabled by bundle result.
612      */
613     static ErrCode IsDistributedEnableByBundle(const NotificationBundleOption &bundleOption, bool &enabled);
614 
615     /**
616      * @brief Obtains the device remind type.
617      * @note Your application must have system signature to call this method.
618      *
619      * @param remindType Indicates the device remind type to get.
620      * @return Returns get device reminder type result.
621      */
622     static ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType);
623 
624     /**
625      * @brief Publishes a continuous task notification.
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     static 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     static 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 Indicates whether is it a system supported template.
645      * @return Returns check result.
646      */
647     static ErrCode IsSupportTemplate(const std::string &templateName, bool &support);
648 
649     /**
650      * @brief Checks whether this application has permission to publish notifications under the user.
651      *
652      * @param userId Indicates the userId of the application.
653      * @param allowed True if the application has permissions; false otherwise.
654      * @return Returns get allowed result.
655      */
656     static ErrCode IsAllowedNotify(const int32_t &userId, bool &allowed);
657 
658     /**
659      * @brief Sets whether to allow all applications to publish notifications on a specified user.
660      * The caller must have system permissions to call this method.
661      *
662      * @param userId Indicates the ID of the user running the application.
663      * @param enabled Specifies whether to allow all applications to publish notifications. The value true
664      *                indicates that notifications are allowed, and the value false indicates that notifications
665      *                are not allowed.
666      * @return Returns set notifications enabled for all bundles result.
667      */
668     static ErrCode SetNotificationsEnabledForAllBundles(const int32_t &userId, bool enabled);
669 
670     /**
671      * @brief Removes notifications under specified user.
672      * @note Your application must have platform signature to use this method.
673      *
674      * @param userId Indicates the ID of user whose notifications are to be removed.
675      * @return Returns remove notification result.
676      */
677     static ErrCode RemoveNotifications(const int32_t &userId);
678 
679     /**
680      * @brief Sets the do not disturb time on a specified user.
681      * @note Your application must have system signature to call this method.
682      *
683      * @param userId Indicates the specific user.
684      * @param doNotDisturbDate Indicates the do not disturb time to set.
685      * @return Returns set do not disturb time result.
686      */
687     static ErrCode SetDoNotDisturbDate(const int32_t &userId, const NotificationDoNotDisturbDate &doNotDisturbDate);
688 
689     /**
690      * @brief Obtains the do not disturb time on a specified user.
691      * @note Your application must have system signature to call this method.
692      *
693      * @param userId Indicates the specific user.
694      * @param doNotDisturbDate Indicates the do not disturb time to get.
695      * @return Returns set do not disturb time result.
696      */
697     static ErrCode GetDoNotDisturbDate(const int32_t &userId, NotificationDoNotDisturbDate &doNotDisturbDate);
698 
699     /**
700      * Set whether the application slot is enabled.
701      *
702      * @param bundleOption Indicates the bundle name and uid of the application.
703      * @param slotType Indicates type of slot.
704      * @param enabled the type of slot enabled.
705      * @return Returns get slot number by bundle result.
706      */
707     static ErrCode SetEnabledForBundleSlot(
708         const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType, bool enabled);
709 
710     /**
711      * Obtains whether the application slot is enabled.
712      *
713      * @param bundleOption Indicates the bundle name and uid of the application.
714      * @param slotType Indicates type of slot.
715      * @param enabled the type of slot enabled to get.
716      * @return Returns get slot number by bundle result.
717      */
718     static ErrCode GetEnabledForBundleSlot(
719         const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType, bool &enabled);
720 
721     /**
722      * @brief Set whether to sync notifications to devices that do not have the app installed.
723      *
724      * @param userId Indicates the specific user.
725      * @param enabled Allow or disallow sync notifications.
726      * @return Returns set enabled result.
727      */
728     static ErrCode SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled);
729 
730     /**
731      * @brief Obtains whether to sync notifications to devices that do not have the app installed.
732      *
733      * @param userId Indicates the specific user.
734      * @param enabled Allow or disallow sync notifications.
735      * @return Returns get enabled result.
736      */
737     static ErrCode GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled);
738 
739     /**
740      * @brief Set badge number.
741      *
742      * @param badgeNumber The badge number.
743      * @return Returns set badge number result.
744      */
745     static ErrCode SetBadgeNumber(int32_t badgeNumber);
746 
747     /**
748      * @brief Register Push Callback.
749      *
750      * @param pushCallback push appliction's Callback.
751      * @return Returns register push callback result.
752      */
753     static ErrCode RegisterPushCallback(const sptr<IRemoteObject>& pushCallback);
754 
755     /**
756      * @brief Unregister Push Callback.
757      *
758      * @return Returns unregister push Callback result.
759      */
760     static ErrCode UnregisterPushCallback();
761 };
762 }  // namespace Notification
763 }  // namespace OHOS
764 
765 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_HELPER_H