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