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