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