1 /*
2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #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 "ans_subscriber_local_live_view_interface.h"
21 #include "disturb_manager.h"
22 #include "message_option.h"
23 #include "message_parcel.h"
24 #include "notification_bundle_option.h"
25 #include "notification_button_option.h"
26 #include "parcel.h"
27 #include "reminder_request_alarm.h"
28 #include "reminder_request_calendar.h"
29 #include "reminder_request_timer.h"
30 #include "slot_manager.h"
31
32 namespace OHOS {
33 namespace Notification {
AnsManagerStub()34 AnsManagerStub::AnsManagerStub() {}
35
~AnsManagerStub()36 AnsManagerStub::~AnsManagerStub() {}
37
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & flags)38 int32_t AnsManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &flags)
39 {
40 std::u16string descriptor = AnsManagerStub::GetDescriptor();
41 std::u16string remoteDescriptor = data.ReadInterfaceToken();
42 if (descriptor != remoteDescriptor) {
43 ANS_LOGE("[OnRemoteRequest] fail: invalid interface token!");
44 return OBJECT_NULL;
45 }
46 ANS_LOGE("[OnRemoteRequest] called");
47 ErrCode result = NO_ERROR;
48 switch (code) {
49 case static_cast<uint32_t>(NotificationInterfaceCode::PUBLISH_NOTIFICATION): {
50 result = HandlePublish(data, reply);
51 break;
52 }
53 case static_cast<uint32_t>(NotificationInterfaceCode::PUBLISH_NOTIFICATION_INDIRECTPROXY): {
54 result = HandlePublishNotificationForIndirectProxy(data, reply);
55 break;
56 }
57 case static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_NOTIFICATION): {
58 result = HandleCancel(data, reply);
59 break;
60 }
61 case static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_ALL_NOTIFICATIONS): {
62 result = HandleCancelAll(data, reply);
63 break;
64 }
65 case static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE_OPTION): {
66 result = HandleCancelAsBundleOption(data, reply);
67 break;
68 }
69 case static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE_AND_USER): {
70 result = HandleCancelAsBundleAndUser(data, reply);
71 break;
72 }
73 case static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE): {
74 result = HandleCancelAsBundle(data, reply);
75 break;
76 }
77 case static_cast<uint32_t>(NotificationInterfaceCode::ADD_SLOT_BY_TYPE): {
78 result = HandleAddSlotByType(data, reply);
79 break;
80 }
81 case static_cast<uint32_t>(NotificationInterfaceCode::ADD_SLOTS):
82 case static_cast<uint32_t>(NotificationInterfaceCode::SET_ENABLED_FOR_BUNDLE_SLOT): {
83 result = DelayedSingleton<SlotManager>::GetInstance()->OnRemoteRequest(code, data, reply);
84 break;
85 }
86 case static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_SLOT_BY_TYPE): {
87 result = HandleRemoveSlotByType(data, reply);
88 break;
89 }
90 case static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_ALL_SLOTS): {
91 result = HandleRemoveAllSlots(data, reply);
92 break;
93 }
94 case static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOT_BY_TYPE): {
95 result = HandleGetSlotByType(data, reply);
96 break;
97 }
98 case static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOTS): {
99 result = HandleGetSlots(data, reply);
100 break;
101 }
102 case static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOT_NUM_AS_BUNDLE): {
103 result = HandleGetSlotNumAsBundle(data, reply);
104 break;
105 }
106 case static_cast<uint32_t>(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATIONS): {
107 result = HandleGetActiveNotifications(data, reply);
108 break;
109 }
110 case static_cast<uint32_t>(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATION_NUMS): {
111 result = HandleGetActiveNotificationNums(data, reply);
112 break;
113 }
114 case static_cast<uint32_t>(NotificationInterfaceCode::GET_ALL_ACTIVE_NOTIFICATIONS): {
115 result = HandleGetAllActiveNotifications(data, reply);
116 break;
117 }
118 case static_cast<uint32_t>(NotificationInterfaceCode::GET_SPECIAL_ACTIVE_NOTIFICATIONS): {
119 result = HandleGetSpecialActiveNotifications(data, reply);
120 break;
121 }
122 case static_cast<uint32_t>(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATION_BY_FILTER): {
123 result = HandleGetActiveNotificationByFilter(data, reply);
124 break;
125 }
126 case static_cast<uint32_t>(NotificationInterfaceCode::CAN_PUBLISH_AS_BUNDLE): {
127 result = HandleCanPublishAsBundle(data, reply);
128 break;
129 }
130 case static_cast<uint32_t>(NotificationInterfaceCode::PUBLISH_AS_BUNDLE): {
131 result = HandlePublishAsBundle(data, reply);
132 break;
133 }
134 case static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_BADGE_NUM): {
135 result = HandleSetNotificationBadgeNum(data, reply);
136 break;
137 }
138 case static_cast<uint32_t>(NotificationInterfaceCode::GET_BUNDLE_IMPORTANCE): {
139 result = HandleGetBundleImportance(data, reply);
140 break;
141 }
142 case static_cast<uint32_t>(NotificationInterfaceCode::IS_NOTIFICATION_POLICY_ACCESS_GRANTED): {
143 result = HandleIsNotificationPolicyAccessGranted(data, reply);
144 break;
145 }
146 case static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_NOTIFICATION): {
147 result = HandleRemoveNotification(data, reply);
148 break;
149 }
150 case static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_ALL_NOTIFICATIONS): {
151 result = HandleRemoveAllNotifications(data, reply);
152 break;
153 }
154 case static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_NOTIFICATIONS_BY_KEYS): {
155 result = HandleRemoveNotifications(data, reply);
156 break;
157 }
158 case static_cast<uint32_t>(NotificationInterfaceCode::DELETE_NOTIFICATION): {
159 result = HandleDelete(data, reply);
160 break;
161 }
162 case static_cast<uint32_t>(NotificationInterfaceCode::DELETE_NOTIFICATION_BY_BUNDLE): {
163 result = HandleDeleteByBundle(data, reply);
164 break;
165 }
166 case static_cast<uint32_t>(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS): {
167 result = HandleDeleteAll(data, reply);
168 break;
169 }
170 case static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOTS_BY_BUNDLE): {
171 result = HandleGetSlotsByBundle(data, reply);
172 break;
173 }
174 case static_cast<uint32_t>(NotificationInterfaceCode::UPDATE_SLOTS): {
175 result = HandleUpdateSlots(data, reply);
176 break;
177 }
178 case static_cast<uint32_t>(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION): {
179 result = HandleRequestEnableNotification(data, reply);
180 break;
181 }
182 case static_cast<uint32_t>(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION_BY_BUNDLE): {
183 result = HandleRequestEnableNotificationByBundle(data, reply);
184 break;
185 }
186 case static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_BUNDLE): {
187 result = HandleSetNotificationsEnabledForBundle(data, reply);
188 break;
189 }
190 case static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_ALL_BUNDLE): {
191 result = HandleSetNotificationsEnabledForAllBundles(data, reply);
192 break;
193 }
194 case static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE): {
195 result = HandleSetNotificationsEnabledForSpecialBundle(data, reply);
196 break;
197 }
198 case static_cast<uint32_t>(NotificationInterfaceCode::SET_SHOW_BADGE_ENABLED_FOR_BUNDLE): {
199 result = HandleSetShowBadgeEnabledForBundle(data, reply);
200 break;
201 }
202 case static_cast<uint32_t>(NotificationInterfaceCode::GET_SHOW_BADGE_ENABLED_FOR_BUNDLE): {
203 result = HandleGetShowBadgeEnabledForBundle(data, reply);
204 break;
205 }
206 case static_cast<uint32_t>(NotificationInterfaceCode::GET_SHOW_BADGE_ENABLED): {
207 result = HandleGetShowBadgeEnabled(data, reply);
208 break;
209 }
210 case static_cast<uint32_t>(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION): {
211 result = HandleSubscribe(data, reply);
212 break;
213 }
214 case static_cast<uint32_t>(NotificationInterfaceCode::UNSUBSCRIBE_NOTIFICATION): {
215 result = HandleUnsubscribe(data, reply);
216 break;
217 }
218 case static_cast<uint32_t>(NotificationInterfaceCode::IS_ALLOWED_NOTIFY): {
219 result = HandleIsAllowedNotify(data, reply);
220 break;
221 }
222 case static_cast<uint32_t>(NotificationInterfaceCode::IS_ALLOWED_NOTIFY_SELF): {
223 result = HandleIsAllowedNotifySelf(data, reply);
224 break;
225 }
226 case static_cast<uint32_t>(NotificationInterfaceCode::CAN_POP_ENABLE_NOTIFICATION_DIALOG): {
227 result = HandleCanPopEnableNotificationDialog(data, reply);
228 break;
229 }
230 case static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_ENABLE_NOTIFICATION_DIALOG): {
231 result = HandleRemoveEnableNotificationDialog(data, reply);
232 break;
233 }
234 case static_cast<uint32_t>(NotificationInterfaceCode::IS_SPECIAL_BUNDLE_ALLOWED_NOTIFY): {
235 result = HandleIsSpecialBundleAllowedNotify(data, reply);
236 break;
237 }
238 case static_cast<uint32_t>(NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE):
239 case static_cast<uint32_t>(NotificationInterfaceCode::GET_DO_NOT_DISTURB_DATE):
240 case static_cast<uint32_t>(NotificationInterfaceCode::DOES_SUPPORT_DO_NOT_DISTURB_MODE): {
241 result = DelayedSingleton<DisturbManager>::GetInstance()->OnRemoteRequest(code, data, reply);
242 break;
243 }
244 case static_cast<uint32_t>(NotificationInterfaceCode::IS_NEED_SILENT_IN_DO_NOT_DISTURB_MODE): {
245 result = HandleIsNeedSilentInDoNotDisturbMode(data, reply);
246 break;
247 }
248 case static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_GROUP): {
249 result = HandleCancelGroup(data, reply);
250 break;
251 }
252 case static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_GROUP_BY_BUNDLE): {
253 result = HandleRemoveGroupByBundle(data, reply);
254 break;
255 }
256 case static_cast<uint32_t>(NotificationInterfaceCode::IS_DISTRIBUTED_ENABLED): {
257 result = HandleIsDistributedEnabled(data, reply);
258 break;
259 }
260 case static_cast<uint32_t>(NotificationInterfaceCode::ENABLE_DISTRIBUTED): {
261 result = HandleEnableDistributed(data, reply);
262 break;
263 }
264 case static_cast<uint32_t>(NotificationInterfaceCode::ENABLE_DISTRIBUTED_BY_BUNDLE): {
265 result = HandleEnableDistributedByBundle(data, reply);
266 break;
267 }
268 case static_cast<uint32_t>(NotificationInterfaceCode::ENABLE_DISTRIBUTED_SELF): {
269 result = HandleEnableDistributedSelf(data, reply);
270 break;
271 }
272 case static_cast<uint32_t>(NotificationInterfaceCode::IS_DISTRIBUTED_ENABLED_BY_BUNDLE): {
273 result = HandleIsDistributedEnableByBundle(data, reply);
274 break;
275 }
276 case static_cast<uint32_t>(NotificationInterfaceCode::GET_DEVICE_REMIND_TYPE): {
277 result = HandleGetDeviceRemindType(data, reply);
278 break;
279 }
280 case static_cast<uint32_t>(NotificationInterfaceCode::SHELL_DUMP): {
281 result = HandleShellDump(data, reply);
282 break;
283 }
284 case static_cast<uint32_t>(NotificationInterfaceCode::PUBLISH_CONTINUOUS_TASK_NOTIFICATION): {
285 result = HandlePublishContinuousTaskNotification(data, reply);
286 break;
287 }
288 case static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_CONTINUOUS_TASK_NOTIFICATION): {
289 result = HandleCancelContinuousTaskNotification(data, reply);
290 break;
291 }
292 case static_cast<uint32_t>(NotificationInterfaceCode::IS_SUPPORT_TEMPLATE): {
293 result = HandleIsSupportTemplate(data, reply);
294 break;
295 }
296 case static_cast<uint32_t>(NotificationInterfaceCode::IS_SPECIAL_USER_ALLOWED_NOTIFY): {
297 result = HandleIsSpecialUserAllowedNotifyByUser(data, reply);
298 break;
299 }
300 case static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_BY_USER): {
301 result = HandleSetNotificationsEnabledByUser(data, reply);
302 break;
303 }
304 case static_cast<uint32_t>(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS_BY_USER): {
305 result = HandleDeleteAllByUser(data, reply);
306 break;
307 }
308 case static_cast<uint32_t>(NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE_BY_USER):
309 case static_cast<uint32_t>(NotificationInterfaceCode::GET_DO_NOT_DISTURB_DATE_BY_USER): {
310 result = DelayedSingleton<DisturbManager>::GetInstance()->OnRemoteRequest(code, data, reply);
311 break;
312 }
313 case static_cast<uint32_t>(NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT): {
314 result = HandleGetEnabledForBundleSlot(data, reply);
315 break;
316 }
317 case static_cast<uint32_t>(NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT_SELF): {
318 result = HandleGetEnabledForBundleSlotSelf(data, reply);
319 break;
320 }
321 case static_cast<uint32_t>(NotificationInterfaceCode::SET_DISTRIBUTED_ENABLED_BY_BUNDLE): {
322 result = HandleSetDistributedEnabledByBundle(data, reply);
323 break;
324 }
325 case static_cast<uint32_t>(NotificationInterfaceCode::GET_DISTRIBUTED_ENABLED_BY_BUNDLE): {
326 result = HandleIsDistributedEnabledByBundle(data, reply);
327 break;
328 }
329 case static_cast<uint32_t>(NotificationInterfaceCode::SET_SMART_REMINDER_ENABLED): {
330 result = HandleSetSmartReminderEnabled(data, reply);
331 break;
332 }
333 case static_cast<uint32_t>(NotificationInterfaceCode::GET_SMART_REMINDER_ENABLED): {
334 result = HandleIsSmartReminderEnabled(data, reply);
335 break;
336 }
337 case static_cast<uint32_t>(NotificationInterfaceCode::SET_DISTRIBUTED_ENABLED_BY_SLOT): {
338 result = HandleSetDistributedEnabledBySlot(data, reply);
339 break;
340 }
341 case static_cast<uint32_t>(NotificationInterfaceCode::GET_DISTRIBUTED_ENABLED_BY_SLOT): {
342 result = HandleIsDistributedEnabledBySlot(data, reply);
343 break;
344 }
345 case static_cast<uint32_t>(NotificationInterfaceCode::SET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP): {
346 result = HandleDistributedSetEnabledWithoutApp(data, reply);
347 break;
348 }
349 case static_cast<uint32_t>(NotificationInterfaceCode::GET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP): {
350 result = HandleDistributedGetEnabledWithoutApp(data, reply);
351 break;
352 }
353 case static_cast<uint32_t>(NotificationInterfaceCode::SET_BADGE_NUMBER): {
354 result = HandleSetBadgeNumber(data, reply);
355 break;
356 }
357 case static_cast<uint32_t>(NotificationInterfaceCode::SET_BADGE_NUMBER_BY_BUNDLE): {
358 result = HandleSetBadgeNumberByBundle(data, reply);
359 break;
360 }
361 case static_cast<uint32_t>(NotificationInterfaceCode::SET_BADGE_NUMBER_FOR_DH_BY_BUNDLE): {
362 result = HandleSetBadgeNumberForDhByBundle(data, reply);
363 break;
364 }
365 case static_cast<uint32_t>(NotificationInterfaceCode::GET_ALL_NOTIFICATION_ENABLE_STATUS): {
366 result = HandleGetAllNotificationEnableStatus(data, reply);
367 break;
368 }
369 case static_cast<uint32_t>(NotificationInterfaceCode::GET_ALL_LIVEVIEW_ENABLE_STATUS): {
370 result = HandleGetAllLiveViewEnabledBundles(data, reply);
371 break;
372 }
373 case static_cast<uint32_t>(NotificationInterfaceCode::GET_ALL_DISTRIBUTED_ENABLE_STATUS): {
374 result = HandleGetAllDistributedEnabledBundles(data, reply);
375 break;
376 }
377 case static_cast<uint32_t>(NotificationInterfaceCode::REGISTER_PUSH_CALLBACK): {
378 result = HandleRegisterPushCallback(data, reply);
379 break;
380 }
381 case static_cast<uint32_t>(NotificationInterfaceCode::UNREGISTER_PUSH_CALLBACK): {
382 result = HandleUnregisterPushCallback(data, reply);
383 break;
384 }
385 case static_cast<uint32_t>(NotificationInterfaceCode::SUBSCRIBE_LOCAL_LIVE_VIEW_NOTIFICATION): {
386 result = HandleSubscribeLocalLiveView(data, reply);
387 break;
388 }
389 case static_cast<uint32_t>(NotificationInterfaceCode::TRIGGER_LOCAL_LIVE_VIEW_NOTIFICATION): {
390 result = HandleTriggerLocalLiveView(data, reply);
391 break;
392 }
393 case static_cast<uint32_t>(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION_SELF): {
394 result = HandleSubscribeSelf(data, reply);
395 break;
396 }
397 case static_cast<uint32_t>(NotificationInterfaceCode::SET_SLOTFLAGS_BY_BUNDLE): {
398 result = HandleSetSlotFlagsAsBundle(data, reply);
399 break;
400 }
401 case static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOTFLAGS_BY_BUNDLE): {
402 result = HandleGetSlotFlagsAsBundle(data, reply);
403 break;
404 }
405 case static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_AGENT_RELATIONSHIP): {
406 result = HandleSetAdditionConfig(data, reply);
407 break;
408 }
409 case static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE_WITH_AGENT): {
410 result = HandleCancelAsBundleWithAgent(data, reply);
411 break;
412 }
413 case static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOT_BY_BUNDLE): {
414 result = HandleGetSlotByBundle(data, reply);
415 break;
416 }
417 case static_cast<uint32_t>(NotificationInterfaceCode::ADD_DO_NOTDISTURB_PROFILES):
418 case static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_DO_NOT_DISTURB_PROFILES): {
419 result = DelayedSingleton<DisturbManager>::GetInstance()->OnRemoteRequest(code, data, reply);
420 break;
421 }
422 case static_cast<uint32_t>(NotificationInterfaceCode::SET_TARGET_DEVICE_STATUS): {
423 result = HandleSetTargetDeviceStatus(data, reply);
424 break;
425 }
426 case static_cast<uint32_t>(NotificationInterfaceCode::SET_TARGET_DEVICE_STATUS_WITH_FLAG): {
427 result = HandleSetDeviceStatus(data, reply);
428 break;
429 }
430 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED
431 case static_cast<uint32_t>(NotificationInterfaceCode::REGISTER_SWING_CALLBACK): {
432 result = HandleRegisterSwingCallback(data, reply);
433 break;
434 }
435 #endif
436 case static_cast<uint32_t>(NotificationInterfaceCode::GET_DONOTDISTURB_PROFILE): {
437 result = DelayedSingleton<DisturbManager>::GetInstance()->OnRemoteRequest(code, data, reply);
438 break;
439 }
440 case static_cast<uint32_t>(NotificationInterfaceCode::UPDATE_NOTIFICATION_TIMER): {
441 result = HandleUpdateNotificationTimerByUid(data, reply);
442 break;
443 }
444 case static_cast<uint32_t>(NotificationInterfaceCode::ALLOW_USE_REMINDER): {
445 result = HandleAllowUseReminder(data, reply);
446 break;
447 }
448 case static_cast<uint32_t>(NotificationInterfaceCode::DISABLE_NOTIFICATION_FEATURE): {
449 result = HandleDisableNotificationFeature(data, reply);
450 break;
451 }
452 case static_cast<uint32_t>(NotificationInterfaceCode::GET_TARGET_DEVICE_STATUS): {
453 result = HandleGetDeviceStatus(data, reply);
454 break;
455 }
456 case static_cast<uint32_t>(NotificationInterfaceCode::GET_NOTIFICATION_REQUEST_BY_HASHCODE): {
457 result = HandleGetNotificationRequest(data, reply);
458 break;
459 }
460 case static_cast<uint32_t>(NotificationInterfaceCode::Set_HASH_CODE_RULE): {
461 result = HandleSetHashCodeRule(data, reply);
462 break;
463 }
464 case static_cast<uint32_t>(NotificationInterfaceCode::GET_ALL_NOTIFICATIONS_BY_SLOTTYPE): {
465 result = HandleGetAllNotificationsBySlotType(data, reply);
466 break;
467 }
468 case static_cast<uint32_t>(NotificationInterfaceCode::REPLY_DISTRIBUTE_OPERATION): {
469 result = HandleReplyDistributeOperation(data, reply);
470 break;
471 }
472 default: {
473 ANS_LOGE("[OnRemoteRequest] fail: unknown code!");
474 return IPCObjectStub::OnRemoteRequest(code, data, reply, flags);
475 }
476 }
477 if (SUCCEEDED(result)) {
478 return NO_ERROR;
479 }
480
481 ANS_LOGE("[OnRemoteRequest] fail: Failed to call interface %{public}u, err:%{public}d", code, result);
482 return result;
483 }
484
HandlePublish(MessageParcel & data,MessageParcel & reply)485 ErrCode AnsManagerStub::HandlePublish(MessageParcel &data, MessageParcel &reply)
486 {
487 std::string label;
488 if (!data.ReadString(label)) {
489 ANS_LOGE("[HandlePublish] fail: read label failed");
490 return ERR_ANS_PARCELABLE_FAILED;
491 }
492
493 sptr<NotificationRequest> notification = data.ReadParcelable<NotificationRequest>();
494 if (!notification) {
495 ANS_LOGE("[HandlePublish] fail: notification ReadParcelable failed");
496 return ERR_ANS_PARCELABLE_FAILED;
497 }
498
499 ErrCode result = Publish(label, notification);
500 if (!reply.WriteInt32(result)) {
501 ANS_LOGE("[HandlePublish] fail: write result failed, ErrCode=%{public}d", result);
502 return ERR_ANS_PARCELABLE_FAILED;
503 }
504 return ERR_OK;
505 }
506
HandlePublishNotificationForIndirectProxy(MessageParcel & data,MessageParcel & reply)507 ErrCode AnsManagerStub::HandlePublishNotificationForIndirectProxy(MessageParcel &data, MessageParcel &reply)
508 {
509 sptr<NotificationRequest> notification = data.ReadParcelable<NotificationRequest>();
510 if (!notification) {
511 ANS_LOGE("[HandlePublishNotificationForIndirectProxy] fail: notification ReadParcelable failed");
512 return ERR_ANS_PARCELABLE_FAILED;
513 }
514
515 ErrCode result = PublishNotificationForIndirectProxy(notification);
516 if (!reply.WriteInt32(result)) {
517 ANS_LOGE("[HandlePublishNotificationForIndirectProxy] fail: write result failed, ErrCode=%{public}d", result);
518 return ERR_ANS_PARCELABLE_FAILED;
519 }
520 return ERR_OK;
521 }
522
HandleCancel(MessageParcel & data,MessageParcel & reply)523 ErrCode AnsManagerStub::HandleCancel(MessageParcel &data, MessageParcel &reply)
524 {
525 int32_t notificationId = 0;
526 if (!data.ReadInt32(notificationId)) {
527 ANS_LOGE("[HandleCancel] fail: read notificationId failed");
528 return ERR_ANS_PARCELABLE_FAILED;
529 }
530
531 std::string label;
532 if (!data.ReadString(label)) {
533 ANS_LOGE("[HandleCancel] fail: read label failed");
534 return ERR_ANS_PARCELABLE_FAILED;
535 }
536
537 std::string appInstanceKey;
538 if (!data.ReadString(appInstanceKey)) {
539 ANS_LOGE("[HandleCancel] fail: read InstanceKey failed");
540 return ERR_ANS_PARCELABLE_FAILED;
541 }
542
543 ErrCode result = Cancel(notificationId, label, appInstanceKey);
544 if (!reply.WriteInt32(result)) {
545 ANS_LOGE("[HandleCancel] fail: write result failed, ErrCode=%{public}d", result);
546 return ERR_ANS_PARCELABLE_FAILED;
547 }
548 return ERR_OK;
549 }
550
HandleCancelAll(MessageParcel & data,MessageParcel & reply)551 ErrCode AnsManagerStub::HandleCancelAll(MessageParcel &data, MessageParcel &reply)
552 {
553 std::string appInstanceKey;
554 if (!data.ReadString(appInstanceKey)) {
555 ANS_LOGE("[HandleCancelAll] fail: read instanceKey failed");
556 return ERR_ANS_PARCELABLE_FAILED;
557 }
558
559 ErrCode result = CancelAll(appInstanceKey);
560 if (!reply.WriteInt32(result)) {
561 ANS_LOGE("[HandleCancelAll] fail: write result failed, ErrCode=%{public}d", result);
562 return ERR_ANS_PARCELABLE_FAILED;
563 }
564 return ERR_OK;
565 }
566
HandleCancelAsBundleOption(MessageParcel & data,MessageParcel & reply)567 ErrCode AnsManagerStub::HandleCancelAsBundleOption(MessageParcel &data, MessageParcel &reply)
568 {
569 sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
570 if (bundleOption == nullptr) {
571 ANS_LOGE("[HandleCancelAsBundle] fail: read BundleOption failed");
572 return ERR_ANS_PARCELABLE_FAILED;
573 }
574 int32_t notificationId = 0;
575 if (!data.ReadInt32(notificationId)) {
576 ANS_LOGE("[HandleCancelAsBundle] fail: read notificationId failed");
577 return ERR_ANS_PARCELABLE_FAILED;
578 }
579 ErrCode result = CancelAsBundle(bundleOption, notificationId);
580 if (!reply.WriteInt32(result)) {
581 ANS_LOGE("[HandleCancelAsBundle] fail: write result failed, ErrCode=%{public}d", result);
582 return ERR_ANS_PARCELABLE_FAILED;
583 }
584 return ERR_OK;
585 }
586
HandleCancelAsBundle(MessageParcel & data,MessageParcel & reply)587 ErrCode AnsManagerStub::HandleCancelAsBundle(MessageParcel &data, MessageParcel &reply)
588 {
589 int32_t notificationId = 0;
590 if (!data.ReadInt32(notificationId)) {
591 ANS_LOGE("[HandleCancelAsBundle] fail: read notificationId failed");
592 return ERR_ANS_PARCELABLE_FAILED;
593 }
594
595 std::string representativeBundle;
596 if (!data.ReadString(representativeBundle)) {
597 ANS_LOGE("[HandleCancelAsBundle] fail: read representativeBundle failed");
598 return ERR_ANS_PARCELABLE_FAILED;
599 }
600
601 int32_t userId = 0;
602 if (!data.ReadInt32(userId)) {
603 ANS_LOGE("[HandleCancelAsBundle] fail: read userId failed");
604 return ERR_ANS_PARCELABLE_FAILED;
605 }
606
607 ErrCode result = CancelAsBundle(notificationId, representativeBundle, userId);
608 if (!reply.WriteInt32(result)) {
609 ANS_LOGE("[HandleCancelAsBundle] fail: write result failed, ErrCode=%{public}d", result);
610 return ERR_ANS_PARCELABLE_FAILED;
611 }
612 return ERR_OK;
613 }
614
HandleCancelAsBundleAndUser(MessageParcel & data,MessageParcel & reply)615 ErrCode AnsManagerStub::HandleCancelAsBundleAndUser(MessageParcel &data, MessageParcel &reply)
616 {
617 sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
618 if (bundleOption == nullptr) {
619 ANS_LOGE("[HandleCancelAsBundle] fail: read BundleOption failed");
620 return ERR_ANS_PARCELABLE_FAILED;
621 }
622 int32_t notificationId = 0;
623 if (!data.ReadInt32(notificationId)) {
624 ANS_LOGE("[HandleCancelAsBundle] fail: read notificationId failed");
625 return ERR_ANS_PARCELABLE_FAILED;
626 }
627
628 int32_t userId = 0;
629 if (!data.ReadInt32(userId)) {
630 ANS_LOGE("[HandleCancelAsBundle] fail: read userId failed");
631 return ERR_ANS_PARCELABLE_FAILED;
632 }
633 ErrCode result = CancelAsBundle(bundleOption, notificationId, userId);
634 if (!reply.WriteInt32(result)) {
635 ANS_LOGE("[HandleCancelAsBundle] fail: write result failed, ErrCode=%{public}d", result);
636 return ERR_ANS_PARCELABLE_FAILED;
637 }
638 return ERR_OK;
639 }
640
HandleAddSlotByType(MessageParcel & data,MessageParcel & reply)641 ErrCode AnsManagerStub::HandleAddSlotByType(MessageParcel &data, MessageParcel &reply)
642 {
643 NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(data.ReadInt32());
644 ErrCode result = AddSlotByType(slotType);
645 if (!reply.WriteInt32(result)) {
646 ANS_LOGE("[HandleAddSlotByType] fail: write result failed, ErrCode=%{public}d", result);
647 return ERR_ANS_PARCELABLE_FAILED;
648 }
649 return ERR_OK;
650 }
651
HandleAddSlots(MessageParcel & data,MessageParcel & reply)652 ErrCode AnsManagerStub::HandleAddSlots(MessageParcel &data, MessageParcel &reply)
653 {
654 std::vector<sptr<NotificationSlot>> slots;
655 if (!ReadParcelableVector(slots, data)) {
656 ANS_LOGE("[HandleAddSlots] fail: read slotsSize failed");
657 return ERR_ANS_PARCELABLE_FAILED;
658 }
659 ErrCode result = AddSlots(slots);
660 if (!reply.WriteInt32(result)) {
661 ANS_LOGE("[HandleAddSlots] fail: write result failed, ErrCode=%{public}d", result);
662 return ERR_ANS_PARCELABLE_FAILED;
663 }
664 return ERR_OK;
665 }
666
HandleRemoveSlotByType(MessageParcel & data,MessageParcel & reply)667 ErrCode AnsManagerStub::HandleRemoveSlotByType(MessageParcel &data, MessageParcel &reply)
668 {
669 NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(data.ReadInt32());
670
671 ErrCode result = RemoveSlotByType(slotType);
672 if (!reply.WriteInt32(result)) {
673 ANS_LOGE("[HandleRemoveSlotByType] fail: write result failed, ErrCode=%{public}d", result);
674 return ERR_ANS_PARCELABLE_FAILED;
675 }
676 return ERR_OK;
677 }
678
HandleRemoveAllSlots(MessageParcel & data,MessageParcel & reply)679 ErrCode AnsManagerStub::HandleRemoveAllSlots(MessageParcel &data, MessageParcel &reply)
680 {
681 ErrCode result = RemoveAllSlots();
682 if (!reply.WriteInt32(result)) {
683 ANS_LOGE("[HandleRemoveAllSlots] fail: write result failed, ErrCode=%{public}d", result);
684 return ERR_ANS_PARCELABLE_FAILED;
685 }
686 return ERR_OK;
687 }
688
HandleGetSlots(MessageParcel & data,MessageParcel & reply)689 ErrCode AnsManagerStub::HandleGetSlots(MessageParcel &data, MessageParcel &reply)
690 {
691 std::vector<sptr<NotificationSlot>> slots;
692 ErrCode result = GetSlots(slots);
693 if (!WriteParcelableVector(slots, reply, result)) {
694 ANS_LOGE("[HandleGetSlots] fail: write slots failed");
695 return ERR_ANS_PARCELABLE_FAILED;
696 }
697
698 return ERR_OK;
699 }
700
HandleGetSlotByType(MessageParcel & data,MessageParcel & reply)701 ErrCode AnsManagerStub::HandleGetSlotByType(MessageParcel &data, MessageParcel &reply)
702 {
703 NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(data.ReadInt32());
704
705 sptr<NotificationSlot> slot = nullptr;
706 ErrCode result = GetSlotByType(slotType, slot);
707 if (!reply.WriteInt32(result)) {
708 ANS_LOGE("[HandleGetSlotByType] fail: write result failed, ErrCode=%{public}d", result);
709 return ERR_ANS_PARCELABLE_FAILED;
710 }
711
712 if (!reply.WriteParcelable(slot)) {
713 ANS_LOGE("[HandleGetSlotByType] fail: write slot failed.");
714 return ERR_ANS_PARCELABLE_FAILED;
715 }
716 return ERR_OK;
717 }
718
HandleGetSlotNumAsBundle(MessageParcel & data,MessageParcel & reply)719 ErrCode AnsManagerStub::HandleGetSlotNumAsBundle(MessageParcel &data, MessageParcel &reply)
720 {
721 sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
722 if (bundleOption == nullptr) {
723 ANS_LOGE("[HandleGetSlotNumAsBundle] fail: read bundle failed.");
724 return ERR_ANS_PARCELABLE_FAILED;
725 }
726
727 uint64_t num = 0;
728 ErrCode result = GetSlotNumAsBundle(bundleOption, num);
729 if (!reply.WriteInt32(result)) {
730 ANS_LOGE("[HandleGetSlotNumAsBundle] fail: write result failed, ErrCode=%{public}d", result);
731 return ERR_ANS_PARCELABLE_FAILED;
732 }
733
734 if (!reply.WriteUint64(num)) {
735 ANS_LOGE("[HandleGetSlotNumAsBundle] fail: write enabled failed, ErrCode=%{public}d", result);
736 return ERR_ANS_PARCELABLE_FAILED;
737 }
738 return ERR_OK;
739 }
740
HandleSetSlotFlagsAsBundle(MessageParcel & data,MessageParcel & reply)741 ErrCode AnsManagerStub::HandleSetSlotFlagsAsBundle(MessageParcel &data, MessageParcel &reply)
742 {
743 sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
744 if (bundleOption == nullptr) {
745 ANS_LOGE("[HandleSetSlotFlagsAsBundle] fail: read bundle failed.");
746 return ERR_ANS_PARCELABLE_FAILED;
747 }
748
749 int32_t slotFlags = 0;
750 if (!data.ReadInt32(slotFlags)) {
751 ANS_LOGE("[HandleSetSlotFlagsAsBundle] fail: read notification failed");
752 return ERR_ANS_PARCELABLE_FAILED;
753 }
754
755 ErrCode result = SetSlotFlagsAsBundle(bundleOption, slotFlags);
756 if (!reply.WriteInt32(result)) {
757 ANS_LOGE("[HandleSetSlotFlagsAsBundle] fail: write result failed, ErrCode=%{public}d", result);
758 return ERR_ANS_PARCELABLE_FAILED;
759 }
760
761 return ERR_OK;
762 }
763
HandleGetSlotFlagsAsBundle(MessageParcel & data,MessageParcel & reply)764 ErrCode AnsManagerStub::HandleGetSlotFlagsAsBundle(MessageParcel &data, MessageParcel &reply)
765 {
766 sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
767 if (bundleOption == nullptr) {
768 ANS_LOGE("[HandleGetSlotFlagsAsBundle] fail: read bundle failed.");
769 return ERR_ANS_PARCELABLE_FAILED;
770 }
771
772 uint32_t slotFlags = 0;
773 ErrCode result = GetSlotFlagsAsBundle(bundleOption, slotFlags);
774 if (!reply.WriteInt32(result)) {
775 ANS_LOGE("[HandleGetSlotFlagsAsBundle] fail: write result failed, ErrCode=%{public}d", result);
776 return ERR_ANS_PARCELABLE_FAILED;
777 }
778
779 if (!reply.WriteUint32(slotFlags)) {
780 ANS_LOGE("[HandleGetSlotFlagsAsBundle] fail: write enabled failed, ErrCode=%{public}d", result);
781 return ERR_ANS_PARCELABLE_FAILED;
782 }
783
784 return ERR_OK;
785 }
786
HandleGetActiveNotifications(MessageParcel & data,MessageParcel & reply)787 ErrCode AnsManagerStub::HandleGetActiveNotifications(MessageParcel &data, MessageParcel &reply)
788 {
789 std::string appInstanceKey;
790 if (!data.ReadString(appInstanceKey)) {
791 ANS_LOGE("[HandleGetActiveNotifications] fail: read instanceKey failed");
792 return ERR_ANS_PARCELABLE_FAILED;
793 }
794 std::vector<sptr<NotificationRequest>> notifications;
795 ErrCode result = GetActiveNotifications(notifications, appInstanceKey);
796 if (!WriteParcelableVector(notifications, reply, result)) {
797 ANS_LOGE("[HandleGetActiveNotifications] fail: write notifications failed");
798 return ERR_ANS_PARCELABLE_FAILED;
799 }
800 return ERR_OK;
801 }
802
HandleGetActiveNotificationNums(MessageParcel & data,MessageParcel & reply)803 ErrCode AnsManagerStub::HandleGetActiveNotificationNums(MessageParcel &data, MessageParcel &reply)
804 {
805 uint64_t num = 0;
806 ErrCode result = GetActiveNotificationNums(num);
807 if (!reply.WriteInt32(result)) {
808 ANS_LOGE("[HandleGetActiveNotificationNums] fail: write result failed, ErrCode=%{public}d", result);
809 return ERR_ANS_PARCELABLE_FAILED;
810 }
811
812 if (!reply.WriteUint64(num)) {
813 ANS_LOGE("[HandleGetActiveNotificationNums] fail: write num failed");
814 return ERR_ANS_PARCELABLE_FAILED;
815 }
816 return ERR_OK;
817 }
818
HandleGetAllActiveNotifications(MessageParcel & data,MessageParcel & reply)819 ErrCode AnsManagerStub::HandleGetAllActiveNotifications(MessageParcel &data, MessageParcel &reply)
820 {
821 std::vector<sptr<Notification>> notifications;
822 ErrCode result = GetAllActiveNotifications(notifications);
823
824 if (!reply.SetMaxCapacity(NotificationConstant::NOTIFICATION_MAX_LIVE_VIEW_SIZE)) {
825 return ERR_ANS_PARCELABLE_FAILED;
826 }
827 if (!WriteParcelableVector(notifications, reply, result)) {
828 ANS_LOGE("[HandleGetAllActiveNotifications] fail: write notifications failed");
829 return ERR_ANS_PARCELABLE_FAILED;
830 }
831 return ERR_OK;
832 }
833
HandleGetSpecialActiveNotifications(MessageParcel & data,MessageParcel & reply)834 ErrCode AnsManagerStub::HandleGetSpecialActiveNotifications(MessageParcel &data, MessageParcel &reply)
835 {
836 std::vector<std::string> key;
837 if (!data.ReadStringVector(&key)) {
838 ANS_LOGE("[HandleGetSpecialActiveNotifications] fail: read key failed");
839 return ERR_ANS_PARCELABLE_FAILED;
840 }
841
842 std::vector<sptr<Notification>> notifications;
843 ErrCode result = GetSpecialActiveNotifications(key, notifications);
844 if (!WriteParcelableVector(notifications, reply, result)) {
845 ANS_LOGE("[HandleGetSpecialActiveNotifications] fail: write notifications failed");
846 return ERR_ANS_PARCELABLE_FAILED;
847 }
848 return ERR_OK;
849 }
850
HandleGetActiveNotificationByFilter(MessageParcel & data,MessageParcel & reply)851 ErrCode AnsManagerStub::HandleGetActiveNotificationByFilter(MessageParcel &data, MessageParcel &reply)
852 {
853 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
854 if (bundleOption == nullptr) {
855 ANS_LOGE("[HandleGetActiveNotificationByFilter] fail: read bundleOption failed.");
856 return ERR_ANS_PARCELABLE_FAILED;
857 }
858
859 int32_t notificationId = 0;
860 if (!data.ReadInt32(notificationId)) {
861 ANS_LOGE("[HandleGetActiveNotificationByFilter] fail: read notificationId failed");
862 return ERR_ANS_PARCELABLE_FAILED;
863 }
864
865 std::string label;
866 if (!data.ReadString(label)) {
867 ANS_LOGE("[HandleGetActiveNotificationByFilter] fail: read label failed");
868 return ERR_ANS_PARCELABLE_FAILED;
869 }
870
871 std::vector<std::string> extraInfoKeys;
872 if (!data.ReadStringVector(&extraInfoKeys)) {
873 ANS_LOGE("[HandleGetActiveNotificationByFilter] fail: read extraInfoKeys failed");
874 return ERR_ANS_PARCELABLE_FAILED;
875 }
876
877 sptr<NotificationRequest> request;
878 ErrCode result = GetActiveNotificationByFilter(bundleOption, notificationId, label, extraInfoKeys, request);
879 if (!reply.WriteInt32(result)) {
880 ANS_LOGE("[HandleGetActiveNotificationByFilter] fail: write result failed, ErrCode=%{public}d", result);
881 return ERR_ANS_PARCELABLE_FAILED;
882 }
883
884 if (!reply.WriteParcelable(request)) {
885 ANS_LOGE("[HandleGetActiveNotificationByFilter] fail: get extra info by filter failed");
886 return ERR_ANS_PARCELABLE_FAILED;
887 }
888 return result;
889 }
890
HandleCanPublishAsBundle(MessageParcel & data,MessageParcel & reply)891 ErrCode AnsManagerStub::HandleCanPublishAsBundle(MessageParcel &data, MessageParcel &reply)
892 {
893 std::string representativeBundle;
894 if (!data.ReadString(representativeBundle)) {
895 ANS_LOGE("[HandleCanPublishAsBundle] fail: read representativeBundle failed");
896 return ERR_ANS_PARCELABLE_FAILED;
897 }
898
899 bool canPublish = false;
900 ErrCode result = CanPublishAsBundle(representativeBundle, canPublish);
901 if (!reply.WriteInt32(result)) {
902 ANS_LOGE("[HandleCanPublishAsBundle] fail: write result failed, ErrCode=%{public}d", result);
903 return ERR_ANS_PARCELABLE_FAILED;
904 }
905
906 if (!reply.WriteBool(canPublish)) {
907 ANS_LOGE("[HandleCanPublishAsBundle] fail: write canPublish failed");
908 return ERR_ANS_PARCELABLE_FAILED;
909 }
910
911 return ERR_OK;
912 }
913
HandlePublishAsBundle(MessageParcel & data,MessageParcel & reply)914 ErrCode AnsManagerStub::HandlePublishAsBundle(MessageParcel &data, MessageParcel &reply)
915 {
916 sptr<NotificationRequest> notification = data.ReadParcelable<NotificationRequest>();
917 if (!notification) {
918 ANS_LOGE("[HandlePublishAsBundle] fail: read notification failed");
919 return ERR_ANS_PARCELABLE_FAILED;
920 }
921
922 std::string representativeBundle;
923 if (!data.ReadString(representativeBundle)) {
924 ANS_LOGE("[HandlePublishAsBundle] fail: read representativeBundle failed.");
925 return ERR_ANS_PARCELABLE_FAILED;
926 }
927
928 ErrCode result = PublishAsBundle(notification, representativeBundle);
929 if (!reply.WriteInt32(result)) {
930 ANS_LOGE("[HandlePublishAsBundle] fail: write result failed, ErrCode=%{public}d", result);
931 return ERR_ANS_PARCELABLE_FAILED;
932 }
933 return ERR_OK;
934 }
935
HandleSetNotificationBadgeNum(MessageParcel & data,MessageParcel & reply)936 ErrCode AnsManagerStub::HandleSetNotificationBadgeNum(MessageParcel &data, MessageParcel &reply)
937 {
938 int32_t num = 0;
939 if (!data.ReadInt32(num)) {
940 ANS_LOGE("[HandleSetNotificationBadgeNum] fail: read notification failed");
941 return ERR_ANS_PARCELABLE_FAILED;
942 }
943
944 ErrCode result = SetNotificationBadgeNum(num);
945 if (!reply.WriteInt32(result)) {
946 ANS_LOGE("[HandleSetNotificationBadgeNum] fail: write result failed, ErrCode=%{public}d", result);
947 return ERR_ANS_PARCELABLE_FAILED;
948 }
949 return ERR_OK;
950 }
951
HandleGetBundleImportance(MessageParcel & data,MessageParcel & reply)952 ErrCode AnsManagerStub::HandleGetBundleImportance(MessageParcel &data, MessageParcel &reply)
953 {
954 int32_t importance = 0;
955 ErrCode result = GetBundleImportance(importance);
956 if (!reply.WriteInt32(result)) {
957 ANS_LOGE("[HandleGetBundleImportance] fail: write result failed, ErrCode=%{public}d", result);
958 return ERR_ANS_PARCELABLE_FAILED;
959 }
960
961 if (!reply.WriteInt32(importance)) {
962 ANS_LOGE("[HandleGetBundleImportance] fail: write importance failed.");
963 return ERR_ANS_PARCELABLE_FAILED;
964 }
965 return ERR_OK;
966 }
967
HandleSetDoNotDisturbDate(MessageParcel & data,MessageParcel & reply)968 ErrCode AnsManagerStub::HandleSetDoNotDisturbDate(MessageParcel &data, MessageParcel &reply)
969 {
970 return ERR_OK;
971 }
972
HandleGetDoNotDisturbDate(MessageParcel & data,MessageParcel & reply)973 ErrCode AnsManagerStub::HandleGetDoNotDisturbDate(MessageParcel &data, MessageParcel &reply)
974 {
975 return ERR_OK;
976 }
977
HandleDoesSupportDoNotDisturbMode(MessageParcel & data,MessageParcel & reply)978 ErrCode AnsManagerStub::HandleDoesSupportDoNotDisturbMode(MessageParcel &data, MessageParcel &reply)
979 {
980 return ERR_OK;
981 }
982
HandleIsNeedSilentInDoNotDisturbMode(MessageParcel & data,MessageParcel & reply)983 ErrCode AnsManagerStub::HandleIsNeedSilentInDoNotDisturbMode(MessageParcel &data, MessageParcel &reply)
984 {
985 std::string phoneNumber;
986 if (!data.ReadString(phoneNumber)) {
987 ANS_LOGE("[HandleIsNeedSilentInDoNotDisturbMode] fail: read phoneNumber failed");
988 return ERR_ANS_PARCELABLE_FAILED;
989 }
990
991 int32_t callerType = 0;
992 if (!data.ReadInt32(callerType)) {
993 ANS_LOGE("[HandleIsNeedSilentInDoNotDisturbMode] fail: read callerType failed");
994 return ERR_ANS_PARCELABLE_FAILED;
995 }
996
997 ErrCode result = IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType);
998 if (!reply.WriteInt32(result)) {
999 ANS_LOGE("[HandleIsNeedSilentInDoNotDisturbMode] fail: write result failed, ErrCode=%{public}d", result);
1000 return ERR_ANS_PARCELABLE_FAILED;
1001 }
1002 return ERR_OK;
1003 }
1004
HandlePublishContinuousTaskNotification(MessageParcel & data,MessageParcel & reply)1005 ErrCode AnsManagerStub::HandlePublishContinuousTaskNotification(MessageParcel &data, MessageParcel &reply)
1006 {
1007 sptr<NotificationRequest> request = data.ReadParcelable<NotificationRequest>();
1008 if (!request) {
1009 ANS_LOGE("[HandlePublishContinuousTaskNotification] fail: notification ReadParcelable failed");
1010 return ERR_ANS_PARCELABLE_FAILED;
1011 }
1012
1013 ErrCode result = PublishContinuousTaskNotification(request);
1014 if (!reply.WriteInt32(result)) {
1015 ANS_LOGE("[HandlePublishContinuousTaskNotification] fail: write result failed, ErrCode=%{public}d", result);
1016 return ERR_ANS_PARCELABLE_FAILED;
1017 }
1018 return ERR_OK;
1019 }
1020
HandleCancelContinuousTaskNotification(MessageParcel & data,MessageParcel & reply)1021 ErrCode AnsManagerStub::HandleCancelContinuousTaskNotification(MessageParcel &data, MessageParcel &reply)
1022 {
1023 std::string label;
1024 if (!data.ReadString(label)) {
1025 ANS_LOGE("[HandleCancelContinuousTaskNotification] fail: read label failed");
1026 return ERR_ANS_PARCELABLE_FAILED;
1027 }
1028
1029 int32_t notificationId = 0;
1030 if (!data.ReadInt32(notificationId)) {
1031 ANS_LOGE("[HandleCancelContinuousTaskNotification] fail: read notificationId failed");
1032 return ERR_ANS_PARCELABLE_FAILED;
1033 }
1034
1035 ErrCode result = CancelContinuousTaskNotification(label, notificationId);
1036 if (!reply.WriteInt32(result)) {
1037 ANS_LOGE("[HandleCancelContinuousTaskNotification] fail: write result failed, ErrCode=%{public}d", result);
1038 return ERR_ANS_PARCELABLE_FAILED;
1039 }
1040 return ERR_OK;
1041 }
1042
HandleIsNotificationPolicyAccessGranted(MessageParcel & data,MessageParcel & reply)1043 ErrCode AnsManagerStub::HandleIsNotificationPolicyAccessGranted(MessageParcel &data, MessageParcel &reply)
1044 {
1045 bool granted = false;
1046 ErrCode result = HasNotificationPolicyAccessPermission(granted);
1047 if (!reply.WriteInt32(result)) {
1048 ANS_LOGE("[HandleIsNotificationPolicyAccessGranted] fail: write result failed, ErrCode=%{public}d", result);
1049 return ERR_ANS_PARCELABLE_FAILED;
1050 }
1051
1052 if (!reply.WriteBool(granted)) {
1053 ANS_LOGE("[HandleIsNotificationPolicyAccessGranted] fail: write granted failed.");
1054 return ERR_ANS_PARCELABLE_FAILED;
1055 }
1056 return ERR_OK;
1057 }
1058
HandleTriggerLocalLiveView(MessageParcel & data,MessageParcel & reply)1059 ErrCode AnsManagerStub::HandleTriggerLocalLiveView(MessageParcel &data, MessageParcel &reply)
1060 {
1061 sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
1062 if (bundleOption == nullptr) {
1063 ANS_LOGE("[HandleTriggerLocalLiveView] fail: read bundle failed.");
1064 return ERR_ANS_PARCELABLE_FAILED;
1065 }
1066
1067 int32_t notificationId = 0;
1068 if (!data.ReadInt32(notificationId)) {
1069 ANS_LOGE("[HandleTriggerLocalLiveView] fail: read notificationId failed");
1070 return ERR_ANS_PARCELABLE_FAILED;
1071 }
1072
1073 sptr<NotificationButtonOption> buttonOption = data.ReadStrongParcelable<NotificationButtonOption>();
1074 if (buttonOption == nullptr) {
1075 ANS_LOGE("[HandleTriggerLocalLiveView] fail: read button failed.");
1076 return ERR_ANS_PARCELABLE_FAILED;
1077 }
1078
1079 ErrCode result = TriggerLocalLiveView(bundleOption, notificationId, buttonOption);
1080 if (!reply.WriteInt32(result)) {
1081 ANS_LOGE("[HandleTriggerLocalLiveView] fail: write result failed, ErrCode=%{public}d", result);
1082 return ERR_ANS_PARCELABLE_FAILED;
1083 }
1084 return ERR_OK;
1085 }
1086
HandleRemoveNotification(MessageParcel & data,MessageParcel & reply)1087 ErrCode AnsManagerStub::HandleRemoveNotification(MessageParcel &data, MessageParcel &reply)
1088 {
1089 sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
1090 if (bundleOption == nullptr) {
1091 ANS_LOGE("[HandleRemoveNotification] fail: read bundle failed.");
1092 return ERR_ANS_PARCELABLE_FAILED;
1093 }
1094
1095 int32_t notificationId = 0;
1096 if (!data.ReadInt32(notificationId)) {
1097 ANS_LOGE("[HandleRemoveNotification] fail: read notificationId failed");
1098 return ERR_ANS_PARCELABLE_FAILED;
1099 }
1100
1101 std::string label;
1102 if (!data.ReadString(label)) {
1103 ANS_LOGE("[HandleRemoveNotification] fail: read label failed");
1104 return ERR_ANS_PARCELABLE_FAILED;
1105 }
1106
1107 int32_t removeReason = 0;
1108 if (!data.ReadInt32(removeReason)) {
1109 ANS_LOGE("[HandleRemoveNotification] fail: read removeReason failed");
1110 return ERR_ANS_PARCELABLE_FAILED;
1111 }
1112
1113 ErrCode result = RemoveNotification(bundleOption, notificationId, label, removeReason);
1114 if (!reply.WriteInt32(result)) {
1115 ANS_LOGE("[HandleRemoveNotification] fail: write result failed, ErrCode=%{public}d", result);
1116 return ERR_ANS_PARCELABLE_FAILED;
1117 }
1118 return ERR_OK;
1119 }
1120
HandleRemoveAllNotifications(MessageParcel & data,MessageParcel & reply)1121 ErrCode AnsManagerStub::HandleRemoveAllNotifications(MessageParcel &data, MessageParcel &reply)
1122 {
1123 sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
1124 if (bundleOption == nullptr) {
1125 ANS_LOGE("[HandleRemoveAllNotifications] fail: read bundle failed.");
1126 return ERR_ANS_PARCELABLE_FAILED;
1127 }
1128
1129 ErrCode result = RemoveAllNotifications(bundleOption);
1130 if (!reply.WriteInt32(result)) {
1131 ANS_LOGE("[HandleRemoveAllNotifications] fail: write result failed, ErrCode=%{public}d", result);
1132 return ERR_ANS_PARCELABLE_FAILED;
1133 }
1134 return ERR_OK;
1135 }
1136
HandleRemoveNotifications(MessageParcel & data,MessageParcel & reply)1137 ErrCode AnsManagerStub::HandleRemoveNotifications(MessageParcel &data, MessageParcel &reply)
1138 {
1139 int32_t keysSize = 0;
1140 if (!data.ReadInt32(keysSize)) {
1141 ANS_LOGE("read keys size failed.");
1142 return false;
1143 }
1144
1145 std::vector<std::string> keys;
1146 if (!data.ReadStringVector(&keys)) {
1147 ANS_LOGE("read keys failed");
1148 return ERR_ANS_PARCELABLE_FAILED;
1149 }
1150
1151 int32_t removeReason = 0;
1152 if (!data.ReadInt32(removeReason)) {
1153 ANS_LOGE("read removeReason failed");
1154 return ERR_ANS_PARCELABLE_FAILED;
1155 }
1156
1157 ErrCode result = RemoveNotifications(keys, removeReason);
1158 if (!reply.WriteInt32(result)) {
1159 ANS_LOGE("write result failed, ErrCode=%{public}d", result);
1160 return ERR_ANS_PARCELABLE_FAILED;
1161 }
1162 return ERR_OK;
1163 }
1164
1165
HandleDelete(MessageParcel & data,MessageParcel & reply)1166 ErrCode AnsManagerStub::HandleDelete(MessageParcel &data, MessageParcel &reply)
1167 {
1168 std::string key;
1169 if (!data.ReadString(key)) {
1170 ANS_LOGE("[HandleDelete] fail: read key failed.");
1171 return ERR_ANS_PARCELABLE_FAILED;
1172 }
1173
1174 int32_t removeReason = 0;
1175 if (!data.ReadInt32(removeReason)) {
1176 ANS_LOGE("[HandleDelete] fail: read removeReason failed");
1177 return ERR_ANS_PARCELABLE_FAILED;
1178 }
1179
1180 ErrCode result = Delete(key, removeReason);
1181 if (!reply.WriteInt32(result)) {
1182 ANS_LOGE("[HandleDelete] fail: write result failed, ErrCode=%{public}d", result);
1183 return ERR_ANS_PARCELABLE_FAILED;
1184 }
1185 return ERR_OK;
1186 }
1187
HandleDeleteByBundle(MessageParcel & data,MessageParcel & reply)1188 ErrCode AnsManagerStub::HandleDeleteByBundle(MessageParcel &data, MessageParcel &reply)
1189 {
1190 sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
1191 if (bundleOption == nullptr) {
1192 ANS_LOGE("[HandleDeleteByBundle] fail: read bundle failed.");
1193 return ERR_ANS_PARCELABLE_FAILED;
1194 }
1195
1196 ErrCode result = DeleteByBundle(bundleOption);
1197 if (!reply.WriteInt32(result)) {
1198 ANS_LOGE("[HandleDeleteByBundle] fail: write result failed, ErrCode=%{public}d", result);
1199 return ERR_ANS_PARCELABLE_FAILED;
1200 }
1201 return ERR_OK;
1202 }
1203
HandleDeleteAll(MessageParcel & data,MessageParcel & reply)1204 ErrCode AnsManagerStub::HandleDeleteAll(MessageParcel &data, MessageParcel &reply)
1205 {
1206 ErrCode result = DeleteAll();
1207 if (!reply.WriteInt32(result)) {
1208 ANS_LOGE("[HandleDeleteAll] fail: write result failed, ErrCode=%{public}d", result);
1209 return ERR_ANS_PARCELABLE_FAILED;
1210 }
1211 return ERR_OK;
1212 }
1213
HandleGetSlotsByBundle(MessageParcel & data,MessageParcel & reply)1214 ErrCode AnsManagerStub::HandleGetSlotsByBundle(MessageParcel &data, MessageParcel &reply)
1215 {
1216 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1217 if (bundleOption == nullptr) {
1218 ANS_LOGE("[HandleGetSlotsByBundle] fail: read bundleOption failed.");
1219 return ERR_ANS_PARCELABLE_FAILED;
1220 }
1221
1222 std::vector<sptr<NotificationSlot>> slots;
1223 ErrCode result = GetSlotsByBundle(bundleOption, slots);
1224 if (!WriteParcelableVector(slots, reply, result)) {
1225 ANS_LOGE("[HandleGetSlotsByBundle] fail: write slots failed.");
1226 return ERR_ANS_PARCELABLE_FAILED;
1227 }
1228 return ERR_OK;
1229 }
1230
HandleGetSlotByBundle(MessageParcel & data,MessageParcel & reply)1231 ErrCode AnsManagerStub::HandleGetSlotByBundle(MessageParcel &data, MessageParcel &reply)
1232 {
1233 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1234 if (bundleOption == nullptr) {
1235 ANS_LOGE("[HandleGetSlotByBundle] fail: read bundleOption failed.");
1236 return ERR_ANS_PARCELABLE_FAILED;
1237 }
1238
1239 NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(data.ReadInt32());
1240
1241 sptr<NotificationSlot> slot = nullptr;
1242 ErrCode result = GetSlotByBundle(bundleOption, slotType, slot);
1243 if (!reply.WriteInt32(result)) {
1244 ANS_LOGE("[HandleGetSlotByBundle] fail: write result failed, ErrCode=%{public}d", result);
1245 return ERR_ANS_PARCELABLE_FAILED;
1246 }
1247
1248 if (!reply.WriteParcelable(slot)) {
1249 ANS_LOGE("[HandleGetSlotByBundle] fail: write slot failed.");
1250 return ERR_ANS_PARCELABLE_FAILED;
1251 }
1252 return ERR_OK;
1253 }
1254
HandleUpdateSlots(MessageParcel & data,MessageParcel & reply)1255 ErrCode AnsManagerStub::HandleUpdateSlots(MessageParcel &data, MessageParcel &reply)
1256 {
1257 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1258 if (bundleOption == nullptr) {
1259 ANS_LOGE("[HandleUpdateSlots] fail: read bundleOption failed.");
1260 return ERR_ANS_PARCELABLE_FAILED;
1261 }
1262
1263 std::vector<sptr<NotificationSlot>> slots;
1264 if (!ReadParcelableVector(slots, data)) {
1265 ANS_LOGE("[HandleUpdateSlots] fail: read slots failed");
1266 return ERR_ANS_PARCELABLE_FAILED;
1267 }
1268
1269 ErrCode result = UpdateSlots(bundleOption, slots);
1270 if (!reply.WriteInt32(result)) {
1271 ANS_LOGE("[HandleUpdateSlots] fail: write result failed, ErrCode=%{public}d", result);
1272 return ERR_ANS_PARCELABLE_FAILED;
1273 }
1274 return ERR_OK;
1275 }
1276
HandleRequestEnableNotification(MessageParcel & data,MessageParcel & reply)1277 ErrCode AnsManagerStub::HandleRequestEnableNotification(MessageParcel &data, MessageParcel &reply)
1278 {
1279 ANS_LOGD("enter");
1280 std::string deviceId;
1281 if (!data.ReadString(deviceId)) {
1282 ANS_LOGE("[HandleRequestEnableNotification] fail: read deviceId failed.");
1283 return ERR_ANS_PARCELABLE_FAILED;
1284 }
1285
1286 sptr<IRemoteObject> callback = data.ReadRemoteObject();
1287 if (callback == nullptr) {
1288 ANS_LOGE("[HandleRequestEnableNotification] fail: read callback failed");
1289 return ERR_ANS_PARCELABLE_FAILED;
1290 }
1291
1292 bool hasCallerToken = false;
1293 if (!data.ReadBool(hasCallerToken)) {
1294 ANS_LOGE("fail: read hasCallerToken failed.");
1295 return ERR_ANS_PARCELABLE_FAILED;
1296 }
1297
1298 sptr<IRemoteObject> callerToken = nullptr;
1299 if (hasCallerToken) {
1300 callerToken = data.ReadRemoteObject();
1301 }
1302
1303 ErrCode result = RequestEnableNotification(deviceId, iface_cast<AnsDialogCallback>(callback), callerToken);
1304 if (!reply.WriteInt32(result)) {
1305 ANS_LOGE("[HandleRequestEnableNotification] fail: write result failed, ErrCode=%{public}d", result);
1306 return ERR_ANS_PARCELABLE_FAILED;
1307 }
1308 return ERR_OK;
1309 }
1310
HandleRequestEnableNotificationByBundle(MessageParcel & data,MessageParcel & reply)1311 ErrCode AnsManagerStub::HandleRequestEnableNotificationByBundle(MessageParcel &data, MessageParcel &reply)
1312 {
1313 ANS_LOGD("enter");
1314 std::string bundleName;
1315 if (!data.ReadString(bundleName)) {
1316 ANS_LOGE("[HandleRequestEnableNotificationByBundle] fail: read bundleName failed.");
1317 return ERR_ANS_PARCELABLE_FAILED;
1318 }
1319
1320 int32_t uid = 0;
1321 if (!data.ReadInt32(uid)) {
1322 ANS_LOGE("[HandleRequestEnableNotificationByBundle] fail: read uid failed");
1323 return ERR_ANS_PARCELABLE_FAILED;
1324 }
1325
1326 ErrCode result = RequestEnableNotification(bundleName, uid);
1327 if (!reply.WriteInt32(result)) {
1328 ANS_LOGE("[HandleRequestEnableNotificationByBundle] fail: write result failed, ErrCode=%{public}d", result);
1329 return ERR_ANS_PARCELABLE_FAILED;
1330 }
1331 return ERR_OK;
1332 }
1333
HandleSetNotificationsEnabledForBundle(MessageParcel & data,MessageParcel & reply)1334 ErrCode AnsManagerStub::HandleSetNotificationsEnabledForBundle(MessageParcel &data, MessageParcel &reply)
1335 {
1336 std::string deviceId;
1337 if (!data.ReadString(deviceId)) {
1338 ANS_LOGE("[HandleSetNotificationsEnabledForBundle] fail: read deviceId failed.");
1339 return ERR_ANS_PARCELABLE_FAILED;
1340 }
1341
1342 bool enabled = false;
1343 if (!data.ReadBool(enabled)) {
1344 ANS_LOGE("[HandleSetNotificationsEnabledForBundle] fail: read enabled failed.");
1345 return ERR_ANS_PARCELABLE_FAILED;
1346 }
1347
1348 ErrCode result = SetNotificationsEnabledForBundle(deviceId, enabled);
1349 if (!reply.WriteInt32(result)) {
1350 ANS_LOGE("[HandleSetNotificationsEnabledForBundle] fail: write result failed, ErrCode=%{public}d", result);
1351 return ERR_ANS_PARCELABLE_FAILED;
1352 }
1353 return ERR_OK;
1354 }
1355
HandleSetNotificationsEnabledForAllBundles(MessageParcel & data,MessageParcel & reply)1356 ErrCode AnsManagerStub::HandleSetNotificationsEnabledForAllBundles(MessageParcel &data, MessageParcel &reply)
1357 {
1358 std::string deviceId;
1359 if (!data.ReadString(deviceId)) {
1360 ANS_LOGE("[HandleSetNotificationsEnabledForAllBundles] fail: read deviceId failed.");
1361 return ERR_ANS_PARCELABLE_FAILED;
1362 }
1363
1364 bool enabled = false;
1365 if (!data.ReadBool(enabled)) {
1366 ANS_LOGE("[HandleSetNotificationsEnabledForAllBundles] fail: read enabled failed.");
1367 return ERR_ANS_PARCELABLE_FAILED;
1368 }
1369
1370 ErrCode result = SetNotificationsEnabledForAllBundles(deviceId, enabled);
1371 if (!reply.WriteInt32(result)) {
1372 ANS_LOGE("[HandleSetNotificationsEnabledForAllBundles] fail: write result failed, ErrCode=%{public}d", result);
1373 return ERR_ANS_PARCELABLE_FAILED;
1374 }
1375 return ERR_OK;
1376 }
1377
HandleSetNotificationsEnabledForSpecialBundle(MessageParcel & data,MessageParcel & reply)1378 ErrCode AnsManagerStub::HandleSetNotificationsEnabledForSpecialBundle(MessageParcel &data, MessageParcel &reply)
1379 {
1380 std::string deviceId;
1381 if (!data.ReadString(deviceId)) {
1382 ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read deviceId failed.");
1383 return ERR_ANS_PARCELABLE_FAILED;
1384 }
1385
1386 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1387 if (bundleOption == nullptr) {
1388 ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read bundleOption failed.");
1389 return ERR_ANS_PARCELABLE_FAILED;
1390 }
1391
1392 bool enabled = false;
1393 if (!data.ReadBool(enabled)) {
1394 ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read enabled failed.");
1395 return ERR_ANS_PARCELABLE_FAILED;
1396 }
1397
1398 ErrCode result = SetNotificationsEnabledForSpecialBundle(deviceId, bundleOption, enabled);
1399 if (!reply.WriteInt32(result)) {
1400 ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: write result failed, ErrCode=%{public}d",
1401 result);
1402 return ERR_ANS_PARCELABLE_FAILED;
1403 }
1404 return ERR_OK;
1405 }
1406
HandleSetShowBadgeEnabledForBundle(MessageParcel & data,MessageParcel & reply)1407 ErrCode AnsManagerStub::HandleSetShowBadgeEnabledForBundle(MessageParcel &data, MessageParcel &reply)
1408 {
1409 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1410 if (bundleOption == nullptr) {
1411 ANS_LOGE("[HandleSetShowBadgeEnabledForBundle] fail: read bundle failed.");
1412 return ERR_ANS_PARCELABLE_FAILED;
1413 }
1414
1415 bool enabled = false;
1416 if (!data.ReadBool(enabled)) {
1417 ANS_LOGE("[HandleSetShowBadgeEnabledForBundle] fail: read enabled failed.");
1418 return ERR_ANS_PARCELABLE_FAILED;
1419 }
1420
1421 ErrCode result = SetShowBadgeEnabledForBundle(bundleOption, enabled);
1422 if (!reply.WriteInt32(result)) {
1423 ANS_LOGE("[HandleSetShowBadgeEnabledForBundle] fail: write result failed, ErrCode=%{public}d", result);
1424 return ERR_ANS_PARCELABLE_FAILED;
1425 }
1426 return ERR_OK;
1427 }
1428
HandleGetShowBadgeEnabledForBundle(MessageParcel & data,MessageParcel & reply)1429 ErrCode AnsManagerStub::HandleGetShowBadgeEnabledForBundle(MessageParcel &data, MessageParcel &reply)
1430 {
1431 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1432 if (bundleOption == nullptr) {
1433 ANS_LOGE("[HandleGetShowBadgeEnabledForBundle] fail: read bundle failed.");
1434 return ERR_ANS_PARCELABLE_FAILED;
1435 }
1436
1437 bool enabled = false;
1438 ErrCode result = GetShowBadgeEnabledForBundle(bundleOption, enabled);
1439 if (!reply.WriteInt32(result)) {
1440 ANS_LOGE("[HandleGetShowBadgeEnabledForBundle] fail: write result failed, ErrCode=%{public}d", result);
1441 return ERR_ANS_PARCELABLE_FAILED;
1442 }
1443
1444 if (!reply.WriteBool(enabled)) {
1445 ANS_LOGE("[HandleGetShowBadgeEnabledForBundle] fail: write enabled failed, ErrCode=%{public}d", result);
1446 return ERR_ANS_PARCELABLE_FAILED;
1447 }
1448 return ERR_OK;
1449 }
1450
HandleGetShowBadgeEnabled(MessageParcel & data,MessageParcel & reply)1451 ErrCode AnsManagerStub::HandleGetShowBadgeEnabled(MessageParcel &data, MessageParcel &reply)
1452 {
1453 bool enabled = false;
1454 ErrCode result = GetShowBadgeEnabled(enabled);
1455 if (!reply.WriteInt32(result)) {
1456 ANS_LOGE("[HandleGetShowBadgeEnabled] fail: write result failed, ErrCode=%{public}d", result);
1457 return ERR_ANS_PARCELABLE_FAILED;
1458 }
1459
1460 if (!reply.WriteBool(enabled)) {
1461 ANS_LOGE("[HandleGetShowBadgeEnabled] fail: write enabled failed, ErrCode=%{public}d", result);
1462 return ERR_ANS_PARCELABLE_FAILED;
1463 }
1464 return ERR_OK;
1465 }
1466
HandleSubscribe(MessageParcel & data,MessageParcel & reply)1467 ErrCode AnsManagerStub::HandleSubscribe(MessageParcel &data, MessageParcel &reply)
1468 {
1469 sptr<IRemoteObject> subscriber = data.ReadRemoteObject();
1470 if (subscriber == nullptr) {
1471 ANS_LOGE("[HandleSubscribe] fail: read subscriber failed");
1472 return ERR_ANS_PARCELABLE_FAILED;
1473 }
1474
1475 bool subcribeInfo = false;
1476 if (!data.ReadBool(subcribeInfo)) {
1477 ANS_LOGE("[HandleSubscribe] fail: read isSubcribeInfo failed");
1478 return ERR_ANS_PARCELABLE_FAILED;
1479 }
1480
1481 sptr<NotificationSubscribeInfo> info = nullptr;
1482 if (subcribeInfo) {
1483 info = data.ReadParcelable<NotificationSubscribeInfo>();
1484 if (info == nullptr) {
1485 ANS_LOGE("[HandleSubscribe] fail: read info failed");
1486 return ERR_ANS_PARCELABLE_FAILED;
1487 }
1488 }
1489
1490 ErrCode result = Subscribe(iface_cast<AnsSubscriberInterface>(subscriber), info);
1491 if (!reply.WriteInt32(result)) {
1492 ANS_LOGE("[HandleSubscribe] fail: write result failed, ErrCode=%{public}d", result);
1493 return ERR_ANS_PARCELABLE_FAILED;
1494 }
1495 return ERR_OK;
1496 }
1497
HandleSubscribeSelf(MessageParcel & data,MessageParcel & reply)1498 ErrCode AnsManagerStub::HandleSubscribeSelf(MessageParcel &data, MessageParcel &reply)
1499 {
1500 sptr<IRemoteObject> subscriber = data.ReadRemoteObject();
1501 if (subscriber == nullptr) {
1502 ANS_LOGE("[HandleSubscribeSelf] fail: read subscriber failed");
1503 return ERR_ANS_PARCELABLE_FAILED;
1504 }
1505
1506 ErrCode result = SubscribeSelf(iface_cast<AnsSubscriberInterface>(subscriber));
1507 if (!reply.WriteInt32(result)) {
1508 ANS_LOGE("[HandleSubscribeSelf] fail: write result failed, ErrCode=%{public}d", result);
1509 return ERR_ANS_PARCELABLE_FAILED;
1510 }
1511 return ERR_OK;
1512 }
1513
HandleSubscribeLocalLiveView(MessageParcel & data,MessageParcel & reply)1514 ErrCode AnsManagerStub::HandleSubscribeLocalLiveView(MessageParcel &data, MessageParcel &reply)
1515 {
1516 sptr<IRemoteObject> subscriber = data.ReadRemoteObject();
1517 if (subscriber == nullptr) {
1518 ANS_LOGE("[HandleSubscribeLocalLiveView] fail: read subscriber failed");
1519 return ERR_ANS_PARCELABLE_FAILED;
1520 }
1521
1522 bool subcribeInfo = false;
1523 if (!data.ReadBool(subcribeInfo)) {
1524 ANS_LOGE("[HandleSubscribeLocalLiveView] fail: read isSubcribeInfo failed");
1525 return ERR_ANS_PARCELABLE_FAILED;
1526 }
1527
1528 sptr<NotificationSubscribeInfo> info = nullptr;
1529 if (subcribeInfo) {
1530 info = data.ReadParcelable<NotificationSubscribeInfo>();
1531 if (info == nullptr) {
1532 ANS_LOGE("[HandleSubscribeLocalLiveView] fail: read info failed");
1533 return ERR_ANS_PARCELABLE_FAILED;
1534 }
1535 }
1536
1537 bool isNative = false;
1538 if (!data.ReadBool(isNative)) {
1539 ANS_LOGE("[HandleSubscribeLocalLiveView] fail: read isNative failed");
1540 return ERR_ANS_PARCELABLE_FAILED;
1541 }
1542
1543 ErrCode result =
1544 SubscribeLocalLiveView(iface_cast<AnsSubscriberLocalLiveViewInterface>(subscriber), info, isNative);
1545 if (!reply.WriteInt32(result)) {
1546 ANS_LOGE("[HandleSubscribeLocalLiveView] fail: write result failed, ErrCode=%{public}d", result);
1547 return ERR_ANS_PARCELABLE_FAILED;
1548 }
1549 return ERR_OK;
1550 }
1551
HandleUnsubscribe(MessageParcel & data,MessageParcel & reply)1552 ErrCode AnsManagerStub::HandleUnsubscribe(MessageParcel &data, MessageParcel &reply)
1553 {
1554 sptr<IRemoteObject> subscriber = data.ReadRemoteObject();
1555 if (subscriber == nullptr) {
1556 ANS_LOGE("[HandleUnsubscribe] fail: read subscriber failed");
1557 return ERR_ANS_PARCELABLE_FAILED;
1558 }
1559
1560 bool subcribeInfo = false;
1561 if (!data.ReadBool(subcribeInfo)) {
1562 ANS_LOGE("[HandleUnsubscribe] fail: read isSubcribeInfo failed");
1563 return ERR_ANS_PARCELABLE_FAILED;
1564 }
1565
1566 sptr<NotificationSubscribeInfo> info = nullptr;
1567 if (subcribeInfo) {
1568 info = data.ReadParcelable<NotificationSubscribeInfo>();
1569 if (info == nullptr) {
1570 ANS_LOGE("[HandleUnsubscribe] fail: read info failed");
1571 return ERR_ANS_PARCELABLE_FAILED;
1572 }
1573 }
1574
1575 ErrCode result = Unsubscribe(iface_cast<AnsSubscriberInterface>(subscriber), info);
1576 if (!reply.WriteInt32(result)) {
1577 ANS_LOGE("[HandleUnsubscribe] fail: write result failed, ErrCode=%{public}d", result);
1578 return ERR_ANS_PARCELABLE_FAILED;
1579 }
1580 return ERR_OK;
1581 }
1582
HandleIsAllowedNotify(MessageParcel & data,MessageParcel & reply)1583 ErrCode AnsManagerStub::HandleIsAllowedNotify(MessageParcel &data, MessageParcel &reply)
1584 {
1585 bool allowed = false;
1586 ErrCode result = IsAllowedNotify(allowed);
1587 if (!reply.WriteInt32(result)) {
1588 ANS_LOGE("[HandleIsAllowedNotify] fail: write result failed, ErrCode=%{public}d", result);
1589 return ERR_ANS_PARCELABLE_FAILED;
1590 }
1591
1592 if (!reply.WriteBool(allowed)) {
1593 ANS_LOGE("[HandleIsAllowedNotify] fail: write allowed failed.");
1594 return ERR_ANS_PARCELABLE_FAILED;
1595 }
1596 return ERR_OK;
1597 }
1598
HandleIsAllowedNotifySelf(MessageParcel & data,MessageParcel & reply)1599 ErrCode AnsManagerStub::HandleIsAllowedNotifySelf(MessageParcel &data, MessageParcel &reply)
1600 {
1601 bool allowed = false;
1602 ErrCode result = IsAllowedNotifySelf(allowed);
1603 if (!reply.WriteInt32(result)) {
1604 ANS_LOGE("[HandleIsAllowedNotifySelf] fail: write result failed, ErrCode=%{public}d", result);
1605 return ERR_ANS_PARCELABLE_FAILED;
1606 }
1607
1608 if (!reply.WriteBool(allowed)) {
1609 ANS_LOGE("[HandleIsAllowedNotifySelf] fail: write allowed failed.");
1610 return ERR_ANS_PARCELABLE_FAILED;
1611 }
1612 return ERR_OK;
1613 }
1614
HandleCanPopEnableNotificationDialog(MessageParcel & data,MessageParcel & reply)1615 ErrCode AnsManagerStub::HandleCanPopEnableNotificationDialog(MessageParcel &data, MessageParcel &reply)
1616 {
1617 sptr<IRemoteObject> callback = data.ReadRemoteObject();
1618 if (callback == nullptr) {
1619 ANS_LOGE("[HandleCanPopEnableNotificationDialog] fail: read callback failed");
1620 return ERR_ANS_PARCELABLE_FAILED;
1621 }
1622 bool canPop = false;
1623 std::string bundleName;
1624 ErrCode result = CanPopEnableNotificationDialog(iface_cast<AnsDialogCallback>(callback), canPop, bundleName);
1625 if (!reply.WriteInt32(result)) {
1626 ANS_LOGE("[HandleCanPopEnableNotificationDialog] fail: write result failed, ErrCode=%{public}d", result);
1627 return ERR_ANS_PARCELABLE_FAILED;
1628 }
1629
1630 if (!reply.WriteBool(canPop)) {
1631 ANS_LOGE("[HandleCanPopEnableNotificationDialog] fail: write canPop failed.");
1632 return ERR_ANS_PARCELABLE_FAILED;
1633 }
1634 if (!reply.WriteString(bundleName)) {
1635 ANS_LOGE("[HandleCanPopEnableNotificationDialog] fail: write bundleName failed.");
1636 return ERR_ANS_PARCELABLE_FAILED;
1637 }
1638 return ERR_OK;
1639 }
1640
HandleRemoveEnableNotificationDialog(MessageParcel & data,MessageParcel & reply)1641 ErrCode AnsManagerStub::HandleRemoveEnableNotificationDialog(MessageParcel &data, MessageParcel &reply)
1642 {
1643 ErrCode result = RemoveEnableNotificationDialog();
1644 if (!reply.WriteInt32(result)) {
1645 ANS_LOGE("[HandleRemoveEnableNotificationDialog] fail: write result failed, ErrCode=%{public}d", result);
1646 return ERR_ANS_PARCELABLE_FAILED;
1647 }
1648 return ERR_OK;
1649 }
1650
HandleIsSpecialBundleAllowedNotify(MessageParcel & data,MessageParcel & reply)1651 ErrCode AnsManagerStub::HandleIsSpecialBundleAllowedNotify(MessageParcel &data, MessageParcel &reply)
1652 {
1653 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1654 if (bundleOption == nullptr) {
1655 ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: read bundle failed.");
1656 return ERR_ANS_PARCELABLE_FAILED;
1657 }
1658
1659 bool allowed = false;
1660 ErrCode result = IsSpecialBundleAllowedNotify(bundleOption, allowed);
1661 if (!reply.WriteInt32(result)) {
1662 ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: write result failed, ErrCode=%{public}d", result);
1663 return ERR_ANS_PARCELABLE_FAILED;
1664 }
1665
1666 if (!reply.WriteBool(allowed)) {
1667 ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: write allowed failed.");
1668 return ERR_ANS_PARCELABLE_FAILED;
1669 }
1670 return ERR_OK;
1671 }
1672
HandleCancelGroup(MessageParcel & data,MessageParcel & reply)1673 ErrCode AnsManagerStub::HandleCancelGroup(MessageParcel &data, MessageParcel &reply)
1674 {
1675 std::string groupName;
1676 if (!data.ReadString(groupName)) {
1677 ANS_LOGE("[HandleCancelGroup] fail: read groupName failed.");
1678 return ERR_ANS_PARCELABLE_FAILED;
1679 }
1680
1681 std::string appInstanceKey;
1682 if (!data.ReadString(appInstanceKey)) {
1683 ANS_LOGE("[HandleCancelGroup] fail: read instanceKey failed");
1684 return ERR_ANS_PARCELABLE_FAILED;
1685 }
1686
1687 ErrCode result = CancelGroup(groupName, appInstanceKey);
1688 if (!reply.WriteInt32(result)) {
1689 ANS_LOGE("[HandleCancelGroup] fail: write result failed, ErrCode=%{public}d", result);
1690 return ERR_ANS_PARCELABLE_FAILED;
1691 }
1692 return ERR_OK;
1693 }
1694
HandleRemoveGroupByBundle(MessageParcel & data,MessageParcel & reply)1695 ErrCode AnsManagerStub::HandleRemoveGroupByBundle(MessageParcel &data, MessageParcel &reply)
1696 {
1697 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1698 if (bundleOption == nullptr) {
1699 ANS_LOGE("[HandleRemoveGroupByBundle] fail: read bundleOption failed.");
1700 return ERR_ANS_PARCELABLE_FAILED;
1701 }
1702
1703 std::string groupName;
1704 if (!data.ReadString(groupName)) {
1705 ANS_LOGE("[HandleRemoveGroupByBundle] fail: read groupName failed.");
1706 return ERR_ANS_PARCELABLE_FAILED;
1707 }
1708
1709 ErrCode result = RemoveGroupByBundle(bundleOption, groupName);
1710 if (!reply.WriteInt32(result)) {
1711 ANS_LOGE("[HandleRemoveGroupByBundle] fail: write result failed, ErrCode=%{public}d", result);
1712 return ERR_ANS_PARCELABLE_FAILED;
1713 }
1714 return ERR_OK;
1715 }
1716
HandleIsDistributedEnabled(MessageParcel & data,MessageParcel & reply)1717 ErrCode AnsManagerStub::HandleIsDistributedEnabled(MessageParcel &data, MessageParcel &reply)
1718 {
1719 bool enabled = false;
1720 ErrCode result = IsDistributedEnabled(enabled);
1721 if (!reply.WriteInt32(result)) {
1722 ANS_LOGE("[HandleIsDistributedEnabled] fail: write result failed, ErrCode=%{public}d", result);
1723 return ERR_ANS_PARCELABLE_FAILED;
1724 }
1725
1726 if (!reply.WriteBool(enabled)) {
1727 ANS_LOGE("[HandleIsDistributedEnabled] fail: write enabled failed.");
1728 return ERR_ANS_PARCELABLE_FAILED;
1729 }
1730
1731 return ERR_OK;
1732 }
1733
HandleEnableDistributed(MessageParcel & data,MessageParcel & reply)1734 ErrCode AnsManagerStub::HandleEnableDistributed(MessageParcel &data, MessageParcel &reply)
1735 {
1736 bool enabled = false;
1737 if (!data.ReadBool(enabled)) {
1738 ANS_LOGE("[HandleEnableDistributed] fail: read enabled failed.");
1739 return ERR_ANS_PARCELABLE_FAILED;
1740 }
1741
1742 ErrCode result = EnableDistributed(enabled);
1743 if (!reply.WriteInt32(result)) {
1744 ANS_LOGE("[HandleEnableDistributed] fail: write result failed, ErrCode=%{public}d", result);
1745 return ERR_ANS_PARCELABLE_FAILED;
1746 }
1747
1748 return ERR_OK;
1749 }
1750
HandleEnableDistributedByBundle(MessageParcel & data,MessageParcel & reply)1751 ErrCode AnsManagerStub::HandleEnableDistributedByBundle(MessageParcel &data, MessageParcel &reply)
1752 {
1753 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1754 if (bundleOption == nullptr) {
1755 ANS_LOGE("[HandleEnableDistributedByBundle] fail: read bundle failed.");
1756 return ERR_ANS_PARCELABLE_FAILED;
1757 }
1758
1759 bool enabled = false;
1760 if (!data.ReadBool(enabled)) {
1761 ANS_LOGE("[HandleEnableDistributedByBundle] fail: read enabled failed.");
1762 return ERR_ANS_PARCELABLE_FAILED;
1763 }
1764
1765 ErrCode result = EnableDistributedByBundle(bundleOption, enabled);
1766 if (!reply.WriteInt32(result)) {
1767 ANS_LOGE("[HandleEnableDistributedByBundle] fail: write result failed, ErrCode=%{public}d", result);
1768 return ERR_ANS_PARCELABLE_FAILED;
1769 }
1770
1771 return ERR_OK;
1772 }
1773
HandleEnableDistributedSelf(MessageParcel & data,MessageParcel & reply)1774 ErrCode AnsManagerStub::HandleEnableDistributedSelf(MessageParcel &data, MessageParcel &reply)
1775 {
1776 bool enabled = false;
1777 if (!data.ReadBool(enabled)) {
1778 ANS_LOGE("[HandleEnableDistributedSelf] fail: read enabled failed.");
1779 return ERR_ANS_PARCELABLE_FAILED;
1780 }
1781
1782 ErrCode result = EnableDistributedSelf(enabled);
1783 if (!reply.WriteInt32(result)) {
1784 ANS_LOGE("[HandleEnableDistributedSelf] fail: write result failed, ErrCode=%{public}d", result);
1785 return ERR_ANS_PARCELABLE_FAILED;
1786 }
1787
1788 return ERR_OK;
1789 }
1790
HandleIsDistributedEnableByBundle(MessageParcel & data,MessageParcel & reply)1791 ErrCode AnsManagerStub::HandleIsDistributedEnableByBundle(MessageParcel &data, MessageParcel &reply)
1792 {
1793 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
1794 if (bundleOption == nullptr) {
1795 ANS_LOGE("[HandleIsDistributedEnableByBundle] fail: read bundle failed.");
1796 return ERR_ANS_PARCELABLE_FAILED;
1797 }
1798
1799 bool enabled = false;
1800 ErrCode result = IsDistributedEnableByBundle(bundleOption, enabled);
1801 if (!reply.WriteInt32(result)) {
1802 ANS_LOGE("[HandleIsDistributedEnableByBundle] fail: write result failed, ErrCode=%{public}d", result);
1803 return ERR_ANS_PARCELABLE_FAILED;
1804 }
1805
1806 if (!reply.WriteBool(enabled)) {
1807 ANS_LOGE("[HandleIsDistributedEnableByBundle] fail: write enabled failed.");
1808 return ERR_ANS_PARCELABLE_FAILED;
1809 }
1810
1811 return ERR_OK;
1812 }
1813
HandleGetDeviceRemindType(MessageParcel & data,MessageParcel & reply)1814 ErrCode AnsManagerStub::HandleGetDeviceRemindType(MessageParcel &data, MessageParcel &reply)
1815 {
1816 auto rType{ NotificationConstant::RemindType::NONE };
1817 ErrCode result = GetDeviceRemindType(rType);
1818 if (!reply.WriteInt32(result)) {
1819 ANS_LOGE("[HandleGetDeviceRemindType] fail: write result failed, ErrCode=%{public}d", result);
1820 return ERR_ANS_PARCELABLE_FAILED;
1821 }
1822
1823 if (!reply.WriteInt32(static_cast<int32_t>(rType))) {
1824 ANS_LOGE("[HandleGetDeviceRemindType] fail: write remind type failed.");
1825 return ERR_ANS_PARCELABLE_FAILED;
1826 }
1827
1828 return ERR_OK;
1829 }
1830
HandleShellDump(MessageParcel & data,MessageParcel & reply)1831 ErrCode AnsManagerStub::HandleShellDump(MessageParcel &data, MessageParcel &reply)
1832 {
1833 std::string cmd;
1834 if (!data.ReadString(cmd)) {
1835 ANS_LOGE("[HandleShellDump] fail: read cmd failed.");
1836 return ERR_ANS_PARCELABLE_FAILED;
1837 }
1838 std::string bundle;
1839 if (!data.ReadString(bundle)) {
1840 ANS_LOGE("[HandleShellDump] fail: read bundle failed.");
1841 return ERR_ANS_PARCELABLE_FAILED;
1842 }
1843 int32_t userId;
1844 if (!data.ReadInt32(userId)) {
1845 ANS_LOGE("[HandleShellDump] fail: read userId failed.");
1846 return ERR_ANS_PARCELABLE_FAILED;
1847 }
1848 int32_t recvUserId;
1849 if (!data.ReadInt32(recvUserId)) {
1850 ANS_LOGE("[HandleShellDump] fail: read recvUserId failed.");
1851 return ERR_ANS_PARCELABLE_FAILED;
1852 }
1853 std::vector<std::string> notificationsInfo;
1854 ErrCode result = ShellDump(cmd, bundle, userId, recvUserId, notificationsInfo);
1855 if (!reply.WriteInt32(result)) {
1856 ANS_LOGE("[HandleGetRecentNotificationsInfo] fail: write result failed, ErrCode=%{public}d", result);
1857 return ERR_ANS_PARCELABLE_FAILED;
1858 }
1859
1860 if (!reply.WriteStringVector(notificationsInfo)) {
1861 ANS_LOGE("[HandleGetRecentNotificationsInfo] fail: write notificationsInfo failed.");
1862 return ERR_ANS_PARCELABLE_FAILED;
1863 }
1864 return ERR_OK;
1865 }
1866
HandleIsSupportTemplate(MessageParcel & data,MessageParcel & reply)1867 ErrCode AnsManagerStub::HandleIsSupportTemplate(MessageParcel &data, MessageParcel &reply)
1868 {
1869 std::string templateName;
1870 if (!data.ReadString(templateName)) {
1871 ANS_LOGE("[HandleIsSupportTemplate] fail: read template name failed.");
1872 return ERR_ANS_PARCELABLE_FAILED;
1873 }
1874 bool support = false;
1875 ErrCode result = IsSupportTemplate(templateName, support);
1876 if (!reply.WriteInt32(result)) {
1877 ANS_LOGE("[HandleIsSupportTemplate] fail: write result failed, ErrCode=%{public}d", result);
1878 return ERR_ANS_PARCELABLE_FAILED;
1879 }
1880 if (!reply.WriteBool(support)) {
1881 ANS_LOGE("[HandleIsSupportTemplate] fail: write support failed.");
1882 return ERR_ANS_PARCELABLE_FAILED;
1883 }
1884 return ERR_OK;
1885 }
1886
HandleIsSpecialUserAllowedNotifyByUser(MessageParcel & data,MessageParcel & reply)1887 ErrCode AnsManagerStub::HandleIsSpecialUserAllowedNotifyByUser(MessageParcel &data, MessageParcel &reply)
1888 {
1889 int32_t userId = SUBSCRIBE_USER_INIT;
1890 if (!data.ReadInt32(userId)) {
1891 ANS_LOGE("[HandleIsSpecialUserAllowedNotifyByUser] fail: read userId failed.");
1892 return ERR_ANS_PARCELABLE_FAILED;
1893 }
1894
1895 bool allowed = false;
1896 ErrCode result = IsSpecialUserAllowedNotify(userId, allowed);
1897 if (!reply.WriteInt32(result)) {
1898 ANS_LOGE("[HandleIsSpecialUserAllowedNotifyByUser] fail: write result failed, ErrCode=%{public}d", result);
1899 return ERR_ANS_PARCELABLE_FAILED;
1900 }
1901
1902 if (!reply.WriteBool(allowed)) {
1903 ANS_LOGE("[HandleIsSpecialUserAllowedNotifyByUser] fail: write allowed failed.");
1904 return ERR_ANS_PARCELABLE_FAILED;
1905 }
1906 return ERR_OK;
1907 }
1908
HandleSetNotificationsEnabledByUser(MessageParcel & data,MessageParcel & reply)1909 ErrCode AnsManagerStub::HandleSetNotificationsEnabledByUser(MessageParcel &data, MessageParcel &reply)
1910 {
1911 int32_t userId = SUBSCRIBE_USER_INIT;
1912 if (!data.ReadInt32(userId)) {
1913 ANS_LOGE("[HandleSetNotificationsEnabledByUser] fail: read userId failed.");
1914 return ERR_ANS_PARCELABLE_FAILED;
1915 }
1916
1917 bool enabled = false;
1918 if (!data.ReadBool(enabled)) {
1919 ANS_LOGE("[HandleSetNotificationsEnabledByUser] fail: read enabled failed.");
1920 return ERR_ANS_PARCELABLE_FAILED;
1921 }
1922
1923 ErrCode result = SetNotificationsEnabledByUser(userId, enabled);
1924 if (!reply.WriteInt32(result)) {
1925 ANS_LOGE("[HandleSetNotificationsEnabledByUser] fail: write result failed, ErrCode=%{public}d", result);
1926 return ERR_ANS_PARCELABLE_FAILED;
1927 }
1928 return ERR_OK;
1929 }
1930
HandleDeleteAllByUser(MessageParcel & data,MessageParcel & reply)1931 ErrCode AnsManagerStub::HandleDeleteAllByUser(MessageParcel &data, MessageParcel &reply)
1932 {
1933 int32_t userId = SUBSCRIBE_USER_INIT;
1934 if (!data.ReadInt32(userId)) {
1935 ANS_LOGE("[HandleDeleteAllByUser] fail: read userId failed.");
1936 return ERR_ANS_PARCELABLE_FAILED;
1937 }
1938
1939 ErrCode result = DeleteAllByUser(userId);
1940 if (!reply.WriteInt32(result)) {
1941 ANS_LOGE("[HandleDeleteAllByUser] fail: write result failed, ErrCode=%{public}d", result);
1942 return ERR_ANS_PARCELABLE_FAILED;
1943 }
1944 return ERR_OK;
1945 }
1946
HandleSetDoNotDisturbDateByUser(MessageParcel & data,MessageParcel & reply)1947 ErrCode AnsManagerStub::HandleSetDoNotDisturbDateByUser(MessageParcel &data, MessageParcel &reply)
1948 {
1949 return ERR_OK;
1950 }
1951
HandleGetDoNotDisturbDateByUser(MessageParcel & data,MessageParcel & reply)1952 ErrCode AnsManagerStub::HandleGetDoNotDisturbDateByUser(MessageParcel &data, MessageParcel &reply)
1953 {
1954 return ERR_OK;
1955 }
1956
HandleSetEnabledForBundleSlot(MessageParcel & data,MessageParcel & reply)1957 ErrCode AnsManagerStub::HandleSetEnabledForBundleSlot(MessageParcel &data, MessageParcel &reply)
1958 {
1959 sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
1960 if (bundleOption == nullptr) {
1961 ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: read bundle failed.");
1962 return ERR_ANS_PARCELABLE_FAILED;
1963 }
1964
1965 int32_t type = 0;
1966 if (!data.ReadInt32(type)) {
1967 ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: read slot type failed.");
1968 return ERR_ANS_PARCELABLE_FAILED;
1969 }
1970 NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(type);
1971
1972 bool enabled = false;
1973 if (!data.ReadBool(enabled)) {
1974 ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: read enabled failed.");
1975 return ERR_ANS_PARCELABLE_FAILED;
1976 }
1977
1978 bool isForceControl = false;
1979 if (!data.ReadBool(isForceControl)) {
1980 ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: read isForceControl failed.");
1981 return ERR_ANS_PARCELABLE_FAILED;
1982 }
1983
1984 ErrCode result = SetEnabledForBundleSlot(bundleOption, slotType, enabled, isForceControl);
1985 if (!reply.WriteInt32(result)) {
1986 ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: write result failed, ErrCode=%{public}d", result);
1987 return ERR_ANS_PARCELABLE_FAILED;
1988 }
1989
1990 return ERR_OK;
1991 }
1992
HandleGetEnabledForBundleSlot(MessageParcel & data,MessageParcel & reply)1993 ErrCode AnsManagerStub::HandleGetEnabledForBundleSlot(MessageParcel &data, MessageParcel &reply)
1994 {
1995 sptr<NotificationBundleOption> bundleOption = data.ReadStrongParcelable<NotificationBundleOption>();
1996 if (bundleOption == nullptr) {
1997 ANS_LOGE("[HandleGetEnabledForBundleSlot] fail: read bundle failed.");
1998 return ERR_ANS_PARCELABLE_FAILED;
1999 }
2000
2001 int32_t type = 0;
2002 if (!data.ReadInt32(type)) {
2003 ANS_LOGE("[HandleGetEnabledForBundleSlot] fail: read slot type failed.");
2004 return ERR_ANS_PARCELABLE_FAILED;
2005 }
2006 NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(type);
2007
2008 bool enabled = false;
2009 ErrCode result = GetEnabledForBundleSlot(bundleOption, slotType, enabled);
2010 if (!reply.WriteInt32(result)) {
2011 ANS_LOGE("[HandleGetEnabledForBundleSlot] fail: write result failed, ErrCode=%{public}d", result);
2012 return ERR_ANS_PARCELABLE_FAILED;
2013 }
2014
2015 if (!reply.WriteBool(enabled)) {
2016 ANS_LOGE("[HandleGetEnabledForBundleSlot] fail: write enabled failed, ErrCode=%{public}d", result);
2017 return ERR_ANS_PARCELABLE_FAILED;
2018 }
2019
2020 return ERR_OK;
2021 }
2022
HandleGetEnabledForBundleSlotSelf(MessageParcel & data,MessageParcel & reply)2023 ErrCode AnsManagerStub::HandleGetEnabledForBundleSlotSelf(MessageParcel &data, MessageParcel &reply)
2024 {
2025 int32_t type = 0;
2026 if (!data.ReadInt32(type)) {
2027 ANS_LOGE("[HandleGetEnabledForBundleSlotSelf] fail: read slot type failed.");
2028 return ERR_ANS_PARCELABLE_FAILED;
2029 }
2030 NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(type);
2031
2032 bool enabled = false;
2033 ErrCode result = GetEnabledForBundleSlotSelf(slotType, enabled);
2034 if (!reply.WriteInt32(result)) {
2035 ANS_LOGE("[HandleGetEnabledForBundleSlotSelf] fail: write result failed, ErrCode=%{public}d", result);
2036 return ERR_ANS_PARCELABLE_FAILED;
2037 }
2038
2039 if (!reply.WriteBool(enabled)) {
2040 ANS_LOGE("[HandleGetEnabledForBundleSlotSelf] fail: write enabled failed, ErrCode=%{public}d", result);
2041 return ERR_ANS_PARCELABLE_FAILED;
2042 }
2043
2044 return ERR_OK;
2045 }
2046
HandleDistributedSetEnabledWithoutApp(MessageParcel & data,MessageParcel & reply)2047 ErrCode AnsManagerStub::HandleDistributedSetEnabledWithoutApp(MessageParcel &data, MessageParcel &reply)
2048 {
2049 int32_t userId = SUBSCRIBE_USER_INIT;
2050 if (!data.ReadInt32(userId)) {
2051 ANS_LOGE("[HandleDistributedSetEnabledWithoutApp] fail: read userId failed.");
2052 return ERR_ANS_PARCELABLE_FAILED;
2053 }
2054
2055 bool enabled = false;
2056 if (!data.ReadBool(enabled)) {
2057 ANS_LOGE("[HandleDistributedSetEnabledWithoutApp] fail: read enabled failed.");
2058 return ERR_ANS_PARCELABLE_FAILED;
2059 }
2060
2061 ErrCode result = SetSyncNotificationEnabledWithoutApp(userId, enabled);
2062 if (!reply.WriteInt32(result)) {
2063 ANS_LOGE("[HandleDistributedSetEnabledWithoutApp] fail: write result failed, ErrCode=%{public}d", result);
2064 return ERR_ANS_PARCELABLE_FAILED;
2065 }
2066
2067 return ERR_OK;
2068 }
2069
HandleDistributedGetEnabledWithoutApp(MessageParcel & data,MessageParcel & reply)2070 ErrCode AnsManagerStub::HandleDistributedGetEnabledWithoutApp(MessageParcel &data, MessageParcel &reply)
2071 {
2072 int32_t userId = SUBSCRIBE_USER_INIT;
2073 if (!data.ReadInt32(userId)) {
2074 ANS_LOGE("[HandleDistributedGetEnabledWithoutApp] fail: read userId failed.");
2075 return ERR_ANS_PARCELABLE_FAILED;
2076 }
2077
2078 bool enabled = false;
2079 ErrCode result = GetSyncNotificationEnabledWithoutApp(userId, enabled);
2080 if (!reply.WriteInt32(result)) {
2081 ANS_LOGE("[HandleDistributedGetEnabledWithoutApp] fail: write result failed, ErrCode=%{public}d", result);
2082 return ERR_ANS_PARCELABLE_FAILED;
2083 }
2084
2085 if (!reply.WriteBool(enabled)) {
2086 ANS_LOGE("[HandleDistributedGetEnabledWithoutApp] fail: write enabled failed.");
2087 return ERR_ANS_PARCELABLE_FAILED;
2088 }
2089
2090 return ERR_OK;
2091 }
2092
HandleSetBadgeNumber(MessageParcel & data,MessageParcel & reply)2093 ErrCode AnsManagerStub::HandleSetBadgeNumber(MessageParcel &data, MessageParcel &reply)
2094 {
2095 int32_t badgeNumber = -1;
2096 if (!data.ReadInt32(badgeNumber)) {
2097 ANSR_LOGE("Read badge number failed.");
2098 return ERR_ANS_PARCELABLE_FAILED;
2099 }
2100
2101 std::string appInstanceKey;
2102 if (!data.ReadString(appInstanceKey)) {
2103 ANSR_LOGE("Read instance key failed.");
2104 return ERR_ANS_PARCELABLE_FAILED;
2105 }
2106
2107 ErrCode result = SetBadgeNumber(badgeNumber, appInstanceKey);
2108 if (!reply.WriteInt32(result)) {
2109 ANSR_LOGE("Write badge number failed");
2110 return ERR_ANS_PARCELABLE_FAILED;
2111 }
2112 return result;
2113 }
2114
HandleSetBadgeNumberByBundle(MessageParcel & data,MessageParcel & reply)2115 ErrCode AnsManagerStub::HandleSetBadgeNumberByBundle(MessageParcel &data, MessageParcel &reply)
2116 {
2117 ANS_LOGD("Called.");
2118 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
2119 if (bundleOption == nullptr) {
2120 ANS_LOGE("Read bundle option failed.");
2121 return ERR_ANS_PARCELABLE_FAILED;
2122 }
2123 int32_t badgeNumber = 0;
2124 if (!data.ReadInt32(badgeNumber)) {
2125 ANS_LOGE("Read badge number failed.");
2126 return ERR_ANS_PARCELABLE_FAILED;
2127 }
2128
2129 ErrCode result = SetBadgeNumberByBundle(bundleOption, badgeNumber);
2130 if (!reply.WriteInt32(result)) {
2131 ANS_LOGE("Write result failed.");
2132 return ERR_ANS_PARCELABLE_FAILED;
2133 }
2134 return result;
2135 }
2136
HandleSetBadgeNumberForDhByBundle(MessageParcel & data,MessageParcel & reply)2137 ErrCode AnsManagerStub::HandleSetBadgeNumberForDhByBundle(MessageParcel &data, MessageParcel &reply)
2138 {
2139 ANS_LOGD("Called.");
2140 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
2141 if (bundleOption == nullptr) {
2142 ANS_LOGE("Read bundle option failed.");
2143 return ERR_ANS_PARCELABLE_FAILED;
2144 }
2145 int32_t badgeNumber = 0;
2146 if (!data.ReadInt32(badgeNumber)) {
2147 ANS_LOGE("Read badge number failed.");
2148 return ERR_ANS_PARCELABLE_FAILED;
2149 }
2150
2151 ErrCode result = SetBadgeNumberForDhByBundle(bundleOption, badgeNumber);
2152 if (!reply.WriteInt32(result)) {
2153 ANS_LOGE("Write result failed.");
2154 return ERR_ANS_PARCELABLE_FAILED;
2155 }
2156 return result;
2157 }
2158
HandleGetAllNotificationEnableStatus(MessageParcel & data,MessageParcel & reply)2159 ErrCode AnsManagerStub::HandleGetAllNotificationEnableStatus(MessageParcel &data, MessageParcel &reply)
2160 {
2161 std::vector<NotificationBundleOption> bundleOption;
2162 ErrCode result = GetAllNotificationEnabledBundles(bundleOption);
2163 int32_t vectorSize = bundleOption.size();
2164 if (vectorSize > MAX_STATUS_VECTOR_NUM) {
2165 ANS_LOGE("Bundle bundleOption vector is over size.");
2166 return ERR_ANS_PARCELABLE_FAILED;
2167 }
2168
2169 if (!reply.WriteInt32(result)) {
2170 ANS_LOGE("Write result failed, ErrCode=%{public}d", result);
2171 return ERR_ANS_PARCELABLE_FAILED;
2172 }
2173
2174 if (!reply.WriteInt32(vectorSize)) {
2175 ANS_LOGE("Write bundleOption size failed.");
2176 return ERR_ANS_PARCELABLE_FAILED;
2177 }
2178
2179 for (const auto &item : bundleOption) {
2180 if (!reply.WriteParcelable(&item)) {
2181 ANS_LOGE("Write bundleOption failed");
2182 return ERR_ANS_PARCELABLE_FAILED;
2183 }
2184 }
2185
2186 return ERR_OK;
2187 }
2188
HandleRegisterPushCallback(MessageParcel & data,MessageParcel & reply)2189 ErrCode AnsManagerStub::HandleRegisterPushCallback(MessageParcel &data, MessageParcel &reply)
2190 {
2191 sptr<IRemoteObject> pushCallBack = data.ReadRemoteObject();
2192 if (pushCallBack == nullptr) {
2193 ANS_LOGE("fail: read JSPushCallBack failed.");
2194 return ERR_ANS_PARCELABLE_FAILED;
2195 }
2196
2197 sptr<NotificationCheckRequest> notificationCheckRequest = data.ReadParcelable<NotificationCheckRequest>();
2198 if (notificationCheckRequest == nullptr) {
2199 ANS_LOGE("fail: read notificationCheckRequest failed.");
2200 return ERR_ANS_PARCELABLE_FAILED;
2201 }
2202
2203 ErrCode result = RegisterPushCallback(pushCallBack, notificationCheckRequest);
2204 if (!reply.WriteInt32(result)) {
2205 ANS_LOGE("fail: write result failed, ErrCode=%{public}d", result);
2206 return ERR_ANS_PARCELABLE_FAILED;
2207 }
2208 return result;
2209 }
2210
HandleUnregisterPushCallback(MessageParcel & data,MessageParcel & reply)2211 ErrCode AnsManagerStub::HandleUnregisterPushCallback(MessageParcel &data, MessageParcel &reply)
2212 {
2213 ErrCode result = UnregisterPushCallback();
2214 if (!reply.WriteInt32(result)) {
2215 ANS_LOGE("fail: write result failed, ErrCode=%{public}d", result);
2216 return ERR_ANS_PARCELABLE_FAILED;
2217 }
2218 return result;
2219 }
HandleGetNotificationRequest(MessageParcel & data,MessageParcel & reply)2220 ErrCode AnsManagerStub::HandleGetNotificationRequest(MessageParcel &data, MessageParcel &reply)
2221 {
2222 std::string hashCode;
2223 if (!data.ReadString(hashCode)) {
2224 ANS_LOGE("read hashCode failed.");
2225 return ERR_ANS_PARCELABLE_FAILED;
2226 }
2227
2228 sptr<NotificationRequest> request;
2229 ErrCode result = GetNotificationRequestByHashCode(hashCode, request);
2230 if (!reply.WriteInt32(result)) {
2231 ANS_LOGE("write result failed, ErrCode=%{public}d", result);
2232 return ERR_ANS_PARCELABLE_FAILED;
2233 }
2234
2235 if (!reply.WriteParcelable(request)) {
2236 ANS_LOGE("get request failed");
2237 return ERR_ANS_PARCELABLE_FAILED;
2238 }
2239 return ERR_OK;
2240 }
2241
HandleAddDoNotDisturbProfiles(MessageParcel & data,MessageParcel & reply)2242 ErrCode AnsManagerStub::HandleAddDoNotDisturbProfiles(MessageParcel &data, MessageParcel &reply)
2243 {
2244 return ERR_OK;
2245 }
2246
HandleSetDistributedEnabledByBundle(MessageParcel & data,MessageParcel & reply)2247 ErrCode AnsManagerStub::HandleSetDistributedEnabledByBundle(MessageParcel &data, MessageParcel &reply)
2248 {
2249 ANS_LOGD("enter");
2250 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
2251 if (bundleOption == nullptr) {
2252 ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read bundleOption failed.");
2253 return ERR_ANS_PARCELABLE_FAILED;
2254 }
2255
2256 std::string deviceType;
2257 if (!data.ReadString(deviceType)) {
2258 ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read deviceId failed.");
2259 return ERR_ANS_PARCELABLE_FAILED;
2260 }
2261
2262 bool enabled = false;
2263 if (!data.ReadBool(enabled)) {
2264 ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read enabled failed.");
2265 return ERR_ANS_PARCELABLE_FAILED;
2266 }
2267
2268 ErrCode result = SetDistributedEnabledByBundle(bundleOption, deviceType, enabled);
2269 if (!reply.WriteInt32(result)) {
2270 ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: write result failed, ErrCode=%{public}d",
2271 result);
2272 return ERR_ANS_PARCELABLE_FAILED;
2273 }
2274 return ERR_OK;
2275 }
2276
HandleRemoveDoNotDisturbProfiles(MessageParcel & data,MessageParcel & reply)2277 ErrCode AnsManagerStub::HandleRemoveDoNotDisturbProfiles(MessageParcel &data, MessageParcel &reply)
2278 {
2279 return ERR_OK;
2280 }
2281
HandleGetAllDistributedEnabledBundles(MessageParcel & data,MessageParcel & reply)2282 ErrCode AnsManagerStub::HandleGetAllDistributedEnabledBundles(MessageParcel &data, MessageParcel &reply)
2283 {
2284 std::string deviceType;
2285 if (!data.ReadString(deviceType)) {
2286 ANS_LOGE("[HandleGetAllDistributedEnabledBundles] fail: read deviceType failed.");
2287 return ERR_ANS_PARCELABLE_FAILED;
2288 }
2289
2290 std::vector<NotificationBundleOption> bundleOption;
2291 ErrCode result = GetAllDistribuedEnabledBundles(deviceType, bundleOption);
2292 int32_t vectorSize = bundleOption.size();
2293 if (vectorSize > MAX_STATUS_VECTOR_NUM) {
2294 ANS_LOGE("Bundle bundleOption vector is over size.");
2295 return ERR_ANS_PARCELABLE_FAILED;
2296 }
2297
2298 if (!reply.WriteInt32(result)) {
2299 ANS_LOGE("Write result failed, ErrCode=%{public}d", result);
2300 return ERR_ANS_PARCELABLE_FAILED;
2301 }
2302
2303 if (!reply.WriteInt32(vectorSize)) {
2304 ANS_LOGE("Write bundleOption size failed.");
2305 return ERR_ANS_PARCELABLE_FAILED;
2306 }
2307
2308 for (const auto &item : bundleOption) {
2309 if (!reply.WriteParcelable(&item)) {
2310 ANS_LOGE("Write bundleOption failed");
2311 return ERR_ANS_PARCELABLE_FAILED;
2312 }
2313 }
2314
2315 return ERR_OK;
2316 }
2317
HandleIsDistributedEnabledByBundle(MessageParcel & data,MessageParcel & reply)2318 ErrCode AnsManagerStub::HandleIsDistributedEnabledByBundle(MessageParcel &data, MessageParcel &reply)
2319 {
2320 ANS_LOGD("enter");
2321 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
2322 if (bundleOption == nullptr) {
2323 ANS_LOGE("[HandleIsDistributedEnabledByBundle] fail: read bundleOption failed.");
2324 return ERR_ANS_PARCELABLE_FAILED;
2325 }
2326
2327 std::string deviceType;
2328 if (!data.ReadString(deviceType)) {
2329 ANS_LOGE("[HandleIsDistributedEnabledByBundle] fail: read deviceId failed.");
2330 return ERR_ANS_PARCELABLE_FAILED;
2331 }
2332
2333 bool enabled = false;
2334 ErrCode result = IsDistributedEnabledByBundle(bundleOption, deviceType, enabled);
2335 if (!reply.WriteInt32(result)) {
2336 ANS_LOGE("[HandleIsDistributedEnabledByBundle] fail: write result failed, ErrCode=%{public}d", result);
2337 return ERR_ANS_PARCELABLE_FAILED;
2338 }
2339
2340 if (!reply.WriteBool(enabled)) {
2341 ANS_LOGE("[HandleIsDistributedEnabledByBundle] fail: write enabled failed.");
2342 return ERR_ANS_PARCELABLE_FAILED;
2343 }
2344 return ERR_OK;
2345 }
2346
HandleSetAdditionConfig(MessageParcel & data,MessageParcel & reply)2347 ErrCode AnsManagerStub::HandleSetAdditionConfig(MessageParcel &data, MessageParcel &reply)
2348 {
2349 std::string key;
2350 if (!data.ReadString(key)) {
2351 ANS_LOGE("Failed to read key.");
2352 return ERR_ANS_PARCELABLE_FAILED;
2353 }
2354
2355 std::string value;
2356 if (!data.ReadString(value)) {
2357 ANS_LOGE("Failed to read value.");
2358 return ERR_ANS_PARCELABLE_FAILED;
2359 }
2360
2361 ErrCode result = SetAdditionConfig(key, value);
2362 if (!reply.WriteInt32(result)) {
2363 ANS_LOGE("Failed to write result, ErrCode=%{public}d", result);
2364 return ERR_ANS_PARCELABLE_FAILED;
2365 }
2366 return result;
2367 }
2368
HandleSetSmartReminderEnabled(MessageParcel & data,MessageParcel & reply)2369 ErrCode AnsManagerStub::HandleSetSmartReminderEnabled(MessageParcel &data, MessageParcel &reply)
2370 {
2371 ANS_LOGD("enter");
2372 std::string deviceType;
2373 if (!data.ReadString(deviceType)) {
2374 ANS_LOGE("[HandleSetSmartReminderEnabled] fail: read deviceId failed.");
2375 return ERR_ANS_PARCELABLE_FAILED;
2376 }
2377
2378 bool enabled = false;
2379 if (!data.ReadBool(enabled)) {
2380 ANS_LOGE("[HandleSetSmartReminderEnabled] fail: read enabled failed.");
2381 return ERR_ANS_PARCELABLE_FAILED;
2382 }
2383
2384 ErrCode result = SetSmartReminderEnabled(deviceType, enabled);
2385 if (!reply.WriteInt32(result)) {
2386 ANS_LOGE("[HandleSetSmartReminderEnabled] fail: write result failed, ErrCode=%{public}d", result);
2387 return ERR_ANS_PARCELABLE_FAILED;
2388 }
2389 return ERR_OK;
2390 }
2391
HandleCancelAsBundleWithAgent(MessageParcel & data,MessageParcel & reply)2392 ErrCode AnsManagerStub::HandleCancelAsBundleWithAgent(MessageParcel &data, MessageParcel &reply)
2393 {
2394 sptr<NotificationBundleOption> bundleOption = data.ReadParcelable<NotificationBundleOption>();
2395 if (bundleOption == nullptr) {
2396 ANS_LOGE("Read bundleOption failed.");
2397 return ERR_ANS_PARCELABLE_FAILED;
2398 }
2399
2400 int32_t id = 0;
2401 if (!data.ReadInt32(id)) {
2402 ANS_LOGE("Read notification id failed.");
2403 return ERR_ANS_PARCELABLE_FAILED;
2404 }
2405
2406 ErrCode result = CancelAsBundleWithAgent(bundleOption, id);
2407 if (!reply.WriteInt32(result)) {
2408 ANS_LOGE("Write result failed, ErrCode=%{public}d", result);
2409 return ERR_ANS_PARCELABLE_FAILED;
2410 }
2411 return result;
2412 }
2413
HandleIsSmartReminderEnabled(MessageParcel & data,MessageParcel & reply)2414 ErrCode AnsManagerStub::HandleIsSmartReminderEnabled(MessageParcel &data, MessageParcel &reply)
2415 {
2416 ANS_LOGD("enter");
2417 std::string deviceType;
2418 if (!data.ReadString(deviceType)) {
2419 ANS_LOGE("[HandleIsSmartReminderEnabled] fail: read deviceId failed.");
2420 return ERR_ANS_PARCELABLE_FAILED;
2421 }
2422
2423 bool enabled = false;
2424 ErrCode result = IsSmartReminderEnabled(deviceType, enabled);
2425 if (!reply.WriteInt32(result)) {
2426 ANS_LOGE("[HandleIsSmartReminderEnabled] fail: write result failed, ErrCode=%{public}d", result);
2427 return ERR_ANS_PARCELABLE_FAILED;
2428 }
2429
2430 if (!reply.WriteBool(enabled)) {
2431 ANS_LOGE("[HandleIsSmartReminderEnabled] fail: write enabled failed.");
2432 return ERR_ANS_PARCELABLE_FAILED;
2433 }
2434 return ERR_OK;
2435 }
2436
HandleSetDistributedEnabledBySlot(MessageParcel & data,MessageParcel & reply)2437 ErrCode AnsManagerStub::HandleSetDistributedEnabledBySlot(MessageParcel &data, MessageParcel &reply)
2438 {
2439 ANS_LOGD("enter");
2440 NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(data.ReadInt32());
2441
2442 std::string deviceType;
2443 if (!data.ReadString(deviceType)) {
2444 ANS_LOGE("[HandleSetDistributedEnabledBySlot] fail: read deviceId failed.");
2445 return ERR_ANS_PARCELABLE_FAILED;
2446 }
2447
2448 bool enabled = false;
2449 if (!data.ReadBool(enabled)) {
2450 ANS_LOGE("[HandleSetDistributedEnabledBySlot] fail: read enabled failed.");
2451 return ERR_ANS_PARCELABLE_FAILED;
2452 }
2453
2454 ErrCode result = SetDistributedEnabledBySlot(slotType, deviceType, enabled);
2455 if (!reply.WriteInt32(result)) {
2456 ANS_LOGE("[HandleSetDistributedEnabledBySlot] fail: write result failed, ErrCode=%{public}d",
2457 result);
2458 return ERR_ANS_PARCELABLE_FAILED;
2459 }
2460 return ERR_OK;
2461 }
2462
HandleGetAllLiveViewEnabledBundles(MessageParcel & data,MessageParcel & reply)2463 ErrCode AnsManagerStub::HandleGetAllLiveViewEnabledBundles(MessageParcel &data, MessageParcel &reply)
2464 {
2465 std::vector<NotificationBundleOption> bundleOption;
2466 ErrCode result = GetAllLiveViewEnabledBundles(bundleOption);
2467 int32_t vectorSize = bundleOption.size();
2468 if (vectorSize > MAX_STATUS_VECTOR_NUM) {
2469 ANS_LOGE("Bundle bundleOption vector is over size.");
2470 return ERR_ANS_PARCELABLE_FAILED;
2471 }
2472
2473 if (!reply.WriteInt32(result)) {
2474 ANS_LOGE("Write result failed, ErrCode=%{public}d", result);
2475 return ERR_ANS_PARCELABLE_FAILED;
2476 }
2477
2478 if (!reply.WriteInt32(vectorSize)) {
2479 ANS_LOGE("Write bundleOption size failed.");
2480 return ERR_ANS_PARCELABLE_FAILED;
2481 }
2482
2483 for (const auto &item : bundleOption) {
2484 if (!reply.WriteParcelable(&item)) {
2485 ANS_LOGE("Write bundleOption failed");
2486 return ERR_ANS_PARCELABLE_FAILED;
2487 }
2488 }
2489
2490 return ERR_OK;
2491 }
2492
HandleIsDistributedEnabledBySlot(MessageParcel & data,MessageParcel & reply)2493 ErrCode AnsManagerStub::HandleIsDistributedEnabledBySlot(MessageParcel &data, MessageParcel &reply)
2494 {
2495 ANS_LOGD("enter");
2496 NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(data.ReadInt32());
2497
2498 std::string deviceType;
2499 if (!data.ReadString(deviceType)) {
2500 ANS_LOGE("[HandleIsDistributedEnabledBySlot] fail: read deviceId failed.");
2501 return ERR_ANS_PARCELABLE_FAILED;
2502 }
2503
2504 bool enabled = false;
2505 ErrCode result = IsDistributedEnabledBySlot(slotType, deviceType, enabled);
2506 if (!reply.WriteInt32(result)) {
2507 ANS_LOGE("[HandleIsDistributedEnabledBySlot] fail: write result failed, ErrCode=%{public}d",
2508 result);
2509 return ERR_ANS_PARCELABLE_FAILED;
2510 }
2511 if (!reply.WriteBool(enabled)) {
2512 ANS_LOGE("[HandleIsDistributedEnabledBySlot] fail: write enabled failed.");
2513 return ERR_ANS_PARCELABLE_FAILED;
2514 }
2515 return ERR_OK;
2516 }
2517
HandleSetTargetDeviceStatus(MessageParcel & data,MessageParcel & reply)2518 ErrCode AnsManagerStub::HandleSetTargetDeviceStatus(MessageParcel &data, MessageParcel &reply)
2519 {
2520 std::string deviceType;
2521 if (!data.ReadString(deviceType)) {
2522 ANS_LOGE("[HandleSetTargetDeviceStatus] fail: read deviceType failed");
2523 return ERR_ANS_PARCELABLE_FAILED;
2524 }
2525
2526 int32_t status = 0;
2527 if (!data.ReadInt32(status)) {
2528 ANS_LOGE("[HandleSetTargetDeviceStatus] fail: read status failed");
2529 return ERR_ANS_PARCELABLE_FAILED;
2530 }
2531
2532 ErrCode result = SetTargetDeviceStatus(deviceType, status);
2533 if (!reply.WriteInt32(result)) {
2534 ANS_LOGE("[HandleSetTargetDeviceStatus] fail: write result failed, ErrCode=%{public}d", result);
2535 return ERR_ANS_PARCELABLE_FAILED;
2536 }
2537 return ERR_OK;
2538 }
2539
HandleGetDoNotDisturbProfile(MessageParcel & data,MessageParcel & reply)2540 ErrCode AnsManagerStub::HandleGetDoNotDisturbProfile(MessageParcel &data, MessageParcel &reply)
2541 {
2542 return ERR_OK;
2543 }
2544
2545 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED
HandleRegisterSwingCallback(MessageParcel & data,MessageParcel & reply)2546 ErrCode AnsManagerStub::HandleRegisterSwingCallback(MessageParcel &data, MessageParcel &reply)
2547 {
2548 sptr<IRemoteObject> swingCallBack = data.ReadRemoteObject();
2549 if (swingCallBack == nullptr) {
2550 ANS_LOGE("fail: read SwingCallBack failed.");
2551 return ERR_ANS_PARCELABLE_FAILED;
2552 }
2553
2554 ErrCode result = RegisterSwingCallback(swingCallBack);
2555 if (!reply.WriteInt32(result)) {
2556 ANS_LOGE("fail: write result failed, ErrCode=%{public}d", result);
2557 return ERR_ANS_PARCELABLE_FAILED;
2558 }
2559 return result;
2560 }
2561 #endif
2562
HandleUpdateNotificationTimerByUid(MessageParcel & data,MessageParcel & reply)2563 ErrCode AnsManagerStub::HandleUpdateNotificationTimerByUid(MessageParcel &data, MessageParcel &reply)
2564 {
2565 int32_t uid = data.ReadInt32();
2566 bool isPaused = data.ReadBool();
2567 ErrCode result = UpdateNotificationTimerByUid(uid, isPaused);
2568 if (!reply.WriteInt32(result)) {
2569 ANS_LOGE("[HandleUpdateNotificationTimerByUid] fail: write result failed, ErrCode=%{public}d", result);
2570 return ERR_ANS_PARCELABLE_FAILED;
2571 }
2572 return ERR_OK;
2573 }
2574
HandleAllowUseReminder(MessageParcel & data,MessageParcel & reply)2575 ErrCode AnsManagerStub::HandleAllowUseReminder(MessageParcel &data, MessageParcel &reply)
2576 {
2577 ANS_LOGD("enter");
2578 std::string bundleName;
2579 if (!data.ReadString(bundleName)) {
2580 ANS_LOGE("fail: read deviceId failed.");
2581 return ERR_ANS_PARCELABLE_FAILED;
2582 }
2583
2584 bool isAllowUseReminder = false;
2585 ErrCode result = AllowUseReminder(bundleName, isAllowUseReminder);
2586 if (!reply.WriteInt32(result)) {
2587 ANS_LOGE("fail: write result failed, ErrCode=%{public}d", result);
2588 return ERR_ANS_PARCELABLE_FAILED;
2589 }
2590
2591 if (!reply.WriteBool(isAllowUseReminder)) {
2592 ANS_LOGE("fail: write enabled failed.");
2593 return ERR_ANS_PARCELABLE_FAILED;
2594 }
2595 return ERR_OK;
2596 }
2597
HandleDisableNotificationFeature(MessageParcel & data,MessageParcel & reply)2598 ErrCode AnsManagerStub::HandleDisableNotificationFeature(MessageParcel &data, MessageParcel &reply)
2599 {
2600 sptr<NotificationDisable> notificationDisable = data.ReadParcelable<NotificationDisable>();
2601 ErrCode result = DisableNotificationFeature(notificationDisable);
2602 if (!reply.WriteInt32(result)) {
2603 ANS_LOGE("[HandleDisableNotificationFeature] fail: write result failed, ErrCode=%{public}d", result);
2604 return ERR_ANS_PARCELABLE_FAILED;
2605 }
2606 return ERR_OK;
2607 }
2608
HandleSetDeviceStatus(MessageParcel & data,MessageParcel & reply)2609 ErrCode AnsManagerStub::HandleSetDeviceStatus(MessageParcel &data, MessageParcel &reply)
2610 {
2611 std::string deviceType;
2612 if (!data.ReadString(deviceType)) {
2613 ANS_LOGE("[HandleSetTargetDeviceStatus] fail: read deviceType failed");
2614 return ERR_ANS_PARCELABLE_FAILED;
2615 }
2616
2617 int32_t status = 0;
2618 if (!data.ReadInt32(status)) {
2619 ANS_LOGE("[HandleSetTargetDeviceStatus] fail: read status failed");
2620 return ERR_ANS_PARCELABLE_FAILED;
2621 }
2622
2623 int32_t controlFlag = 0;
2624 if (!data.ReadInt32(controlFlag)) {
2625 ANS_LOGE("[HandleSetTargetDeviceStatus] fail: read status failed");
2626 return ERR_ANS_PARCELABLE_FAILED;
2627 }
2628
2629 ErrCode result = SetTargetDeviceStatus(deviceType, status, controlFlag);
2630 if (!reply.WriteInt32(result)) {
2631 ANS_LOGE("[HandleSetTargetDeviceStatus] fail: write result failed, ErrCode=%{public}d", result);
2632 return ERR_ANS_PARCELABLE_FAILED;
2633 }
2634 return ERR_OK;
2635 }
2636
HandleGetDeviceStatus(MessageParcel & data,MessageParcel & reply)2637 ErrCode AnsManagerStub::HandleGetDeviceStatus(MessageParcel &data, MessageParcel &reply)
2638 {
2639 std::string deviceType;
2640 if (!data.ReadString(deviceType)) {
2641 ANS_LOGE("[HandleGetDeviceStatus] fail: read deviceType failed");
2642 return ERR_ANS_PARCELABLE_FAILED;
2643 }
2644
2645 int32_t status = 0;
2646 ErrCode result = GetTargetDeviceStatus(deviceType, status);
2647 if (!reply.WriteInt32(result)) {
2648 ANS_LOGE("[HandleGetDeviceStatus] fail: write result failed, ErrCode=%{public}d", result);
2649 return ERR_ANS_PARCELABLE_FAILED;
2650 }
2651 if (!reply.WriteInt32(status)) {
2652 ANS_LOGE("[HandleGetDeviceStatus] fail: write slot failed.");
2653 return ERR_ANS_PARCELABLE_FAILED;
2654 }
2655 return ERR_OK;
2656 }
2657
HandleSetHashCodeRule(MessageParcel & data,MessageParcel & reply)2658 ErrCode AnsManagerStub::HandleSetHashCodeRule(MessageParcel &data, MessageParcel &reply)
2659 {
2660 int32_t type = 0;
2661 if (!data.ReadInt32(type)) {
2662 ANS_LOGE("[HandleSetHashCodeRule] fail: read type failed");
2663 return ERR_ANS_PARCELABLE_FAILED;
2664 }
2665
2666 ErrCode result = SetHashCodeRule(type);
2667 if (!reply.WriteInt32(result)) {
2668 ANS_LOGE("[HandleSetHashCodeRule] fail: write result failed, ErrCode=%{public}d", result);
2669 return ERR_ANS_PARCELABLE_FAILED;
2670 }
2671 return ERR_OK;
2672 }
2673
HandleDistributeOperation(MessageParcel & data,MessageParcel & reply)2674 ErrCode AnsManagerStub::HandleDistributeOperation(MessageParcel &data, MessageParcel &reply)
2675 {
2676 sptr<IRemoteObject> remote = data.ReadRemoteObject();
2677 if (remote == nullptr) {
2678 ANS_LOGE("remote is nullptr");
2679 return ERR_INVALID_DATA;
2680 }
2681
2682 sptr<OperationCallbackInterface> callback = iface_cast<OperationCallbackInterface>(remote);
2683 if (callback.GetRefPtr() == nullptr) {
2684 ANS_LOGE("callback is null");
2685 return ERR_INVALID_DATA;
2686 }
2687
2688 sptr<NotificationOperationInfo> info = nullptr;
2689 info = data.ReadParcelable<NotificationOperationInfo>();
2690 if (info == nullptr) {
2691 ANS_LOGE("[HandleSubscribe] fail: read info failed");
2692 return ERR_ANS_PARCELABLE_FAILED;
2693 }
2694
2695 ErrCode result = DistributeOperation(info, callback);
2696 if (!reply.WriteInt32(result)) {
2697 ANS_LOGE("write result failed, ErrCode=%{public}d", result);
2698 return ERR_ANS_PARCELABLE_FAILED;
2699 }
2700 return ERR_OK;
2701 }
2702
HandleReplyDistributeOperation(MessageParcel & data,MessageParcel & reply)2703 ErrCode AnsManagerStub::HandleReplyDistributeOperation(MessageParcel &data, MessageParcel &reply)
2704 {
2705 std::string hashCode;
2706 if (!data.ReadString(hashCode)) {
2707 ANS_LOGE("read hashCode failed.");
2708 return ERR_ANS_PARCELABLE_FAILED;
2709 }
2710
2711 int32_t resultCode = 0;
2712 if (!data.ReadInt32(resultCode)) {
2713 ANS_LOGE("read hashCode failed.");
2714 return ERR_ANS_PARCELABLE_FAILED;
2715 }
2716
2717 ErrCode result = ReplyDistributeOperation(hashCode, resultCode);
2718 if (!reply.WriteInt32(result)) {
2719 ANS_LOGE("write result failed, ErrCode=%{public}d", result);
2720 return ERR_ANS_PARCELABLE_FAILED;
2721 }
2722
2723 return ERR_OK;
2724 }
2725
HandleGetAllNotificationsBySlotType(MessageParcel & data,MessageParcel & reply)2726 ErrCode AnsManagerStub::HandleGetAllNotificationsBySlotType(MessageParcel &data, MessageParcel &reply)
2727 {
2728 NotificationConstant::SlotType slotType = static_cast<NotificationConstant::SlotType>(data.ReadInt32());
2729 std::vector<sptr<Notification>> notifications;
2730 ErrCode result = GetAllNotificationsBySlotType(notifications, slotType);
2731
2732 if (!reply.SetMaxCapacity(NotificationConstant::NOTIFICATION_MAX_LIVE_VIEW_SIZE)) {
2733 ANS_LOGE("[HandleGetAllActiveNotifications] fail:: set max capacity");
2734 return ERR_ANS_PARCELABLE_FAILED;
2735 }
2736 if (!WriteParcelableVector(notifications, reply, result)) {
2737 ANS_LOGE("[HandleGetAllActiveNotifications] fail: write notifications failed");
2738 return ERR_ANS_PARCELABLE_FAILED;
2739 }
2740 return ERR_OK;
2741 }
2742 } // namespace Notification
2743 } // namespace OHOS
2744