• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 #include "ans_manager_stub.h"
17 #include "ans_const_define.h"
18 #include "ans_inner_errors.h"
19 #include "ans_log_wrapper.h"
20 #include "message_option.h"
21 #include "message_parcel.h"
22 #include "parcel.h"
23 #include "reminder_request_alarm.h"
24 #include "reminder_request_calendar.h"
25 #include "reminder_request_timer.h"
26 
27 namespace OHOS {
28 namespace Notification {
29 const std::map<NotificationInterfaceCode, std::function<ErrCode(AnsManagerStub *, MessageParcel &, MessageParcel &)>>
30     AnsManagerStub::interfaces_ = {
31         {NotificationInterfaceCode::PUBLISH_NOTIFICATION,
32             std::bind(
33                 &AnsManagerStub::HandlePublish, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
34         {NotificationInterfaceCode::CANCEL_NOTIFICATION,
35             std::bind(
36                 &AnsManagerStub::HandleCancel, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
37         {NotificationInterfaceCode::CANCEL_ALL_NOTIFICATIONS,
38             std::bind(
39                 &AnsManagerStub::HandleCancelAll, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
40         {NotificationInterfaceCode::CANCEL_AS_BUNDLE,
41             std::bind(&AnsManagerStub::HandleCancelAsBundle, std::placeholders::_1, std::placeholders::_2,
42                 std::placeholders::_3)},
43         {NotificationInterfaceCode::ADD_SLOT_BY_TYPE,
44             std::bind(&AnsManagerStub::HandleAddSlotByType, std::placeholders::_1, std::placeholders::_2,
45                 std::placeholders::_3)},
46         {NotificationInterfaceCode::ADD_SLOTS,
47             std::bind(
48                 &AnsManagerStub::HandleAddSlots, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
49         {NotificationInterfaceCode::REMOVE_SLOT_BY_TYPE,
50             std::bind(&AnsManagerStub::HandleRemoveSlotByType, std::placeholders::_1, std::placeholders::_2,
51                 std::placeholders::_3)},
52         {NotificationInterfaceCode::REMOVE_ALL_SLOTS,
53             std::bind(&AnsManagerStub::HandleRemoveAllSlots, std::placeholders::_1, std::placeholders::_2,
54                 std::placeholders::_3)},
55         {NotificationInterfaceCode::GET_SLOT_BY_TYPE,
56             std::bind(&AnsManagerStub::HandleGetSlotByType, std::placeholders::_1, std::placeholders::_2,
57                 std::placeholders::_3)},
58         {NotificationInterfaceCode::GET_SLOTS,
59             std::bind(
60                 &AnsManagerStub::HandleGetSlots, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
61         {NotificationInterfaceCode::GET_SLOT_NUM_AS_BUNDLE,
62             std::bind(&AnsManagerStub::HandleGetSlotNumAsBundle, std::placeholders::_1, std::placeholders::_2,
63                 std::placeholders::_3)},
64         {NotificationInterfaceCode::GET_ACTIVE_NOTIFICATIONS,
65             std::bind(&AnsManagerStub::HandleGetActiveNotifications, std::placeholders::_1, std::placeholders::_2,
66                 std::placeholders::_3)},
67         {NotificationInterfaceCode::GET_ACTIVE_NOTIFICATION_NUMS,
68             std::bind(&AnsManagerStub::HandleGetActiveNotificationNums, std::placeholders::_1, std::placeholders::_2,
69                 std::placeholders::_3)},
70         {NotificationInterfaceCode::GET_ALL_ACTIVE_NOTIFICATIONS,
71             std::bind(&AnsManagerStub::HandleGetAllActiveNotifications, std::placeholders::_1, std::placeholders::_2,
72                 std::placeholders::_3)},
73         {NotificationInterfaceCode::GET_SPECIAL_ACTIVE_NOTIFICATIONS,
74             std::bind(&AnsManagerStub::HandleGetSpecialActiveNotifications, std::placeholders::_1,
75                 std::placeholders::_2, std::placeholders::_3)},
76         {NotificationInterfaceCode::SET_NOTIFICATION_AGENT,
77             std::bind(&AnsManagerStub::HandleSetNotificationAgent, std::placeholders::_1, std::placeholders::_2,
78                 std::placeholders::_3)},
79         {NotificationInterfaceCode::GET_NOTIFICATION_AGENT,
80             std::bind(&AnsManagerStub::HandleGetNotificationAgent, std::placeholders::_1, std::placeholders::_2,
81                 std::placeholders::_3)},
82         {NotificationInterfaceCode::CAN_PUBLISH_AS_BUNDLE,
83             std::bind(&AnsManagerStub::HandleCanPublishAsBundle, std::placeholders::_1, std::placeholders::_2,
84                 std::placeholders::_3)},
85         {NotificationInterfaceCode::PUBLISH_AS_BUNDLE,
86             std::bind(&AnsManagerStub::HandlePublishAsBundle, std::placeholders::_1, std::placeholders::_2,
87                 std::placeholders::_3)},
88         {NotificationInterfaceCode::SET_NOTIFICATION_BADGE_NUM,
89             std::bind(&AnsManagerStub::HandleSetNotificationBadgeNum, std::placeholders::_1, std::placeholders::_2,
90                 std::placeholders::_3)},
91         {NotificationInterfaceCode::GET_BUNDLE_IMPORTANCE,
92             std::bind(&AnsManagerStub::HandleGetBundleImportance, std::placeholders::_1, std::placeholders::_2,
93                 std::placeholders::_3)},
94         {NotificationInterfaceCode::IS_NOTIFICATION_POLICY_ACCESS_GRANTED,
95             std::bind(&AnsManagerStub::HandleIsNotificationPolicyAccessGranted, std::placeholders::_1,
96                 std::placeholders::_2, std::placeholders::_3)},
97         {NotificationInterfaceCode::REMOVE_NOTIFICATION,
98             std::bind(&AnsManagerStub::HandleRemoveNotification, std::placeholders::_1, std::placeholders::_2,
99                 std::placeholders::_3)},
100         {NotificationInterfaceCode::REMOVE_ALL_NOTIFICATIONS,
101             std::bind(&AnsManagerStub::HandleRemoveAllNotifications, std::placeholders::_1, std::placeholders::_2,
102                 std::placeholders::_3)},
103         {NotificationInterfaceCode::REMOVE_NOTIFICATIONS_BY_KEYS,
104             std::bind(&AnsManagerStub::HandleRemoveNotifications, std::placeholders::_1, std::placeholders::_2,
105                 std::placeholders::_3)},
106         {NotificationInterfaceCode::DELETE_NOTIFICATION,
107             std::bind(
108                 &AnsManagerStub::HandleDelete, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
109         {NotificationInterfaceCode::DELETE_NOTIFICATION_BY_BUNDLE,
110             std::bind(&AnsManagerStub::HandleDeleteByBundle, std::placeholders::_1, std::placeholders::_2,
111                 std::placeholders::_3)},
112         {NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS,
113             std::bind(
114                 &AnsManagerStub::HandleDeleteAll, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
115         {NotificationInterfaceCode::GET_SLOTS_BY_BUNDLE,
116             std::bind(&AnsManagerStub::HandleGetSlotsByBundle, std::placeholders::_1, std::placeholders::_2,
117                 std::placeholders::_3)},
118         {NotificationInterfaceCode::UPDATE_SLOTS,
119             std::bind(&AnsManagerStub::HandleUpdateSlots, std::placeholders::_1, std::placeholders::_2,
120                 std::placeholders::_3)},
121         {NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION,
122             std::bind(&AnsManagerStub::HandleRequestEnableNotification, std::placeholders::_1, std::placeholders::_2,
123                 std::placeholders::_3)},
124         {NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_BUNDLE,
125             std::bind(&AnsManagerStub::HandleSetNotificationsEnabledForBundle, std::placeholders::_1,
126                 std::placeholders::_2, std::placeholders::_3)},
127         {NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_ALL_BUNDLE,
128             std::bind(&AnsManagerStub::HandleSetNotificationsEnabledForAllBundles, std::placeholders::_1,
129                 std::placeholders::_2, std::placeholders::_3)},
130         {NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE,
131             std::bind(&AnsManagerStub::HandleSetNotificationsEnabledForSpecialBundle, std::placeholders::_1,
132                 std::placeholders::_2, std::placeholders::_3)},
133         {NotificationInterfaceCode::SET_SHOW_BADGE_ENABLED_FOR_BUNDLE,
134             std::bind(&AnsManagerStub::HandleSetShowBadgeEnabledForBundle, std::placeholders::_1, std::placeholders::_2,
135                 std::placeholders::_3)},
136         {NotificationInterfaceCode::GET_SHOW_BADGE_ENABLED_FOR_BUNDLE,
137             std::bind(&AnsManagerStub::HandleGetShowBadgeEnabledForBundle, std::placeholders::_1, std::placeholders::_2,
138                 std::placeholders::_3)},
139         {NotificationInterfaceCode::GET_SHOW_BADGE_ENABLED,
140             std::bind(&AnsManagerStub::HandleGetShowBadgeEnabled, std::placeholders::_1, std::placeholders::_2,
141                 std::placeholders::_3)},
142         {NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION,
143             std::bind(
144                 &AnsManagerStub::HandleSubscribe, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
145         {NotificationInterfaceCode::UNSUBSCRIBE_NOTIFICATION,
146             std::bind(&AnsManagerStub::HandleUnsubscribe, std::placeholders::_1, std::placeholders::_2,
147                 std::placeholders::_3)},
148         {NotificationInterfaceCode::IS_ALLOWED_NOTIFY,
149             std::bind(&AnsManagerStub::HandleIsAllowedNotify, std::placeholders::_1, std::placeholders::_2,
150                 std::placeholders::_3)},
151         {NotificationInterfaceCode::IS_ALLOWED_NOTIFY_SELF,
152             std::bind(&AnsManagerStub::HandleIsAllowedNotifySelf, std::placeholders::_1, std::placeholders::_2,
153                 std::placeholders::_3)},
154         {NotificationInterfaceCode::IS_SPECIAL_BUNDLE_ALLOWED_NOTIFY,
155             std::bind(&AnsManagerStub::HandleIsSpecialBundleAllowedNotify, std::placeholders::_1, std::placeholders::_2,
156                 std::placeholders::_3)},
157         {NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE,
158             std::bind(&AnsManagerStub::HandleSetDoNotDisturbDate, std::placeholders::_1, std::placeholders::_2,
159                 std::placeholders::_3)},
160         {NotificationInterfaceCode::GET_DO_NOT_DISTURB_DATE,
161             std::bind(&AnsManagerStub::HandleGetDoNotDisturbDate, std::placeholders::_1, std::placeholders::_2,
162                 std::placeholders::_3)},
163         {NotificationInterfaceCode::DOES_SUPPORT_DO_NOT_DISTURB_MODE,
164             std::bind(&AnsManagerStub::HandleDoesSupportDoNotDisturbMode, std::placeholders::_1, std::placeholders::_2,
165                 std::placeholders::_3)},
166         {NotificationInterfaceCode::CANCEL_GROUP,
167             std::bind(&AnsManagerStub::HandleCancelGroup, std::placeholders::_1, std::placeholders::_2,
168                 std::placeholders::_3)},
169         {NotificationInterfaceCode::REMOVE_GROUP_BY_BUNDLE,
170             std::bind(&AnsManagerStub::HandleRemoveGroupByBundle, std::placeholders::_1, std::placeholders::_2,
171                 std::placeholders::_3)},
172         {NotificationInterfaceCode::IS_DISTRIBUTED_ENABLED,
173             std::bind(&AnsManagerStub::HandleIsDistributedEnabled, std::placeholders::_1, std::placeholders::_2,
174                 std::placeholders::_3)},
175         {NotificationInterfaceCode::ENABLE_DISTRIBUTED,
176             std::bind(&AnsManagerStub::HandleEnableDistributed, std::placeholders::_1, std::placeholders::_2,
177                 std::placeholders::_3)},
178         {NotificationInterfaceCode::ENABLE_DISTRIBUTED_BY_BUNDLE,
179             std::bind(&AnsManagerStub::HandleEnableDistributedByBundle, std::placeholders::_1, std::placeholders::_2,
180                 std::placeholders::_3)},
181         {NotificationInterfaceCode::ENABLE_DISTRIBUTED_SELF,
182             std::bind(&AnsManagerStub::HandleEnableDistributedSelf, std::placeholders::_1, std::placeholders::_2,
183                 std::placeholders::_3)},
184         {NotificationInterfaceCode::IS_DISTRIBUTED_ENABLED_BY_BUNDLE,
185             std::bind(&AnsManagerStub::HandleIsDistributedEnableByBundle, std::placeholders::_1, std::placeholders::_2,
186                 std::placeholders::_3)},
187         {NotificationInterfaceCode::GET_DEVICE_REMIND_TYPE,
188             std::bind(&AnsManagerStub::HandleGetDeviceRemindType, std::placeholders::_1, std::placeholders::_2,
189                 std::placeholders::_3)},
190         {NotificationInterfaceCode::SHELL_DUMP,
191             std::bind(
192                 &AnsManagerStub::HandleShellDump, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)},
193         {NotificationInterfaceCode::PUBLISH_CONTINUOUS_TASK_NOTIFICATION,
194             std::bind(
195                 &AnsManagerStub::HandlePublishContinuousTaskNotification, std::placeholders::_1, std::placeholders::_2,
196                 std::placeholders::_3)},
197         {NotificationInterfaceCode::CANCEL_CONTINUOUS_TASK_NOTIFICATION,
198             std::bind(
199                 &AnsManagerStub::HandleCancelContinuousTaskNotification, std::placeholders::_1, std::placeholders::_2,
200                 std::placeholders::_3)},
201         {NotificationInterfaceCode::PUBLISH_REMINDER,
202             std::bind(&AnsManagerStub::HandlePublishReminder, std::placeholders::_1, std::placeholders::_2,
203                 std::placeholders::_3)},
204         {NotificationInterfaceCode::CANCEL_REMINDER,
205             std::bind(&AnsManagerStub::HandleCancelReminder, std::placeholders::_1, std::placeholders::_2,
206                 std::placeholders::_3)},
207         {NotificationInterfaceCode::CANCEL_ALL_REMINDERS,
208             std::bind(
209                 &AnsManagerStub::HandleCancelAllReminders, std::placeholders::_1, std::placeholders::_2,
210                 std::placeholders::_3)},
211         {NotificationInterfaceCode::GET_ALL_VALID_REMINDERS,
212             std::bind(&AnsManagerStub::HandleGetValidReminders, std::placeholders::_1, std::placeholders::_2,
213                 std::placeholders::_3)},
214         {NotificationInterfaceCode::IS_SUPPORT_TEMPLATE,
215             std::bind(
216                 &AnsManagerStub::HandleIsSupportTemplate, std::placeholders::_1, std::placeholders::_2,
217                 std::placeholders::_3)},
218         {NotificationInterfaceCode::IS_SPECIAL_USER_ALLOWED_NOTIFY,
219             std::bind(&AnsManagerStub::HandleIsSpecialUserAllowedNotifyByUser, std::placeholders::_1,
220                 std::placeholders::_2, std::placeholders::_3)},
221         {NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_BY_USER,
222             std::bind(&AnsManagerStub::HandleSetNotificationsEnabledByUser, std::placeholders::_1,
223                 std::placeholders::_2, std::placeholders::_3)},
224         {NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS_BY_USER,
225             std::bind(&AnsManagerStub::HandleDeleteAllByUser, std::placeholders::_1, std::placeholders::_2,
226                 std::placeholders::_3)},
227         {NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE_BY_USER,
228             std::bind(&AnsManagerStub::HandleSetDoNotDisturbDateByUser, std::placeholders::_1, std::placeholders::_2,
229                 std::placeholders::_3)},
230         {NotificationInterfaceCode::GET_DO_NOT_DISTURB_DATE_BY_USER,
231             std::bind(&AnsManagerStub::HandleGetDoNotDisturbDateByUser, std::placeholders::_1, std::placeholders::_2,
232                 std::placeholders::_3)},
233         {NotificationInterfaceCode::SET_ENABLED_FOR_BUNDLE_SLOT,
234             std::bind(&AnsManagerStub::HandleSetEnabledForBundleSlot, std::placeholders::_1, std::placeholders::_2,
235                 std::placeholders::_3)},
236         {NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT,
237             std::bind(&AnsManagerStub::HandleGetEnabledForBundleSlot, std::placeholders::_1, std::placeholders::_2,
238                 std::placeholders::_3)},
239         {NotificationInterfaceCode::SET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP,
240             std::bind(&AnsManagerStub::HandleDistributedSetEnabledWithoutApp, std::placeholders::_1,
241                 std::placeholders::_2, std::placeholders::_3)},
242         {NotificationInterfaceCode::GET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP,
243             std::bind(&AnsManagerStub::HandleDistributedGetEnabledWithoutApp, std::placeholders::_1,
244                 std::placeholders::_2, std::placeholders::_3)},
245         {NotificationInterfaceCode::SET_BADGE_NUMBER,
246             std::bind(&AnsManagerStub::HandleSetBadgeNumber, std::placeholders::_1,
247                 std::placeholders::_2, std::placeholders::_3)},
248         {NotificationInterfaceCode::REGISTER_PUSH_CALLBACK,
249             std::bind(&AnsManagerStub::HandleRegisterPushCallback, std::placeholders::_1,
250                 std::placeholders::_2, std::placeholders::_3)},
251         {NotificationInterfaceCode::UNREGISTER_PUSH_CALLBACK,
252             std::bind(&AnsManagerStub::HandleUnregisterPushCallback, std::placeholders::_1,
253                 std::placeholders::_2, std::placeholders::_3)},
254 };
255 
AnsManagerStub()256 AnsManagerStub::AnsManagerStub()
257 {}
258 
~AnsManagerStub()259 AnsManagerStub::~AnsManagerStub()
260 {}
261 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & flags)262 int32_t AnsManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &flags)
263 {
264     std::u16string descriptor = AnsManagerStub::GetDescriptor();
265     std::u16string remoteDescriptor = data.ReadInterfaceToken();
266     if (descriptor != remoteDescriptor) {
267         ANS_LOGE("[OnRemoteRequest] fail: invalid interface token!");
268         return OBJECT_NULL;
269     }
270 
271     auto it = interfaces_.find(static_cast<NotificationInterfaceCode>(code));
272     if (it == interfaces_.end()) {
273         ANS_LOGE("[OnRemoteRequest] fail: unknown code!");
274         return IPCObjectStub::OnRemoteRequest(code, data, reply, flags);
275     }
276 
277     auto fun = it->second;
278     if (fun == nullptr) {
279         ANS_LOGE("[OnRemoteRequest] fail: not find function!");
280         return IPCObjectStub::OnRemoteRequest(code, data, reply, flags);
281     }
282 
283     ErrCode result = fun(this, data, reply);
284     if (SUCCEEDED(result)) {
285         return NO_ERROR;
286     }
287 
288     ANS_LOGE("[OnRemoteRequest] fail: Failed to call interface %{public}u, err:%{public}d", code, result);
289     return result;
290 }
291 
HandlePublish(MessageParcel & data,MessageParcel & reply)292 ErrCode AnsManagerStub::HandlePublish(MessageParcel &data, MessageParcel &reply)
293 {
294     std::string label;
295     if (!data.ReadString(label)) {
296         ANS_LOGE("[HandlePublish] fail: read label failed");
297         return ERR_ANS_PARCELABLE_FAILED;
298     }
299 
300     sptr<NotificationRequest> notification = data.ReadParcelable<NotificationRequest>();
301     if (!notification) {
302         ANS_LOGE("[HandlePublish] fail: notification ReadParcelable failed");
303         return ERR_ANS_PARCELABLE_FAILED;
304     }
305 
306     ErrCode result = Publish(label, notification);
307     if (!reply.WriteInt32(result)) {
308         ANS_LOGE("[HandlePublish] fail: write result failed, ErrCode=%{public}d", result);
309         return ERR_ANS_PARCELABLE_FAILED;
310     }
311     return ERR_OK;
312 }
313 
HandleCancel(MessageParcel & data,MessageParcel & reply)314 ErrCode AnsManagerStub::HandleCancel(MessageParcel &data, MessageParcel &reply)
315 {
316     int32_t notificationId = 0;
317     if (!data.ReadInt32(notificationId)) {
318         ANS_LOGE("[HandleCancel] fail: read notificationId failed");
319         return ERR_ANS_PARCELABLE_FAILED;
320     }
321 
322     std::string label;
323     if (!data.ReadString(label)) {
324         ANS_LOGE("[HandleCancel] fail: read label failed");
325         return ERR_ANS_PARCELABLE_FAILED;
326     }
327 
328     ErrCode result = Cancel(notificationId, label);
329     if (!reply.WriteInt32(result)) {
330         ANS_LOGE("[HandleCancel] fail: write result failed, ErrCode=%{public}d", result);
331         return ERR_ANS_PARCELABLE_FAILED;
332     }
333     return ERR_OK;
334 }
335 
HandleCancelAll(MessageParcel & data,MessageParcel & reply)336 ErrCode AnsManagerStub::HandleCancelAll(MessageParcel &data, MessageParcel &reply)
337 {
338     ErrCode result = CancelAll();
339     if (!reply.WriteInt32(result)) {
340         ANS_LOGE("[HandleCancelAll] fail: write result failed, ErrCode=%{public}d", result);
341         return ERR_ANS_PARCELABLE_FAILED;
342     }
343     return ERR_OK;
344 }
345 
HandleCancelAsBundle(MessageParcel & data,MessageParcel & reply)346 ErrCode AnsManagerStub::HandleCancelAsBundle(MessageParcel &data, MessageParcel &reply)
347 {
348     int32_t notificationId = 0;
349     if (!data.ReadInt32(notificationId)) {
350         ANS_LOGE("[HandleCancelAsBundle] fail: read notificationId failed");
351         return ERR_ANS_PARCELABLE_FAILED;
352     }
353 
354     std::string representativeBundle;
355     if (!data.ReadString(representativeBundle)) {
356         ANS_LOGE("[HandleCancelAsBundle] fail: read representativeBundle failed");
357         return ERR_ANS_PARCELABLE_FAILED;
358     }
359 
360     int32_t userId = 0;
361     if (!data.ReadInt32(userId)) {
362         ANS_LOGE("[HandleCancelAsBundle] fail: read userId failed");
363         return ERR_ANS_PARCELABLE_FAILED;
364     }
365 
366     ErrCode result = CancelAsBundle(notificationId, representativeBundle, userId);
367     if (!reply.WriteInt32(result)) {
368         ANS_LOGE("[HandleCancelAsBundle] fail: write result failed, ErrCode=%{public}d", result);
369         return ERR_ANS_PARCELABLE_FAILED;
370     }
371     return ERR_OK;
372 }
373 
HandleAddSlotByType(MessageParcel & data,MessageParcel & reply)374 ErrCode AnsManagerStub::HandleAddSlotByType(MessageParcel &data, MessageParcel &reply)
375 {
376     NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(data.ReadInt32());
377     ErrCode result = AddSlotByType(slotType);
378     if (!reply.WriteInt32(result)) {
379         ANS_LOGE("[HandleAddSlotByType] fail: write result failed, ErrCode=%{public}d", result);
380         return ERR_ANS_PARCELABLE_FAILED;
381     }
382     return ERR_OK;
383 }
384 
HandleAddSlots(MessageParcel & data,MessageParcel & reply)385 ErrCode AnsManagerStub::HandleAddSlots(MessageParcel &data, MessageParcel &reply)
386 {
387     std::vector<sptr<NotificationSlot>> slots;
388     if (!ReadParcelableVector(slots, data)) {
389         ANS_LOGE("[HandleAddSlots] fail: read slotsSize failed");
390         return ERR_ANS_PARCELABLE_FAILED;
391     }
392     ErrCode result = AddSlots(slots);
393     if (!reply.WriteInt32(result)) {
394         ANS_LOGE("[HandleAddSlots] fail: write result failed, ErrCode=%{public}d", result);
395         return ERR_ANS_PARCELABLE_FAILED;
396     }
397     return ERR_OK;
398 }
399 
HandleRemoveSlotByType(MessageParcel & data,MessageParcel & reply)400 ErrCode AnsManagerStub::HandleRemoveSlotByType(MessageParcel &data, MessageParcel &reply)
401 {
402     NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(data.ReadInt32());
403 
404     ErrCode result = RemoveSlotByType(slotType);
405     if (!reply.WriteInt32(result)) {
406         ANS_LOGE("[HandleRemoveSlotByType] fail: write result failed, ErrCode=%{public}d", result);
407         return ERR_ANS_PARCELABLE_FAILED;
408     }
409     return ERR_OK;
410 }
411 
HandleRemoveAllSlots(MessageParcel & data,MessageParcel & reply)412 ErrCode AnsManagerStub::HandleRemoveAllSlots(MessageParcel &data, MessageParcel &reply)
413 {
414     ErrCode result = RemoveAllSlots();
415     if (!reply.WriteInt32(result)) {
416         ANS_LOGE("[HandleRemoveAllSlots] fail: write result failed, ErrCode=%{public}d", result);
417         return ERR_ANS_PARCELABLE_FAILED;
418     }
419     return ERR_OK;
420 }
421 
HandleGetSlots(MessageParcel & data,MessageParcel & reply)422 ErrCode AnsManagerStub::HandleGetSlots(MessageParcel &data, MessageParcel &reply)
423 {
424     std::vector<sptr<NotificationSlot>> slots;
425     ErrCode result = GetSlots(slots);
426     if (!WriteParcelableVector(slots, reply, result)) {
427         ANS_LOGE("[HandleGetSlots] fail: write slots failed");
428         return ERR_ANS_PARCELABLE_FAILED;
429     }
430 
431     return ERR_OK;
432 }
433 
HandleGetSlotByType(MessageParcel & data,MessageParcel & reply)434 ErrCode AnsManagerStub::HandleGetSlotByType(MessageParcel &data, MessageParcel &reply)
435 {
436     NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(data.ReadInt32());
437 
438     sptr<NotificationSlot> slot = nullptr;
439     ErrCode result = GetSlotByType(slotType, slot);
440     if (!reply.WriteInt32(result)) {
441         ANS_LOGE("[HandleGetSlotByType] fail: write result failed, ErrCode=%{public}d", result);
442         return ERR_ANS_PARCELABLE_FAILED;
443     }
444 
445     if (!reply.WriteParcelable(slot)) {
446         ANS_LOGE("[HandleGetSlotByType] fail: write slot failed.");
447         return ERR_ANS_PARCELABLE_FAILED;
448     }
449     return ERR_OK;
450 }
451 
HandleGetSlotNumAsBundle(MessageParcel & data,MessageParcel & reply)452 ErrCode AnsManagerStub::HandleGetSlotNumAsBundle(MessageParcel &data, MessageParcel &reply)
453 {
454     sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
455     if (bundleOption == nullptr) {
456         ANS_LOGE("[HandleGetSlotNumAsBundle] fail: read bundle failed.");
457         return ERR_ANS_PARCELABLE_FAILED;
458     }
459 
460     uint64_t num = 0;
461     ErrCode result = GetSlotNumAsBundle(bundleOption, num);
462     if (!reply.WriteInt32(result)) {
463         ANS_LOGE("[HandleGetSlotNumAsBundle] fail: write result failed, ErrCode=%{public}d", result);
464         return ERR_ANS_PARCELABLE_FAILED;
465     }
466 
467     if (!reply.WriteUint64(num)) {
468         ANS_LOGE("[HandleGetSlotNumAsBundle] fail: write enabled failed, ErrCode=%{public}d", result);
469         return ERR_ANS_PARCELABLE_FAILED;
470     }
471     return ERR_OK;
472 }
473 
HandleGetActiveNotifications(MessageParcel & data,MessageParcel & reply)474 ErrCode AnsManagerStub::HandleGetActiveNotifications(MessageParcel &data, MessageParcel &reply)
475 {
476     std::vector<sptr<NotificationRequest>> notifications;
477     ErrCode result = GetActiveNotifications(notifications);
478     if (!WriteParcelableVector(notifications, reply, result)) {
479         ANS_LOGE("[HandleGetActiveNotifications] fail: write notifications failed");
480         return ERR_ANS_PARCELABLE_FAILED;
481     }
482     return ERR_OK;
483 }
484 
HandleGetActiveNotificationNums(MessageParcel & data,MessageParcel & reply)485 ErrCode AnsManagerStub::HandleGetActiveNotificationNums(MessageParcel &data, MessageParcel &reply)
486 {
487     uint64_t num = 0;
488     ErrCode result = GetActiveNotificationNums(num);
489     if (!reply.WriteInt32(result)) {
490         ANS_LOGE("[HandleGetActiveNotificationNums] fail: write result failed, ErrCode=%{public}d", result);
491         return ERR_ANS_PARCELABLE_FAILED;
492     }
493 
494     if (!reply.WriteUint64(num)) {
495         ANS_LOGE("[HandleGetActiveNotificationNums] fail: write num failed");
496         return ERR_ANS_PARCELABLE_FAILED;
497     }
498     return ERR_OK;
499 }
500 
HandleGetAllActiveNotifications(MessageParcel & data,MessageParcel & reply)501 ErrCode AnsManagerStub::HandleGetAllActiveNotifications(MessageParcel &data, MessageParcel &reply)
502 {
503     std::vector<sptr<Notification>> notifications;
504     ErrCode result = GetAllActiveNotifications(notifications);
505     if (!WriteParcelableVector(notifications, reply, result)) {
506         ANS_LOGE("[HandleGetAllActiveNotifications] fail: write notifications failed");
507         return ERR_ANS_PARCELABLE_FAILED;
508     }
509     return ERR_OK;
510 }
511 
HandleGetSpecialActiveNotifications(MessageParcel & data,MessageParcel & reply)512 ErrCode AnsManagerStub::HandleGetSpecialActiveNotifications(MessageParcel &data, MessageParcel &reply)
513 {
514     std::vector<std::string> key;
515     if (!data.ReadStringVector(&key)) {
516         ANS_LOGE("[HandleGetSpecialActiveNotifications] fail: read key failed");
517         return ERR_ANS_PARCELABLE_FAILED;
518     }
519 
520     std::vector<sptr<Notification>> notifications;
521     ErrCode result = GetSpecialActiveNotifications(key, notifications);
522     if (!WriteParcelableVector(notifications, reply, result)) {
523         ANS_LOGE("[HandleGetSpecialActiveNotifications] fail: write notifications failed");
524         return ERR_ANS_PARCELABLE_FAILED;
525     }
526     return ERR_OK;
527 }
528 
HandleSetNotificationAgent(MessageParcel & data,MessageParcel & reply)529 ErrCode AnsManagerStub::HandleSetNotificationAgent(MessageParcel &data, MessageParcel &reply)
530 {
531     std::string agent;
532     if (!data.ReadString(agent)) {
533         ANS_LOGE("[HandleSetNotificationAgent] fail: read agent failed");
534         return ERR_ANS_PARCELABLE_FAILED;
535     }
536 
537     ErrCode result = SetNotificationAgent(agent);
538     if (!reply.WriteInt32(result)) {
539         ANS_LOGE("[HandleSetNotificationAgent] fail: write result failed, ErrCode=%{public}d", result);
540         return ERR_ANS_PARCELABLE_FAILED;
541     }
542     return ERR_OK;
543 }
544 
HandleGetNotificationAgent(MessageParcel & data,MessageParcel & reply)545 ErrCode AnsManagerStub::HandleGetNotificationAgent(MessageParcel &data, MessageParcel &reply)
546 {
547     std::string agent;
548     ErrCode result = GetNotificationAgent(agent);
549     if (!reply.WriteInt32(result)) {
550         ANS_LOGE("[HandleGetNotificationAgent] fail: write result failed, ErrCode=%{public}d", result);
551         return ERR_ANS_PARCELABLE_FAILED;
552     }
553 
554     if (!reply.WriteString(agent)) {
555         ANS_LOGE("[HandleGetNotificationAgent] fail: write agent failed");
556         return ERR_ANS_PARCELABLE_FAILED;
557     }
558 
559     return ERR_OK;
560 }
561 
HandleCanPublishAsBundle(MessageParcel & data,MessageParcel & reply)562 ErrCode AnsManagerStub::HandleCanPublishAsBundle(MessageParcel &data, MessageParcel &reply)
563 {
564     std::string representativeBundle;
565     if (!data.ReadString(representativeBundle)) {
566         ANS_LOGE("[HandleCanPublishAsBundle] fail: read representativeBundle failed");
567         return ERR_ANS_PARCELABLE_FAILED;
568     }
569 
570     bool canPublish = false;
571     ErrCode result = CanPublishAsBundle(representativeBundle, canPublish);
572     if (!reply.WriteInt32(result)) {
573         ANS_LOGE("[HandleCanPublishAsBundle] fail: write result failed, ErrCode=%{public}d", result);
574         return ERR_ANS_PARCELABLE_FAILED;
575     }
576 
577     if (!reply.WriteBool(canPublish)) {
578         ANS_LOGE("[HandleCanPublishAsBundle] fail: write canPublish failed");
579         return ERR_ANS_PARCELABLE_FAILED;
580     }
581 
582     return ERR_OK;
583 }
584 
HandlePublishAsBundle(MessageParcel & data,MessageParcel & reply)585 ErrCode AnsManagerStub::HandlePublishAsBundle(MessageParcel &data, MessageParcel &reply)
586 {
587     sptr<NotificationRequest> notification = data.ReadParcelable<NotificationRequest>();
588     if (!notification) {
589         ANS_LOGE("[HandlePublishAsBundle] fail: read notification failed");
590         return ERR_ANS_PARCELABLE_FAILED;
591     }
592 
593     std::string representativeBundle;
594     if (!data.ReadString(representativeBundle)) {
595         ANS_LOGE("[HandlePublishAsBundle] fail: read representativeBundle failed.");
596         return ERR_ANS_PARCELABLE_FAILED;
597     }
598 
599     ErrCode result = PublishAsBundle(notification, representativeBundle);
600     if (!reply.WriteInt32(result)) {
601         ANS_LOGE("[HandlePublishAsBundle] fail: write result failed, ErrCode=%{public}d", result);
602         return ERR_ANS_PARCELABLE_FAILED;
603     }
604     return ERR_OK;
605 }
606 
HandleSetNotificationBadgeNum(MessageParcel & data,MessageParcel & reply)607 ErrCode AnsManagerStub::HandleSetNotificationBadgeNum(MessageParcel &data, MessageParcel &reply)
608 {
609     int32_t num = 0;
610     if (!data.ReadInt32(num)) {
611         ANS_LOGE("[HandleSetNotificationBadgeNum] fail: read notification failed");
612         return ERR_ANS_PARCELABLE_FAILED;
613     }
614 
615     ErrCode result = SetNotificationBadgeNum(num);
616     if (!reply.WriteInt32(result)) {
617         ANS_LOGE("[HandleSetNotificationBadgeNum] fail: write result failed, ErrCode=%{public}d", result);
618         return ERR_ANS_PARCELABLE_FAILED;
619     }
620     return ERR_OK;
621 }
622 
HandleGetBundleImportance(MessageParcel & data,MessageParcel & reply)623 ErrCode AnsManagerStub::HandleGetBundleImportance(MessageParcel &data, MessageParcel &reply)
624 {
625     int32_t importance = 0;
626     ErrCode result = GetBundleImportance(importance);
627     if (!reply.WriteInt32(result)) {
628         ANS_LOGE("[HandleGetBundleImportance] fail: write result failed, ErrCode=%{public}d", result);
629         return ERR_ANS_PARCELABLE_FAILED;
630     }
631 
632     if (!reply.WriteInt32(importance)) {
633         ANS_LOGE("[HandleGetBundleImportance] fail: write importance failed.");
634         return ERR_ANS_PARCELABLE_FAILED;
635     }
636     return ERR_OK;
637 }
638 
HandleSetDoNotDisturbDate(MessageParcel & data,MessageParcel & reply)639 ErrCode AnsManagerStub::HandleSetDoNotDisturbDate(MessageParcel &data, MessageParcel &reply)
640 {
641     sptr<NotificationDoNotDisturbDate> date = data.ReadParcelable<NotificationDoNotDisturbDate>();
642     if (date == nullptr) {
643         ANS_LOGE("[HandleSetDoNotDisturbDate] fail: read date failed.");
644         return ERR_ANS_PARCELABLE_FAILED;
645     }
646 
647     ErrCode result = SetDoNotDisturbDate(date);
648     if (!reply.WriteInt32(result)) {
649         ANS_LOGE("[HandleSetDoNotDisturbDate] fail: write result failed, ErrCode=%{public}d", result);
650         return ERR_ANS_PARCELABLE_FAILED;
651     }
652 
653     return ERR_OK;
654 }
655 
HandleGetDoNotDisturbDate(MessageParcel & data,MessageParcel & reply)656 ErrCode AnsManagerStub::HandleGetDoNotDisturbDate(MessageParcel &data, MessageParcel &reply)
657 {
658     sptr<NotificationDoNotDisturbDate> date = nullptr;
659 
660     ErrCode result = GetDoNotDisturbDate(date);
661     if (!reply.WriteInt32(result)) {
662         ANS_LOGE("[HandleSetDoNotDisturbDate] fail: write result failed, ErrCode=%{public}d", result);
663         return ERR_ANS_PARCELABLE_FAILED;
664     }
665 
666     if (result == ERR_OK) {
667         if (!reply.WriteParcelable(date)) {
668             ANS_LOGE("[HandleSetDoNotDisturbDate] fail: write date failed.");
669             return ERR_ANS_PARCELABLE_FAILED;
670         }
671     }
672 
673     return ERR_OK;
674 }
675 
HandleDoesSupportDoNotDisturbMode(MessageParcel & data,MessageParcel & reply)676 ErrCode AnsManagerStub::HandleDoesSupportDoNotDisturbMode(MessageParcel &data, MessageParcel &reply)
677 {
678     bool support = false;
679 
680     ErrCode result = DoesSupportDoNotDisturbMode(support);
681     if (!reply.WriteInt32(result)) {
682         ANS_LOGE("[HandleDoesSupportDoNotDisturbMode] fail: write result failed, ErrCode=%{public}d", result);
683         return ERR_ANS_PARCELABLE_FAILED;
684     }
685 
686     if (!reply.WriteBool(support)) {
687         ANS_LOGE("[HandleDoesSupportDoNotDisturbMode] fail: write doesSupport failed.");
688         return ERR_ANS_PARCELABLE_FAILED;
689     }
690 
691     return ERR_OK;
692 }
693 
HandlePublishContinuousTaskNotification(MessageParcel & data,MessageParcel & reply)694 ErrCode AnsManagerStub::HandlePublishContinuousTaskNotification(MessageParcel &data, MessageParcel &reply)
695 {
696     sptr<NotificationRequest> request = data.ReadParcelable<NotificationRequest>();
697     if (!request) {
698         ANS_LOGE("[HandlePublishContinuousTaskNotification] fail: notification ReadParcelable failed");
699         return ERR_ANS_PARCELABLE_FAILED;
700     }
701 
702     ErrCode result = PublishContinuousTaskNotification(request);
703     if (!reply.WriteInt32(result)) {
704         ANS_LOGE("[HandlePublishContinuousTaskNotification] fail: write result failed, ErrCode=%{public}d", result);
705         return ERR_ANS_PARCELABLE_FAILED;
706     }
707     return ERR_OK;
708 }
709 
HandleCancelContinuousTaskNotification(MessageParcel & data,MessageParcel & reply)710 ErrCode AnsManagerStub::HandleCancelContinuousTaskNotification(MessageParcel &data, MessageParcel &reply)
711 {
712     std::string label;
713     if (!data.ReadString(label)) {
714         ANS_LOGE("[HandleCancelContinuousTaskNotification] fail: read label failed");
715         return ERR_ANS_PARCELABLE_FAILED;
716     }
717 
718     int32_t notificationId = 0;
719     if (!data.ReadInt32(notificationId)) {
720         ANS_LOGE("[HandleCancelContinuousTaskNotification] fail: read notificationId failed");
721         return ERR_ANS_PARCELABLE_FAILED;
722     }
723 
724     ErrCode result = CancelContinuousTaskNotification(label, notificationId);
725     if (!reply.WriteInt32(result)) {
726         ANS_LOGE("[HandleCancelContinuousTaskNotification] fail: write result failed, ErrCode=%{public}d", result);
727         return ERR_ANS_PARCELABLE_FAILED;
728     }
729     return ERR_OK;
730 }
731 
HandleIsNotificationPolicyAccessGranted(MessageParcel & data,MessageParcel & reply)732 ErrCode AnsManagerStub::HandleIsNotificationPolicyAccessGranted(MessageParcel &data, MessageParcel &reply)
733 {
734     bool granted = false;
735     ErrCode result = HasNotificationPolicyAccessPermission(granted);
736     if (!reply.WriteInt32(result)) {
737         ANS_LOGE("[HandleIsNotificationPolicyAccessGranted] fail: write result failed, ErrCode=%{public}d", result);
738         return ERR_ANS_PARCELABLE_FAILED;
739     }
740 
741     if (!reply.WriteBool(granted)) {
742         ANS_LOGE("[HandleIsNotificationPolicyAccessGranted] fail: write granted failed.");
743         return ERR_ANS_PARCELABLE_FAILED;
744     }
745     return ERR_OK;
746 }
747 
HandleRemoveNotification(MessageParcel & data,MessageParcel & reply)748 ErrCode AnsManagerStub::HandleRemoveNotification(MessageParcel &data, MessageParcel &reply)
749 {
750     sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
751     if (bundleOption == nullptr) {
752         ANS_LOGE("[HandleRemoveNotification] fail: read bundle failed.");
753         return ERR_ANS_PARCELABLE_FAILED;
754     }
755 
756     int32_t notificationId = 0;
757     if (!data.ReadInt32(notificationId)) {
758         ANS_LOGE("[HandleRemoveNotification] fail: read notificationId failed");
759         return ERR_ANS_PARCELABLE_FAILED;
760     }
761 
762     std::string label;
763     if (!data.ReadString(label)) {
764         ANS_LOGE("[HandleRemoveNotification] fail: read label failed");
765         return ERR_ANS_PARCELABLE_FAILED;
766     }
767 
768     int32_t removeReason = 0;
769     if (!data.ReadInt32(removeReason)) {
770         ANS_LOGE("[HandleRemoveNotification] fail: read removeReason failed");
771         return ERR_ANS_PARCELABLE_FAILED;
772     }
773 
774     ErrCode result = RemoveNotification(bundleOption, notificationId, label, removeReason);
775     if (!reply.WriteInt32(result)) {
776         ANS_LOGE("[HandleRemoveNotification] fail: write result failed, ErrCode=%{public}d", result);
777         return ERR_ANS_PARCELABLE_FAILED;
778     }
779     return ERR_OK;
780 }
781 
HandleRemoveAllNotifications(MessageParcel & data,MessageParcel & reply)782 ErrCode AnsManagerStub::HandleRemoveAllNotifications(MessageParcel &data, MessageParcel &reply)
783 {
784     sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
785     if (bundleOption == nullptr) {
786         ANS_LOGE("[HandleRemoveAllNotifications] fail: read bundle failed.");
787         return ERR_ANS_PARCELABLE_FAILED;
788     }
789 
790     ErrCode result = RemoveAllNotifications(bundleOption);
791     if (!reply.WriteInt32(result)) {
792         ANS_LOGE("[HandleRemoveAllNotifications] fail: write result failed, ErrCode=%{public}d", result);
793         return ERR_ANS_PARCELABLE_FAILED;
794     }
795     return ERR_OK;
796 }
797 
HandleRemoveNotifications(MessageParcel & data,MessageParcel & reply)798 ErrCode AnsManagerStub::HandleRemoveNotifications(MessageParcel &data, MessageParcel &reply)
799 {
800     int32_t keysSize = 0;
801     if (!data.ReadInt32(keysSize)) {
802         ANS_LOGE("read keys size failed.");
803         return false;
804     }
805 
806     std::vector<std::string> keys;
807     if (!data.ReadStringVector(&keys)) {
808         ANS_LOGE("read keys failed");
809         return ERR_ANS_PARCELABLE_FAILED;
810     }
811 
812     int32_t removeReason = 0;
813     if (!data.ReadInt32(removeReason)) {
814         ANS_LOGE("read removeReason failed");
815         return ERR_ANS_PARCELABLE_FAILED;
816     }
817 
818     ErrCode result = RemoveNotifications(keys, removeReason);
819     if (!reply.WriteInt32(result)) {
820         ANS_LOGE("write result failed, ErrCode=%{public}d", result);
821         return ERR_ANS_PARCELABLE_FAILED;
822     }
823     return ERR_OK;
824 }
825 
826 
HandleDelete(MessageParcel & data,MessageParcel & reply)827 ErrCode AnsManagerStub::HandleDelete(MessageParcel &data, MessageParcel &reply)
828 {
829     std::string key;
830     if (!data.ReadString(key)) {
831         ANS_LOGE("[HandleDelete] fail: read key failed.");
832         return ERR_ANS_PARCELABLE_FAILED;
833     }
834 
835     int32_t removeReason = 0;
836     if (!data.ReadInt32(removeReason)) {
837         ANS_LOGE("[HandleDelete] fail: read removeReason failed");
838         return ERR_ANS_PARCELABLE_FAILED;
839     }
840 
841     ErrCode result = Delete(key, removeReason);
842     if (!reply.WriteInt32(result)) {
843         ANS_LOGE("[HandleDelete] fail: write result failed, ErrCode=%{public}d", result);
844         return ERR_ANS_PARCELABLE_FAILED;
845     }
846     return ERR_OK;
847 }
848 
HandleDeleteByBundle(MessageParcel & data,MessageParcel & reply)849 ErrCode AnsManagerStub::HandleDeleteByBundle(MessageParcel &data, MessageParcel &reply)
850 {
851     sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
852     if (bundleOption == nullptr) {
853         ANS_LOGE("[HandleDeleteByBundle] fail: read bundle failed.");
854         return ERR_ANS_PARCELABLE_FAILED;
855     }
856 
857     ErrCode result = DeleteByBundle(bundleOption);
858     if (!reply.WriteInt32(result)) {
859         ANS_LOGE("[HandleDeleteByBundle] fail: write result failed, ErrCode=%{public}d", result);
860         return ERR_ANS_PARCELABLE_FAILED;
861     }
862     return ERR_OK;
863 }
864 
HandleDeleteAll(MessageParcel & data,MessageParcel & reply)865 ErrCode AnsManagerStub::HandleDeleteAll(MessageParcel &data, MessageParcel &reply)
866 {
867     ErrCode result = DeleteAll();
868     if (!reply.WriteInt32(result)) {
869         ANS_LOGE("[HandleDeleteAll] fail: write result failed, ErrCode=%{public}d", result);
870         return ERR_ANS_PARCELABLE_FAILED;
871     }
872     return ERR_OK;
873 }
874 
HandleGetSlotsByBundle(MessageParcel & data,MessageParcel & reply)875 ErrCode AnsManagerStub::HandleGetSlotsByBundle(MessageParcel &data, MessageParcel &reply)
876 {
877     sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
878     if (bundleOption == nullptr) {
879         ANS_LOGE("[HandleGetSlotsByBundle] fail: read bundleOption failed.");
880         return ERR_ANS_PARCELABLE_FAILED;
881     }
882 
883     std::vector<sptr<NotificationSlot>> slots;
884     ErrCode result = GetSlotsByBundle(bundleOption, slots);
885     if (!WriteParcelableVector(slots, reply, result)) {
886         ANS_LOGE("[HandleGetSlotsByBundle] fail: write slots failed.");
887         return ERR_ANS_PARCELABLE_FAILED;
888     }
889     return ERR_OK;
890 }
891 
HandleUpdateSlots(MessageParcel & data,MessageParcel & reply)892 ErrCode AnsManagerStub::HandleUpdateSlots(MessageParcel &data, MessageParcel &reply)
893 {
894     sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
895     if (bundleOption == nullptr) {
896         ANS_LOGE("[HandleUpdateSlots] fail: read bundleOption failed.");
897         return ERR_ANS_PARCELABLE_FAILED;
898     }
899 
900     std::vector<sptr<NotificationSlot>> slots;
901     if (!ReadParcelableVector(slots, data)) {
902         ANS_LOGE("[HandleUpdateSlots] fail: read slots failed");
903         return ERR_ANS_PARCELABLE_FAILED;
904     }
905 
906     ErrCode result = UpdateSlots(bundleOption, slots);
907     if (!reply.WriteInt32(result)) {
908         ANS_LOGE("[HandleUpdateSlots] fail: write result failed, ErrCode=%{public}d", result);
909         return ERR_ANS_PARCELABLE_FAILED;
910     }
911     return ERR_OK;
912 }
913 
HandleRequestEnableNotification(MessageParcel & data,MessageParcel & reply)914 ErrCode AnsManagerStub::HandleRequestEnableNotification(MessageParcel &data, MessageParcel &reply)
915 {
916     ANS_LOGI("enter");
917     std::string deviceId;
918     if (!data.ReadString(deviceId)) {
919         ANS_LOGE("[HandleRequestEnableNotification] fail: read deviceId failed.");
920         return ERR_ANS_PARCELABLE_FAILED;
921     }
922 
923     bool hasCallerToken = false;
924     if (!data.ReadBool(hasCallerToken)) {
925         ANS_LOGE("fail: read hasCallerToken failed.");
926         return ERR_ANS_PARCELABLE_FAILED;
927     }
928 
929     sptr<IRemoteObject> callerToken = nullptr;
930     if (hasCallerToken) {
931         callerToken = data.ReadRemoteObject();
932     }
933 
934     ErrCode result = RequestEnableNotification(deviceId, callerToken);
935     if (!reply.WriteInt32(result)) {
936         ANS_LOGE("[HandleRequestEnableNotification] fail: write result failed, ErrCode=%{public}d", result);
937         return ERR_ANS_PARCELABLE_FAILED;
938     }
939     return ERR_OK;
940 }
941 
HandleSetNotificationsEnabledForBundle(MessageParcel & data,MessageParcel & reply)942 ErrCode AnsManagerStub::HandleSetNotificationsEnabledForBundle(MessageParcel &data, MessageParcel &reply)
943 {
944     std::string deviceId;
945     if (!data.ReadString(deviceId)) {
946         ANS_LOGE("[HandleSetNotificationsEnabledForBundle] fail: read deviceId failed.");
947         return ERR_ANS_PARCELABLE_FAILED;
948     }
949 
950     bool enabled = false;
951     if (!data.ReadBool(enabled)) {
952         ANS_LOGE("[HandleSetNotificationsEnabledForBundle] fail: read enabled failed.");
953         return ERR_ANS_PARCELABLE_FAILED;
954     }
955 
956     ErrCode result = SetNotificationsEnabledForBundle(deviceId, enabled);
957     if (!reply.WriteInt32(result)) {
958         ANS_LOGE("[HandleSetNotificationsEnabledForBundle] fail: write result failed, ErrCode=%{public}d", result);
959         return ERR_ANS_PARCELABLE_FAILED;
960     }
961     return ERR_OK;
962 }
963 
HandleSetNotificationsEnabledForAllBundles(MessageParcel & data,MessageParcel & reply)964 ErrCode AnsManagerStub::HandleSetNotificationsEnabledForAllBundles(MessageParcel &data, MessageParcel &reply)
965 {
966     std::string deviceId;
967     if (!data.ReadString(deviceId)) {
968         ANS_LOGE("[HandleSetNotificationsEnabledForAllBundles] fail: read deviceId failed.");
969         return ERR_ANS_PARCELABLE_FAILED;
970     }
971 
972     bool enabled = false;
973     if (!data.ReadBool(enabled)) {
974         ANS_LOGE("[HandleSetNotificationsEnabledForAllBundles] fail: read enabled failed.");
975         return ERR_ANS_PARCELABLE_FAILED;
976     }
977 
978     ErrCode result = SetNotificationsEnabledForAllBundles(deviceId, enabled);
979     if (!reply.WriteInt32(result)) {
980         ANS_LOGE("[HandleSetNotificationsEnabledForAllBundles] fail: write result failed, ErrCode=%{public}d", result);
981         return ERR_ANS_PARCELABLE_FAILED;
982     }
983     return ERR_OK;
984 }
985 
HandleSetNotificationsEnabledForSpecialBundle(MessageParcel & data,MessageParcel & reply)986 ErrCode AnsManagerStub::HandleSetNotificationsEnabledForSpecialBundle(MessageParcel &data, MessageParcel &reply)
987 {
988     std::string deviceId;
989     if (!data.ReadString(deviceId)) {
990         ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read deviceId failed.");
991         return ERR_ANS_PARCELABLE_FAILED;
992     }
993 
994     sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
995     if (bundleOption == nullptr) {
996         ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read bundleOption failed.");
997         return ERR_ANS_PARCELABLE_FAILED;
998     }
999 
1000     bool enabled = false;
1001     if (!data.ReadBool(enabled)) {
1002         ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read enabled failed.");
1003         return ERR_ANS_PARCELABLE_FAILED;
1004     }
1005 
1006     ErrCode result = SetNotificationsEnabledForSpecialBundle(deviceId, bundleOption, enabled);
1007     if (!reply.WriteInt32(result)) {
1008         ANS_LOGE(
1009             "[HandleSetNotificationsEnabledForSpecialBundle] fail: write result failed, ErrCode=%{public}d", result);
1010         return ERR_ANS_PARCELABLE_FAILED;
1011     }
1012     return ERR_OK;
1013 }
1014 
HandleSetShowBadgeEnabledForBundle(MessageParcel & data,MessageParcel & reply)1015 ErrCode AnsManagerStub::HandleSetShowBadgeEnabledForBundle(MessageParcel &data, MessageParcel &reply)
1016 {
1017     sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1018     if (bundleOption == nullptr) {
1019         ANS_LOGE("[HandleSetShowBadgeEnabledForBundle] fail: read bundle failed.");
1020         return ERR_ANS_PARCELABLE_FAILED;
1021     }
1022 
1023     bool enabled = false;
1024     if (!data.ReadBool(enabled)) {
1025         ANS_LOGE("[HandleSetShowBadgeEnabledForBundle] fail: read enabled failed.");
1026         return ERR_ANS_PARCELABLE_FAILED;
1027     }
1028 
1029     ErrCode result = SetShowBadgeEnabledForBundle(bundleOption, enabled);
1030     if (!reply.WriteInt32(result)) {
1031         ANS_LOGE("[HandleSetShowBadgeEnabledForBundle] fail: write result failed, ErrCode=%{public}d", result);
1032         return ERR_ANS_PARCELABLE_FAILED;
1033     }
1034     return ERR_OK;
1035 }
1036 
HandleGetShowBadgeEnabledForBundle(MessageParcel & data,MessageParcel & reply)1037 ErrCode AnsManagerStub::HandleGetShowBadgeEnabledForBundle(MessageParcel &data, MessageParcel &reply)
1038 {
1039     sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1040     if (bundleOption == nullptr) {
1041         ANS_LOGE("[HandleGetShowBadgeEnabledForBundle] fail: read bundle failed.");
1042         return ERR_ANS_PARCELABLE_FAILED;
1043     }
1044 
1045     bool enabled = false;
1046     ErrCode result = GetShowBadgeEnabledForBundle(bundleOption, enabled);
1047     if (!reply.WriteInt32(result)) {
1048         ANS_LOGE("[HandleGetShowBadgeEnabledForBundle] fail: write result failed, ErrCode=%{public}d", result);
1049         return ERR_ANS_PARCELABLE_FAILED;
1050     }
1051 
1052     if (!reply.WriteBool(enabled)) {
1053         ANS_LOGE("[HandleGetShowBadgeEnabledForBundle] fail: write enabled failed, ErrCode=%{public}d", result);
1054         return ERR_ANS_PARCELABLE_FAILED;
1055     }
1056     return ERR_OK;
1057 }
1058 
HandleGetShowBadgeEnabled(MessageParcel & data,MessageParcel & reply)1059 ErrCode AnsManagerStub::HandleGetShowBadgeEnabled(MessageParcel &data, MessageParcel &reply)
1060 {
1061     bool enabled = false;
1062     ErrCode result = GetShowBadgeEnabled(enabled);
1063     if (!reply.WriteInt32(result)) {
1064         ANS_LOGE("[HandleGetShowBadgeEnabled] fail: write result failed, ErrCode=%{public}d", result);
1065         return ERR_ANS_PARCELABLE_FAILED;
1066     }
1067 
1068     if (!reply.WriteBool(enabled)) {
1069         ANS_LOGE("[HandleGetShowBadgeEnabled] fail: write enabled failed, ErrCode=%{public}d", result);
1070         return ERR_ANS_PARCELABLE_FAILED;
1071     }
1072     return ERR_OK;
1073 }
1074 
HandleSubscribe(MessageParcel & data,MessageParcel & reply)1075 ErrCode AnsManagerStub::HandleSubscribe(MessageParcel &data, MessageParcel &reply)
1076 {
1077     sptr<IRemoteObject> subscriber = data.ReadRemoteObject();
1078     if (subscriber == nullptr) {
1079         ANS_LOGE("[HandleSubscribe] fail: read subscriber failed");
1080         return ERR_ANS_PARCELABLE_FAILED;
1081     }
1082 
1083     bool subcribeInfo = false;
1084     if (!data.ReadBool(subcribeInfo)) {
1085         ANS_LOGE("[HandleSubscribe] fail: read isSubcribeInfo failed");
1086         return ERR_ANS_PARCELABLE_FAILED;
1087     }
1088 
1089     sptr<NotificationSubscribeInfo> info = nullptr;
1090     if (subcribeInfo) {
1091         info = data.ReadParcelable<NotificationSubscribeInfo>();
1092         if (info == nullptr) {
1093             ANS_LOGE("[HandleSubscribe] fail: read info failed");
1094             return ERR_ANS_PARCELABLE_FAILED;
1095         }
1096     }
1097 
1098     ErrCode result = Subscribe(iface_cast<AnsSubscriberInterface>(subscriber), info);
1099     if (!reply.WriteInt32(result)) {
1100         ANS_LOGE("[HandleSubscribe] fail: write result failed, ErrCode=%{public}d", result);
1101         return ERR_ANS_PARCELABLE_FAILED;
1102     }
1103     return ERR_OK;
1104 }
1105 
HandleUnsubscribe(MessageParcel & data,MessageParcel & reply)1106 ErrCode AnsManagerStub::HandleUnsubscribe(MessageParcel &data, MessageParcel &reply)
1107 {
1108     sptr<IRemoteObject> subscriber = data.ReadRemoteObject();
1109     if (subscriber == nullptr) {
1110         ANS_LOGE("[HandleUnsubscribe] fail: read subscriber failed");
1111         return ERR_ANS_PARCELABLE_FAILED;
1112     }
1113 
1114     bool subcribeInfo = false;
1115     if (!data.ReadBool(subcribeInfo)) {
1116         ANS_LOGE("[HandleUnsubscribe] fail: read isSubcribeInfo failed");
1117         return ERR_ANS_PARCELABLE_FAILED;
1118     }
1119 
1120     sptr<NotificationSubscribeInfo> info = nullptr;
1121     if (subcribeInfo) {
1122         info = data.ReadParcelable<NotificationSubscribeInfo>();
1123         if (info == nullptr) {
1124             ANS_LOGE("[HandleUnsubscribe] fail: read info failed");
1125             return ERR_ANS_PARCELABLE_FAILED;
1126         }
1127     }
1128 
1129     ErrCode result = Unsubscribe(iface_cast<AnsSubscriberInterface>(subscriber), info);
1130     if (!reply.WriteInt32(result)) {
1131         ANS_LOGE("[HandleUnsubscribe] fail: write result failed, ErrCode=%{public}d", result);
1132         return ERR_ANS_PARCELABLE_FAILED;
1133     }
1134     return ERR_OK;
1135 }
1136 
HandleIsAllowedNotify(MessageParcel & data,MessageParcel & reply)1137 ErrCode AnsManagerStub::HandleIsAllowedNotify(MessageParcel &data, MessageParcel &reply)
1138 {
1139     bool allowed = false;
1140     ErrCode result = IsAllowedNotify(allowed);
1141     if (!reply.WriteInt32(result)) {
1142         ANS_LOGE("[HandleIsAllowedNotify] fail: write result failed, ErrCode=%{public}d", result);
1143         return ERR_ANS_PARCELABLE_FAILED;
1144     }
1145 
1146     if (!reply.WriteBool(allowed)) {
1147         ANS_LOGE("[HandleIsAllowedNotify] fail: write allowed failed.");
1148         return ERR_ANS_PARCELABLE_FAILED;
1149     }
1150     return ERR_OK;
1151 }
1152 
HandleIsAllowedNotifySelf(MessageParcel & data,MessageParcel & reply)1153 ErrCode AnsManagerStub::HandleIsAllowedNotifySelf(MessageParcel &data, MessageParcel &reply)
1154 {
1155     bool allowed = false;
1156     ErrCode result = IsAllowedNotifySelf(allowed);
1157     if (!reply.WriteInt32(result)) {
1158         ANS_LOGE("[HandleIsAllowedNotifySelf] fail: write result failed, ErrCode=%{public}d", result);
1159         return ERR_ANS_PARCELABLE_FAILED;
1160     }
1161 
1162     if (!reply.WriteBool(allowed)) {
1163         ANS_LOGE("[HandleIsAllowedNotifySelf] fail: write allowed failed.");
1164         return ERR_ANS_PARCELABLE_FAILED;
1165     }
1166     return ERR_OK;
1167 }
1168 
HandleIsSpecialBundleAllowedNotify(MessageParcel & data,MessageParcel & reply)1169 ErrCode AnsManagerStub::HandleIsSpecialBundleAllowedNotify(MessageParcel &data, MessageParcel &reply)
1170 {
1171     sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1172     if (bundleOption == nullptr) {
1173         ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: read bundle failed.");
1174         return ERR_ANS_PARCELABLE_FAILED;
1175     }
1176 
1177     bool allowed = false;
1178     ErrCode result = IsSpecialBundleAllowedNotify(bundleOption, allowed);
1179     if (!reply.WriteInt32(result)) {
1180         ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: write result failed, ErrCode=%{public}d", result);
1181         return ERR_ANS_PARCELABLE_FAILED;
1182     }
1183 
1184     if (!reply.WriteBool(allowed)) {
1185         ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: write allowed failed.");
1186         return ERR_ANS_PARCELABLE_FAILED;
1187     }
1188     return ERR_OK;
1189 }
1190 
HandleCancelGroup(MessageParcel & data,MessageParcel & reply)1191 ErrCode AnsManagerStub::HandleCancelGroup(MessageParcel &data, MessageParcel &reply)
1192 {
1193     std::string groupName;
1194     if (!data.ReadString(groupName)) {
1195         ANS_LOGE("[HandleCancelGroup] fail: read groupName failed.");
1196         return ERR_ANS_PARCELABLE_FAILED;
1197     }
1198 
1199     ErrCode result = CancelGroup(groupName);
1200     if (!reply.WriteInt32(result)) {
1201         ANS_LOGE("[HandleCancelGroup] fail: write result failed, ErrCode=%{public}d", result);
1202         return ERR_ANS_PARCELABLE_FAILED;
1203     }
1204     return ERR_OK;
1205 }
1206 
HandleRemoveGroupByBundle(MessageParcel & data,MessageParcel & reply)1207 ErrCode AnsManagerStub::HandleRemoveGroupByBundle(MessageParcel &data, MessageParcel &reply)
1208 {
1209     sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1210     if (bundleOption == nullptr) {
1211         ANS_LOGE("[HandleRemoveGroupByBundle] fail: read bundleOption failed.");
1212         return ERR_ANS_PARCELABLE_FAILED;
1213     }
1214 
1215     std::string groupName;
1216     if (!data.ReadString(groupName)) {
1217         ANS_LOGE("[HandleRemoveGroupByBundle] fail: read groupName failed.");
1218         return ERR_ANS_PARCELABLE_FAILED;
1219     }
1220 
1221     ErrCode result = RemoveGroupByBundle(bundleOption, groupName);
1222     if (!reply.WriteInt32(result)) {
1223         ANS_LOGE("[HandleRemoveGroupByBundle] fail: write result failed, ErrCode=%{public}d", result);
1224         return ERR_ANS_PARCELABLE_FAILED;
1225     }
1226     return ERR_OK;
1227 }
1228 
HandleIsDistributedEnabled(MessageParcel & data,MessageParcel & reply)1229 ErrCode AnsManagerStub::HandleIsDistributedEnabled(MessageParcel &data, MessageParcel &reply)
1230 {
1231     bool enabled = false;
1232     ErrCode result = IsDistributedEnabled(enabled);
1233     if (!reply.WriteInt32(result)) {
1234         ANS_LOGE("[HandleIsDistributedEnabled] fail: write result failed, ErrCode=%{public}d", result);
1235         return ERR_ANS_PARCELABLE_FAILED;
1236     }
1237 
1238     if (!reply.WriteBool(enabled)) {
1239         ANS_LOGE("[HandleIsDistributedEnabled] fail: write enabled failed.");
1240         return ERR_ANS_PARCELABLE_FAILED;
1241     }
1242 
1243     return ERR_OK;
1244 }
1245 
HandleEnableDistributed(MessageParcel & data,MessageParcel & reply)1246 ErrCode AnsManagerStub::HandleEnableDistributed(MessageParcel &data, MessageParcel &reply)
1247 {
1248     bool enabled = false;
1249     if (!data.ReadBool(enabled)) {
1250         ANS_LOGE("[HandleEnableDistributed] fail: read enabled failed.");
1251         return ERR_ANS_PARCELABLE_FAILED;
1252     }
1253 
1254     ErrCode result = EnableDistributed(enabled);
1255     if (!reply.WriteInt32(result)) {
1256         ANS_LOGE("[HandleEnableDistributed] fail: write result failed, ErrCode=%{public}d", result);
1257         return ERR_ANS_PARCELABLE_FAILED;
1258     }
1259 
1260     return ERR_OK;
1261 }
1262 
HandleEnableDistributedByBundle(MessageParcel & data,MessageParcel & reply)1263 ErrCode AnsManagerStub::HandleEnableDistributedByBundle(MessageParcel &data, MessageParcel &reply)
1264 {
1265     sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1266     if (bundleOption == nullptr) {
1267         ANS_LOGE("[HandleEnableDistributedByBundle] fail: read bundle failed.");
1268         return ERR_ANS_PARCELABLE_FAILED;
1269     }
1270 
1271     bool enabled = false;
1272     if (!data.ReadBool(enabled)) {
1273         ANS_LOGE("[HandleEnableDistributedByBundle] fail: read enabled failed.");
1274         return ERR_ANS_PARCELABLE_FAILED;
1275     }
1276 
1277     ErrCode result = EnableDistributedByBundle(bundleOption, enabled);
1278     if (!reply.WriteInt32(result)) {
1279         ANS_LOGE("[HandleEnableDistributedByBundle] fail: write result failed, ErrCode=%{public}d", result);
1280         return ERR_ANS_PARCELABLE_FAILED;
1281     }
1282 
1283     return ERR_OK;
1284 }
1285 
HandleEnableDistributedSelf(MessageParcel & data,MessageParcel & reply)1286 ErrCode AnsManagerStub::HandleEnableDistributedSelf(MessageParcel &data, MessageParcel &reply)
1287 {
1288     bool enabled = false;
1289     if (!data.ReadBool(enabled)) {
1290         ANS_LOGE("[HandleEnableDistributedSelf] fail: read enabled failed.");
1291         return ERR_ANS_PARCELABLE_FAILED;
1292     }
1293 
1294     ErrCode result = EnableDistributedSelf(enabled);
1295     if (!reply.WriteInt32(result)) {
1296         ANS_LOGE("[HandleEnableDistributedSelf] fail: write result failed, ErrCode=%{public}d", result);
1297         return ERR_ANS_PARCELABLE_FAILED;
1298     }
1299 
1300     return ERR_OK;
1301 }
1302 
HandleIsDistributedEnableByBundle(MessageParcel & data,MessageParcel & reply)1303 ErrCode AnsManagerStub::HandleIsDistributedEnableByBundle(MessageParcel &data, MessageParcel &reply)
1304 {
1305     sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1306     if (bundleOption == nullptr) {
1307         ANS_LOGE("[HandleIsDistributedEnableByBundle] fail: read bundle failed.");
1308         return ERR_ANS_PARCELABLE_FAILED;
1309     }
1310 
1311     bool enabled = false;
1312     ErrCode result = IsDistributedEnableByBundle(bundleOption, enabled);
1313     if (!reply.WriteInt32(result)) {
1314         ANS_LOGE("[HandleIsDistributedEnableByBundle] fail: write result failed, ErrCode=%{public}d", result);
1315         return ERR_ANS_PARCELABLE_FAILED;
1316     }
1317 
1318     if (!reply.WriteBool(enabled)) {
1319         ANS_LOGE("[HandleIsDistributedEnableByBundle] fail: write enabled failed.");
1320         return ERR_ANS_PARCELABLE_FAILED;
1321     }
1322 
1323     return ERR_OK;
1324 }
1325 
HandleGetDeviceRemindType(MessageParcel & data,MessageParcel & reply)1326 ErrCode AnsManagerStub::HandleGetDeviceRemindType(MessageParcel &data, MessageParcel &reply)
1327 {
1328     auto rType {NotificationConstant::RemindType::NONE};
1329     ErrCode result = GetDeviceRemindType(rType);
1330     if (!reply.WriteInt32(result)) {
1331         ANS_LOGE("[HandleGetDeviceRemindType] fail: write result failed, ErrCode=%{public}d", result);
1332         return ERR_ANS_PARCELABLE_FAILED;
1333     }
1334 
1335     if (!reply.WriteInt32(static_cast<int32_t>(rType))) {
1336         ANS_LOGE("[HandleGetDeviceRemindType] fail: write remind type failed.");
1337         return ERR_ANS_PARCELABLE_FAILED;
1338     }
1339 
1340     return ERR_OK;
1341 }
1342 
HandleShellDump(MessageParcel & data,MessageParcel & reply)1343 ErrCode AnsManagerStub::HandleShellDump(MessageParcel &data, MessageParcel &reply)
1344 {
1345     std::string cmd;
1346     if (!data.ReadString(cmd)) {
1347         ANS_LOGE("[HandleShellDump] fail: read cmd failed.");
1348         return ERR_ANS_PARCELABLE_FAILED;
1349     }
1350     std::string bundle;
1351     if (!data.ReadString(bundle)) {
1352         ANS_LOGE("[HandleShellDump] fail: read bundle failed.");
1353         return ERR_ANS_PARCELABLE_FAILED;
1354     }
1355     int32_t userId;
1356     if (!data.ReadInt32(userId)) {
1357         ANS_LOGE("[HandleShellDump] fail: read userId failed.");
1358         return ERR_ANS_PARCELABLE_FAILED;
1359     }
1360     std::vector<std::string> notificationsInfo;
1361     ErrCode result = ShellDump(cmd, bundle, userId, notificationsInfo);
1362     if (!reply.WriteInt32(result)) {
1363         ANS_LOGE("[HandleGetRecentNotificationsInfo] fail: write result failed, ErrCode=%{public}d", result);
1364         return ERR_ANS_PARCELABLE_FAILED;
1365     }
1366 
1367     if (!reply.WriteStringVector(notificationsInfo)) {
1368         ANS_LOGE("[HandleGetRecentNotificationsInfo] fail: write notificationsInfo failed.");
1369         return ERR_ANS_PARCELABLE_FAILED;
1370     }
1371     return ERR_OK;
1372 }
1373 
HandlePublishReminder(MessageParcel & data,MessageParcel & reply)1374 ErrCode AnsManagerStub::HandlePublishReminder(MessageParcel &data, MessageParcel &reply)
1375 {
1376     ANSR_LOGI("HandlePublishReminder");
1377     uint8_t typeInfo = static_cast<uint8_t>(ReminderRequest::ReminderType::INVALID);
1378     if (!data.ReadUint8(typeInfo)) {
1379         ANSR_LOGE("Failed to read reminder type");
1380         return ERR_ANS_PARCELABLE_FAILED;
1381     }
1382     ReminderRequest::ReminderType reminderType = static_cast<ReminderRequest::ReminderType>(typeInfo);
1383     sptr<ReminderRequest> reminder;
1384     if (ReminderRequest::ReminderType::ALARM == reminderType) {
1385         ANSR_LOGD("Publish alarm");
1386         reminder = data.ReadParcelable<ReminderRequestAlarm>();
1387     } else if (ReminderRequest::ReminderType::TIMER == reminderType) {
1388         ANSR_LOGD("Publish timer");
1389         reminder = data.ReadParcelable<ReminderRequestTimer>();
1390     } else if (ReminderRequest::ReminderType::CALENDAR == reminderType) {
1391         ANSR_LOGD("Publish calendar");
1392         reminder = data.ReadParcelable<ReminderRequestCalendar>();
1393     } else {
1394         ANSR_LOGE("Reminder type invalid");
1395         return ERR_ANS_INVALID_PARAM;
1396     }
1397     if (!reminder) {
1398         ANSR_LOGE("Reminder ReadParcelable failed");
1399         return ERR_ANS_PARCELABLE_FAILED;
1400     }
1401 
1402     ErrCode result = PublishReminder(reminder);
1403 
1404     if (!reply.WriteInt32(reminder->GetReminderId())) {
1405         ANSR_LOGE("Write back reminderId failed");
1406         return ERR_ANS_PARCELABLE_FAILED;
1407     }
1408     if (!reply.WriteInt32(result)) {
1409         ANSR_LOGE("Write back result failed");
1410         return ERR_ANS_PARCELABLE_FAILED;
1411     }
1412     return result;
1413 }
1414 
HandleCancelReminder(MessageParcel & data,MessageParcel & reply)1415 ErrCode AnsManagerStub::HandleCancelReminder(MessageParcel &data, MessageParcel &reply)
1416 {
1417     ANSR_LOGI("HandleCancelReminder");
1418     int32_t reminderId = -1;
1419     if (!data.ReadInt32(reminderId)) {
1420         ANSR_LOGE("Read reminder id failed.");
1421         return ERR_ANS_PARCELABLE_FAILED;
1422     }
1423 
1424     ErrCode result = CancelReminder(reminderId);
1425     if (!reply.WriteInt32(result)) {
1426         ANSR_LOGE("Write back result failed");
1427         return ERR_ANS_PARCELABLE_FAILED;
1428     }
1429     return result;
1430 }
1431 
HandleCancelAllReminders(MessageParcel & data,MessageParcel & reply)1432 ErrCode AnsManagerStub::HandleCancelAllReminders(MessageParcel &data, MessageParcel &reply)
1433 {
1434     ErrCode result = CancelAllReminders();
1435     if (!reply.WriteInt32(result)) {
1436         ANSR_LOGE("Write back result failed");
1437         return ERR_ANS_PARCELABLE_FAILED;
1438     }
1439     return result;
1440 }
1441 
HandleGetValidReminders(MessageParcel & data,MessageParcel & reply)1442 ErrCode AnsManagerStub::HandleGetValidReminders(MessageParcel &data, MessageParcel &reply)
1443 {
1444     ANSR_LOGI("HandleGetValidReminders");
1445     std::vector<sptr<ReminderRequest>> validReminders;
1446     ErrCode result = GetValidReminders(validReminders);
1447 
1448     ANSR_LOGD("Write back size=%{public}zu", validReminders.size());
1449     if (!reply.WriteUint8(static_cast<uint8_t>(validReminders.size()))) {
1450         ANSR_LOGE("Write back reminder count failed");
1451         return ERR_ANS_PARCELABLE_FAILED;
1452     }
1453 
1454     for (auto it = validReminders.begin(); it != validReminders.end(); ++it) {
1455         sptr<ReminderRequest> reminder = (*it);
1456         uint8_t reminderType = static_cast<uint8_t>(reminder->GetReminderType());
1457         ANSR_LOGD("ReminderType=%{public}d", reminderType);
1458         if (!reply.WriteUint8(reminderType)) {
1459             ANSR_LOGW("Write reminder type failed");
1460             return ERR_ANS_PARCELABLE_FAILED;
1461         }
1462         if (!reply.WriteParcelable(reminder)) {
1463             ANSR_LOGW("Write reminder parcelable failed");
1464             return ERR_ANS_PARCELABLE_FAILED;
1465         }
1466     }
1467     if (!reply.WriteInt32(result)) {
1468         ANSR_LOGE("Write back result failed");
1469         return ERR_ANS_PARCELABLE_FAILED;
1470     }
1471     return result;
1472 }
1473 
1474 template<typename T>
WriteParcelableVector(const std::vector<sptr<T>> & parcelableVector,MessageParcel & reply,ErrCode & result)1475 bool AnsManagerStub::WriteParcelableVector(
1476     const std::vector<sptr<T>> &parcelableVector, MessageParcel &reply, ErrCode &result)
1477 {
1478     if (!reply.WriteInt32(result)) {
1479         ANS_LOGE("write result failed, ErrCode=%{public}d", result);
1480         return false;
1481     }
1482 
1483     if (!reply.WriteInt32(parcelableVector.size())) {
1484         ANS_LOGE("write ParcelableVector size failed");
1485         return false;
1486     }
1487 
1488     for (auto &parcelable : parcelableVector) {
1489         if (!reply.WriteStrongParcelable(parcelable)) {
1490             ANS_LOGE("write ParcelableVector failed");
1491             return false;
1492         }
1493     }
1494     return true;
1495 }
1496 
1497 template<typename T>
ReadParcelableVector(std::vector<sptr<T>> & parcelableInfos,MessageParcel & data)1498 bool AnsManagerStub::ReadParcelableVector(std::vector<sptr<T>> &parcelableInfos, MessageParcel &data)
1499 {
1500     int32_t infoSize = 0;
1501     if (!data.ReadInt32(infoSize)) {
1502         ANS_LOGE("read Parcelable size failed.");
1503         return false;
1504     }
1505 
1506     parcelableInfos.clear();
1507     infoSize = (infoSize < MAX_PARCELABLE_VECTOR_NUM) ? infoSize : MAX_PARCELABLE_VECTOR_NUM;
1508     for (int32_t index = 0; index < infoSize; index++) {
1509         sptr<T> info = data.ReadStrongParcelable<T>();
1510         if (info == nullptr) {
1511             ANS_LOGE("read Parcelable infos failed.");
1512             return false;
1513         }
1514         parcelableInfos.emplace_back(info);
1515     }
1516 
1517     return true;
1518 }
1519 
HandleIsSupportTemplate(MessageParcel & data,MessageParcel & reply)1520 ErrCode AnsManagerStub::HandleIsSupportTemplate(MessageParcel &data, MessageParcel &reply)
1521 {
1522     std::string templateName;
1523     if (!data.ReadString(templateName)) {
1524         ANS_LOGE("[HandleIsSupportTemplate] fail: read template name failed.");
1525         return ERR_ANS_PARCELABLE_FAILED;
1526     }
1527     bool support = false;
1528     ErrCode result = IsSupportTemplate(templateName, support);
1529     if (!reply.WriteInt32(result)) {
1530         ANS_LOGE("[HandleIsSupportTemplate] fail: write result failed, ErrCode=%{public}d", result);
1531         return ERR_ANS_PARCELABLE_FAILED;
1532     }
1533     if (!reply.WriteBool(support)) {
1534         ANS_LOGE("[HandleIsSupportTemplate] fail: write support failed.");
1535         return ERR_ANS_PARCELABLE_FAILED;
1536     }
1537     return ERR_OK;
1538 }
1539 
HandleIsSpecialUserAllowedNotifyByUser(MessageParcel & data,MessageParcel & reply)1540 ErrCode AnsManagerStub::HandleIsSpecialUserAllowedNotifyByUser(MessageParcel &data, MessageParcel &reply)
1541 {
1542     int32_t userId = SUBSCRIBE_USER_INIT;
1543     if (!data.ReadInt32(userId)) {
1544         ANS_LOGE("[HandleIsSpecialUserAllowedNotifyByUser] fail: read userId failed.");
1545         return ERR_ANS_PARCELABLE_FAILED;
1546     }
1547 
1548     bool allowed = false;
1549     ErrCode result = IsSpecialUserAllowedNotify(userId, allowed);
1550     if (!reply.WriteInt32(result)) {
1551         ANS_LOGE("[HandleIsSpecialUserAllowedNotifyByUser] fail: write result failed, ErrCode=%{public}d", result);
1552         return ERR_ANS_PARCELABLE_FAILED;
1553     }
1554 
1555     if (!reply.WriteBool(allowed)) {
1556         ANS_LOGE("[HandleIsSpecialUserAllowedNotifyByUser] fail: write allowed failed.");
1557         return ERR_ANS_PARCELABLE_FAILED;
1558     }
1559     return ERR_OK;
1560 }
1561 
HandleSetNotificationsEnabledByUser(MessageParcel & data,MessageParcel & reply)1562 ErrCode AnsManagerStub::HandleSetNotificationsEnabledByUser(MessageParcel &data, MessageParcel &reply)
1563 {
1564     int32_t userId = SUBSCRIBE_USER_INIT;
1565     if (!data.ReadInt32(userId)) {
1566         ANS_LOGE("[HandleSetNotificationsEnabledByUser] fail: read userId failed.");
1567         return ERR_ANS_PARCELABLE_FAILED;
1568     }
1569 
1570     bool enabled = false;
1571     if (!data.ReadBool(enabled)) {
1572         ANS_LOGE("[HandleSetNotificationsEnabledByUser] fail: read enabled failed.");
1573         return ERR_ANS_PARCELABLE_FAILED;
1574     }
1575 
1576     ErrCode result = SetNotificationsEnabledByUser(userId, enabled);
1577     if (!reply.WriteInt32(result)) {
1578         ANS_LOGE("[HandleSetNotificationsEnabledByUser] fail: write result failed, ErrCode=%{public}d", result);
1579         return ERR_ANS_PARCELABLE_FAILED;
1580     }
1581     return ERR_OK;
1582 }
1583 
HandleDeleteAllByUser(MessageParcel & data,MessageParcel & reply)1584 ErrCode AnsManagerStub::HandleDeleteAllByUser(MessageParcel &data, MessageParcel &reply)
1585 {
1586     int32_t userId = SUBSCRIBE_USER_INIT;
1587     if (!data.ReadInt32(userId)) {
1588         ANS_LOGE("[HandleDeleteAllByUser] fail: read userId failed.");
1589         return ERR_ANS_PARCELABLE_FAILED;
1590     }
1591 
1592     ErrCode result = DeleteAllByUser(userId);
1593     if (!reply.WriteInt32(result)) {
1594         ANS_LOGE("[HandleDeleteAllByUser] fail: write result failed, ErrCode=%{public}d", result);
1595         return ERR_ANS_PARCELABLE_FAILED;
1596     }
1597     return ERR_OK;
1598 }
1599 
HandleSetDoNotDisturbDateByUser(MessageParcel & data,MessageParcel & reply)1600 ErrCode AnsManagerStub::HandleSetDoNotDisturbDateByUser(MessageParcel &data, MessageParcel &reply)
1601 {
1602     int32_t userId = SUBSCRIBE_USER_INIT;
1603     if (!data.ReadInt32(userId)) {
1604         ANS_LOGE("[HandleSetDoNotDisturbDateByUser] fail: read userId failed.");
1605         return ERR_ANS_PARCELABLE_FAILED;
1606     }
1607 
1608     sptr<NotificationDoNotDisturbDate> date = data.ReadParcelable<NotificationDoNotDisturbDate>();
1609     if (date == nullptr) {
1610         ANS_LOGE("[HandleSetDoNotDisturbDateByUser] fail: read date failed.");
1611         return ERR_ANS_PARCELABLE_FAILED;
1612     }
1613 
1614     ErrCode result = SetDoNotDisturbDate(userId, date);
1615     if (!reply.WriteInt32(result)) {
1616         ANS_LOGE("[HandleSetDoNotDisturbDateByUser] fail: write result failed, ErrCode=%{public}d", result);
1617         return ERR_ANS_PARCELABLE_FAILED;
1618     }
1619 
1620     return ERR_OK;
1621 }
1622 
HandleGetDoNotDisturbDateByUser(MessageParcel & data,MessageParcel & reply)1623 ErrCode AnsManagerStub::HandleGetDoNotDisturbDateByUser(MessageParcel &data, MessageParcel &reply)
1624 {
1625     int32_t userId = SUBSCRIBE_USER_INIT;
1626     if (!data.ReadInt32(userId)) {
1627         ANS_LOGE("[HandleGetDoNotDisturbDateByUser] fail: read userId failed.");
1628         return ERR_ANS_PARCELABLE_FAILED;
1629     }
1630 
1631     sptr<NotificationDoNotDisturbDate> date = nullptr;
1632     ErrCode result = GetDoNotDisturbDate(userId, date);
1633     if (!reply.WriteInt32(result)) {
1634         ANS_LOGE("[HandleGetDoNotDisturbDateByUser] fail: write result failed, ErrCode=%{public}d", result);
1635         return ERR_ANS_PARCELABLE_FAILED;
1636     }
1637 
1638     if (result == ERR_OK) {
1639         if (!reply.WriteParcelable(date)) {
1640             ANS_LOGE("[HandleGetDoNotDisturbDateByUser] fail: write date failed.");
1641             return ERR_ANS_PARCELABLE_FAILED;
1642         }
1643     }
1644 
1645     return ERR_OK;
1646 }
1647 
HandleSetEnabledForBundleSlot(MessageParcel & data,MessageParcel & reply)1648 ErrCode AnsManagerStub::HandleSetEnabledForBundleSlot(MessageParcel &data, MessageParcel &reply)
1649 {
1650     sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
1651     if (bundleOption == nullptr) {
1652         ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: read bundle failed.");
1653         return ERR_ANS_PARCELABLE_FAILED;
1654     }
1655 
1656     int32_t type = 0;
1657     if (!data.ReadInt32(type)) {
1658         ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: read slot type failed.");
1659         return ERR_ANS_PARCELABLE_FAILED;
1660     }
1661     NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(type);
1662 
1663     bool enabled = false;
1664     if (!data.ReadBool(enabled)) {
1665         ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: read enabled failed.");
1666         return ERR_ANS_PARCELABLE_FAILED;
1667     }
1668 
1669     ErrCode result = SetEnabledForBundleSlot(bundleOption, slotType, enabled);
1670     if (!reply.WriteInt32(result)) {
1671         ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: write result failed, ErrCode=%{public}d", result);
1672         return ERR_ANS_PARCELABLE_FAILED;
1673     }
1674 
1675     return ERR_OK;
1676 }
1677 
HandleGetEnabledForBundleSlot(MessageParcel & data,MessageParcel & reply)1678 ErrCode AnsManagerStub::HandleGetEnabledForBundleSlot(MessageParcel &data, MessageParcel &reply)
1679 {
1680     sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
1681     if (bundleOption == nullptr) {
1682         ANS_LOGE("[HandleGetEnabledForBundleSlot] fail: read bundle failed.");
1683         return ERR_ANS_PARCELABLE_FAILED;
1684     }
1685 
1686     int32_t type = 0;
1687     if (!data.ReadInt32(type)) {
1688         ANS_LOGE("[HandleGetEnabledForBundleSlot] fail: read slot type failed.");
1689         return ERR_ANS_PARCELABLE_FAILED;
1690     }
1691     NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(type);
1692 
1693     bool enabled = false;
1694     ErrCode result = GetEnabledForBundleSlot(bundleOption, slotType, enabled);
1695     if (!reply.WriteInt32(result)) {
1696         ANS_LOGE("[HandleGetEnabledForBundleSlot] fail: write result failed, ErrCode=%{public}d", result);
1697         return ERR_ANS_PARCELABLE_FAILED;
1698     }
1699 
1700     if (!reply.WriteBool(enabled)) {
1701         ANS_LOGE("[HandleGetEnabledForBundleSlot] fail: write enabled failed, ErrCode=%{public}d", result);
1702         return ERR_ANS_PARCELABLE_FAILED;
1703     }
1704 
1705     return ERR_OK;
1706 }
1707 
HandleDistributedSetEnabledWithoutApp(MessageParcel & data,MessageParcel & reply)1708 ErrCode AnsManagerStub::HandleDistributedSetEnabledWithoutApp(MessageParcel &data, MessageParcel &reply)
1709 {
1710     int32_t userId = SUBSCRIBE_USER_INIT;
1711     if (!data.ReadInt32(userId)) {
1712         ANS_LOGE("[HandleDistributedSetEnabledWithoutApp] fail: read userId failed.");
1713         return ERR_ANS_PARCELABLE_FAILED;
1714     }
1715 
1716     bool enabled = false;
1717     if (!data.ReadBool(enabled)) {
1718         ANS_LOGE("[HandleDistributedSetEnabledWithoutApp] fail: read enabled failed.");
1719         return ERR_ANS_PARCELABLE_FAILED;
1720     }
1721 
1722     ErrCode result = SetSyncNotificationEnabledWithoutApp(userId, enabled);
1723     if (!reply.WriteInt32(result)) {
1724         ANS_LOGE("[HandleDistributedSetEnabledWithoutApp] fail: write result failed, ErrCode=%{public}d",
1725             result);
1726         return ERR_ANS_PARCELABLE_FAILED;
1727     }
1728 
1729     return ERR_OK;
1730 }
1731 
HandleDistributedGetEnabledWithoutApp(MessageParcel & data,MessageParcel & reply)1732 ErrCode AnsManagerStub::HandleDistributedGetEnabledWithoutApp(MessageParcel &data, MessageParcel &reply)
1733 {
1734     int32_t userId = SUBSCRIBE_USER_INIT;
1735     if (!data.ReadInt32(userId)) {
1736         ANS_LOGE("[HandleDistributedGetEnabledWithoutApp] fail: read userId failed.");
1737         return ERR_ANS_PARCELABLE_FAILED;
1738     }
1739 
1740     bool enabled = false;
1741     ErrCode result = GetSyncNotificationEnabledWithoutApp(userId, enabled);
1742     if (!reply.WriteInt32(result)) {
1743         ANS_LOGE("[HandleDistributedGetEnabledWithoutApp] fail: write result failed, ErrCode=%{public}d",
1744             result);
1745         return ERR_ANS_PARCELABLE_FAILED;
1746     }
1747 
1748     if (!reply.WriteBool(enabled)) {
1749         ANS_LOGE("[HandleDistributedGetEnabledWithoutApp] fail: write enabled failed.");
1750         return ERR_ANS_PARCELABLE_FAILED;
1751     }
1752 
1753     return ERR_OK;
1754 }
1755 
HandleSetBadgeNumber(MessageParcel & data,MessageParcel & reply)1756 ErrCode AnsManagerStub::HandleSetBadgeNumber(MessageParcel &data, MessageParcel &reply)
1757 {
1758     ANSR_LOGI("HandleSetBadgeNumber");
1759     int32_t badgeNumber = -1;
1760     if (!data.ReadInt32(badgeNumber)) {
1761         ANSR_LOGE("Read badge number failed.");
1762         return ERR_ANS_PARCELABLE_FAILED;
1763     }
1764 
1765     ErrCode result = SetBadgeNumber(badgeNumber);
1766     if (!reply.WriteInt32(result)) {
1767         ANSR_LOGE("Write badge number failed");
1768         return ERR_ANS_PARCELABLE_FAILED;
1769     }
1770     return result;
1771 }
1772 
HandleRegisterPushCallback(MessageParcel & data,MessageParcel & reply)1773 ErrCode AnsManagerStub::HandleRegisterPushCallback(MessageParcel &data, MessageParcel &reply)
1774 {
1775     sptr<IRemoteObject> pushCallBack = data.ReadRemoteObject();
1776     if (pushCallBack == nullptr) {
1777         ANS_LOGE("fail: read JSPushCallBack failed.");
1778         return ERR_ANS_PARCELABLE_FAILED;
1779     }
1780 
1781     ErrCode result = RegisterPushCallback(pushCallBack);
1782     if (!reply.WriteInt32(result)) {
1783         ANS_LOGE("fail: write result failed, ErrCode=%{public}d", result);
1784         return ERR_ANS_PARCELABLE_FAILED;
1785     }
1786     return result;
1787 }
1788 
HandleUnregisterPushCallback(MessageParcel & data,MessageParcel & reply)1789 ErrCode AnsManagerStub::HandleUnregisterPushCallback(MessageParcel &data, MessageParcel &reply)
1790 {
1791     ErrCode result = UnregisterPushCallback();
1792     if (!reply.WriteInt32(result)) {
1793         ANS_LOGE("fail: write result failed, ErrCode=%{public}d", result);
1794         return ERR_ANS_PARCELABLE_FAILED;
1795     }
1796     return result;
1797 }
1798 
Publish(const std::string & label,const sptr<NotificationRequest> & notification)1799 ErrCode AnsManagerStub::Publish(const std::string &label, const sptr<NotificationRequest> &notification)
1800 {
1801     ANS_LOGE("AnsManagerStub::Publish called!");
1802     return ERR_INVALID_OPERATION;
1803 }
1804 
Cancel(int notificationId,const std::string & label)1805 ErrCode AnsManagerStub::Cancel(int notificationId, const std::string &label)
1806 {
1807     ANS_LOGE("AnsManagerStub::Cancel called!");
1808     return ERR_INVALID_OPERATION;
1809 }
1810 
CancelAll()1811 ErrCode AnsManagerStub::CancelAll()
1812 {
1813     ANS_LOGE("AnsManagerStub::CancelAll called!");
1814     return ERR_INVALID_OPERATION;
1815 }
1816 
CancelAsBundle(int32_t notificationId,const std::string & representativeBundle,int32_t userId)1817 ErrCode AnsManagerStub::CancelAsBundle(int32_t notificationId, const std::string &representativeBundle, int32_t userId)
1818 {
1819     ANS_LOGE("AnsManagerStub::CancelAsBundle called!");
1820     return ERR_INVALID_OPERATION;
1821 }
1822 
AddSlotByType(NotificationConstant::SlotType slotType)1823 ErrCode AnsManagerStub::AddSlotByType(NotificationConstant::SlotType slotType)
1824 {
1825     ANS_LOGE("AnsManagerStub::AddSlotByType called!");
1826     return ERR_INVALID_OPERATION;
1827 }
1828 
AddSlots(const std::vector<sptr<NotificationSlot>> & slots)1829 ErrCode AnsManagerStub::AddSlots(const std::vector<sptr<NotificationSlot>> &slots)
1830 {
1831     ANS_LOGE("AnsManagerStub::AddSlots called!");
1832     return ERR_INVALID_OPERATION;
1833 }
1834 
RemoveSlotByType(const NotificationConstant::SlotType & slotType)1835 ErrCode AnsManagerStub::RemoveSlotByType(const NotificationConstant::SlotType &slotType)
1836 {
1837     ANS_LOGE("AnsManagerStub::RemoveSlotByType called!");
1838     return ERR_INVALID_OPERATION;
1839 }
1840 
RemoveAllSlots()1841 ErrCode AnsManagerStub::RemoveAllSlots()
1842 {
1843     ANS_LOGE("AnsManagerStub::RemoveAllSlots called!");
1844     return ERR_INVALID_OPERATION;
1845 }
1846 
GetSlotByType(const NotificationConstant::SlotType & slotType,sptr<NotificationSlot> & slot)1847 ErrCode AnsManagerStub::GetSlotByType(const NotificationConstant::SlotType &slotType, sptr<NotificationSlot> &slot)
1848 {
1849     ANS_LOGE("AnsManagerStub::GetSlotByType called!");
1850     return ERR_INVALID_OPERATION;
1851 }
1852 
GetSlots(std::vector<sptr<NotificationSlot>> & slots)1853 ErrCode AnsManagerStub::GetSlots(std::vector<sptr<NotificationSlot>> &slots)
1854 {
1855     ANS_LOGE("AnsManagerStub::GetSlots called!");
1856     return ERR_INVALID_OPERATION;
1857 }
1858 
GetSlotNumAsBundle(const sptr<NotificationBundleOption> & bundleOption,uint64_t & num)1859 ErrCode AnsManagerStub::GetSlotNumAsBundle(const sptr<NotificationBundleOption> &bundleOption, uint64_t &num)
1860 {
1861     ANS_LOGE("AnsManagerStub::GetSlotNumAsBundle called!");
1862     return ERR_INVALID_OPERATION;
1863 }
1864 
GetActiveNotifications(std::vector<sptr<NotificationRequest>> & notifications)1865 ErrCode AnsManagerStub::GetActiveNotifications(std::vector<sptr<NotificationRequest>> &notifications)
1866 {
1867     ANS_LOGE("AnsManagerStub::GetActiveNotifications called!");
1868     return ERR_INVALID_OPERATION;
1869 }
1870 
GetActiveNotificationNums(uint64_t & num)1871 ErrCode AnsManagerStub::GetActiveNotificationNums(uint64_t &num)
1872 {
1873     ANS_LOGE("AnsManagerStub::GetActiveNotificationNums called!");
1874     return ERR_INVALID_OPERATION;
1875 }
1876 
GetAllActiveNotifications(std::vector<sptr<Notification>> & notifications)1877 ErrCode AnsManagerStub::GetAllActiveNotifications(std::vector<sptr<Notification>> &notifications)
1878 {
1879     ANS_LOGE("AnsManagerStub::GetAllActiveNotifications called!");
1880     return ERR_INVALID_OPERATION;
1881 }
1882 
GetSpecialActiveNotifications(const std::vector<std::string> & key,std::vector<sptr<Notification>> & notifications)1883 ErrCode AnsManagerStub::GetSpecialActiveNotifications(
1884     const std::vector<std::string> &key, std::vector<sptr<Notification>> &notifications)
1885 {
1886     ANS_LOGE("AnsManagerStub::GetSpecialActiveNotifications called!");
1887     return ERR_INVALID_OPERATION;
1888 }
1889 
SetNotificationAgent(const std::string & agent)1890 ErrCode AnsManagerStub::SetNotificationAgent(const std::string &agent)
1891 {
1892     ANS_LOGE("AnsManagerStub::SetNotificationAgent called!");
1893     return ERR_INVALID_OPERATION;
1894 }
1895 
GetNotificationAgent(std::string & agent)1896 ErrCode AnsManagerStub::GetNotificationAgent(std::string &agent)
1897 {
1898     ANS_LOGE("AnsManagerStub::GetNotificationAgent called!");
1899     return ERR_INVALID_OPERATION;
1900 }
1901 
CanPublishAsBundle(const std::string & representativeBundle,bool & canPublish)1902 ErrCode AnsManagerStub::CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish)
1903 {
1904     ANS_LOGE("AnsManagerStub::CanPublishAsBundle called!");
1905     return ERR_INVALID_OPERATION;
1906 }
1907 
PublishAsBundle(const sptr<NotificationRequest> notification,const std::string & representativeBundle)1908 ErrCode AnsManagerStub::PublishAsBundle(
1909     const sptr<NotificationRequest> notification, const std::string &representativeBundle)
1910 {
1911     ANS_LOGE("AnsManagerStub::PublishAsBundle called!");
1912     return ERR_INVALID_OPERATION;
1913 }
1914 
SetNotificationBadgeNum(int num)1915 ErrCode AnsManagerStub::SetNotificationBadgeNum(int num)
1916 {
1917     ANS_LOGE("AnsManagerStub::SetNotificationBadgeNum called!");
1918     return ERR_INVALID_OPERATION;
1919 }
1920 
GetBundleImportance(int & importance)1921 ErrCode AnsManagerStub::GetBundleImportance(int &importance)
1922 {
1923     ANS_LOGE("AnsManagerStub::GetBundleImportance called!");
1924     return ERR_INVALID_OPERATION;
1925 }
1926 
HasNotificationPolicyAccessPermission(bool & granted)1927 ErrCode AnsManagerStub::HasNotificationPolicyAccessPermission(bool &granted)
1928 {
1929     ANS_LOGE("AnsManagerStub::HasNotificationPolicyAccessPermission called!");
1930     return ERR_INVALID_OPERATION;
1931 }
1932 
RemoveNotification(const sptr<NotificationBundleOption> & bundleOption,int notificationId,const std::string & label,int32_t removeReason)1933 ErrCode AnsManagerStub::RemoveNotification(const sptr<NotificationBundleOption> &bundleOption,
1934     int notificationId, const std::string &label, int32_t removeReason)
1935 {
1936     ANS_LOGE("AnsManagerStub::RemoveNotification called!");
1937     return ERR_INVALID_OPERATION;
1938 }
1939 
RemoveAllNotifications(const sptr<NotificationBundleOption> & bundleOption)1940 ErrCode AnsManagerStub::RemoveAllNotifications(const sptr<NotificationBundleOption> &bundleOption)
1941 {
1942     ANS_LOGE("AnsManagerStub::RemoveAllNotifications called!");
1943     return ERR_INVALID_OPERATION;
1944 }
1945 
RemoveNotifications(const std::vector<std::string> & keys,int32_t removeReason)1946 ErrCode AnsManagerStub::RemoveNotifications(const std::vector<std::string> &keys, int32_t removeReason)
1947 {
1948     ANS_LOGD("called!");
1949     return ERR_INVALID_OPERATION;
1950 }
1951 
Delete(const std::string & key,int32_t removeReason)1952 ErrCode AnsManagerStub::Delete(const std::string &key, int32_t removeReason)
1953 {
1954     ANS_LOGE("AnsManagerStub::Delete called!");
1955     return ERR_INVALID_OPERATION;
1956 }
1957 
DeleteByBundle(const sptr<NotificationBundleOption> & bundleOption)1958 ErrCode AnsManagerStub::DeleteByBundle(const sptr<NotificationBundleOption> &bundleOption)
1959 {
1960     ANS_LOGE("AnsManagerStub::DeleteByBundle called!");
1961     return ERR_INVALID_OPERATION;
1962 }
1963 
DeleteAll()1964 ErrCode AnsManagerStub::DeleteAll()
1965 {
1966     ANS_LOGE("AnsManagerStub::DeleteAll called!");
1967     return ERR_INVALID_OPERATION;
1968 }
1969 
GetSlotsByBundle(const sptr<NotificationBundleOption> & bundleOption,std::vector<sptr<NotificationSlot>> & slots)1970 ErrCode AnsManagerStub::GetSlotsByBundle(
1971     const sptr<NotificationBundleOption> &bundleOption, std::vector<sptr<NotificationSlot>> &slots)
1972 {
1973     ANS_LOGE("AnsManagerStub::GetSlotsByBundle called!");
1974     return ERR_INVALID_OPERATION;
1975 }
1976 
UpdateSlots(const sptr<NotificationBundleOption> & bundleOption,const std::vector<sptr<NotificationSlot>> & slots)1977 ErrCode AnsManagerStub::UpdateSlots(
1978     const sptr<NotificationBundleOption> &bundleOption, const std::vector<sptr<NotificationSlot>> &slots)
1979 {
1980     ANS_LOGE("AnsManagerStub::UpdateSlots called!");
1981     return ERR_INVALID_OPERATION;
1982 }
1983 
RequestEnableNotification(const std::string & deviceId,const sptr<IRemoteObject> & callerToken)1984 ErrCode AnsManagerStub::RequestEnableNotification(const std::string &deviceId, const sptr<IRemoteObject> &callerToken)
1985 {
1986     ANS_LOGE("AnsManagerStub::RequestEnableNotification called!");
1987     return ERR_INVALID_OPERATION;
1988 }
1989 
SetNotificationsEnabledForBundle(const std::string & bundle,bool enabled)1990 ErrCode AnsManagerStub::SetNotificationsEnabledForBundle(const std::string &bundle, bool enabled)
1991 {
1992     ANS_LOGE("AnsManagerStub::SetNotificationsEnabledForBundle called!");
1993     return ERR_INVALID_OPERATION;
1994 }
1995 
SetNotificationsEnabledForAllBundles(const std::string & deviceId,bool enabled)1996 ErrCode AnsManagerStub::SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled)
1997 {
1998     ANS_LOGE("AnsManagerStub::SetNotificationsEnabledForAllBundles called!");
1999     return ERR_INVALID_OPERATION;
2000 }
2001 
SetNotificationsEnabledForSpecialBundle(const std::string & deviceId,const sptr<NotificationBundleOption> & bundleOption,bool enabled)2002 ErrCode AnsManagerStub::SetNotificationsEnabledForSpecialBundle(
2003     const std::string &deviceId, const sptr<NotificationBundleOption> &bundleOption, bool enabled)
2004 {
2005     ANS_LOGE("AnsManagerStub::SetNotificationsEnabledForSpecialBundle called!");
2006     return ERR_INVALID_OPERATION;
2007 }
2008 
SetShowBadgeEnabledForBundle(const sptr<NotificationBundleOption> & bundleOption,bool enabled)2009 ErrCode AnsManagerStub::SetShowBadgeEnabledForBundle(const sptr<NotificationBundleOption> &bundleOption, bool enabled)
2010 {
2011     ANS_LOGE("AnsManagerStub::SetShowBadgeEnabledForBundle called!");
2012     return ERR_INVALID_OPERATION;
2013 }
2014 
GetShowBadgeEnabledForBundle(const sptr<NotificationBundleOption> & bundleOption,bool & enabled)2015 ErrCode AnsManagerStub::GetShowBadgeEnabledForBundle(const sptr<NotificationBundleOption> &bundleOption, bool &enabled)
2016 {
2017     ANS_LOGE("AnsManagerStub::GetShowBadgeEnabledForBundle called!");
2018     return ERR_INVALID_OPERATION;
2019 }
2020 
GetShowBadgeEnabled(bool & enabled)2021 ErrCode AnsManagerStub::GetShowBadgeEnabled(bool &enabled)
2022 {
2023     ANS_LOGE("AnsManagerStub::GetShowBadgeEnabled called!");
2024     return ERR_INVALID_OPERATION;
2025 }
2026 
Subscribe(const sptr<AnsSubscriberInterface> & subscriber,const sptr<NotificationSubscribeInfo> & info)2027 ErrCode AnsManagerStub::Subscribe(const sptr<AnsSubscriberInterface> &subscriber,
2028     const sptr<NotificationSubscribeInfo> &info)
2029 {
2030     ANS_LOGE("AnsManagerStub::Subscribe called!");
2031     return ERR_INVALID_OPERATION;
2032 }
2033 
Unsubscribe(const sptr<AnsSubscriberInterface> & subscriber,const sptr<NotificationSubscribeInfo> & info)2034 ErrCode AnsManagerStub::Unsubscribe(const sptr<AnsSubscriberInterface> &subscriber,
2035     const sptr<NotificationSubscribeInfo> &info)
2036 {
2037     ANS_LOGE("AnsManagerStub::Unsubscribe called!");
2038     return ERR_INVALID_OPERATION;
2039 }
2040 
IsAllowedNotify(bool & allowed)2041 ErrCode AnsManagerStub::IsAllowedNotify(bool &allowed)
2042 {
2043     ANS_LOGE("AnsManagerStub::IsAllowedNotify called!");
2044     return ERR_INVALID_OPERATION;
2045 }
2046 
IsAllowedNotifySelf(bool & allowed)2047 ErrCode AnsManagerStub::IsAllowedNotifySelf(bool &allowed)
2048 {
2049     ANS_LOGE("AnsManagerStub::IsAllowedNotifySelf called!");
2050     return ERR_INVALID_OPERATION;
2051 }
2052 
IsSpecialBundleAllowedNotify(const sptr<NotificationBundleOption> & bundleOption,bool & allowed)2053 ErrCode AnsManagerStub::IsSpecialBundleAllowedNotify(const sptr<NotificationBundleOption> &bundleOption, bool &allowed)
2054 {
2055     ANS_LOGE("AnsManagerStub::IsSpecialBundleAllowedNotify called!");
2056     return ERR_INVALID_OPERATION;
2057 }
2058 
CancelGroup(const std::string & groupName)2059 ErrCode AnsManagerStub::CancelGroup(const std::string &groupName)
2060 {
2061     ANS_LOGE("AnsManagerStub::CancelGroup called!");
2062     return ERR_INVALID_OPERATION;
2063 }
2064 
RemoveGroupByBundle(const sptr<NotificationBundleOption> & bundleOption,const std::string & groupName)2065 ErrCode AnsManagerStub::RemoveGroupByBundle(
2066     const sptr<NotificationBundleOption> &bundleOption, const std::string &groupName)
2067 {
2068     ANS_LOGE("AnsManagerStub::RemoveGroupByBundle called!");
2069     return ERR_INVALID_OPERATION;
2070 }
2071 
SetDoNotDisturbDate(const sptr<NotificationDoNotDisturbDate> & date)2072 ErrCode AnsManagerStub::SetDoNotDisturbDate(const sptr<NotificationDoNotDisturbDate> &date)
2073 {
2074     ANS_LOGE("AnsManagerStub::SetDoNotDisturbDate called!");
2075     return ERR_INVALID_OPERATION;
2076 }
2077 
GetDoNotDisturbDate(sptr<NotificationDoNotDisturbDate> & date)2078 ErrCode AnsManagerStub::GetDoNotDisturbDate(sptr<NotificationDoNotDisturbDate> &date)
2079 {
2080     ANS_LOGE("AnsManagerStub::GetDoNotDisturbDate called!");
2081     return ERR_INVALID_OPERATION;
2082 }
2083 
DoesSupportDoNotDisturbMode(bool & doesSupport)2084 ErrCode AnsManagerStub::DoesSupportDoNotDisturbMode(bool &doesSupport)
2085 {
2086     ANS_LOGE("AnsManagerStub::DoesSupportDoNotDisturbMode called!");
2087     return ERR_INVALID_OPERATION;
2088 }
2089 
IsDistributedEnabled(bool & enabled)2090 ErrCode AnsManagerStub::IsDistributedEnabled(bool &enabled)
2091 {
2092     ANS_LOGE("AnsManagerStub::IsDistributedEnabled called!");
2093     return ERR_INVALID_OPERATION;
2094 }
2095 
EnableDistributed(bool enabled)2096 ErrCode AnsManagerStub::EnableDistributed(bool enabled)
2097 {
2098     ANS_LOGE("AnsManagerStub::EnableDistributed called!");
2099     return ERR_INVALID_OPERATION;
2100 }
2101 
EnableDistributedByBundle(const sptr<NotificationBundleOption> & bundleOption,bool enabled)2102 ErrCode AnsManagerStub::EnableDistributedByBundle(const sptr<NotificationBundleOption> &bundleOption, bool enabled)
2103 {
2104     ANS_LOGE("AnsManagerStub::EnableDistributedByBundle called!");
2105     return ERR_INVALID_OPERATION;
2106 }
2107 
EnableDistributedSelf(bool enabled)2108 ErrCode AnsManagerStub::EnableDistributedSelf(bool enabled)
2109 {
2110     ANS_LOGE("AnsManagerStub::EnableDistributedSelf called!");
2111     return ERR_INVALID_OPERATION;
2112 }
2113 
IsDistributedEnableByBundle(const sptr<NotificationBundleOption> & bundleOption,bool & enabled)2114 ErrCode AnsManagerStub::IsDistributedEnableByBundle(const sptr<NotificationBundleOption> &bundleOption, bool &enabled)
2115 {
2116     ANS_LOGE("AnsManagerStub::IsDistributedEnableByBundle called!");
2117     return ERR_INVALID_OPERATION;
2118 }
2119 
GetDeviceRemindType(NotificationConstant::RemindType & remindType)2120 ErrCode AnsManagerStub::GetDeviceRemindType(NotificationConstant::RemindType &remindType)
2121 {
2122     ANS_LOGE("AnsManagerStub::GetDeviceRemindType called!");
2123     return ERR_INVALID_OPERATION;
2124 }
2125 
PublishContinuousTaskNotification(const sptr<NotificationRequest> & request)2126 ErrCode AnsManagerStub::PublishContinuousTaskNotification(const sptr<NotificationRequest> &request)
2127 {
2128     ANS_LOGE("AnsManagerStub::PublishContinuousTaskNotification called!");
2129     return ERR_INVALID_OPERATION;
2130 }
2131 
CancelContinuousTaskNotification(const std::string & label,int32_t notificationId)2132 ErrCode AnsManagerStub::CancelContinuousTaskNotification(const std::string &label, int32_t notificationId)
2133 {
2134     ANS_LOGE("AnsManagerStub::CancelContinuousTaskNotification called!");
2135     return ERR_INVALID_OPERATION;
2136 }
2137 
PublishReminder(sptr<ReminderRequest> & reminder)2138 ErrCode AnsManagerStub::PublishReminder(sptr<ReminderRequest> &reminder)
2139 {
2140     ANS_LOGE("AnsManagerStub::PublishReminder called!");
2141     return ERR_INVALID_OPERATION;
2142 }
2143 
CancelReminder(const int32_t reminderId)2144 ErrCode AnsManagerStub::CancelReminder(const int32_t reminderId)
2145 {
2146     ANS_LOGE("AnsManagerStub::CancelReminder called!");
2147     return ERR_INVALID_OPERATION;
2148 }
2149 
GetValidReminders(std::vector<sptr<ReminderRequest>> & reminders)2150 ErrCode AnsManagerStub::GetValidReminders(std::vector<sptr<ReminderRequest>> &reminders)
2151 {
2152     ANS_LOGE("AnsManagerStub::getValidReminders called!");
2153     return ERR_INVALID_OPERATION;
2154 }
2155 
CancelAllReminders()2156 ErrCode AnsManagerStub::CancelAllReminders()
2157 {
2158     ANS_LOGE("AnsManagerStub::cancelAllReminders called!");
2159     return ERR_INVALID_OPERATION;
2160 }
2161 
IsSupportTemplate(const std::string & templateName,bool & support)2162 ErrCode AnsManagerStub::IsSupportTemplate(const std::string &templateName, bool &support)
2163 {
2164     ANS_LOGE("AnsManagerStub::IsSupportTemplate called!");
2165     return ERR_INVALID_OPERATION;
2166 }
2167 
IsSpecialUserAllowedNotify(const int32_t & userId,bool & allowed)2168 ErrCode AnsManagerStub::IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed)
2169 {
2170     ANS_LOGE("AnsManagerStub::IsSpecialUserAllowedNotify called!");
2171     return ERR_INVALID_OPERATION;
2172 }
2173 
SetNotificationsEnabledByUser(const int32_t & deviceId,bool enabled)2174 ErrCode AnsManagerStub::SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled)
2175 {
2176     ANS_LOGE("AnsManagerStub::SetNotificationsEnabledByUser called!");
2177     return ERR_INVALID_OPERATION;
2178 }
2179 
DeleteAllByUser(const int32_t & userId)2180 ErrCode AnsManagerStub::DeleteAllByUser(const int32_t &userId)
2181 {
2182     ANS_LOGE("AnsManagerStub::DeleteAllByUser called!");
2183     return ERR_INVALID_OPERATION;
2184 }
2185 
SetDoNotDisturbDate(const int32_t & userId,const sptr<NotificationDoNotDisturbDate> & date)2186 ErrCode AnsManagerStub::SetDoNotDisturbDate(const int32_t &userId, const sptr<NotificationDoNotDisturbDate> &date)
2187 {
2188     ANS_LOGE("AnsManagerStub::SetDoNotDisturbDate called!");
2189     return ERR_INVALID_OPERATION;
2190 }
2191 
GetDoNotDisturbDate(const int32_t & userId,sptr<NotificationDoNotDisturbDate> & date)2192 ErrCode AnsManagerStub::GetDoNotDisturbDate(const int32_t &userId, sptr<NotificationDoNotDisturbDate> &date)
2193 {
2194     ANS_LOGE("AnsManagerStub::GetDoNotDisturbDate called!");
2195     return ERR_INVALID_OPERATION;
2196 }
2197 
SetEnabledForBundleSlot(const sptr<NotificationBundleOption> & bundleOption,const NotificationConstant::SlotType & slotType,bool enabled)2198 ErrCode AnsManagerStub::SetEnabledForBundleSlot(
2199     const sptr<NotificationBundleOption> &bundleOption, const NotificationConstant::SlotType &slotType, bool enabled)
2200 {
2201     ANS_LOGE("AnsManagerStub::SetEnabledForBundleSlot called!");
2202     return ERR_INVALID_OPERATION;
2203 }
2204 
GetEnabledForBundleSlot(const sptr<NotificationBundleOption> & bundleOption,const NotificationConstant::SlotType & slotType,bool & enabled)2205 ErrCode AnsManagerStub::GetEnabledForBundleSlot(
2206     const sptr<NotificationBundleOption> &bundleOption, const NotificationConstant::SlotType &slotType, bool &enabled)
2207 {
2208     ANS_LOGE("AnsManagerStub::GetEnabledForBundleSlot called!");
2209     return ERR_INVALID_OPERATION;
2210 }
2211 
2212 
ShellDump(const std::string & cmd,const std::string & bundle,int32_t userId,std::vector<std::string> & dumpInfo)2213 ErrCode AnsManagerStub::ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId,
2214     std::vector<std::string> &dumpInfo)
2215 {
2216     ANS_LOGE("AnsManagerStub::ShellDump called!");
2217     return ERR_INVALID_OPERATION;
2218 }
2219 
SetSyncNotificationEnabledWithoutApp(const int32_t userId,const bool enabled)2220 ErrCode AnsManagerStub::SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled)
2221 {
2222     ANS_LOGE("AnsManagerStub::SetSyncNotificationEnabledWithoutApp called!");
2223     return ERR_INVALID_OPERATION;
2224 }
2225 
GetSyncNotificationEnabledWithoutApp(const int32_t userId,bool & enabled)2226 ErrCode AnsManagerStub::GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled)
2227 {
2228     ANS_LOGE("AnsManagerStub::GetSyncNotificationEnabledWithoutApp called!");
2229     return ERR_INVALID_OPERATION;
2230 }
2231 
SetBadgeNumber(int32_t badgeNumber)2232 ErrCode AnsManagerStub::SetBadgeNumber(int32_t badgeNumber)
2233 {
2234     ANS_LOGE("AnsManagerStub::SetBadgeNumber called!");
2235     return ERR_INVALID_OPERATION;
2236 }
2237 
RegisterPushCallback(const sptr<IRemoteObject> & pushCallback)2238 ErrCode AnsManagerStub::RegisterPushCallback(const sptr<IRemoteObject>& pushCallback)
2239 {
2240     ANS_LOGE("RegisterPushCallback called!");
2241     return ERR_INVALID_OPERATION;
2242 }
2243 
UnregisterPushCallback()2244 ErrCode AnsManagerStub::UnregisterPushCallback()
2245 {
2246     ANS_LOGE("UnregisterPushCallback called!");
2247     return ERR_INVALID_OPERATION;
2248 }
2249 }  // namespace Notification
2250 }  // namespace OHOS
2251