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