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