1 /*
2  * Copyright (c) 2021-2024 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 "notification_do_not_disturb_profile.h"
24 #include "enabled_notification_callback_data.h"
25 #include "notification_request.h"
26 #include "notification_slot.h"
27 #include "notification_sorting_map.h"
28 #include "notification_subscriber.h"
29 #include "notification_local_live_view_subscriber.h"
30 #include "want_params.h"
31 #include <memory>
32 
33 namespace OHOS {
34 namespace Notification {
35 class NotificationHelper {
36 public:
37     /**
38      * @brief Creates a notification slot.
39      * @note You can call the NotificationRequest::SetSlotType(NotificationConstant::SlotType) method to bind the slot
40      * for publishing. A NotificationSlot instance cannot be used directly after being initialized. Instead, you have to
41      * call this method to create a notification slot and bind the slot ID to a NotificationRequest object so that the
42      * notification published can have all the characteristics set in the NotificationSlot. After a notification slot is
43      * created by using this method, only the name and description of the notification slot can be changed. Changes to
44      * the other attributes, such as the vibration status and notification tone, will no longer take effect.
45      *
46      * @param slot Indicates the notification slot to be created, which is set by NotificationSlot.
47      *             This parameter must be specified.
48      * @return Returns add notification slot result.
49      */
50     static ErrCode AddNotificationSlot(const NotificationSlot &slot);
51 
52     /**
53      * @brief Adds a notification slot by type.
54      *
55      * @param slotType Indicates the notification slot type to be added.
56      * @return Returns add notification slot result.
57      */
58     static ErrCode AddSlotByType(const NotificationConstant::SlotType &slotType);
59 
60     /**
61      * @brief Creates multiple notification slots.
62      *
63      * @param slots Indicates the notification slots to create.
64      * @return Returns add notification slots result.
65      */
66     static ErrCode AddNotificationSlots(const std::vector<NotificationSlot> &slots);
67 
68     /**
69      * @brief Deletes a created notification slot based on the slot ID.
70      *
71      * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot
72      *                 This parameter must be specified.
73      * @return Returns remove notification slot result.
74      */
75     static ErrCode RemoveNotificationSlot(const NotificationConstant::SlotType &slotType);
76 
77     /**
78      * @brief Deletes all notification slots.
79      *
80      * @return Returns remove all slots result.
81      */
82     static ErrCode RemoveAllSlots();
83 
84     /**
85      * @brief Queries a created notification slot.
86      *
87      * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This
88      *        parameter must be specified.
89      * @param slot Indicates the created NotificationSlot.
90      * @return Returns the get notification slot result.
91      */
92     static ErrCode GetNotificationSlot(const NotificationConstant::SlotType &slotType, sptr<NotificationSlot> &slot);
93 
94     /**
95      * @brief Obtains all notification slots of this application.
96      * @param slots Indicates the created NotificationSlot.
97      * @return Returns all notification slots of this application.
98      */
99     static ErrCode GetNotificationSlots(std::vector<sptr<NotificationSlot>> &slots);
100 
101     /**
102      * @brief Obtains number of slot.
103      *
104      * @param bundleOption Indicates the bundle name and uid of the application.
105      * @param num Indicates number of slot.
106      * @return Returns get slot number by bundle result.
107      */
108     static ErrCode GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, uint64_t &num);
109 
110     /**
111      * @brief Obtains slotflags of bundle.
112      *
113      * @param bundleOption Indicates the bundle name and uid of the application.
114      * @param slotFlags Indicates slotFlags of bundle.
115      * @return Returns get slotFlags by bundle result.
116      */
117     static ErrCode GetNotificationSlotFlagsAsBundle(const NotificationBundleOption &bundleOption, uint32_t &slotFlags);
118 
119     /**
120      * @brief set slotflags of bundle.
121      *
122      * @param bundleOption Indicates the bundle name and uid of the application.
123      * @param slotFlags Indicates slotFlags of bundle.
124      * @return Returns get slotFlags by bundle result.
125      */
126     static ErrCode SetNotificationSlotFlagsAsBundle(const NotificationBundleOption &bundleOption, uint32_t slotFlags);
127 
128     /**
129      * @brief Publishes a notification.
130      * @note If a notification with the same ID has been published by the current application and has not been deleted,
131      * this method will update the notification.
132      *
133      * @param request Indicates the NotificationRequest object for setting the notification content.
134      *                This parameter must be specified.
135      * @return Returns publish notification result.
136      */
137     static ErrCode PublishNotification(const NotificationRequest &request);
138 
139     /**
140      * @brief Publishes a notification.
141      * @note If a notification with the same ID has been published by the current application and has not been deleted,
142      * this method will update the notification.
143      *
144      * @param request Indicates the NotificationRequest object for setting the notification content.
145      *                This parameter must be specified.
146      * @return Returns publish notification result.
147      */
148     static ErrCode PublishNotificationForIndirectProxy(const NotificationRequest &request);
149 
150     /**
151      * @brief Publishes a notification with a specified label.
152      * @note If a notification with the same ID has been published by the current application and has not been deleted,
153      *       this method will update the notification.
154      *
155      * @param label Indicates the label of the notification to publish.
156      * @param request Indicates the NotificationRequest object for setting the notification content.
157      *                This parameter must be specified.
158      * @return Returns publish notification result.
159      */
160     static ErrCode PublishNotification(const std::string &label, const NotificationRequest &request);
161 
162     /**
163      * @brief Cancels a published notification.
164      *
165      * @param notificationId Indicates the unique notification ID in the application.
166      *                       The value must be the ID of a published notification.
167      *                       Otherwise, this method does not take effect.
168      * @return Returns cancel notification result.
169      */
170     static ErrCode CancelNotification(int32_t notificationId);
171 
172     /**
173      * @brief Cancels a published notification matching the specified label and notificationId.
174      *
175      * @param label Indicates the label of the notification to cancel.
176      * @param notificationId Indicates the ID of the notification to cancel.
177      * @return Returns cancel notification result.
178      */
179     static ErrCode CancelNotification(const std::string &label, int32_t notificationId);
180 
181     /**
182      * @brief Cancels all the published notifications.
183      *
184      * @note To cancel a specified notification, see CancelNotification(int32_t).
185      * @return Returns cancel all notifications result.
186      */
187     static ErrCode CancelAllNotifications();
188 
189     /**
190      * @brief Cancels a published agent notification.
191      *
192      * @param notificationId Indicates the unique notification ID in the application.
193      *                       The value must be the ID of a published notification.
194      *                       Otherwise, this method does not take effect.
195      * @param representativeBundle Indicates the name of application bundle your application is representing.
196      * @param userId Indicates the specific user.
197      * @return Returns cancel notification result.
198      */
199     static ErrCode CancelAsBundle(int32_t notificationId, const std::string &representativeBundle, int32_t userId);
200 
201     /**
202      * @brief Cancels a published agent notification.
203      *
204      * @param bundleOption Indicates the bundle of application bundle your application is representing.
205      * @param notificationId Indicates the unique notification ID in the application.
206      *                       The value must be the ID of a published notification.
207      *                       Otherwise, this method does not take effect.
208      * @return Returns cancel notification result.
209      */
210     static ErrCode CancelAsBundle(const NotificationBundleOption &bundleOption, int32_t notificationId);
211 
212     /**
213      * @brief Obtains the number of active notifications of the current application in the system.
214      *
215      * @param nums Indicates the number of active notifications of the current application.
216      * @return Returns get active notification nums result.
217      */
218     static ErrCode GetActiveNotificationNums(uint64_t &num);
219 
220     /**
221      * @brief Obtains active notifications of the current application in the system.
222      *
223      * @param  request Indicates active NotificationRequest objects of the current application.
224      * @return Returns get active notifications result.
225      */
226     static ErrCode GetActiveNotifications(std::vector<sptr<NotificationRequest>> &request);
227 
228     /**
229      * @brief Allows another application to act as an agent to publish notifications in the name of your application
230      * bundle.
231      *
232      * @param agent Indicates the name of the application bundle that can publish notifications for your application.
233      * @return Returns set notification agent result.
234      */
235     static ErrCode SetNotificationAgent(const std::string &agent);
236 
237     /**
238      * @brief Obtains the name of the application bundle that can publish notifications in the name of your application.
239      *
240      * @param agent Indicates the name of the application bundle that can publish notifications for your application if
241      * any; returns null otherwise.
242      * @return Returns get notification agent result.
243      */
244     static ErrCode GetNotificationAgent(std::string &agent);
245 
246     /**
247      * @brief Checks whether your application has permission to publish notifications by calling
248      * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the
249      * given representativeBundle.
250      *
251      * @param representativeBundle Indicates the name of application bundle your application is representing.
252      * @param canPublish Indicates whether your application has permission to publish notifications.
253      * @return Returns can publish notification as bundle result.
254      */
255     static ErrCode CanPublishNotificationAsBundle(const std::string &representativeBundle, bool &canPublish);
256 
257     /**
258      * @brief Publishes a notification in the name of a specified application bundle.
259      * @note If the notification to be published has the same ID as a published notification that has not been canceled,
260      * the existing notification will be replaced by the new one.
261      *
262      * @param request Indicates the NotificationRequest object for setting the notification content.
263      *                This parameter must be specified.
264      * @param representativeBundle Indicates the name of the application bundle that allows your application to publish
265      *                             notifications for it by calling setNotificationAgent.
266      * @return Returns publish notification as bundle result.
267      */
268     static ErrCode PublishNotificationAsBundle(
269         const std::string &representativeBundle, const NotificationRequest &request);
270 
271     /**
272      * @brief Sets the number of active notifications of the current application as the number to be displayed on the
273      * notification badge.
274      *
275      * @return Returns set notification badge num result.
276      */
277     static ErrCode SetNotificationBadgeNum();
278 
279     /**
280      * @brief Sets the number to be displayed on the notification badge of the application.
281      *
282      * @param num Indicates the number to display. A negative number indicates that the badge setting remains unchanged.
283      *            The value 0 indicates that no badge is displayed on the application icon.
284      *            If the value is greater than 99, 99+ will be displayed.
285      * @return Returns set notification badge num result.
286      */
287     static ErrCode SetNotificationBadgeNum(int32_t num);
288 
289     /**
290      * @brief Checks whether this application has permission to publish notifications. The caller must have
291      * system permissions to call this method.
292      *
293      * @param  allowed True if this application has the permission; returns false otherwise
294      * @return Returns is allowed notify result.
295      */
296     static ErrCode IsAllowedNotify(bool &allowed);
297 
298     /**
299      * @brief Checks whether this application has permission to publish notifications.
300      *
301      * @param  allowed True if this application has the permission; returns false otherwise
302      * @return Returns is allowed notify result.
303      */
304     static ErrCode IsAllowedNotifySelf(bool &allowed);
305 
306     /**
307      * @brief Checks whether this application can pop enable notification dialog.
308      *
309      * @param  canPop True if can pop enable notification dialog
310      * @return Returns is canPop result.
311      */
312     static ErrCode CanPopEnableNotificationDialog(sptr<AnsDialogHostClient> &hostClient,
313         bool &canPop, std::string &bundleName);
314 
315     /**
316      * @brief remove enable notification dialog.
317      *
318      * @return Returns remove dialog result.
319      */
320     static ErrCode RemoveEnableNotificationDialog();
321 
322     /**
323      * @brief Allow the current application to publish notifications on a specified device.
324      *
325      * @param deviceId Indicates the ID of the device running the application. At present, this parameter can
326      *                 only be null or an empty string, indicating the current device.
327      * @return Returns set notifications enabled for default bundle result.
328      */
329     static ErrCode RequestEnableNotification(std::string &deviceId,
330         sptr<AnsDialogHostClient> &hostClient,
331         sptr<IRemoteObject> &callerToken);
332 
333     /**
334      * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy.
335      *
336      * @param hasPermission True if this application is suspended; false otherwise.
337      * @return Returns has notification policy access permission.
338      */
339     static ErrCode HasNotificationPolicyAccessPermission(bool &hasPermission);
340 
341     /**
342      * @brief Obtains the importance level of this application.
343      *
344      * @param  importance Indicates the importance level of this application, which can be LEVEL_NONE,
345                LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED.
346      * @return Returns get bundle importance result
347      */
348     static ErrCode GetBundleImportance(NotificationSlot::NotificationLevel &importance);
349 
350     /**
351      * @brief Subscribes to notifications from all applications. This method can be called only by applications
352      * with required system permissions.
353      * @note  To subscribe to a notification, inherit the {NotificationSubscriber} class, override its
354      *        callback methods and create a subscriber. The subscriber will be used as a parameter of this method.
355      *        After the notification is published, subscribers that meet the filter criteria can receive the
356      *        notification. To subscribe to notifications published only by specified sources, for example,
357      *        notifications from certain applications,
358      *        call the {SubscribeNotification(NotificationSubscriber, NotificationSubscribeInfo)} method.
359      * @deprecated This function is deprecated,
360      *             use 'SubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber)'.
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      * @brief Subscribes to notifications from all applications. This method can be called only by applications
369      * with required system permissions.
370      * @note  To subscribe to a notification, inherit the {NotificationSubscriber} class, override its
371      *        callback methods and create a subscriber. The subscriber will be used as a parameter of this method.
372      *        After the notification is published, subscribers that meet the filter criteria can receive the
373      *        notification. To subscribe to notifications published only by specified sources, for example,
374      *        notifications from certain applications,
375      *        call the {SubscribeNotification(NotificationSubscriber, NotificationSubscribeInfo)} method.
376      *
377      * @param subscriber Indicates the {NotificationSubscriber} to receive notifications.
378      *                   This parameter must be specified.
379      * @return Returns unsubscribe notification result.
380      */
381     static ErrCode SubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber);
382 
383     /**
384      * @brief Subscribes to notifications from the appliaction self.
385      * @note  To subscribe to a notification, inherit the {NotificationSubscriber} class, override its
386      *        callback methods and create a subscriber. The subscriber will be used as a parameter of this method.
387      *        After the notification is published, subscribers that meet the filter criteria can receive the
388      *        notification.
389      * @deprecated This function is deprecated,
390      *             use 'SubscribeNotificationSelf(const std::shared_ptr<NotificationSubscriber> &subscriber)'.
391      * @param subscriber Indicates the {NotificationSubscriber} to receive notifications.
392      *                   This parameter must be specified.
393      * @return Returns unsubscribe notification result.
394      */
395     static ErrCode SubscribeNotificationSelf(const NotificationSubscriber &subscriber);
396 
397     /**
398      * @brief Subscribes to notifications from the appliaction self.
399      * @note  To subscribe to a notification, inherit the {NotificationSubscriber} class, override its
400      *        callback methods and create a subscriber. The subscriber will be used as a parameter of this method.
401      *        After the notification is published, subscribers that meet the filter criteria can receive the
402      *        notification.
403      *
404      * @param subscriber Indicates the {NotificationSubscriber} to receive notifications.
405      *                   This parameter must be specified.
406      * @return Returns unsubscribe notification result.
407      */
408     static ErrCode SubscribeNotificationSelf(const std::shared_ptr<NotificationSubscriber> &subscriber);
409 
410     /**
411      * @brief Subscribes to all notifications based on the filtering criteria. This method can be called only
412      * by applications with required system permissions.
413      * @note  After {subscribeInfo} is specified, a subscriber receives only the notifications that
414      *        meet the filter criteria specified by {subscribeInfo}.
415      *        To subscribe to a notification, inherit the {NotificationSubscriber} class, override its
416      *        callback methods and create a subscriber. The subscriber will be used as a parameter of this method.
417      *        After the notification is published, subscribers that meet the filter criteria can receive the
418      *        notification. To subscribe to and receive all notifications, call the
419      *        {SubscribeNotification(NotificationSubscriber)} method.
420      * @deprecated This function is deprecated,
421      *             use 'SubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber,
422      *             const sptr<NotificationSubscribeInfo> &subscribeInfo)'.
423      * @param subscriber Indicates the subscribers to receive notifications. This parameter must be specified.
424      *                   For details, see {NotificationSubscriber}.
425      * @param subscribeInfo Indicates the filters for specified notification sources, including application name,
426      *                      user ID, or device name. This parameter is optional.
427      * @return Returns subscribe notification result.
428      */
429     static ErrCode SubscribeNotification(
430         const NotificationSubscriber &subscriber, const NotificationSubscribeInfo &subscribeInfo);
431 
432     /**
433      * @brief Subscribes to all notifications based on the filtering criteria. This method can be called only
434      * by applications with required system permissions.
435      * @note  After {subscribeInfo} is specified, a subscriber receives only the notifications that
436      *        meet the filter criteria specified by {subscribeInfo}.
437      *        To subscribe to a notification, inherit the {NotificationSubscriber} class, override its
438      *        callback methods and create a subscriber. The subscriber will be used as a parameter of this method.
439      *        After the notification is published, subscribers that meet the filter criteria can receive the
440      *        notification. To subscribe to and receive all notifications, call the
441      *        {SubscribeNotification(NotificationSubscriber)} method.
442      *
443      * @param subscriber Indicates the subscribers to receive notifications. This parameter must be specified.
444      *                   For details, see {NotificationSubscriber}.
445      * @param subscribeInfo Indicates the filters for specified notification sources, including application name,
446      *                      user ID, or device name. This parameter is optional.
447      * @return Returns subscribe notification result.
448      */
449     static ErrCode SubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber,
450         const sptr<NotificationSubscribeInfo> &subscribeInfo);
451 
452     /**
453      * @brief Subscribes the localLiveView button click. This method can be called only
454      * by applications with required system permissions.
455      * @note  To subscribe to a button click, inherit the {NotificationLocalLiveViewSubscriber} class, override its
456      *        callback methods and create a subscriber. The subscriber will be used as a parameter of this method.
457      *        After the button is clicked, subscribers that meet the filter criteria can receive the response
458      *
459      * @param subscriber Indicates the subscribers to receive notifications. This parameter must be specified.
460      *                   For details, see {NotificationSubscriber}.
461      * @return Returns subscribe notification result.
462      */
463     static ErrCode SubscribeLocalLiveViewNotification(const NotificationLocalLiveViewSubscriber &subscriber,
464         const bool isNative = true);
465 
466     /**
467      * @brief Unsubscribes from all notifications. This method can be called only by applications with required
468      * system permissions.
469      * @note Generally, you subscribe to a notification by calling the
470      *       {SubscribeNotification(NotificationSubscriber)} method. If you do not want your application
471      *       to receive a notification any longer, unsubscribe from that notification using this method.
472      *       You can unsubscribe from only those notifications that your application has subscribed to.
473      *        To unsubscribe from notifications published only by specified sources, for example,
474      *       notifications from certain applications, call the
475      *       {UnSubscribeNotification(NotificationSubscriber, NotificationSubscribeInfo)} method.
476      * @deprecated This function is deprecated,
477      *             use 'UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber)'.
478      * @param subscriber Indicates the {NotificationSubscriber} to receive notifications.
479      *                   This parameter must be specified.
480      * @return Returns unsubscribe notification result.
481      */
482     static ErrCode UnSubscribeNotification(NotificationSubscriber &subscriber);
483 
484     /**
485      * @brief Unsubscribes from all notifications. This method can be called only by applications with required
486      * system permissions.
487      * @note Generally, you subscribe to a notification by calling the
488      *       {SubscribeNotification(NotificationSubscriber)} method. If you do not want your application
489      *       to receive a notification any longer, unsubscribe from that notification using this method.
490      *       You can unsubscribe from only those notifications that your application has subscribed to.
491      *        To unsubscribe from notifications published only by specified sources, for example,
492      *       notifications from certain applications, call the
493      *       {UnSubscribeNotification(NotificationSubscriber, NotificationSubscribeInfo)} method.
494      *
495      * @param subscriber Indicates the {NotificationSubscriber} to receive notifications.
496      *                   This parameter must be specified.
497      * @return Returns unsubscribe notification result.
498      */
499     static ErrCode UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber);
500 
501     /**
502      * @brief Unsubscribes from all notifications based on the filtering criteria. This method can be called
503      * only by applications with required system permissions.
504      * @note A subscriber will no longer receive the notifications from specified notification sources.
505      * @deprecated This function is deprecated,
506      *             use 'UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber,
507      *             const sptr<NotificationSubscribeInfo> &subscribeInfo)'.
508      * @param subscriber Indicates the {NotificationSubscriber} to receive notifications.
509      *                   This parameter must be specified.
510      * @param subscribeInfo Indicates the filters for , including application name,
511      *                      user ID, or device name. This parameter is optional.
512      * @return Returns unsubscribe notification result.
513      */
514     static ErrCode UnSubscribeNotification(NotificationSubscriber &subscriber, NotificationSubscribeInfo subscribeInfo);
515 
516     /**
517      * @brief Unsubscribes from all notifications based on the filtering criteria. This method can be called
518      * only by applications with required system permissions.
519      * @note A subscriber will no longer receive the notifications from specified notification sources.
520      *
521      * @param subscriber Indicates the {NotificationSubscriber} to receive notifications.
522      *                   This parameter must be specified.
523      * @param subscribeInfo Indicates the filters for , including application name,
524      *                      user ID, or device name. This parameter is optional.
525      * @return Returns unsubscribe notification result.
526      */
527     static ErrCode UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber,
528         const sptr<NotificationSubscribeInfo> &subscribeInfo);
529 
530     /**
531      * @brief Trigger the local live view after the button has been clicked.
532      * @note Your application must have platform signature to use this method.
533      *
534      * @param bundleOption Indicates the bundle name and uid of the application whose notifications has been clicked.
535      * @param notificationId Indicates the id of the notification.
536      * @param buttonOption Indicates which button has been clicked.
537      * @return Returns trigger localLiveView result.
538      */
539     static ErrCode TriggerLocalLiveView(const NotificationBundleOption &bundleOption,
540         const int32_t notificationId, const NotificationButtonOption &buttonOption);
541 
542     /**
543      * @brief Removes a specified removable notification of other applications.
544      * @note Your application must have platform signature to use this method.
545      *
546      * @param key Indicates the key of the notification to remove.
547      * @param removeReason Indicates the reason of remove notification.
548      * @return Returns remove notification result.
549      */
550     static ErrCode RemoveNotification(const std::string &key, int32_t removeReason);
551 
552     /**
553      * @brief Removes a specified removable notification of other applications.
554      * @note Your application must have platform signature to use this method.
555      *
556      * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed.
557      * @param notificationId Indicates the id of the notification to remove.
558      * @param label Indicates the label of the notification to remove.
559      * @param removeReason Indicates the reason of remove notification.
560      * @return Returns remove notification result.
561      */
562     static ErrCode RemoveNotification(const NotificationBundleOption &bundleOption,
563         const int32_t notificationId, const std::string &label, int32_t removeReason);
564 
565     /**
566      * @brief Removes a specified removable notification of other applications.
567      * @note Your application must have platform signature to use this method.
568      *
569      * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed.
570      * @return Returns remove notification result.
571      */
572     static ErrCode RemoveAllNotifications(const NotificationBundleOption &bundleOption);
573 
574     static ErrCode RemoveNotifications(const std::vector<std::string> hashcodes, int32_t removeReason);
575 
576     /**
577      * @brief Removes all removable notifications of a specified bundle.
578      * @note Your application must have platform signature to use this method.
579      *
580      * @param bundleOption Indicates the bundle name and uid of the application whose notifications are to be removed.
581      * @return Returns remove notifications result.
582      */
583     static ErrCode RemoveNotificationsByBundle(const NotificationBundleOption &bundleOption);
584 
585     /**
586      * @brief Removes all removable notifications in the system.
587      * @note Your application must have platform signature to use this method.
588      * @return Returns remove notifications result.
589      */
590     static ErrCode RemoveNotifications();
591 
592     /**
593      * @brief Obtains all notification slots belonging to the specified bundle.
594      *
595      * @param bundleOption Indicates the bundle name and uid of the application.
596      * @param slots Indicates a list of notification slots.
597      * @return Returns get notification slots for bundle result.
598      */
599     static ErrCode GetNotificationSlotsForBundle(
600         const NotificationBundleOption &bundleOption, std::vector<sptr<NotificationSlot>> &slots);
601 
602     /**
603      * @brief Obtains all notification slots belonging to the specified bundle.
604      *
605      * @param bundleOption Indicates the bundle name and uid of the application.
606      * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot.
607      * @param slot Indicates a notification slot.
608      * @return Returns get notification slots for bundle result.
609      */
610     static ErrCode GetNotificationSlotForBundle(
611         const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType,
612         sptr<NotificationSlot> &slot);
613 
614     /**
615      * @brief Update all notification slots for the specified bundle.
616      *
617      * @param bundleOption Indicates the bundle name and uid of the application.
618      * @param slots Indicates a list of new notification slots.
619      * @return Returns update notification slots for bundle result.
620      */
621     static ErrCode UpdateNotificationSlots(
622         const NotificationBundleOption &bundleOption, const std::vector<sptr<NotificationSlot>> &slots);
623 
624     /**
625      * @brief Obtains all active notifications in the current system. The caller must have system permissions to
626      * call this method.
627      *
628      * @param notification Indicates all active notifications of this application.
629      * @return Returns get all active notifications
630      */
631     static ErrCode GetAllActiveNotifications(std::vector<sptr<Notification>> &notification);
632 
633     /**
634      * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method
635      * to obtain particular active notifications, you must have received the notifications and obtained the key
636      * via {Notification::GetKey()}.
637      *
638      * @param key Indicates the key array for querying corresponding active notifications.
639      *            If this parameter is null, this method returns all active notifications in the system.
640      * @param notification Indicates the set of active notifications corresponding to the specified key.
641      * @return Returns get all active notifications.
642      */
643     static ErrCode GetAllActiveNotifications(
644         const std::vector<std::string> key, std::vector<sptr<Notification>> &notification);
645 
646     /**
647      * @brief Obtains the active notifications by filter.
648      * @param filter
649      * @param extraInfo
650      * @return
651      */
652     static ErrCode GetActiveNotificationByFilter(
653         const LiveViewFilter &filter, sptr<NotificationRequest> &request);
654 
655     /**
656      * @brief Checks whether a specified application has the permission to publish notifications. If bundle specifies
657      * the current application, no permission is required for calling this method. If bundle specifies another
658      * application, the caller must have system permissions.
659      *
660      * @param bundleOption Indicates the bundle name and uid of the application.
661      * @param allowed True if the application has permissions; false otherwise.
662      * @return Returns is allowed notify result.
663      */
664     static ErrCode IsAllowedNotify(const NotificationBundleOption &bundleOption, bool &allowed);
665 
666     /**
667      * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must
668      * have system permissions to call this method.
669      *
670      * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only
671      *                 be null or an empty string, indicating the current device.
672      * @param enabled Specifies whether to allow all applications to publish notifications. The value true
673      *                indicates that notifications are allowed, and the value false indicates that notifications
674      *                are not allowed.
675      * @return Returns set notifications enabled for all bundles result.
676      */
677     static ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled);
678 
679     /**
680      * @brief Sets whether to allow the current application to publish notifications on a specified device. The caller
681      * must have system permissions to call this method.
682      *
683      * @param deviceId Indicates the ID of the device running the application. At present, this parameter can
684      *                 only be null or an empty string, indicating the current device.
685      * @param enabled Specifies whether to allow the current application to publish notifications. The value
686      *                true indicates that notifications are allowed, and the value false indicates that
687      *                notifications are not allowed.
688      * @return Returns set notifications enabled for default bundle result.
689      */
690     static ErrCode SetNotificationsEnabledForDefaultBundle(const std::string &deviceId, bool enabled);
691 
692     /**
693      * @brief Sets whether to allow a specified application to publish notifications on a specified device. The caller
694      * must have system permissions to call this method.
695      *
696      * @param bundleOption Indicates the bundle name and uid of the application.
697      * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only
698      *                 be null or an empty string, indicating the current device.
699      * @param enabled Specifies whether to allow the given application to publish notifications. The value
700      *                true indicates that notifications are allowed, and the value false indicates that notifications
701      *                are not allowed.
702      * @return Returns set notifications enabled for specified bundle result.
703      */
704     static ErrCode SetNotificationsEnabledForSpecifiedBundle(
705         const NotificationBundleOption &bundleOption, std::string &deviceId, bool enabled);
706 
707     /**
708      * @brief Sets whether to allow a specified application to show badge.
709      *
710      * @param bundleOption Indicates the bundle name and uid of the application.
711      * @param enabled Specifies whether to allow the given application to show badge.
712      * @return Returns set result.
713      */
714     static ErrCode SetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool enabled);
715 
716     /**
717      * @brief Obtains the flag that whether to allow a specified application to show badge.
718      *
719      * @param bundleOption Indicates the bundle name and uid of the application.
720      * @param enabled Specifies whether to allow the given application to show badge.
721      * @return Returns get result.
722      */
723     static ErrCode GetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool &enabled);
724 
725     /**
726      * @brief Obtains the flag that whether to allow the current application to show badge.
727      *
728      * @param enabled Specifies whether to allow the given application to show badge.
729      * @return Returns get result.
730      */
731     static ErrCode GetShowBadgeEnabled(bool &enabled);
732 
733     /**
734      * @brief Cancel the notification of the specified group of this application.
735      *
736      * @param groupName Indicates the specified group name.
737      * @return Returns cancel group result.
738      */
739     static ErrCode CancelGroup(const std::string &groupName);
740 
741     /**
742      * @brief Remove the notification of the specified group of the specified application.
743      *
744      * @param bundleOption Indicates the bundle name and uid of the specified application.
745      * @param groupName Indicates the specified group name.
746      * @return Returns remove group by bundle result.
747      */
748     static ErrCode RemoveGroupByBundle(const NotificationBundleOption &bundleOption, const std::string &groupName);
749 
750     /**
751      * @brief Sets the do not disturb time.
752      * @note Your application must have system signature to call this method.
753      *
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 NotificationDoNotDisturbDate &doNotDisturbDate);
758 
759     /**
760      * @brief Obtains the do not disturb time.
761      * @note Your application must have system signature to call this method.
762      *
763      * @param doNotDisturbDate Indicates the do not disturb time to get.
764      * @return Returns set do not disturb time result.
765      */
766     static ErrCode GetDoNotDisturbDate(NotificationDoNotDisturbDate &doNotDisturbDate);
767 
768     /**
769      * @brief Obtains the flag that whether to support do not disturb mode.
770      *
771      * @param doesSupport Specifies whether to support do not disturb mode.
772      * @return Returns check result.
773      */
774     static ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport);
775 
776     /**
777      * @brief Is coming call need silent in do not disturb mode.
778      *
779      * @param phoneNumber the calling format number.
780      * @return Returns silent in do not disturb mode.
781      */
782     static ErrCode IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType);
783 
784     /**
785      * @brief Check if the device supports distributed notification.
786      *
787      * @param enabled True if the device supports distributed notification; false otherwise.
788      * @return Returns is distributed enabled result.
789      */
790     static ErrCode IsDistributedEnabled(bool &enabled);
791 
792     /**
793      * @brief Set whether the device supports distributed notifications.
794      *
795      * @param enable Specifies whether to enable the device to support distributed notification.
796      *               The value true indicates that the device is enabled to support distributed notifications, and
797      *               the value false indicates that the device is forbidden to support distributed notifications.
798      * @return Returns enable distributed result.
799      */
800     static ErrCode EnableDistributed(const bool enabled);
801 
802     /**
803      * @brief Set whether an application supports distributed notifications.
804      *
805      * @param bundleOption Indicates the bundle name and uid of an application.
806      * @param enabled Specifies whether to enable an application to support distributed notification.
807      *                The value true indicates that the application is enabled to support distributed notifications,
808      *                and the value false indicates that the application is forbidden to support distributed
809      *                notifications.
810      * @return Returns enable distributed by bundle result.
811      */
812     static ErrCode EnableDistributedByBundle(const NotificationBundleOption &bundleOption, const bool enabled);
813 
814     /**
815      * @brief Set whether this application supports distributed notifications.
816      *
817      * @param enabled Specifies whether to enable this application to support distributed notification.
818      *                The value true indicates that this application is enabled to support distributed notifications,
819      *                and the value false indicates that this application is forbidden to support distributed
820      *                notifications.
821      * @return Returns enable distributed self result.
822      */
823     static ErrCode EnableDistributedSelf(const bool enabled);
824 
825     /**
826      * @brief Check whether an application supports distributed notifications.
827      *
828      * @param bundleOption Indicates the bundle name and uid of an application.
829      * @param enabled True if the application supports distributed notification; false otherwise.
830      * @return Returns is distributed enabled by bundle result.
831      */
832     static ErrCode IsDistributedEnableByBundle(const NotificationBundleOption &bundleOption, bool &enabled);
833 
834     /**
835      * @brief Obtains the device remind type.
836      * @note Your application must have system signature to call this method.
837      *
838      * @param remindType Indicates the device remind type to get.
839      * @return Returns get device reminder type result.
840      */
841     static ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType);
842 
843     /**
844      * @brief Publishes a continuous task notification.
845      * @param request Indicates the NotificationRequest object for setting the notification content.
846      *                This parameter must be specified.
847      * @return Returns publish continuous task notification result.
848      */
849     static ErrCode PublishContinuousTaskNotification(const NotificationRequest &request);
850 
851     /**
852      * @brief Cancels a published continuous task notification matching the specified label and notificationId.
853      *
854      * @param label Indicates the label of the continuous task notification to cancel.
855      * @param notificationId Indicates the ID of the continuous task notification to cancel.
856      * @return Returns cancel continuous task notification result.
857      */
858     static ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId);
859 
860     /**
861      * @brief Obtains whether the template is supported by the system.
862      *
863      * @param support Indicates whether is it a system supported template.
864      * @return Returns check result.
865      */
866     static ErrCode IsSupportTemplate(const std::string &templateName, bool &support);
867 
868     /**
869      * @brief Checks whether this application has permission to publish notifications under the user.
870      *
871      * @param userId Indicates the userId of the application.
872      * @param allowed True if the application has permissions; false otherwise.
873      * @return Returns get allowed result.
874      */
875     static ErrCode IsAllowedNotify(const int32_t &userId, bool &allowed);
876 
877     /**
878      * @brief Sets whether to allow all applications to publish notifications on a specified user.
879      * The caller must have system permissions to call this method.
880      *
881      * @param userId Indicates the ID of the user running the application.
882      * @param enabled Specifies whether to allow all applications to publish notifications. The value true
883      *                indicates that notifications are allowed, and the value false indicates that notifications
884      *                are not allowed.
885      * @return Returns set notifications enabled for all bundles result.
886      */
887     static ErrCode SetNotificationsEnabledForAllBundles(const int32_t &userId, bool enabled);
888 
889     /**
890      * @brief Removes notifications under specified user.
891      * @note Your application must have platform signature to use this method.
892      *
893      * @param userId Indicates the ID of user whose notifications are to be removed.
894      * @return Returns remove notification result.
895      */
896     static ErrCode RemoveNotifications(const int32_t &userId);
897 
898     /**
899      * @brief Sets the do not disturb time on a specified user.
900      * @note Your application must have system signature to call this method.
901      *
902      * @param userId Indicates the specific user.
903      * @param doNotDisturbDate Indicates the do not disturb time to set.
904      * @return Returns set do not disturb time result.
905      */
906     static ErrCode SetDoNotDisturbDate(const int32_t &userId, const NotificationDoNotDisturbDate &doNotDisturbDate);
907 
908     /**
909      * @brief Obtains the do not disturb time on a specified user.
910      * @note Your application must have system signature to call this method.
911      *
912      * @param userId Indicates the specific user.
913      * @param doNotDisturbDate Indicates the do not disturb time to get.
914      * @return Returns set do not disturb time result.
915      */
916     static ErrCode GetDoNotDisturbDate(const int32_t &userId, NotificationDoNotDisturbDate &doNotDisturbDate);
917 
918     /**
919      * @brief Obtains the do not disturb  on a specified user.
920      * @note Your application must have system signature to call this method.
921      *
922      * @param profiles Indicates the do not disturb time to add.
923      * @return Returns set do not disturb time result.
924      */
925     static ErrCode AddDoNotDisturbProfiles(const std::vector<sptr<NotificationDoNotDisturbProfile>> &profiles);
926 
927     /**
928      * @brief Obtains the do not disturb on a specified user.
929      * @note Your application must have system signature to call this method.
930      *
931      * @param profiles Indicates the do not disturb time to remove.
932      * @return Returns set do not disturb time result.
933      */
934     static ErrCode RemoveDoNotDisturbProfiles(const std::vector<sptr<NotificationDoNotDisturbProfile>> &profiles);
935 
936     /**
937      * Set whether the application slot is enabled.
938      *
939      * @param bundleOption Indicates the bundle name and uid of the application.
940      * @param slotType Indicates type of slot.
941      * @param enabled the type of slot enabled.
942      * @param isForceControl Indicates whether the slot is affected by the notification switch.
943      * @return Returns get slot number by bundle result.
944      */
945     static ErrCode SetEnabledForBundleSlot(const NotificationBundleOption &bundleOption,
946         const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl);
947 
948     /**
949      * Obtains whether the application slot is enabled.
950      *
951      * @param bundleOption Indicates the bundle name and uid of the application.
952      * @param slotType Indicates type of slot.
953      * @param enabled the type of slot enabled to get.
954      * @return Returns get slot number by bundle result.
955      */
956     static ErrCode GetEnabledForBundleSlot(
957         const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType, bool &enabled);
958 
959     /**
960      * Obtains whether the current application slot is enabled.
961      *
962      * @param slotType Indicates type of slot.
963      * @param enabled the type of slot enabled to get.
964      * @return Returns get enabled result.
965      */
966     static ErrCode GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled);
967 
968     /**
969      * @brief Set whether to sync notifications to devices that do not have the app installed.
970      *
971      * @param userId Indicates the specific user.
972      * @param enabled Allow or disallow sync notifications.
973      * @return Returns set enabled result.
974      */
975     static ErrCode SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled);
976 
977     /**
978      * @brief Obtains whether to sync notifications to devices that do not have the app installed.
979      *
980      * @param userId Indicates the specific user.
981      * @param enabled Allow or disallow sync notifications.
982      * @return Returns get enabled result.
983      */
984     static ErrCode GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled);
985 
986     /**
987      * @brief Set badge number.
988      *
989      * @param badgeNumber The badge number.
990      * @return Returns set badge number result.
991      */
992     static ErrCode SetBadgeNumber(int32_t badgeNumber);
993 
994     /**
995      * @brief Set badge number by bundle.
996      *
997      * @param bundleOption Indicates the bundle name and uid of the application.
998      * @param badgeNumber The badge number.
999      * @return Returns set badge number by bundle result.
1000      */
1001     static ErrCode SetBadgeNumberByBundle(const NotificationBundleOption &bundleOption, int32_t badgeNumber);
1002 
1003     /**
1004      * @brief Obtains allow notification application list.
1005      *
1006      * @param bundleOption Indicates the bundle bundleOption.
1007      * @return Returns ERR_OK on success, others on failure.
1008      */
1009     static ErrCode GetAllNotificationEnabledBundles(std::vector<NotificationBundleOption> &bundleOption);
1010 
1011     /**
1012      * @brief Register Push Callback.
1013      *
1014      * @param pushCallback push appliction's Callback.
1015      * @param notificationCheckRequest Filter conditions for push check.
1016      * @return Returns register push callback result.
1017      */
1018     static ErrCode RegisterPushCallback(
1019         const sptr<IRemoteObject>& pushCallback, const sptr<NotificationCheckRequest> &notificationCheckRequest);
1020 
1021     /**
1022      * @brief Unregister Push Callback.
1023      *
1024      * @return Returns unregister push Callback result.
1025      */
1026     static ErrCode UnregisterPushCallback();
1027 
1028     /**
1029      * @brief Sets whether to allow a specified application to publish notifications cross
1030      * device collaboration. The caller must have system permissions to call this method.
1031      *
1032      * @param bundleOption Indicates the bundle name and uid of the application.
1033      * @param deviceType Indicates the type of the device running the application.
1034      * @param enabled Specifies whether to allow the given application to publish notifications. The value
1035      *                true indicates that notifications are allowed, and the value false indicates that
1036      *                notifications are not allowed.
1037      * @return Returns set notifications enabled for specified bundle result.
1038      */
1039     static ErrCode SetDistributedEnabledByBundle(
1040         const NotificationBundleOption &bundleOption, const std::string &deviceType, const bool enabled);
1041 
1042     /**
1043      * @brief Get whether to allow a specified application to publish notifications cross
1044      * device collaboration. The caller must have system permissions to call this method.
1045      *
1046      * @param bundleOption Indicates the bundle name and uid of the application.
1047      * @param deviceType Indicates the type of the device running the application.
1048      * @param enabled Specifies whether to allow the given application to publish notifications. The value
1049      *                true indicates that notifications are allowed, and the value false indicates that
1050      *                notifications are not allowed.
1051      * @return Returns set notifications enabled for specified bundle result.
1052      */
1053     static ErrCode IsDistributedEnabledByBundle(
1054         const NotificationBundleOption &bundleOption, const std::string &deviceType, bool &enabled);
1055 
1056     /**
1057      * @brief Get Enable smartphone to collaborate with other devices for intelligent reminders
1058      *
1059      * @param deviceType Indicates the type of the device running the application.
1060      * @param enabled Specifies whether to allow the given application to publish notifications.
1061      *                The value true indicates that notifications are allowed, and the value
1062      *                false indicates that notifications are not allowed.
1063      * @return Returns set notifications enabled for specified bundle result.
1064      */
1065     static ErrCode IsSmartReminderEnabled(const std::string &deviceType, bool &enabled);
1066 
1067     /**
1068      * @brief Set Enable smartphone to collaborate with other devices for intelligent reminders
1069      *
1070      * @param deviceType Indicates the type of the device running the application.
1071      * @param enabled Specifies whether to allow the given application to publish notifications.
1072      *                The value true indicates that notifications are allowed, and the value
1073      *                false indicates that notifications are not allowed.
1074      * @return Returns set notifications enabled for specified bundle result.
1075      */
1076     static ErrCode SetSmartReminderEnabled(const std::string &deviceType, const bool enabled);
1077 
1078     /**
1079      * @brief Set agent relationship.
1080      *
1081      * @param key Indicates storing agent relationship if the value is "PROXY_PKG".
1082      * @param value Indicates key-value pair of agent relationship.
1083      * @return Returns set result.
1084      */
1085     static ErrCode SetAdditionConfig(const std::string &key, const std::string &value);
1086 
1087     /**
1088      * @brief Cancels a published agent notification.
1089      *
1090      * @param bundleOption Indicates the bundle name and uid of the application.
1091      * @param id Indicates the unique notification ID in the application.
1092      * @return Returns cancel result.
1093      */
1094     static ErrCode CancelAsBundleWithAgent(const NotificationBundleOption &bundleOption, const int32_t id);
1095 
1096     /**
1097      * @brief Set the status of the target device.
1098      *
1099      * @param deviceType Type of the device whose status you want to set.
1100      * @param status The status.
1101      * @return Returns set result.
1102      */
1103     static ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status);
1104 
1105     /**
1106      * @brief Register Swing Callback Function.
1107      *
1108      * @param swingCallback swing Callback Function.
1109      * @return Returns register swing callback result.
1110      */
1111     static ErrCode RegisterSwingCallback(const std::function<void(bool, int)> swingCbFunc);
1112 
1113     /**
1114      * @brief Get do not disturb profile by id.
1115      *
1116      * @param id Profile id.
1117      * @param status Indicates the NotificationDoNotDisturbProfile objects.
1118      * @return Returns ERR_OK on success, others on failure.
1119      */
1120     static ErrCode GetDoNotDisturbProfile(int32_t id, sptr<NotificationDoNotDisturbProfile> &profile);
1121 
1122     /**
1123      * @brief Update Notification Timer by uid
1124      *
1125      * @param uid uid.
1126      * @return Returns Update result.
1127      */
1128     static ErrCode UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused);
1129 };
1130 }  // namespace Notification
1131 }  // namespace OHOS
1132 
1133 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_HELPER_H
1134