1 /*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "accessible_ability_manager_service_proxy.h"
17 #include "accessibility_ability_info_parcel.h"
18 #include "accessibility_caption_parcel.h"
19 #include "accessibility_event_info_parcel.h"
20 #include "accessibility_ipc_interface_code.h"
21 #include "hilog_wrapper.h"
22
23 namespace OHOS {
24 namespace Accessibility {
AccessibleAbilityManagerServiceProxy(const sptr<IRemoteObject> & impl)25 AccessibleAbilityManagerServiceProxy::AccessibleAbilityManagerServiceProxy(const sptr<IRemoteObject> &impl)
26 : IRemoteProxy<IAccessibleAbilityManagerService>(impl)
27 {}
28
~AccessibleAbilityManagerServiceProxy()29 AccessibleAbilityManagerServiceProxy::~AccessibleAbilityManagerServiceProxy()
30 {}
31
WriteInterfaceToken(MessageParcel & data)32 bool AccessibleAbilityManagerServiceProxy::WriteInterfaceToken(MessageParcel &data)
33 {
34 HILOG_DEBUG();
35 if (!data.WriteInterfaceToken(IAccessibleAbilityManagerService::GetDescriptor())) {
36 HILOG_ERROR("write interface token failed");
37 return false;
38 }
39 return true;
40 }
41
SendTransactCmd(AccessibilityInterfaceCode code,MessageParcel & data,MessageParcel & reply,MessageOption & option)42 bool AccessibleAbilityManagerServiceProxy::SendTransactCmd(AccessibilityInterfaceCode code,
43 MessageParcel &data, MessageParcel &reply, MessageOption &option)
44 {
45 HILOG_DEBUG();
46
47 sptr<IRemoteObject> remoteServiceProxy= Remote();
48 if (!remoteServiceProxy) {
49 HILOG_ERROR("fail to send transact cmd %{public}d due to remote object", code);
50 return false;
51 }
52 int32_t resultServiceProxy =
53 remoteServiceProxy->SendRequest(static_cast<uint32_t>(code), data, reply, option);
54 if (resultServiceProxy != NO_ERROR) {
55 HILOG_ERROR("receive error transact code %{public}d in transact cmd %{public}d", resultServiceProxy, code);
56 return false;
57 }
58 return true;
59 }
60
SendEvent(const AccessibilityEventInfo & uiEvent)61 RetError AccessibleAbilityManagerServiceProxy::SendEvent(const AccessibilityEventInfo &uiEvent)
62 {
63 HILOG_DEBUG();
64 MessageParcel data;
65 MessageParcel reply;
66 MessageOption option(MessageOption::TF_ASYNC);
67 AccessibilityEventInfoParcel eventInfoParcel(uiEvent);
68
69 if (!WriteInterfaceToken(data)) {
70 HILOG_ERROR("fail, connection write Token");
71 return RET_ERR_IPC_FAILED;
72 }
73
74 if (!data.WriteParcelable(&eventInfoParcel)) {
75 HILOG_ERROR("fail, connection write parcelable AccessibilityEventInfo error");
76 return RET_ERR_IPC_FAILED;
77 }
78
79 if (!SendTransactCmd(AccessibilityInterfaceCode::SEND_EVENT, data, reply, option)) {
80 HILOG_ERROR("SendEvent fail");
81 return RET_ERR_IPC_FAILED;
82 }
83 return RET_OK;
84 }
85
SetCaptionProperty(const AccessibilityConfig::CaptionProperty & caption)86 RetError AccessibleAbilityManagerServiceProxy::SetCaptionProperty(const AccessibilityConfig::CaptionProperty &caption)
87 {
88 HILOG_DEBUG();
89 MessageParcel data;
90 MessageParcel reply;
91 MessageOption option;
92 CaptionPropertyParcel captionParcel(caption);
93
94 if (!WriteInterfaceToken(data)) {
95 HILOG_ERROR("fail, connection write Token");
96 return RET_ERR_IPC_FAILED;
97 }
98
99 if (!data.WriteParcelable(&captionParcel)) {
100 HILOG_ERROR("fail, connection write parcelable Caption Property ");
101 return RET_ERR_IPC_FAILED;
102 }
103
104 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_CAPTION_PROPERTY, data, reply, option)) {
105 HILOG_ERROR("SetCaptionProperty fail");
106 return RET_ERR_IPC_FAILED;
107 }
108 return static_cast<RetError>(reply.ReadInt32());
109 }
110
SetCaptionState(const bool state)111 RetError AccessibleAbilityManagerServiceProxy::SetCaptionState(const bool state)
112 {
113 HILOG_DEBUG();
114 MessageParcel data;
115 MessageParcel reply;
116 MessageOption option;
117
118 if (!WriteInterfaceToken(data)) {
119 HILOG_ERROR("SetCaptionState fail, connection write Token");
120 return RET_ERR_IPC_FAILED;
121 }
122
123 if (!data.WriteBool(state)) {
124 HILOG_ERROR("SetCaptionState fail, connection write parcelable Caption State ");
125 return RET_ERR_IPC_FAILED;
126 }
127
128 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_CAPTION_STATE, data, reply, option)) {
129 HILOG_ERROR("SetCaptionState fail");
130 return RET_ERR_IPC_FAILED;
131 }
132 return static_cast<RetError>(reply.ReadInt32());
133 }
134
RegisterStateObserver(const sptr<IAccessibleAbilityManagerStateObserver> & client)135 uint32_t AccessibleAbilityManagerServiceProxy::RegisterStateObserver(
136 const sptr<IAccessibleAbilityManagerStateObserver> &client)
137 {
138 HILOG_DEBUG();
139 MessageParcel data;
140 MessageParcel reply;
141 MessageOption option;
142
143 if (!client) {
144 HILOG_ERROR("RegisterStateObserver fail, Input client is null");
145 return TRANSACTION_ERR;
146 }
147
148 if (!WriteInterfaceToken(data)) {
149 HILOG_ERROR("RegisterStateObserver fail, connection write Token error");
150 return TRANSACTION_ERR;
151 }
152
153 if (!data.WriteRemoteObject(client->AsObject())) {
154 HILOG_ERROR("RegisterStateObserver fail, connection write client error");
155 return TRANSACTION_ERR;
156 }
157
158 if (!SendTransactCmd(AccessibilityInterfaceCode::REGISTER_STATE_CALLBACK,
159 data, reply, option)) {
160 HILOG_ERROR("RegisterStateCallback fail");
161 return TRANSACTION_ERR;
162 }
163
164 return reply.ReadUint32();
165 }
166
GetAbilityList(const uint32_t abilityTypes,const int32_t stateType,std::vector<AccessibilityAbilityInfo> & infos)167 RetError AccessibleAbilityManagerServiceProxy::GetAbilityList(const uint32_t abilityTypes, const int32_t stateType,
168 std::vector<AccessibilityAbilityInfo> &infos)
169 {
170 HILOG_DEBUG();
171 MessageParcel data;
172 MessageParcel reply;
173 MessageOption option;
174
175 if (!WriteInterfaceToken(data)) {
176 HILOG_ERROR("fail, connection write Token error");
177 return RET_ERR_IPC_FAILED;
178 }
179
180 if (!data.WriteUint32(abilityTypes)) {
181 HILOG_ERROR("fail, connection write abilityTypes error");
182 return RET_ERR_IPC_FAILED;
183 }
184
185 if (!data.WriteInt32(stateType)) {
186 HILOG_ERROR("fail, connection write stateType error");
187 return RET_ERR_IPC_FAILED;
188 }
189
190 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_ABILITYLIST,
191 data, reply, option)) {
192 HILOG_ERROR("GetAbilityList fail");
193 return RET_ERR_IPC_FAILED;
194 }
195 // read result
196 int32_t abilityInfoSize = reply.ReadInt32();
197 for (int32_t i = 0; i < abilityInfoSize; i++) {
198 sptr<AccessibilityAbilityInfoParcel> info = reply.ReadStrongParcelable<AccessibilityAbilityInfoParcel>();
199 if (!info) {
200 HILOG_ERROR("ReadStrongParcelable<AccessibilityAbilityInfoParcel> failed");
201 return RET_ERR_IPC_FAILED;
202 }
203 infos.emplace_back(*info);
204 }
205 return static_cast<RetError>(reply.ReadInt32());
206 }
207
RegisterElementOperator(int32_t windowId,const sptr<IAccessibilityElementOperator> & operation)208 RetError AccessibleAbilityManagerServiceProxy::RegisterElementOperator(
209 int32_t windowId, const sptr<IAccessibilityElementOperator> &operation)
210 {
211 HILOG_DEBUG();
212 MessageParcel data;
213 MessageParcel reply;
214 MessageOption option(MessageOption::TF_ASYNC);
215
216 if (!operation) {
217 HILOG_ERROR("fail, Input operation is null");
218 return RET_ERR_INVALID_PARAM;
219 }
220
221 if (!WriteInterfaceToken(data)) {
222 HILOG_ERROR("fail, connection write Token");
223 return RET_ERR_IPC_FAILED;
224 }
225
226 if (!data.WriteInt32(windowId)) {
227 HILOG_ERROR("fail, connection write windowId error");
228 return RET_ERR_IPC_FAILED;
229 }
230
231 if (!data.WriteRemoteObject(operation->AsObject())) {
232 HILOG_ERROR("fail, connection write parcelable operation error");
233 return RET_ERR_IPC_FAILED;
234 }
235
236 if (!SendTransactCmd(AccessibilityInterfaceCode::REGISTER_INTERACTION_CONNECTION,
237 data, reply, option)) {
238 HILOG_ERROR("RegisterElementOperator fail");
239 return RET_ERR_IPC_FAILED;
240 }
241 return RET_OK;
242 }
243
DeregisterElementOperator(const int32_t windowId)244 RetError AccessibleAbilityManagerServiceProxy::DeregisterElementOperator(const int32_t windowId)
245 {
246 HILOG_DEBUG("windowId(%{public}d)", windowId);
247 MessageParcel data;
248 MessageParcel reply;
249 MessageOption option(MessageOption::TF_ASYNC);
250
251 if (!WriteInterfaceToken(data)) {
252 HILOG_ERROR("fail, connection write Token");
253 return RET_ERR_IPC_FAILED;
254 }
255
256 if (!data.WriteInt32(windowId)) {
257 HILOG_ERROR("fail, connection write userId error");
258 return RET_ERR_IPC_FAILED;
259 }
260
261 if (!SendTransactCmd(AccessibilityInterfaceCode::DEREGISTER_INTERACTION_CONNECTION,
262 data, reply, option)) {
263 HILOG_ERROR("DeregisterElementOperator fail");
264 return RET_ERR_IPC_FAILED;
265 }
266 return RET_OK;
267 }
268
GetCaptionProperty(AccessibilityConfig::CaptionProperty & caption)269 RetError AccessibleAbilityManagerServiceProxy::GetCaptionProperty(AccessibilityConfig::CaptionProperty &caption)
270 {
271 HILOG_DEBUG();
272 MessageParcel data;
273 MessageParcel reply;
274 MessageOption option;
275 AccessibilityConfig::CaptionProperty property = {};
276 if (!WriteInterfaceToken(data)) {
277 HILOG_ERROR("fail, connection write Token error");
278 return RET_ERR_IPC_FAILED;
279 }
280
281 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_CAPTION_PROPERTY,
282 data, reply, option)) {
283 HILOG_ERROR("GetCaptionProperty fail");
284 return RET_ERR_IPC_FAILED;
285 }
286 RetError ret = static_cast<RetError>(reply.ReadInt32());
287 if (ret == RET_OK) {
288 caption = *reply.ReadStrongParcelable<CaptionPropertyParcel>();
289 }
290 return ret;
291 }
292
RegisterCaptionObserver(const sptr<IAccessibleAbilityManagerCaptionObserver> & client)293 uint32_t AccessibleAbilityManagerServiceProxy::RegisterCaptionObserver(
294 const sptr<IAccessibleAbilityManagerCaptionObserver> &client)
295 {
296 HILOG_DEBUG();
297 MessageParcel data;
298 MessageParcel reply;
299 MessageOption option;
300
301 if (!client) {
302 HILOG_ERROR("RegisterCaptionObserver fail, Input client is null");
303 return TRANSACTION_ERR;
304 }
305
306 if (!WriteInterfaceToken(data)) {
307 HILOG_ERROR("RegisterCaptionObserver fail, connection write Token error");
308 return TRANSACTION_ERR;
309 }
310
311 if (!data.WriteRemoteObject(client->AsObject())) {
312 HILOG_ERROR("RegisterCaptionObserver fail, connection write client error");
313 return TRANSACTION_ERR;
314 }
315
316 if (!SendTransactCmd(AccessibilityInterfaceCode::REGISTER_CAPTION_PROPERTY_CALLBACK,
317 data, reply, option)) {
318 HILOG_ERROR("RegisterCaptionPropertyCallback fail");
319 return TRANSACTION_ERR;
320 }
321
322 return reply.ReadUint32();
323 }
324
GetEnabledState()325 bool AccessibleAbilityManagerServiceProxy::GetEnabledState()
326 {
327 HILOG_DEBUG();
328 MessageParcel data;
329 MessageParcel reply;
330 MessageOption option;
331
332 if (!WriteInterfaceToken(data)) {
333 HILOG_ERROR("fail, connection write Token");
334 return false;
335 }
336 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_ENABLED,
337 data, reply, option)) {
338 HILOG_ERROR("GetEnabledState fail");
339 return false;
340 }
341 return reply.ReadBool();
342 }
343
GetCaptionState(bool & state)344 RetError AccessibleAbilityManagerServiceProxy::GetCaptionState(bool &state)
345 {
346 HILOG_DEBUG();
347 MessageParcel data;
348 MessageParcel reply;
349 MessageOption option;
350
351 if (!WriteInterfaceToken(data)) {
352 HILOG_ERROR("fail, connection write Token");
353 return RET_ERR_IPC_FAILED;
354 }
355 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_CAPTION_STATE,
356 data, reply, option)) {
357 HILOG_ERROR("GetCaptionState fail");
358 return RET_ERR_IPC_FAILED;
359 }
360 RetError ret = static_cast<RetError>(reply.ReadInt32());
361 if (ret == RET_OK) {
362 state = reply.ReadBool();
363 }
364 return ret;
365 }
366
GetTouchGuideState()367 bool AccessibleAbilityManagerServiceProxy::GetTouchGuideState()
368 {
369 HILOG_DEBUG();
370 MessageParcel data;
371 MessageParcel reply;
372 MessageOption option;
373
374 if (!WriteInterfaceToken(data)) {
375 HILOG_ERROR("fail, connection write Token");
376 return false;
377 }
378 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_TOUCH_GUIDE_STATE,
379 data, reply, option)) {
380 HILOG_ERROR("GetTouchGuideState fail");
381 return false;
382 }
383 return reply.ReadBool();
384 }
385
GetGestureState()386 bool AccessibleAbilityManagerServiceProxy::GetGestureState()
387 {
388 HILOG_DEBUG();
389 MessageParcel data;
390 MessageParcel reply;
391 MessageOption option;
392
393 if (!WriteInterfaceToken(data)) {
394 HILOG_ERROR("fail, connection write Token");
395 return false;
396 }
397 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_GESTURE_STATE,
398 data, reply, option)) {
399 HILOG_ERROR("GetGestureState fail");
400 return false;
401 }
402 return reply.ReadBool();
403 }
404
GetKeyEventObserverState()405 bool AccessibleAbilityManagerServiceProxy::GetKeyEventObserverState()
406 {
407 HILOG_DEBUG();
408 MessageParcel data;
409 MessageParcel reply;
410 MessageOption option;
411
412 if (!WriteInterfaceToken(data)) {
413 HILOG_ERROR("fail, connection write Token");
414 return false;
415 }
416 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_KEY_EVENT_OBSERVE_STATE,
417 data, reply, option)) {
418 HILOG_ERROR("GetKeyEventObserverState fail");
419 return false;
420 }
421 return reply.ReadBool();
422 }
423
EnableAbility(const std::string & name,const uint32_t capabilities)424 RetError AccessibleAbilityManagerServiceProxy::EnableAbility(const std::string &name, const uint32_t capabilities)
425 {
426 HILOG_DEBUG();
427 MessageParcel data;
428 MessageParcel reply;
429 MessageOption option;
430
431 if (!WriteInterfaceToken(data)) {
432 HILOG_ERROR("EnableAbility fail, connection write Token");
433 return RET_ERR_IPC_FAILED;
434 }
435
436 if (!data.WriteString(name)) {
437 HILOG_ERROR("name write error: %{public}s, ", name.c_str());
438 return RET_ERR_IPC_FAILED;
439 }
440
441 if (!data.WriteUint32(capabilities)) {
442 HILOG_ERROR("capabilities write error: %{public}d, ", capabilities);
443 return RET_ERR_IPC_FAILED;
444 }
445
446 if (!SendTransactCmd(AccessibilityInterfaceCode::ENABLE_ABILITIES,
447 data, reply, option)) {
448 HILOG_ERROR("EnableAbility fail");
449 return RET_ERR_IPC_FAILED;
450 }
451 return static_cast<RetError>(reply.ReadInt32());
452 }
453
GetEnabledAbilities(std::vector<std::string> & enabledAbilities)454 RetError AccessibleAbilityManagerServiceProxy::GetEnabledAbilities(std::vector<std::string> &enabledAbilities)
455 {
456 HILOG_DEBUG();
457 MessageParcel data;
458 MessageParcel reply;
459 MessageOption option;
460
461 if (!WriteInterfaceToken(data)) {
462 HILOG_ERROR("fail, connection write Token error");
463 return RET_ERR_IPC_FAILED;
464 }
465 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_ENABLED_OBJECT,
466 data, reply, option)) {
467 HILOG_ERROR("GetEnabledAbilities fail");
468 return RET_ERR_IPC_FAILED;
469 }
470
471 int32_t dev_num = reply.ReadInt32();
472 for (int32_t i = 0; i < dev_num; i++) {
473 enabledAbilities.push_back(reply.ReadString());
474 }
475 return static_cast<RetError>(reply.ReadInt32());
476 }
477
DisableAbility(const std::string & name)478 RetError AccessibleAbilityManagerServiceProxy::DisableAbility(const std::string &name)
479 {
480 HILOG_DEBUG();
481 MessageParcel data;
482 MessageParcel reply;
483 MessageOption option;
484
485 if (!WriteInterfaceToken(data)) {
486 HILOG_ERROR("DisableAbility fail, connection write Token");
487 return RET_ERR_IPC_FAILED;
488 }
489
490 if (!data.WriteString(name)) {
491 HILOG_ERROR("name write error: %{public}s, ", name.c_str());
492 return RET_ERR_IPC_FAILED;
493 }
494 if (!SendTransactCmd(AccessibilityInterfaceCode::DISABLE_ABILITIES,
495 data, reply, option)) {
496 HILOG_ERROR("DisableAbility fail");
497 return RET_ERR_IPC_FAILED;
498 }
499 return static_cast<RetError>(reply.ReadInt32());
500 }
501
GetActiveWindow()502 int32_t AccessibleAbilityManagerServiceProxy::GetActiveWindow()
503 {
504 HILOG_DEBUG();
505 MessageParcel data;
506 MessageParcel reply;
507 MessageOption option;
508
509 if (!WriteInterfaceToken(data)) {
510 HILOG_ERROR("fail, connection write Token");
511 return false;
512 }
513
514 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_ACTIVE_WINDOW,
515 data, reply, option)) {
516 HILOG_ERROR("GetActiveWindow fail");
517 return false;
518 }
519 return reply.ReadInt32();
520 }
521
EnableUITestAbility(const sptr<IRemoteObject> & obj)522 RetError AccessibleAbilityManagerServiceProxy::EnableUITestAbility(const sptr<IRemoteObject> &obj)
523 {
524 HILOG_DEBUG();
525 MessageParcel data;
526 MessageParcel reply;
527 MessageOption option;
528
529 if (!WriteInterfaceToken(data)) {
530 HILOG_ERROR("fail, connection write Token");
531 return RET_ERR_IPC_FAILED;
532 }
533
534 if (!data.WriteRemoteObject(obj)) {
535 HILOG_ERROR("fail, connection write obj");
536 return RET_ERR_IPC_FAILED;
537 }
538
539 if (!SendTransactCmd(AccessibilityInterfaceCode::ENABLE_UI_TEST_ABILITY,
540 data, reply, option)) {
541 HILOG_ERROR("EnableUITestAbility fail");
542 return RET_ERR_IPC_FAILED;
543 }
544 RetError result = static_cast<RetError>(reply.ReadInt32());
545 HILOG_DEBUG("enable result is %{public}d", result);
546 return result;
547 }
548
DisableUITestAbility()549 RetError AccessibleAbilityManagerServiceProxy::DisableUITestAbility()
550 {
551 HILOG_DEBUG();
552 MessageParcel data;
553 MessageParcel reply;
554 MessageOption option;
555
556 if (!WriteInterfaceToken(data)) {
557 HILOG_ERROR("fail, connection write Token");
558 return RET_ERR_IPC_FAILED;
559 }
560
561 if (!SendTransactCmd(AccessibilityInterfaceCode::DISABLE_UI_TEST_ABILITY,
562 data, reply, option)) {
563 HILOG_ERROR("DisableUITestAbility fail");
564 return RET_ERR_IPC_FAILED;
565 }
566 return static_cast<RetError>(reply.ReadInt32());
567 }
568
SetScreenMagnificationState(const bool state)569 RetError AccessibleAbilityManagerServiceProxy::SetScreenMagnificationState(const bool state)
570 {
571 HILOG_DEBUG();
572 MessageParcel data;
573 MessageParcel reply;
574 MessageOption option;
575
576 if (!WriteInterfaceToken(data)) {
577 HILOG_ERROR("SetScreenMagnificationState fail, connection write Token");
578 return RET_ERR_IPC_FAILED;
579 }
580
581 if (!data.WriteBool(state)) {
582 HILOG_ERROR("SetScreenMagnificationState fail, connection write parcelable Caption State ");
583 return RET_ERR_IPC_FAILED;
584 }
585
586 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_SCREENMAGNIFIER_STATE, data, reply, option)) {
587 HILOG_ERROR("SetScreenMagnificationState fail");
588 return RET_ERR_IPC_FAILED;
589 }
590
591 return static_cast<RetError>(reply.ReadInt32());
592 }
593
SetShortKeyState(const bool state)594 RetError AccessibleAbilityManagerServiceProxy::SetShortKeyState(const bool state)
595 {
596 HILOG_DEBUG();
597 MessageParcel data;
598 MessageParcel reply;
599 MessageOption option;
600
601 if (!WriteInterfaceToken(data)) {
602 HILOG_ERROR("SetShortKeyState fail, connection write Token");
603 return RET_ERR_IPC_FAILED;
604 }
605
606 if (!data.WriteBool(state)) {
607 HILOG_ERROR("SetShortKeyState fail, connection write parcelable Caption State ");
608 return RET_ERR_IPC_FAILED;
609 }
610
611 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_SHORTKEY_STATE, data, reply, option)) {
612 HILOG_ERROR("SetShortKeyState fail");
613 return RET_ERR_IPC_FAILED;
614 }
615
616 return static_cast<RetError>(reply.ReadInt32());
617 }
618
SetMouseKeyState(const bool state)619 RetError AccessibleAbilityManagerServiceProxy::SetMouseKeyState(const bool state)
620 {
621 HILOG_DEBUG();
622 MessageParcel data;
623 MessageParcel reply;
624 MessageOption option;
625
626 if (!WriteInterfaceToken(data)) {
627 HILOG_ERROR("SetMouseKeyState fail, connection write Token");
628 return RET_ERR_IPC_FAILED;
629 }
630
631 if (!data.WriteBool(state)) {
632 HILOG_ERROR("SetMouseKeyState fail, connection write parcelable Caption State");
633 return RET_ERR_IPC_FAILED;
634 }
635
636 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_MOUSEKEY_STATE, data, reply, option)) {
637 HILOG_ERROR("SetMouseKeyState fail");
638 return RET_ERR_IPC_FAILED;
639 }
640
641 return static_cast<RetError>(reply.ReadInt32());
642 }
643
SetMouseAutoClick(const int32_t time)644 RetError AccessibleAbilityManagerServiceProxy::SetMouseAutoClick(const int32_t time)
645 {
646 HILOG_DEBUG();
647 MessageParcel data;
648 MessageParcel reply;
649 MessageOption option;
650
651 if (!WriteInterfaceToken(data)) {
652 HILOG_ERROR("fail, connection write Token");
653 return RET_ERR_IPC_FAILED;
654 }
655
656 if (!data.WriteInt32(time)) {
657 HILOG_ERROR("fail, connection write SetMouseAutoClick time");
658 return RET_ERR_IPC_FAILED;
659 }
660
661 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_MOUSEKEY_AUTOCLICK, data, reply, option)) {
662 HILOG_ERROR("SetMouseAutoClick fail");
663 return RET_ERR_IPC_FAILED;
664 }
665
666 return static_cast<RetError>(reply.ReadInt32());
667 }
668
SetShortkeyTarget(const std::string & name)669 RetError AccessibleAbilityManagerServiceProxy::SetShortkeyTarget(const std::string &name)
670 {
671 HILOG_DEBUG();
672 MessageParcel data;
673 MessageParcel reply;
674 MessageOption option;
675
676 if (!WriteInterfaceToken(data)) {
677 HILOG_ERROR("DisableAbility fail, connection write Token");
678 return RET_ERR_IPC_FAILED;
679 }
680
681 if (!data.WriteString(name)) {
682 HILOG_ERROR("fail, connection write SetShortkeyTarget name");
683 return RET_ERR_IPC_FAILED;
684 }
685
686 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_SHORTKEY_TARGET, data, reply, option)) {
687 HILOG_ERROR("SetShortkeyTarget fail");
688 return RET_ERR_IPC_FAILED;
689 }
690
691 return static_cast<RetError>(reply.ReadInt32());
692 }
693
SetHighContrastTextState(const bool state)694 RetError AccessibleAbilityManagerServiceProxy::SetHighContrastTextState(const bool state)
695 {
696 HILOG_DEBUG();
697 MessageParcel data;
698 MessageParcel reply;
699 MessageOption option;
700
701 if (!WriteInterfaceToken(data)) {
702 HILOG_ERROR("SetHighContrastTextState fail, connection write Token");
703 return RET_ERR_IPC_FAILED;
704 }
705
706 if (!data.WriteBool(state)) {
707 HILOG_ERROR("SetHighContrastTextState fail, connection write parcelable Caption State");
708 return RET_ERR_IPC_FAILED;
709 }
710
711 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_HIGHCONTRASTTEXT_STATE, data, reply, option)) {
712 HILOG_ERROR("SetHighContrastTextState fail");
713 return RET_ERR_IPC_FAILED;
714 }
715
716 return static_cast<RetError>(reply.ReadInt32());
717 }
718
SetInvertColorState(const bool state)719 RetError AccessibleAbilityManagerServiceProxy::SetInvertColorState(const bool state)
720 {
721 HILOG_DEBUG();
722 MessageParcel data;
723 MessageParcel reply;
724 MessageOption option;
725
726 if (!WriteInterfaceToken(data)) {
727 HILOG_ERROR("SetInvertColorState fail, connection write Token");
728 return RET_ERR_IPC_FAILED;
729 }
730
731 if (!data.WriteBool(state)) {
732 HILOG_ERROR("SetInvertColorState fail, connection write parcelable Caption State ");
733 return RET_ERR_IPC_FAILED;
734 }
735
736 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_INVERTCOLOR_STATE, data, reply, option)) {
737 HILOG_ERROR("SetInvertColorState fail");
738 return RET_ERR_IPC_FAILED;
739 }
740
741 return static_cast<RetError>(reply.ReadInt32());
742 }
743
SetAnimationOffState(const bool state)744 RetError AccessibleAbilityManagerServiceProxy::SetAnimationOffState(const bool state)
745 {
746 HILOG_DEBUG();
747 MessageParcel data;
748 MessageParcel reply;
749 MessageOption option;
750
751 if (!WriteInterfaceToken(data)) {
752 HILOG_ERROR("SetAnimationOffState fail, connection write Token");
753 return RET_ERR_IPC_FAILED;
754 }
755
756 if (!data.WriteBool(state)) {
757 HILOG_ERROR("SetAnimationOffState fail, connection write parcelable Caption State ");
758 return RET_ERR_IPC_FAILED;
759 }
760
761 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_ANIMATIONOFF_STATE, data, reply, option)) {
762 HILOG_ERROR("SetAnimationOffState fail");
763 return RET_ERR_IPC_FAILED;
764 }
765
766 return static_cast<RetError>(reply.ReadInt32());
767 }
768
SetAudioMonoState(const bool state)769 RetError AccessibleAbilityManagerServiceProxy::SetAudioMonoState(const bool state)
770 {
771 HILOG_DEBUG();
772 MessageParcel data;
773 MessageParcel reply;
774 MessageOption option;
775
776 if (!WriteInterfaceToken(data)) {
777 HILOG_ERROR("SetAudioMonoState fail, connection write Token");
778 return RET_ERR_IPC_FAILED;
779 }
780
781 if (!data.WriteBool(state)) {
782 HILOG_ERROR("SetAudioMonoState fail, connection write parcelable Caption State ");
783 return RET_ERR_IPC_FAILED;
784 }
785
786 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_AUDIOMONO_STATE, data, reply, option)) {
787 HILOG_ERROR("SetAudioMonoState fail");
788 return RET_ERR_IPC_FAILED;
789 }
790
791 return static_cast<RetError>(reply.ReadInt32());
792 }
793
SetDaltonizationColorFilter(const uint32_t filter)794 RetError AccessibleAbilityManagerServiceProxy::SetDaltonizationColorFilter(const uint32_t filter)
795 {
796 HILOG_DEBUG();
797 MessageParcel data;
798 MessageParcel reply;
799 MessageOption option;
800
801 if (!WriteInterfaceToken(data)) {
802 HILOG_ERROR("fail, connection write Token");
803 return RET_ERR_IPC_FAILED;
804 }
805
806 if (!data.WriteUint32(filter)) {
807 HILOG_ERROR("fail, connection write SetDaltonizationColorFilter time");
808 return RET_ERR_IPC_FAILED;
809 }
810
811 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_DALTONIZATION_COLORFILTER,
812 data, reply, option)) {
813 HILOG_ERROR("SetDaltonizationColorFilter fail");
814 return RET_ERR_IPC_FAILED;
815 }
816
817 return static_cast<RetError>(reply.ReadInt32());
818 }
819
SetContentTimeout(const uint32_t time)820 RetError AccessibleAbilityManagerServiceProxy::SetContentTimeout(const uint32_t time)
821 {
822 HILOG_DEBUG();
823 MessageParcel data;
824 MessageParcel reply;
825 MessageOption option;
826
827 if (!WriteInterfaceToken(data)) {
828 HILOG_ERROR("fail, connection write Token");
829 return RET_ERR_IPC_FAILED;
830 }
831
832 if (!data.WriteUint32(time)) {
833 HILOG_ERROR("fail, connection write SetContentTimeout time");
834 return RET_ERR_IPC_FAILED;
835 }
836
837 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_CONTENT_TIMEOUT, data, reply, option)) {
838 HILOG_ERROR("SetContentTimeout fail");
839 return RET_ERR_IPC_FAILED;
840 }
841
842 return static_cast<RetError>(reply.ReadInt32());
843 }
844
SetBrightnessDiscount(const float discount)845 RetError AccessibleAbilityManagerServiceProxy::SetBrightnessDiscount(const float discount)
846 {
847 HILOG_DEBUG();
848 MessageParcel data;
849 MessageParcel reply;
850 MessageOption option;
851
852 if (!WriteInterfaceToken(data)) {
853 HILOG_ERROR("fail, connection write Token");
854 return RET_ERR_IPC_FAILED;
855 }
856
857 if (!data.WriteFloat(discount)) {
858 HILOG_ERROR("fail, connection write SetBrightnessDiscount time");
859 return RET_ERR_IPC_FAILED;
860 }
861
862 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_BRIGHTNESS_DISCOUNT, data, reply, option)) {
863 HILOG_ERROR("SetBrightnessDiscount fail");
864 return RET_ERR_IPC_FAILED;
865 }
866
867 return static_cast<RetError>(reply.ReadInt32());
868 }
869
SetAudioBalance(const float balance)870 RetError AccessibleAbilityManagerServiceProxy::SetAudioBalance(const float balance)
871 {
872 HILOG_DEBUG();
873 MessageParcel data;
874 MessageParcel reply;
875 MessageOption option;
876
877 if (!WriteInterfaceToken(data)) {
878 HILOG_ERROR("fail, connection write Token");
879 return RET_ERR_IPC_FAILED;
880 }
881
882 if (!data.WriteFloat(balance)) {
883 HILOG_ERROR("fail, connection write SetAudioBalance time");
884 return RET_ERR_IPC_FAILED;
885 }
886
887 if (!SendTransactCmd(AccessibilityInterfaceCode::SET_AUDIO_BALANCE, data, reply, option)) {
888 HILOG_ERROR("SetAudioBalance fail");
889 return RET_ERR_IPC_FAILED;
890 }
891
892 return static_cast<RetError>(reply.ReadInt32());
893 }
894
GetScreenMagnificationState(bool & state)895 RetError AccessibleAbilityManagerServiceProxy::GetScreenMagnificationState(bool &state)
896 {
897 HILOG_DEBUG();
898 MessageParcel data;
899 MessageParcel reply;
900 MessageOption option;
901
902 if (!WriteInterfaceToken(data)) {
903 HILOG_ERROR("fail, connection write Token");
904 return RET_ERR_IPC_FAILED;
905 }
906 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_SCREENMAGNIFIER_STATE,
907 data, reply, option)) {
908 HILOG_ERROR("GetScreenMagnificationState fail");
909 return RET_ERR_IPC_FAILED;
910 }
911
912 RetError ret = static_cast<RetError>(reply.ReadInt32());
913 if (ret == RET_OK) {
914 state = reply.ReadBool();
915 }
916 return ret;
917 }
918
GetShortKeyState(bool & state)919 RetError AccessibleAbilityManagerServiceProxy::GetShortKeyState(bool &state)
920 {
921 HILOG_DEBUG();
922 MessageParcel data;
923 MessageParcel reply;
924 MessageOption option;
925
926 if (!WriteInterfaceToken(data)) {
927 HILOG_ERROR("fail, connection write Token");
928 return RET_ERR_IPC_FAILED;
929 }
930 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_SHORTKEY_STATE,
931 data, reply, option)) {
932 HILOG_ERROR("GetShortKeyState fail");
933 return RET_ERR_IPC_FAILED;
934 }
935 RetError ret = static_cast<RetError>(reply.ReadInt32());
936 if (ret == RET_OK) {
937 state = reply.ReadBool();
938 }
939 return ret;
940 }
941
GetMouseKeyState(bool & state)942 RetError AccessibleAbilityManagerServiceProxy::GetMouseKeyState(bool &state)
943 {
944 HILOG_DEBUG();
945 MessageParcel data;
946 MessageParcel reply;
947 MessageOption option;
948
949 if (!WriteInterfaceToken(data)) {
950 HILOG_ERROR("fail, connection write Token");
951 return RET_ERR_IPC_FAILED;
952 }
953 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_MOUSEKEY_STATE,
954 data, reply, option)) {
955 HILOG_ERROR("GetMouseKeyState fail");
956 return RET_ERR_IPC_FAILED;
957 }
958 RetError ret = static_cast<RetError>(reply.ReadInt32());
959 if (ret == RET_OK) {
960 state = reply.ReadBool();
961 }
962 return ret;
963 }
964
GetMouseAutoClick(int32_t & time)965 RetError AccessibleAbilityManagerServiceProxy::GetMouseAutoClick(int32_t &time)
966 {
967 HILOG_DEBUG();
968 MessageParcel data;
969 MessageParcel reply;
970 MessageOption option;
971
972 if (!WriteInterfaceToken(data)) {
973 HILOG_ERROR("fail, connection write Token");
974 return RET_ERR_IPC_FAILED;
975 }
976 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_MOUSEKEY_AUTOCLICK,
977 data, reply, option)) {
978 HILOG_ERROR("GetMouseAutoClick fail");
979 return RET_ERR_IPC_FAILED;
980 }
981 RetError ret = static_cast<RetError>(reply.ReadInt32());
982 if (ret == RET_OK) {
983 time = reply.ReadInt32();
984 }
985 return ret;
986 }
987
GetShortkeyTarget(std::string & name)988 RetError AccessibleAbilityManagerServiceProxy::GetShortkeyTarget(std::string &name)
989 {
990 HILOG_DEBUG();
991 MessageParcel data;
992 MessageParcel reply;
993 MessageOption option;
994 if (!WriteInterfaceToken(data)) {
995 HILOG_ERROR("fail, connection write Token");
996 return RET_ERR_IPC_FAILED;
997 }
998 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_SHORTKEY_TARGET,
999 data, reply, option)) {
1000 HILOG_ERROR("GetShortkeyTarget fail");
1001 return RET_ERR_IPC_FAILED;
1002 }
1003 RetError ret = static_cast<RetError>(reply.ReadInt32());
1004 if (ret == RET_OK) {
1005 name = reply.ReadString();
1006 }
1007 return ret;
1008 }
1009
GetHighContrastTextState(bool & state)1010 RetError AccessibleAbilityManagerServiceProxy::GetHighContrastTextState(bool &state)
1011 {
1012 HILOG_DEBUG();
1013 MessageParcel data;
1014 MessageParcel reply;
1015 MessageOption option;
1016
1017 if (!WriteInterfaceToken(data)) {
1018 HILOG_ERROR("fail, connection write Token");
1019 return RET_ERR_IPC_FAILED;
1020 }
1021 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_HIGHCONTRASTTEXT_STATE,
1022 data, reply, option)) {
1023 HILOG_ERROR("GetHighContrastTextState fail");
1024 return RET_ERR_IPC_FAILED;
1025 }
1026 RetError ret = static_cast<RetError>(reply.ReadInt32());
1027 if (ret == RET_OK) {
1028 state = reply.ReadBool();
1029 }
1030 return ret;
1031 }
1032
GetInvertColorState(bool & state)1033 RetError AccessibleAbilityManagerServiceProxy::GetInvertColorState(bool &state)
1034 {
1035 HILOG_DEBUG();
1036 MessageParcel data;
1037 MessageParcel reply;
1038 MessageOption option;
1039
1040 if (!WriteInterfaceToken(data)) {
1041 HILOG_ERROR("fail, connection write Token");
1042 return RET_ERR_IPC_FAILED;
1043 }
1044 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_INVERTCOLOR_STATE,
1045 data, reply, option)) {
1046 HILOG_ERROR("GetInvertColorState fail");
1047 return RET_ERR_IPC_FAILED;
1048 }
1049 RetError ret = static_cast<RetError>(reply.ReadInt32());
1050 if (ret == RET_OK) {
1051 state = reply.ReadBool();
1052 }
1053 return ret;
1054 }
1055
GetAnimationOffState(bool & state)1056 RetError AccessibleAbilityManagerServiceProxy::GetAnimationOffState(bool &state)
1057 {
1058 HILOG_DEBUG();
1059 MessageParcel data;
1060 MessageParcel reply;
1061 MessageOption option;
1062
1063 if (!WriteInterfaceToken(data)) {
1064 HILOG_ERROR("fail, connection write Token");
1065 return RET_ERR_IPC_FAILED;
1066 }
1067 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_ANIMATIONOFF_STATE,
1068 data, reply, option)) {
1069 HILOG_ERROR("GetAnimationOffState fail");
1070 return RET_ERR_IPC_FAILED;
1071 }
1072 RetError ret = static_cast<RetError>(reply.ReadInt32());
1073 if (ret == RET_OK) {
1074 state = reply.ReadBool();
1075 }
1076 return ret;
1077 }
1078
GetAudioMonoState(bool & state)1079 RetError AccessibleAbilityManagerServiceProxy::GetAudioMonoState(bool &state)
1080 {
1081 HILOG_DEBUG();
1082 MessageParcel data;
1083 MessageParcel reply;
1084 MessageOption option;
1085
1086 if (!WriteInterfaceToken(data)) {
1087 HILOG_ERROR("fail, connection write Token");
1088 return RET_ERR_IPC_FAILED;
1089 }
1090 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_AUDIOMONO_STATE,
1091 data, reply, option)) {
1092 HILOG_ERROR("GetAudioMonoState fail");
1093 return RET_ERR_IPC_FAILED;
1094 }
1095 RetError ret = static_cast<RetError>(reply.ReadInt32());
1096 if (ret == RET_OK) {
1097 state = reply.ReadBool();
1098 }
1099 return ret;
1100 }
1101
GetDaltonizationColorFilter(uint32_t & type)1102 RetError AccessibleAbilityManagerServiceProxy::GetDaltonizationColorFilter(uint32_t &type)
1103 {
1104 HILOG_DEBUG();
1105 MessageParcel data;
1106 MessageParcel reply;
1107 MessageOption option;
1108
1109 if (!WriteInterfaceToken(data)) {
1110 HILOG_ERROR("fail, connection write Token");
1111 return RET_ERR_IPC_FAILED;
1112 }
1113 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_DALTONIZATION_COLORFILTER,
1114 data, reply, option)) {
1115 HILOG_ERROR("GetDaltonizationColorFilter fail");
1116 return RET_ERR_IPC_FAILED;
1117 }
1118 RetError ret = static_cast<RetError>(reply.ReadInt32());
1119 if (ret == RET_OK) {
1120 type = reply.ReadUint32();
1121 }
1122 return ret;
1123 }
1124
GetContentTimeout(uint32_t & timer)1125 RetError AccessibleAbilityManagerServiceProxy::GetContentTimeout(uint32_t &timer)
1126 {
1127 HILOG_DEBUG();
1128 MessageParcel data;
1129 MessageParcel reply;
1130 MessageOption option;
1131
1132 if (!WriteInterfaceToken(data)) {
1133 HILOG_ERROR("fail, connection write Token");
1134 return RET_ERR_IPC_FAILED;
1135 }
1136 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_CONTENT_TIMEOUT,
1137 data, reply, option)) {
1138 HILOG_ERROR("GetContentTimeout fail");
1139 return RET_ERR_IPC_FAILED;
1140 }
1141 RetError ret = static_cast<RetError>(reply.ReadInt32());
1142 if (ret == RET_OK) {
1143 timer = reply.ReadUint32();
1144 }
1145 return ret;
1146 }
1147
GetBrightnessDiscount(float & brightness)1148 RetError AccessibleAbilityManagerServiceProxy::GetBrightnessDiscount(float &brightness)
1149 {
1150 HILOG_DEBUG();
1151 MessageParcel data;
1152 MessageParcel reply;
1153 MessageOption option;
1154
1155 if (!WriteInterfaceToken(data)) {
1156 HILOG_ERROR("fail, connection write Token");
1157 return RET_ERR_IPC_FAILED;
1158 }
1159 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_BRIGHTNESS_DISCOUNT,
1160 data, reply, option)) {
1161 HILOG_ERROR("GetBrightnessDiscount fail");
1162 return RET_ERR_IPC_FAILED;
1163 }
1164 RetError ret = static_cast<RetError>(reply.ReadInt32());
1165 if (ret == RET_OK) {
1166 brightness = reply.ReadFloat();
1167 }
1168 return ret;
1169 }
1170
GetAudioBalance(float & balance)1171 RetError AccessibleAbilityManagerServiceProxy::GetAudioBalance(float &balance)
1172 {
1173 HILOG_DEBUG();
1174 MessageParcel data;
1175 MessageParcel reply;
1176 MessageOption option;
1177
1178 if (!WriteInterfaceToken(data)) {
1179 HILOG_ERROR("fail, connection write Token");
1180 return RET_ERR_IPC_FAILED;
1181 }
1182 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_AUDIO_BALANCE,
1183 data, reply, option)) {
1184 HILOG_ERROR("GetAudioBalance fail");
1185 return RET_ERR_IPC_FAILED;
1186 }
1187 RetError ret = static_cast<RetError>(reply.ReadInt32());
1188 if (ret == RET_OK) {
1189 balance = reply.ReadFloat();
1190 }
1191 return ret;
1192 }
1193
GetAllConfigs(AccessibilityConfigData & configData)1194 void AccessibleAbilityManagerServiceProxy::GetAllConfigs(AccessibilityConfigData& configData)
1195 {
1196 HILOG_DEBUG();
1197 MessageParcel data;
1198 MessageParcel reply;
1199 MessageOption option;
1200
1201 if (!WriteInterfaceToken(data)) {
1202 HILOG_ERROR("fail, connection write Token");
1203 return;
1204 }
1205 if (!SendTransactCmd(AccessibilityInterfaceCode::GET_ALL_CONFIGS,
1206 data, reply, option)) {
1207 HILOG_ERROR("GetAllConfigs fail");
1208 return;
1209 }
1210 configData.highContrastText_ = reply.ReadBool();
1211 configData.invertColor_ = reply.ReadBool();
1212 configData.animationOff_ = reply.ReadBool();
1213 configData.audioMono_ = reply.ReadBool();
1214 configData.mouseKey_ = reply.ReadBool();
1215 configData.captionState_ = reply.ReadBool();
1216 configData.screenMagnifier_ = reply.ReadBool();
1217 configData.shortkey_ = reply.ReadBool();
1218 configData.mouseAutoClick_ = reply.ReadInt32();
1219 configData.daltonizationColorFilter_ = reply.ReadUint32();
1220 configData.contentTimeout_ = reply.ReadUint32();
1221 configData.brightnessDiscount_ = reply.ReadFloat();
1222 configData.audioBalance_ = reply.ReadFloat();
1223 configData.shortkeyTarget_ = reply.ReadString();
1224 configData.captionProperty_ = *reply.ReadStrongParcelable<CaptionPropertyParcel>();
1225 }
1226
RegisterEnableAbilityListsObserver(const sptr<IAccessibilityEnableAbilityListsObserver> & observer)1227 void AccessibleAbilityManagerServiceProxy::RegisterEnableAbilityListsObserver(
1228 const sptr<IAccessibilityEnableAbilityListsObserver> &observer)
1229 {
1230 HILOG_DEBUG();
1231 MessageParcel data;
1232 MessageParcel reply;
1233 MessageOption option(MessageOption::TF_ASYNC);
1234
1235 if (!observer) {
1236 HILOG_ERROR("observer is nullptr");
1237 return;
1238 }
1239
1240 if (!WriteInterfaceToken(data)) {
1241 HILOG_ERROR("write interface token error");
1242 return;
1243 }
1244
1245 if (!data.WriteRemoteObject(observer->AsObject())) {
1246 HILOG_ERROR("observer write remote object error");
1247 return;
1248 }
1249
1250 if (!SendTransactCmd(AccessibilityInterfaceCode::REGISTER_ENABLE_ABILITY_LISTS_OBSERVER,
1251 data, reply, option)) {
1252 HILOG_ERROR("RegisterEnableAbilityListsObserver fail");
1253 return;
1254 }
1255 }
1256
RegisterConfigObserver(const sptr<IAccessibleAbilityManagerConfigObserver> & client)1257 uint32_t AccessibleAbilityManagerServiceProxy::RegisterConfigObserver(
1258 const sptr<IAccessibleAbilityManagerConfigObserver> &client)
1259 {
1260 HILOG_DEBUG();
1261 MessageParcel data;
1262 MessageParcel reply;
1263 MessageOption option(MessageOption::TF_SYNC);
1264
1265 if (!client) {
1266 HILOG_ERROR("RegisterConfigObserver fail, Input client is null");
1267 return TRANSACTION_ERR;
1268 }
1269
1270 if (!WriteInterfaceToken(data)) {
1271 HILOG_ERROR("RegisterConfigObserver fail, connection write Token error");
1272 return TRANSACTION_ERR;
1273 }
1274
1275 if (!data.WriteRemoteObject(client->AsObject())) {
1276 HILOG_ERROR("RegisterConfigObserver fail, connection write client error");
1277 return TRANSACTION_ERR;
1278 }
1279
1280 if (!SendTransactCmd(AccessibilityInterfaceCode::REGISTER_CONFIG_CALLBACK,
1281 data, reply, option)) {
1282 HILOG_ERROR("RegisterStateCallback fail");
1283 return TRANSACTION_ERR;
1284 }
1285
1286 return reply.ReadUint32();
1287 }
1288 } // namespace Accessibility
1289 } // namespace OHOS