• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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_STUB_H
17 #define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_STUB_H
18 
19 #include <functional>
20 #include <map>
21 
22 #include "ans_manager_interface.h"
23 #include "iremote_stub.h"
24 
25 namespace OHOS {
26 namespace Notification {
27 class AnsManagerStub : public IRemoteStub<AnsManagerInterface> {
28 public:
29     AnsManagerStub();
30     ~AnsManagerStub() override;
31     DISALLOW_COPY_AND_MOVE(AnsManagerStub);
32 
33     /**
34      * @brief Handle remote request.
35      *
36      * @param data Indicates the input parcel.
37      * @param reply Indicates the output parcel.
38      * @param option Indicates the message option.
39      * @return Returns ERR_OK on success, others on failure.
40      */
41     virtual int OnRemoteRequest(
42         uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
43 
44     /**
45      * @brief Publishes a notification with a specified label.
46      * @note If a notification with the same ID has been published by the current application and has not been deleted,
47      *       this method will update the notification.
48      *
49      * @param label Indicates the label of the notification to publish.
50      * @param notification Indicates the NotificationRequest object for setting the notification content.
51      *                This parameter must be specified.
52      * @return Returns ERR_OK on success, others on failure.
53      */
54     virtual ErrCode Publish(const std::string &label, const sptr<NotificationRequest> &notification) override;
55 
56     /**
57      * @brief Publishes a notification on a specified remote device.
58      * @note If a notification with the same ID has been published by the current application and has not been deleted,
59      *       this method will update the notification.
60      *
61      * @param notification Indicates the NotificationRequest object for setting the notification content.
62      *                This parameter must be specified.
63      * @param deviceId Indicates the ID of the remote device. If this parameter is null or an empty string,
64      *                 the notification will be published on the local device.
65      * @return Returns ERR_OK on success, others on failure.
66      */
67     virtual ErrCode PublishToDevice(
68         const sptr<NotificationRequest> &notification, const std::string &deviceId) override;
69 
70     /**
71      * @brief Cancels a published notification matching the specified label and notificationId.
72      *
73      * @param notificationId Indicates the ID of the notification to cancel.
74      * @param label Indicates the label of the notification to cancel.
75      * @return Returns cancel notification result.
76      */
77     virtual ErrCode Cancel(int32_t notificationId, const std::string &label) override;
78 
79     /**
80      * @brief Cancels all the published notifications.
81      *
82      * @return Returns ERR_OK on success, others on failure.
83      */
84     virtual ErrCode CancelAll() override;
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) override;
98 
99     /**
100      * @brief Adds a notification slot by type.
101      *
102      * @param slotType Indicates the notification slot type to be added.
103      * @return Returns ERR_OK on success, others on failure.
104      */
105     virtual ErrCode AddSlotByType(NotificationConstant::SlotType slotType) override;
106 
107     /**
108      * @brief Creates multiple notification slots.
109      *
110      * @param slots Indicates the notification slots to create.
111      * @return Returns ERR_OK on success, others on failure.
112      */
113     virtual ErrCode AddSlots(const std::vector<sptr<NotificationSlot>> &slots) override;
114 
115     /**
116      * @brief Deletes a created notification slot based on the slot ID.
117      *
118      * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot
119      *                 This parameter must be specified.
120      * @return Returns ERR_OK on success, others on failure.
121      */
122     virtual ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) override;
123 
124     /**
125      * @brief Deletes all notification slots.
126      *
127      * @return Returns ERR_OK on success, others on failure.
128      */
129     virtual ErrCode RemoveAllSlots() override;
130 
131     /**
132      * @brief Queries a created notification slot.
133      *
134      * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This
135      *        parameter must be specified.
136      * @param slot Indicates the created NotificationSlot.
137      * @return Returns ERR_OK on success, others on failure.
138      */
139     virtual ErrCode GetSlotByType(
140         const NotificationConstant::SlotType &slotType, sptr<NotificationSlot> &slot) override;
141 
142     /**
143      * @brief Obtains all notification slots of this application.
144      *
145      * @param slots Indicates the created NotificationSlot.
146      * @return Returns ERR_OK on success, others on failure.
147      */
148     virtual ErrCode GetSlots(std::vector<sptr<NotificationSlot>> &slots) override;
149 
150     /**
151      * @brief Obtains the number of slot.
152      *
153      * @param bundleOption Indicates the bundle name and uid of the application.
154      * @param num Indicates the number of slot.
155      * @return Returns ERR_OK on success, others on failure.
156      */
157     virtual ErrCode GetSlotNumAsBundle(const sptr<NotificationBundleOption> &bundleOption, uint64_t &num) override;
158 
159     /**
160      * @brief Obtains active notifications of the current application in the system.
161      *
162      * @param notifications Indicates active NotificationRequest objects of the current application.
163      * @return Returns ERR_OK on success, others on failure.
164      */
165     virtual ErrCode GetActiveNotifications(std::vector<sptr<NotificationRequest>> &notifications) override;
166 
167     /**
168      * @brief Obtains the number of active notifications of the current application in the system.
169      *
170      * @param num Indicates the number of active notifications of the current application.
171      * @return Returns ERR_OK on success, others on failure.
172      */
173     virtual ErrCode GetActiveNotificationNums(uint64_t &num) override;
174 
175     /**
176      * @brief Obtains all active notifications in the current system. The caller must have system permissions to
177      * call this method.
178      *
179      * @param notifications Indicates all active notifications of this application.
180      * @return Returns ERR_OK on success, others on failure.
181      */
182     virtual ErrCode GetAllActiveNotifications(std::vector<sptr<Notification>> &notifications) override;
183 
184     /**
185      * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method
186      * to obtain particular active notifications, you must have received the notifications and obtained the key
187      * via {Notification::GetKey()}.
188      *
189      * @param key Indicates the key array for querying corresponding active notifications.
190      *            If this parameter is null, this method returns all active notifications in the system.
191      * @param notification Indicates the set of active notifications corresponding to the specified key.
192      * @return Returns ERR_OK on success, others on failure.
193      */
194     virtual ErrCode GetSpecialActiveNotifications(
195         const std::vector<std::string> &key, std::vector<sptr<Notification>> &notifications) override;
196 
197     /**
198      * @brief Allows another application to act as an agent to publish notifications in the name of your application
199      * bundle.
200      *
201      * @param agent Indicates the name of the application bundle that can publish notifications for your application.
202      * @return Returns ERR_OK on success, others on failure.
203      */
204     virtual ErrCode SetNotificationAgent(const std::string &agent) override;
205 
206     /**
207      * @brief Obtains the name of the application bundle that can publish notifications in the name of your application.
208      *
209      * @param agent Indicates the name of the application bundle that can publish notifications for your application if
210      * any; returns null otherwise.
211      * @return Returns ERR_OK on success, others on failure.
212      */
213     virtual ErrCode GetNotificationAgent(std::string &agent) override;
214 
215     /**
216      * @brief Checks whether your application has permission to publish notifications by calling
217      * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the
218      * given representativeBundle.
219      *
220      * @param representativeBundle Indicates the name of application bundle your application is representing.
221      * @param canPublish Indicates whether your application has permission to publish notifications.
222      * @return Returns ERR_OK on success, others on failure.
223      */
224     virtual ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) override;
225 
226     /**
227      * @brief Publishes a notification in the name of a specified application bundle.
228      * @note If the notification to be published has the same ID as a published notification that has not been canceled,
229      * the existing notification will be replaced by the new one.
230      *
231      * @param notification Indicates the NotificationRequest object for setting the notification content.
232      *                This parameter must be specified.
233      * @param representativeBundle Indicates the name of the application bundle that allows your application to publish
234      *                             notifications for it by calling setNotificationAgent.
235      * @return Returns ERR_OK on success, others on failure.
236      */
237     virtual ErrCode PublishAsBundle(
238         const sptr<NotificationRequest> notification, const std::string &representativeBundle) override;
239 
240     /**
241      * @brief Sets the number of active notifications of the current application as the number to be displayed on the
242      * notification badge.
243      *
244      * @param num Indicates the badge number.
245      * @return Returns ERR_OK on success, others on failure.
246      */
247     virtual ErrCode SetNotificationBadgeNum(int32_t num) override;
248 
249     /**
250      * @brief Obtains the importance level of this application.
251      *
252      * @param importance Indicates the importance level of this application, which can be LEVEL_NONE,
253                LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED.
254      * @return Returns ERR_OK on success, others on failure.
255      */
256     virtual ErrCode GetBundleImportance(int32_t &importance) override;
257 
258     /**
259      * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy.
260      *
261      * @param granted True if the application has permission; false for otherwise.
262      * @return Returns ERR_OK on success, others on failure.
263      */
264     virtual ErrCode HasNotificationPolicyAccessPermission(bool &granted) override;
265 
266     /**
267      * @brief Set whether to allow private notifications.
268      *
269      * @param allow Indicates the flag that allows private notification.
270      * @return Returns ERR_OK on success, others on failure.
271      */
272     virtual ErrCode SetPrivateNotificationsAllowed(bool allow) override;
273 
274     /**
275      * @brief Get whether to allow private notifications.
276      *
277      * @param allow Indicates the flag that allows private notification.
278      * @return Returns ERR_OK on success, others on failure.
279      */
280     virtual ErrCode GetPrivateNotificationsAllowed(bool &allow) override;
281 
282     /**
283      * @brief Delete notification.
284      *
285      * @param bundleOption Indicates the NotificationBundleOption of the notification.
286      * @param notificationId Indicates the id of the notification.
287      * @param label Indicates the label of the notification.
288      * @param removeReason Indicates the reason of remove notification.
289      * @return Returns ERR_OK on success, others on failure.
290      */
291     virtual ErrCode RemoveNotification(const sptr<NotificationBundleOption> &bundleOption, int32_t notificationId,
292         const std::string &label, int32_t removeReason) override;
293 
294     /**
295      * @brief Delete all notifications.
296      *
297      * @param bundleOption Indicates the NotificationBundleOption of notifications.
298      * @return Returns ERR_OK on success, others on failure.
299      */
300     virtual ErrCode RemoveAllNotifications(const sptr<NotificationBundleOption> &bundleOption) override;
301 
302     /**
303      * @brief Delete notification based on key.
304      *
305      * @param key Indicates the key to delete notification.
306      * @param removeReason Indicates the reason of remove notification.
307      * @return Returns ERR_OK on success, others on failure.
308      */
309     virtual ErrCode Delete(const std::string &key, int32_t removeReason) override;
310 
311     /**
312      * @brief Remove notifications based on bundle.
313      *
314      * @param bundleOption Indicates the NotificationBundleOption of notifications.
315      * @return Returns ERR_OK on success, others on failure.
316      */
317     virtual ErrCode DeleteByBundle(const sptr<NotificationBundleOption> &bundleOption) override;
318 
319     /**
320      * @brief Remove all notifications.
321      *
322      * @return Returns ERR_OK on success, others on failure.
323      */
324     virtual ErrCode DeleteAll() override;
325 
326     /**
327      * @brief Get all the slots corresponding to the bundle.
328      *
329      * @param bundleOption Indicates the NotificationBundleOption object.
330      * @param slots Indicates the notification slots.
331      * @return Returns ERR_OK on success, others on failure.
332      */
333     virtual ErrCode GetSlotsByBundle(
334         const sptr<NotificationBundleOption> &bundleOption, std::vector<sptr<NotificationSlot>> &slots) override;
335 
336     /**
337      * @brief Update slots according to bundle.
338      *
339      * @param bundleOption Indicates the NotificationBundleOption object.
340      * @param slots Indicates the notification slots to be updated.
341      * @return Returns ERR_OK on success, others on failure.
342      */
343     virtual ErrCode UpdateSlots(
344         const sptr<NotificationBundleOption> &bundleOption, const std::vector<sptr<NotificationSlot>> &slots) override;
345 
346     /**
347      * @brief Allow notifications to be sent based on the deviceId.
348      *
349      * @param deviceId Indicates the device Id.
350      * @return Returns ERR_OK on success, others on failure.
351      */
352     ErrCode RequestEnableNotification(const std::string &deviceId) override;
353 
354     /**
355      * @brief Set whether to allow the specified deviceId to send notifications for current bundle.
356      *
357      * @param deviceId Indicates the device Id.
358      * @param enabled Indicates the flag that allows notification to be pulished.
359      * @return Returns ERR_OK on success, others on failure.
360      */
361     virtual ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) override;
362 
363     /**
364      * @brief Set whether to allow the specified deviceId to send notifications for all bundles.
365      *
366      * @param deviceId Indicates the device Id.
367      * @param enabled Indicates the flag that allows notification to be pulished.
368      * @return Returns ERR_OK on success, others on failure.
369      */
370     virtual ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) override;
371 
372     /**
373      * @brief Set whether to allow the specified bundle to send notifications.
374      *
375      * @param bundleOption Indicates the NotificationBundleOption object.
376      * @param enabled Indicates the flag that allows notification to be pulished.
377      * @return Returns ERR_OK on success, others on failure.
378      */
379     virtual ErrCode SetNotificationsEnabledForSpecialBundle(
380         const std::string &deviceId, const sptr<NotificationBundleOption> &bundleOption, bool enabled) override;
381 
382     /**
383      * @brief Sets whether the bundle allows the banner to display notification.
384      *
385      * @param bundleOption Indicates the NotificationBundleOption object.
386      * @param enabled Indicates the flag that allows badge to be shown.
387      * @return Returns ERR_OK on success, others on failure.
388      */
389     virtual ErrCode SetShowBadgeEnabledForBundle(
390         const sptr<NotificationBundleOption> &bundleOption, bool enabled) override;
391 
392     /**
393      * @brief Gets whether the bundle allows the badge to display the status of notifications.
394      *
395      * @param bundleOption Indicates the NotificationBundleOption object.
396      * @param enabled Indicates the flag that allows badge to be shown.
397      * @return Returns ERR_OK on success, others on failure.
398      */
399     virtual ErrCode GetShowBadgeEnabledForBundle(
400         const sptr<NotificationBundleOption> &bundleOption, bool &enabled) override;
401 
402     /**
403      * @brief Gets whether allows the badge to display the status of notifications.
404      *
405      * @param enabled Indicates the flag that allows badge to be shown.
406      * @return Returns ERR_OK on success, others on failure.
407      */
408     virtual ErrCode GetShowBadgeEnabled(bool &enabled) override;
409 
410     /**
411      * @brief Subscribes notifications.
412      *
413      * @param subscriber Indicates the subscriber.
414      * @param info Indicates the NotificationSubscribeInfo object.
415      * @return Returns ERR_OK on success, others on failure.
416      */
417     virtual ErrCode Subscribe(
418         const sptr<AnsSubscriberInterface> &subscriber, const sptr<NotificationSubscribeInfo> &info) override;
419 
420     /**
421      * @brief Unsubscribes notifications.
422      *
423      * @param subscriber Indicates the subscriber.
424      * @param info Indicates the NotificationSubscribeInfo object.
425      * @return Returns ERR_OK on success, others on failure.
426      */
427     virtual ErrCode Unsubscribe(
428         const sptr<AnsSubscriberInterface> &subscriber, const sptr<NotificationSubscribeInfo> &info) override;
429 
430     /**
431      * @brief Obtains whether notifications are suspended.
432      *
433      * @param suspended Indicates the suspended status.
434      * @return Returns ERR_OK on success, others on failure.
435      */
436     virtual ErrCode AreNotificationsSuspended(bool &suspended) override;
437 
438     /**
439      * @brief Get the notification sorting status of the current app.
440      *
441      * @param sortingMap Indicates the NotificationSortingMap object.
442      * @return Returns ERR_OK on success, others on failure.
443      */
444     virtual ErrCode GetCurrentAppSorting(sptr<NotificationSortingMap> &sortingMap) override;
445 
446     /**
447      * @brief Checks whether this device is allowed to publish notifications.
448      *
449      * @param allowed Indicates the flag that allows notification.
450      * @return Returns ERR_OK on success, others on failure.
451      */
452     virtual ErrCode IsAllowedNotify(bool &allowed) override;
453 
454     /**
455      * @brief Checks whether this application is allowed to publish notifications.
456      *
457      * @param allowed Indicates the flag that allows notification.
458      * @return Returns ERR_OK on success, others on failure.
459      */
460     virtual ErrCode IsAllowedNotifySelf(bool &allowed) override;
461 
462     /**
463      * @brief Checks whether notifications are allowed for a specific bundle.
464      *
465      * @param bundleOption Indicates the NotificationBundleOption object.
466      * @param allowed Indicates the flag that allows notification.
467      * @return Returns ERR_OK on success, others on failure.
468      */
469     virtual ErrCode IsSpecialBundleAllowedNotify(
470         const sptr<NotificationBundleOption> &bundleOption, bool &allowed) override;
471 
472     /**
473      * @brief Set do not disturb date.
474      *
475      * @param date Indicates the NotificationDoNotDisturbDate object.
476      * @return Returns ERR_OK on success, others on failure.
477      */
478     virtual ErrCode SetDoNotDisturbDate(const sptr<NotificationDoNotDisturbDate> &date) override;
479 
480     /**
481      * @brief Get do not disturb date.
482      *
483      * @param date Indicates the NotificationDoNotDisturbDate object.
484      * @return Returns ERR_OK on success, others on failure.
485      */
486     virtual ErrCode GetDoNotDisturbDate(sptr<NotificationDoNotDisturbDate> &date) override;
487 
488     /**
489      * @brief Get whether Do Not Disturb mode is supported.
490      *
491      * @param doesSupport Indicates the flag that supports DND mode.
492      * @return Returns ERR_OK on success, others on failure.
493      */
494     virtual ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) override;
495 
496     /**
497      * @brief Cancel notifications according to group.
498      *
499      * @param groupName Indicates the group name.
500      * @return Returns ERR_OK on success, others on failure.
501      */
502     virtual ErrCode CancelGroup(const std::string &groupName) override;
503 
504     /**
505      * @brief Delete notifications according to bundle and group.
506      *
507      * @param bundleOption Indicates the NotificationBundleOption object.
508      * @param groupName Indicates the group name.
509      * @return Returns ERR_OK on success, others on failure.
510      */
511     virtual ErrCode RemoveGroupByBundle(
512         const sptr<NotificationBundleOption> &bundleOption, const std::string &groupName) override;
513 
514     /**
515      * @brief Gets whether distributed notification is enabled.
516      *
517      * @param enabled Indicates the enabled flag.
518      * @return Returns ERR_OK on success, others on failure.
519      */
520     virtual ErrCode IsDistributedEnabled(bool &enabled) override;
521 
522     /**
523      * @brief Sets distributed notification enabled or disabled.
524      *
525      * @param enabled Indicates the enabled flag.
526      * @return Returns ERR_OK on success, others on failure.
527      */
528     virtual ErrCode EnableDistributed(bool enabled) override;
529 
530     /**
531      * @brief Sets distributed notification enabled or disabled for specific bundle.
532      *
533      * @param bundleOption Indicates the NotificationBundleOption object.
534      * @param enabled Indicates the enabled flag.
535      * @return Returns ERR_OK on success, others on failure.
536      */
537     virtual ErrCode EnableDistributedByBundle(
538         const sptr<NotificationBundleOption> &bundleOption, bool enabled) override;
539 
540     /**
541      * @brief Sets distributed notification enabled or disabled for current bundle.
542      *
543      * @param enabled Indicates the enabled flag.
544      * @return Returns ERR_OK on success, others on failure.
545      */
546     virtual ErrCode EnableDistributedSelf(bool enabled) override;
547 
548     /**
549      * @brief Gets whether distributed notification is enabled for specific bundle.
550      *
551      * @param bundleOption Indicates the NotificationBundleOption object.
552      * @param enabled Indicates the enabled flag.
553      * @return Returns ERR_OK on success, others on failure.
554      */
555     virtual ErrCode IsDistributedEnableByBundle(
556         const sptr<NotificationBundleOption> &bundleOption, bool &enabled) override;
557 
558     /**
559      * @brief Get the reminder type of the current device.
560      *
561      * @param remindType Reminder type for the device.
562      * @return Returns ERR_OK on success, others on failure.
563      */
564     virtual ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) override;
565 
566     /**
567      * @brief Publishes a continuous notification.
568      *
569      * @param request Notification requests that need to be posted.
570      * @return Returns ERR_OK on success, others on failure.
571      */
572     virtual ErrCode PublishContinuousTaskNotification(const sptr<NotificationRequest> &request) override;
573 
574     /**
575      * @brief Cancels a continuous notification.
576      *
577      * @param label Identifies the label of the specified notification.
578      * @param notificationId Identifies the id of the specified notification.
579      * @return Returns ERR_OK on success, others on failure.
580      */
581     virtual ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) override;
582 
583     /**
584      * @brief Publishes a reminder notification.
585      *
586      * @param reminder Identifies the reminder notification request that needs to be published.
587      * @return Returns ERR_OK on success, others on failure.
588      */
589     virtual ErrCode PublishReminder(sptr<ReminderRequest> &reminder) override;
590 
591     /**
592      * @brief Cancel a reminder notifications.
593      *
594      * @param reminderId Identifies the reminders id that needs to be canceled.
595      * @return Returns ERR_OK on success, others on failure.
596      */
597     virtual ErrCode CancelReminder(const int32_t reminderId) override;
598 
599     /**
600      * @brief Get all valid reminder notifications.
601      *
602      * @param reminders Identifies the list of all valid notifications.
603      * @return Returns ERR_OK on success, others on failure.
604      */
605     virtual ErrCode GetValidReminders(std::vector<sptr<ReminderRequest>> &reminders) override;
606 
607     /**
608      * @brief Cancel all reminder notifications.
609      *
610      * @return Returns ERR_OK on success, others on failure.
611      */
612     virtual ErrCode CancelAllReminders() override;
613 
614     /**
615      * @brief Checks whether this device is support template.
616      *
617      * @param templateName Identifies the template name for searching as a condition.
618      * @param support Identifies the support flag.
619      * @return Returns ERR_OK on success, others on failure.
620      */
621     virtual ErrCode IsSupportTemplate(const std::string &templateName, bool &support) override;
622 
623     /**
624      * @brief Checks Whether the specified users is allowed to publish notifications.
625      *
626      * @param userId Identifies the user's id.
627      * @param allowed Identifies the allowed flag.
628      * @return Returns ERR_OK on success, others on failure.
629      */
630     virtual ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) override;
631 
632     /**
633      * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must
634      * have system permissions to call this method.
635      *
636      * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only
637      *                 be null or an empty string, indicating the current device.
638      * @param enabled Specifies whether to allow all applications to publish notifications. The value true
639      *                indicates that notifications are allowed, and the value false indicates that notifications
640      *                are not allowed.
641      * @return Returns ERR_OK on success, others on failure.
642      */
643     virtual ErrCode SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) override;
644 
645     /**
646      * @brief Delete all notifications by user.
647      *
648      * @param userId Indicates the user id.
649      * @return Returns ERR_OK on success, others on failure.
650      */
651     virtual ErrCode DeleteAllByUser(const int32_t &userId) override;
652 
653     /**
654      * @brief Set do not disturb date by user.
655      *
656      * @param userId Indicates the user id.
657      * @param date Indicates NotificationDoNotDisturbDate object.
658      * @return Returns ERR_OK on success, others on failure.
659      */
660     virtual ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr<NotificationDoNotDisturbDate> &date) override;
661 
662     /**
663      * @brief Get the do not disturb date by user.
664      *
665      * @param userId Indicates the user id.
666      * @param date Indicates the NotificationDoNotDisturbDate object.
667      * @return Returns ERR_OK on success, others on failure.
668      */
669     virtual ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr<NotificationDoNotDisturbDate> &date) override;
670     virtual ErrCode SetEnabledForBundleSlot(const sptr<NotificationBundleOption> &bundleOption,
671         const NotificationConstant::SlotType &slotType, bool enabled) override;
672     virtual ErrCode GetEnabledForBundleSlot(const sptr<NotificationBundleOption> &bundleOption,
673         const NotificationConstant::SlotType &slotType, bool &enabled) override;
674 
675     /**
676      * @brief Obtains specific datas via specified dump option.
677      *
678      * @param cmd Indicates the specified dump command.
679      * @param bundle Indicates the specified bundle name.
680      * @param userId Indicates the specified userId.
681      * @param dumpInfo Indicates the container containing datas.
682      * @return Returns check result.
683      */
684     virtual ErrCode ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId,
685         std::vector<std::string> &dumpInfo) override;
686 
687     /**
688      * @brief Set whether to sync notifications to devices that do not have the app installed.
689      *
690      * @param userId Indicates the specific user.
691      * @param enabled Allow or disallow sync notifications.
692      * @return Returns set enabled result.
693      */
694     virtual ErrCode SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled) override;
695 
696     /**
697      * @brief Obtains whether to sync notifications to devices that do not have the app installed.
698      *
699      * @param userId Indicates the specific user.
700      * @param enabled Allow or disallow sync notifications.
701      * @return Returns get enabled result.
702      */
703     virtual ErrCode GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled) override;
704 
705 private:
706     static const std::map<uint32_t, std::function<ErrCode(AnsManagerStub *, MessageParcel &, MessageParcel &)>>
707         interfaces_;
708 
709     ErrCode HandlePublish(MessageParcel &data, MessageParcel &reply);
710     ErrCode HandlePublishToDevice(MessageParcel &data, MessageParcel &reply);
711     ErrCode HandleCancel(MessageParcel &data, MessageParcel &reply);
712     ErrCode HandleCancelAll(MessageParcel &data, MessageParcel &reply);
713     ErrCode HandleCancelAsBundle(MessageParcel &data, MessageParcel &reply);
714     ErrCode HandleAddSlotByType(MessageParcel &data, MessageParcel &reply);
715     ErrCode HandleAddSlots(MessageParcel &data, MessageParcel &reply);
716     ErrCode HandleRemoveSlotByType(MessageParcel &data, MessageParcel &reply);
717     ErrCode HandleRemoveAllSlots(MessageParcel &data, MessageParcel &reply);
718     ErrCode HandleGetSlots(MessageParcel &data, MessageParcel &reply);
719     ErrCode HandleGetSlotByType(MessageParcel &data, MessageParcel &reply);
720     ErrCode HandleGetSlotNumAsBundle(MessageParcel &data, MessageParcel &reply);
721     ErrCode HandleGetActiveNotifications(MessageParcel &data, MessageParcel &reply);
722     ErrCode HandleGetActiveNotificationNums(MessageParcel &data, MessageParcel &reply);
723     ErrCode HandleGetAllActiveNotifications(MessageParcel &data, MessageParcel &reply);
724     ErrCode HandleGetSpecialActiveNotifications(MessageParcel &data, MessageParcel &reply);
725     ErrCode HandleSetNotificationAgent(MessageParcel &data, MessageParcel &reply);
726     ErrCode HandleGetNotificationAgent(MessageParcel &data, MessageParcel &reply);
727     ErrCode HandleCanPublishAsBundle(MessageParcel &data, MessageParcel &reply);
728     ErrCode HandlePublishAsBundle(MessageParcel &data, MessageParcel &reply);
729     ErrCode HandleSetNotificationBadgeNum(MessageParcel &data, MessageParcel &reply);
730     ErrCode HandleGetBundleImportance(MessageParcel &data, MessageParcel &reply);
731     ErrCode HandleIsNotificationPolicyAccessGranted(MessageParcel &data, MessageParcel &reply);
732     ErrCode HandleSetPrivateNotificationsAllowed(MessageParcel &data, MessageParcel &reply);
733     ErrCode HandleGetPrivateNotificationsAllowed(MessageParcel &data, MessageParcel &reply);
734     ErrCode HandleRemoveNotification(MessageParcel &data, MessageParcel &reply);
735     ErrCode HandleRemoveAllNotifications(MessageParcel &data, MessageParcel &reply);
736     ErrCode HandleDelete(MessageParcel &data, MessageParcel &reply);
737     ErrCode HandleDeleteByBundle(MessageParcel &data, MessageParcel &reply);
738     ErrCode HandleDeleteAll(MessageParcel &data, MessageParcel &reply);
739     ErrCode HandleGetSlotsByBundle(MessageParcel &data, MessageParcel &reply);
740     ErrCode HandleUpdateSlots(MessageParcel &data, MessageParcel &reply);
741     ErrCode HandleRequestEnableNotification(MessageParcel &data, MessageParcel &reply);
742     ErrCode HandleSetNotificationsEnabledForBundle(MessageParcel &data, MessageParcel &reply);
743     ErrCode HandleSetNotificationsEnabledForAllBundles(MessageParcel &data, MessageParcel &reply);
744     ErrCode HandleSetNotificationsEnabledForSpecialBundle(MessageParcel &data, MessageParcel &reply);
745     ErrCode HandleSetShowBadgeEnabledForBundle(MessageParcel &data, MessageParcel &reply);
746     ErrCode HandleGetShowBadgeEnabledForBundle(MessageParcel &data, MessageParcel &reply);
747     ErrCode HandleGetShowBadgeEnabled(MessageParcel &data, MessageParcel &reply);
748     ErrCode HandleSubscribe(MessageParcel &data, MessageParcel &reply);
749     ErrCode HandleUnsubscribe(MessageParcel &data, MessageParcel &reply);
750     ErrCode HandleAreNotificationsSuspended(MessageParcel &data, MessageParcel &reply);
751     ErrCode HandleGetCurrentAppSorting(MessageParcel &data, MessageParcel &reply);
752     ErrCode HandleIsAllowedNotify(MessageParcel &data, MessageParcel &reply);
753     ErrCode HandleIsAllowedNotifySelf(MessageParcel &data, MessageParcel &reply);
754     ErrCode HandleIsSpecialBundleAllowedNotify(MessageParcel &data, MessageParcel &reply);
755     ErrCode HandleIsDistributedEnabled(MessageParcel &data, MessageParcel &reply);
756     ErrCode HandleEnableDistributed(MessageParcel &data, MessageParcel &reply);
757     ErrCode HandleEnableDistributedByBundle(MessageParcel &data, MessageParcel &reply);
758     ErrCode HandleEnableDistributedSelf(MessageParcel &data, MessageParcel &reply);
759     ErrCode HandleIsDistributedEnableByBundle(MessageParcel &data, MessageParcel &reply);
760     ErrCode HandleShellDump(MessageParcel &data, MessageParcel &reply);
761     ErrCode HandleCancelGroup(MessageParcel &data, MessageParcel &reply);
762     ErrCode HandleRemoveGroupByBundle(MessageParcel &data, MessageParcel &reply);
763     ErrCode HandleSetDoNotDisturbDate(MessageParcel &data, MessageParcel &reply);
764     ErrCode HandleGetDoNotDisturbDate(MessageParcel &data, MessageParcel &reply);
765     ErrCode HandleDoesSupportDoNotDisturbMode(MessageParcel &data, MessageParcel &reply);
766     ErrCode HandleGetDeviceRemindType(MessageParcel &data, MessageParcel &reply);
767     ErrCode HandlePublishContinuousTaskNotification(MessageParcel &data, MessageParcel &reply);
768     ErrCode HandleCancelContinuousTaskNotification(MessageParcel &data, MessageParcel &reply);
769     ErrCode HandlePublishReminder(MessageParcel &data, MessageParcel &reply);
770     ErrCode HandleCancelReminder(MessageParcel &data, MessageParcel &reply);
771     ErrCode HandleGetValidReminders(MessageParcel &data, MessageParcel &reply);
772     ErrCode HandleCancelAllReminders(MessageParcel &data, MessageParcel &reply);
773     ErrCode HandleIsSupportTemplate(MessageParcel &data, MessageParcel &reply);
774     ErrCode HandleIsSpecialUserAllowedNotifyByUser(MessageParcel &data, MessageParcel &reply);
775     ErrCode HandleSetNotificationsEnabledByUser(MessageParcel &data, MessageParcel &reply);
776     ErrCode HandleDeleteAllByUser(MessageParcel &data, MessageParcel &reply);
777     ErrCode HandleSetDoNotDisturbDateByUser(MessageParcel &data, MessageParcel &reply);
778     ErrCode HandleGetDoNotDisturbDateByUser(MessageParcel &data, MessageParcel &reply);
779     ErrCode HandleSetEnabledForBundleSlot(MessageParcel &data, MessageParcel &reply);
780     ErrCode HandleGetEnabledForBundleSlot(MessageParcel &data, MessageParcel &reply);
781     ErrCode HandleDistributedSetEnabledWithoutApp(MessageParcel &data, MessageParcel &reply);
782     ErrCode HandleDistributedGetEnabledWithoutApp(MessageParcel &data, MessageParcel &reply);
783 
784     template<typename T>
785     bool WriteParcelableVector(const std::vector<sptr<T>> &parcelableVector, MessageParcel &reply, ErrCode &result);
786 
787     template<typename T>
788     bool ReadParcelableVector(std::vector<sptr<T>> &parcelableInfos, MessageParcel &data);
789 };
790 }  // namespace Notification
791 }  // namespace OHOS
792 
793 #endif  // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_STUB_H
794