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