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 "interfaces/inner_api/ui_session/ui_content_proxy.h"
17
18 #include "ipc_skeleton.h"
19
20 #include "adapter/ohos/entrance/ui_session/include/ui_service_hilog.h"
21
22 namespace OHOS::Ace {
GetInspectorTree(const std::function<void (std::string,int32_t,bool)> & eventCallback)23 int32_t UIContentServiceProxy::GetInspectorTree(const std::function<void(std::string, int32_t, bool)>& eventCallback)
24 {
25 MessageParcel data;
26 MessageParcel reply;
27 MessageOption option;
28 if (!data.WriteInterfaceToken(GetDescriptor())) {
29 LOGW("GetInspectorTree write interface token failed");
30 return FAILED;
31 }
32 if (report_ == nullptr) {
33 LOGW("reportStub is nullptr");
34 return FAILED;
35 }
36 report_->RegisterGetInspectorTreeCallback(eventCallback);
37 if (Remote()->SendRequest(UI_CONTENT_SERVICE_GET_TREE, data, reply, option) != ERR_NONE) {
38 LOGW("GetInspectorTree send request failed");
39 return REPLY_ERROR;
40 }
41 return NO_ERROR;
42 }
43
GetVisibleInspectorTree(const std::function<void (std::string,int32_t,bool)> & eventCallback)44 int32_t UIContentServiceProxy::GetVisibleInspectorTree(
45 const std::function<void(std::string, int32_t, bool)>& eventCallback)
46 {
47 MessageParcel data;
48 MessageParcel reply;
49 MessageOption option;
50 if (!data.WriteInterfaceToken(GetDescriptor())) {
51 LOGW("GetVisibleInspectorTree write interface token failed");
52 return FAILED;
53 }
54 if (report_ == nullptr) {
55 LOGW("reportStub is nullptr");
56 return FAILED;
57 }
58 report_->RegisterGetInspectorTreeCallback(eventCallback);
59 if (Remote()->SendRequest(GET_VISIBLE_TREE, data, reply, option) != ERR_NONE) {
60 LOGW("GetVisibleInspectorTree send request failed");
61 return REPLY_ERROR;
62 }
63 return NO_ERROR;
64 }
65
Connect(const EventCallback & eventCallback)66 int32_t UIContentServiceProxy::Connect(const EventCallback& eventCallback)
67 {
68 MessageParcel data;
69 MessageParcel reply;
70 MessageOption option;
71 if (!data.WriteInterfaceToken(GetDescriptor())) {
72 LOGW("connect write interface token failed");
73 return FAILED;
74 }
75 report_ = new (std::nothrow) UiReportStub();
76 processId_ = IPCSkeleton::GetCallingRealPid();
77 isConnected = true;
78 if (report_ == nullptr) {
79 LOGW("connect failed,create reportStub failed");
80 return FAILED;
81 }
82 report_->RegisterGetBaseInfoCallback(eventCallback);
83 if (!data.WriteRemoteObject(report_)) {
84 LOGW("write reportStub failed");
85 return FAILED;
86 }
87 if (!data.WriteInt32(processId_)) {
88 LOGW("write processId failed");
89 return FAILED;
90 }
91 if (Remote()->SendRequest(UI_CONTENT_CONNECT, data, reply, option) != ERR_NONE) {
92 LOGW("connect send request failed");
93 return REPLY_ERROR;
94 }
95 return NO_ERROR;
96 }
97
RegisterClickEventCallback(const EventCallback & eventCallback)98 int32_t UIContentServiceProxy::RegisterClickEventCallback(const EventCallback& eventCallback)
99 {
100 MessageParcel data;
101 MessageParcel reply;
102 MessageOption option;
103 if (!data.WriteInterfaceToken(GetDescriptor())) {
104 LOGW("RegisterClickEventCallback write interface token failed");
105 return FAILED;
106 }
107 if (report_ == nullptr) {
108 LOGW("reportStub is nullptr");
109 return FAILED;
110 }
111 report_->RegisterClickEventCallback(eventCallback);
112 if (Remote()->SendRequest(REGISTER_CLICK_EVENT, data, reply, option) != ERR_NONE) {
113 LOGW("RegisterClickEventCallback send request failed");
114 return REPLY_ERROR;
115 }
116 return NO_ERROR;
117 }
118
RegisterSearchEventCallback(const EventCallback & eventCallback)119 int32_t UIContentServiceProxy::RegisterSearchEventCallback(const EventCallback& eventCallback)
120 {
121 MessageParcel data;
122 MessageParcel reply;
123 MessageOption option;
124 if (!data.WriteInterfaceToken(GetDescriptor())) {
125 LOGW("RegisterSearchEventCallback write interface token failed");
126 return FAILED;
127 }
128 if (report_ == nullptr) {
129 LOGW("reportStub is nullptr");
130 return FAILED;
131 }
132 report_->RegisterSearchEventCallback(eventCallback);
133 if (Remote()->SendRequest(REGISTER_SEARCH_EVENT, data, reply, option) != ERR_NONE) {
134 LOGW("RegisterSearchEventCallback send request failed");
135 return REPLY_ERROR;
136 }
137 return NO_ERROR;
138 }
139
RegisterRouterChangeEventCallback(const EventCallback & eventCallback)140 int32_t UIContentServiceProxy::RegisterRouterChangeEventCallback(const EventCallback& eventCallback)
141 {
142 MessageParcel data;
143 MessageParcel reply;
144 MessageOption option;
145 if (!data.WriteInterfaceToken(GetDescriptor())) {
146 LOGW("RegisterRouterChangeEventCallback write interface token failed");
147 return FAILED;
148 }
149 if (report_ == nullptr) {
150 LOGW("reportStub is nullptr");
151 return FAILED;
152 }
153 report_->RegisterRouterChangeEventCallback(eventCallback);
154 if (Remote()->SendRequest(REGISTER_ROUTER_CHANGE_EVENT, data, reply, option) != ERR_NONE) {
155 LOGW("RegisterRouterChangeEventCallback send request failed");
156 return REPLY_ERROR;
157 }
158 return NO_ERROR;
159 }
160
RegisterComponentChangeEventCallback(const EventCallback & eventCallback)161 int32_t UIContentServiceProxy::RegisterComponentChangeEventCallback(const EventCallback& eventCallback)
162 {
163 MessageParcel data;
164 MessageParcel reply;
165 MessageOption option;
166 if (!data.WriteInterfaceToken(GetDescriptor())) {
167 LOGW("RegisterComponentChangeEventCallback write interface token failed");
168 return FAILED;
169 }
170 if (report_ == nullptr) {
171 LOGW("reportStub is nullptr");
172 return FAILED;
173 }
174 report_->RegisterComponentChangeEventCallback(eventCallback);
175 if (Remote()->SendRequest(REGISTER_COMPONENT_EVENT, data, reply, option) != ERR_NONE) {
176 LOGW("RegisterComponentChangeEventCallback send request failed");
177 return REPLY_ERROR;
178 }
179 return NO_ERROR;
180 }
181
RegisterWebUnfocusEventCallback(const std::function<void (int64_t accessibilityId,const std::string & data)> & eventCallback)182 int32_t UIContentServiceProxy::RegisterWebUnfocusEventCallback(
183 const std::function<void(int64_t accessibilityId, const std::string& data)>& eventCallback)
184 {
185 MessageParcel data;
186 MessageParcel reply;
187 MessageOption option;
188 if (!data.WriteInterfaceToken(GetDescriptor())) {
189 LOGW("RegisterWebUnfocusEventCallback write interface token failed");
190 return FAILED;
191 }
192 if (report_ == nullptr) {
193 LOGW("reportStub is nullptr,connect is not execute");
194 return FAILED;
195 }
196 report_->RegisterWebUnfocusEventCallback(eventCallback);
197 if (Remote()->SendRequest(REGISTER_WEB_UNFOCUS_EVENT, data, reply, option) != ERR_NONE) {
198 LOGW("RegisterWebUnfocusEventCallback send request failed");
199 return REPLY_ERROR;
200 }
201 return NO_ERROR;
202 }
203
SendCommand(int32_t id,const std::string & command)204 int32_t UIContentServiceProxy::SendCommand(int32_t id, const std::string& command)
205 {
206 MessageParcel data;
207 MessageParcel reply;
208 MessageOption option;
209 if (!data.WriteInterfaceToken(GetDescriptor())) {
210 LOGW("SendCommand write interface token failed");
211 return FAILED;
212 }
213 if (!data.WriteInt32(id) || !data.WriteString(command)) {
214 LOGW("SendCommand write data failed");
215 return FAILED;
216 }
217 if (Remote()->SendRequest(SENDCOMMAND_EVENT, data, reply, option) != ERR_NONE) {
218 LOGW("SendCommand send request failed");
219 return REPLY_ERROR;
220 }
221 return NO_ERROR;
222 }
223
SendCommandAsync(int32_t id,const std::string & command)224 int32_t UIContentServiceProxy::SendCommandAsync(int32_t id, const std::string& command)
225 {
226 MessageParcel data;
227 MessageParcel reply;
228 MessageOption option(MessageOption::TF_ASYNC);
229 if (!data.WriteInterfaceToken(GetDescriptor())) {
230 LOGW("SendCommand Async write interface token failed");
231 return FAILED;
232 }
233 if (!data.WriteInt32(id) || !data.WriteString(command)) {
234 LOGW("SendCommand Async write data failed");
235 return FAILED;
236 }
237 return Remote()->SendRequest(SENDCOMMAND_ASYNC_EVENT, data, reply, option);
238 }
239
SendCommand(const std::string command)240 int32_t UIContentServiceProxy::SendCommand(const std::string command)
241 {
242 MessageParcel data;
243 MessageParcel reply;
244 MessageOption option(MessageOption::TF_ASYNC);
245 if (!data.WriteInterfaceToken(GetDescriptor())) {
246 LOGW("SendCommand write interface token failed");
247 return FAILED;
248 }
249
250 if (report_ == nullptr) {
251 LOGW("SendCommand is nullptr,connect is not execute");
252 return FAILED;
253 }
254
255 if (!data.WriteString(command)) {
256 LOGW("SendCommand WriteStringVector failed");
257 return FAILED;
258 }
259
260 if (Remote()->SendRequest(SEND_COMMAND, data, reply, option) != ERR_NONE) {
261 LOGW("SendCommand send request failed");
262 return REPLY_ERROR;
263 }
264 return NO_ERROR;
265 }
266
UnregisterClickEventCallback()267 int32_t UIContentServiceProxy::UnregisterClickEventCallback()
268 {
269 MessageParcel data;
270 MessageParcel reply;
271 MessageOption option;
272 if (!data.WriteInterfaceToken(GetDescriptor())) {
273 LOGW("UnregisterClickEventCallback write interface token failed");
274 return FAILED;
275 }
276 if (report_ == nullptr) {
277 LOGW("reportStub is nullptr");
278 return FAILED;
279 }
280 report_->UnregisterClickEventCallback();
281 if (Remote()->SendRequest(UNREGISTER_CLICK_EVENT, data, reply, option) != ERR_NONE) {
282 LOGW("UnregisterClickEventCallback send request failed");
283 return REPLY_ERROR;
284 }
285 return NO_ERROR;
286 }
287
UnregisterSearchEventCallback()288 int32_t UIContentServiceProxy::UnregisterSearchEventCallback()
289 {
290 MessageParcel data;
291 MessageParcel reply;
292 MessageOption option;
293 if (!data.WriteInterfaceToken(GetDescriptor())) {
294 LOGW("UnregisterSearchEventCallback write interface token failed");
295 return FAILED;
296 }
297 if (report_ == nullptr) {
298 LOGW("reportStub is nullptr");
299 return FAILED;
300 }
301 report_->UnregisterSearchEventCallback();
302 if (Remote()->SendRequest(UNREGISTER_SEARCH_EVENT, data, reply, option) != ERR_NONE) {
303 LOGW("UnregisterSearchEventCallback send request failed");
304 return REPLY_ERROR;
305 }
306 return NO_ERROR;
307 }
308
UnregisterRouterChangeEventCallback()309 int32_t UIContentServiceProxy::UnregisterRouterChangeEventCallback()
310 {
311 MessageParcel data;
312 MessageParcel reply;
313 MessageOption option;
314 if (!data.WriteInterfaceToken(GetDescriptor())) {
315 LOGW("UnregisterRouterChangeEventCallback write interface token failed");
316 return FAILED;
317 }
318 if (report_ == nullptr) {
319 LOGW("reportStub is nullptr");
320 return FAILED;
321 }
322 report_->UnregisterRouterChangeEventCallback();
323 if (Remote()->SendRequest(UNREGISTER_ROUTER_CHANGE_EVENT, data, reply, option) != ERR_NONE) {
324 LOGW("UnregisterRouterChangeEventCallback send request failed");
325 return REPLY_ERROR;
326 }
327 return NO_ERROR;
328 }
329
UnregisterComponentChangeEventCallback()330 int32_t UIContentServiceProxy::UnregisterComponentChangeEventCallback()
331 {
332 MessageParcel data;
333 MessageParcel reply;
334 MessageOption option;
335 if (!data.WriteInterfaceToken(GetDescriptor())) {
336 LOGW("UnregisterComponentChangeEventCallback write interface token failed");
337 return FAILED;
338 }
339 if (report_ == nullptr) {
340 LOGW("reportStub is nullptr");
341 return FAILED;
342 }
343 report_->UnregisterComponentChangeEventCallback();
344 if (Remote()->SendRequest(UNREGISTER_COMPONENT_EVENT, data, reply, option) != ERR_NONE) {
345 LOGW("UnregisterComponentChangeEventCallback send request failed");
346 return REPLY_ERROR;
347 }
348 return NO_ERROR;
349 }
350
UnregisterWebUnfocusEventCallback()351 int32_t UIContentServiceProxy::UnregisterWebUnfocusEventCallback()
352 {
353 MessageParcel data;
354 MessageParcel reply;
355 MessageOption option;
356 if (!data.WriteInterfaceToken(GetDescriptor())) {
357 LOGW("UnregisterWebUnfocusEventCallback write interface token failed");
358 return FAILED;
359 }
360 if (report_ == nullptr) {
361 LOGW("reportStub is nullptr,connect is not execute");
362 return FAILED;
363 }
364 report_->UnregisterWebUnfocusEventCallback();
365 if (Remote()->SendRequest(UNREGISTER_WEB_UNFOCUS_EVENT, data, reply, option) != ERR_NONE) {
366 LOGW("UnregisterWebUnfocusEventCallback send request failed");
367 return REPLY_ERROR;
368 }
369 return NO_ERROR;
370 }
371
IsConnect()372 bool UIContentServiceProxy::IsConnect()
373 {
374 return isConnected;
375 }
376
GetWebViewTranslateText(const std::string & data,const std::function<void (int32_t,std::string)> & eventCallback)377 int32_t UIContentServiceProxy::GetWebViewTranslateText(
378 const std::string& data, const std::function<void(int32_t, std::string)>& eventCallback)
379 {
380 MessageParcel value;
381 MessageParcel reply;
382 MessageOption option(MessageOption::TF_ASYNC);
383 if (!value.WriteInterfaceToken(GetDescriptor())) {
384 LOGW("GetWebViewTranslateText write interface token failed");
385 return FAILED;
386 }
387
388 if (report_ == nullptr) {
389 LOGW("GetWebViewTranslateText is nullptr,connect is not execute");
390 return FAILED;
391 }
392 if (!value.WriteString(data)) {
393 LOGW("GetWebViewTranslateText write interface token failed");
394 return FAILED;
395 }
396 if (report_ == nullptr) {
397 LOGW("GetWebViewTranslateText is nullptr,connect is not execute");
398 return FAILED;
399 }
400 report_->RegisterGetTranslateTextCallback(eventCallback);
401
402 if (Remote()->SendRequest(GET_WEB_TRANSLATE_TEXT, value, reply, option) != ERR_NONE) {
403 LOGW("GetWebViewTranslateText send request failed");
404 return REPLY_ERROR;
405 }
406 return NO_ERROR;
407 }
408
ResetTranslateTextAll()409 int32_t UIContentServiceProxy::ResetTranslateTextAll()
410 {
411 MessageParcel data;
412 MessageParcel reply;
413 MessageOption option(MessageOption::TF_ASYNC);
414 if (!data.WriteInterfaceToken(GetDescriptor())) {
415 LOGW("ResetTranslateTextAll write interface token failed");
416 return FAILED;
417 }
418 if (report_ == nullptr) {
419 LOGW("ResetTranslateTextAll is nullptr,connect is not execute");
420 return FAILED;
421 }
422 if (Remote()->SendRequest(RESET_ALL_TEXT, data, reply, option) != ERR_NONE) {
423 LOGW("ResetTranslateTextAll send request failed");
424 return REPLY_ERROR;
425 }
426 return NO_ERROR;
427 }
428
ResetTranslateText(int32_t nodeId)429 int32_t UIContentServiceProxy::ResetTranslateText(int32_t nodeId)
430 {
431 MessageParcel data;
432 MessageParcel reply;
433 MessageOption option(MessageOption::TF_ASYNC);
434 if (!data.WriteInterfaceToken(GetDescriptor())) {
435 LOGW("ResetTranslateText write interface token failed");
436 return FAILED;
437 }
438 if (report_ == nullptr) {
439 LOGW("ResetTranslateText is nullptr,connect is not execute");
440 return FAILED;
441 }
442 if (Remote()->SendRequest(RESET_TEXT_BY_ID, data, reply, option) != ERR_NONE) {
443 LOGW("ResetTranslateText send request failed");
444 return REPLY_ERROR;
445 }
446 return NO_ERROR;
447 }
448
GetWebViewCurrentLanguage(const EventCallback & eventCallback)449 int32_t UIContentServiceProxy::GetWebViewCurrentLanguage(const EventCallback& eventCallback)
450 {
451 MessageParcel data;
452 MessageParcel reply;
453 MessageOption option(MessageOption::TF_ASYNC);
454 if (!data.WriteInterfaceToken(GetDescriptor())) {
455 LOGW("GetWebViewCurrentLanguage write interface token failed");
456 return FAILED;
457 }
458 if (!data.WriteInt32(processId_)) {
459 LOGW("write processId failed");
460 return FAILED;
461 }
462 if (report_ == nullptr) {
463 LOGW("GetWebViewCurrentLanguage is nullptr,connect is not execute");
464 return FAILED;
465 }
466 report_->RegisterGetWebViewCurrentLanguage(eventCallback);
467 if (Remote()->SendRequest(GET_WEB_VIEW_LANGUAGE, data, reply, option) != ERR_NONE) {
468 LOGW("GetWebViewCurrentLanguage send request failed");
469 return REPLY_ERROR;
470 }
471 return NO_ERROR;
472 }
473
GetCurrentPageName(const std::function<void (std::string)> & finishCallback)474 int32_t UIContentServiceProxy::GetCurrentPageName(const std::function<void(std::string)>& finishCallback)
475 {
476 MessageParcel data;
477 MessageParcel reply;
478 MessageOption option(MessageOption::TF_ASYNC);
479 if (!data.WriteInterfaceToken(GetDescriptor())) {
480 LOGW("GetCurrentPageName write interface token failed");
481 return FAILED;
482 }
483 if (!data.WriteInt32(processId_)) {
484 LOGW("write processId failed");
485 return FAILED;
486 }
487 if (report_ == nullptr) {
488 LOGW("GetCurrentPageName is nullptr,connect is not execute");
489 return FAILED;
490 }
491 report_->RegisterGetCurrentPageName(finishCallback);
492 if (Remote()->SendRequest(GET_CURRENT_PAGE_NAME, data, reply, option) != ERR_NONE) {
493 LOGW("GetCurrentPageName send request failed");
494 return REPLY_ERROR;
495 }
496 return NO_ERROR;
497 }
498
StartWebViewTranslate(const std::string & data,const std::function<void (int32_t,std::string)> & eventCallback)499 int32_t UIContentServiceProxy::StartWebViewTranslate(
500 const std::string& data, const std::function<void(int32_t, std::string)>& eventCallback)
501 {
502 MessageParcel value;
503 MessageParcel reply;
504 MessageOption option(MessageOption::TF_ASYNC);
505 if (!value.WriteInterfaceToken(GetDescriptor())) {
506 LOGW("StartWebViewTranslate write interface token failed");
507 return FAILED;
508 }
509
510 if (report_ == nullptr) {
511 LOGW("StartWebViewTranslate is nullptr,connect is not execute");
512 return FAILED;
513 }
514 if (!value.WriteString(data)) {
515 LOGW("StartWebViewTranslate write interface token failed");
516 return FAILED;
517 }
518 if (!value.WriteInt32(processId_)) {
519 LOGW("write processId failed");
520 return FAILED;
521 }
522 report_->RegisterGetTranslateTextCallback(eventCallback);
523 if (Remote()->SendRequest(CONTINUE_GET_WEB_TEXT, value, reply, option) != ERR_NONE) {
524 LOGW("StartWebViewTranslate send request failed");
525 return REPLY_ERROR;
526 }
527 return NO_ERROR;
528 }
529
SendTranslateResult(int32_t nodeId,std::vector<std::string> results,std::vector<int32_t> ids)530 int32_t UIContentServiceProxy::SendTranslateResult(
531 int32_t nodeId, std::vector<std::string> results, std::vector<int32_t> ids)
532 {
533 MessageParcel data;
534 MessageParcel reply;
535 MessageOption option(MessageOption::TF_ASYNC);
536 if (!data.WriteInterfaceToken(GetDescriptor())) {
537 LOGW("SendTranslateResult write interface token failed");
538 return FAILED;
539 }
540 if (!data.WriteInt32(nodeId)) {
541 LOGW("SendTranslateResult write interface token failed");
542 return FAILED;
543 }
544 if (!data.WriteStringVector(results)) {
545 LOGW("SendTranslateResult WriteStringVector failed");
546 return FAILED;
547 }
548 if (!data.WriteInt32Vector(ids)) {
549 LOGW("SendTranslateResult WriteInt32Vector token failed");
550 return FAILED;
551 }
552 if (Remote()->SendRequest(SEND_TRANSLATE_RESULT, data, reply, option) != ERR_NONE) {
553 LOGW("SendTranslateResult send request failed");
554 return REPLY_ERROR;
555 }
556 return NO_ERROR;
557 }
558
EndWebViewTranslate()559 int32_t UIContentServiceProxy::EndWebViewTranslate()
560 {
561 MessageParcel data;
562 MessageParcel reply;
563 MessageOption option(MessageOption::TF_ASYNC);
564 if (!data.WriteInterfaceToken(GetDescriptor())) {
565 LOGW("ResetTranslateTextAll write interface token failed");
566 return FAILED;
567 }
568 if (report_ == nullptr) {
569 LOGW("ResetTranslateTextAll is nullptr,connect is not execute");
570 return FAILED;
571 }
572 if (Remote()->SendRequest(END_WEB_TRANSLATE, data, reply, option) != ERR_NONE) {
573 LOGW("ResetTranslateTextAll send request failed");
574 return REPLY_ERROR;
575 }
576 return NO_ERROR;
577 }
578
SendTranslateResult(int32_t nodeId,std::string result)579 int32_t UIContentServiceProxy::SendTranslateResult(int32_t nodeId, std::string result)
580 {
581 MessageParcel data;
582 MessageParcel reply;
583 MessageOption option(MessageOption::TF_ASYNC);
584 if (!data.WriteInterfaceToken(GetDescriptor())) {
585 LOGW("SendTranslateResult write interface token failed");
586 return FAILED;
587 }
588 if (!data.WriteInt32(nodeId)) {
589 LOGW("SendTranslateResult write interface token failed");
590 return FAILED;
591 }
592 if (!data.WriteString(result)) {
593 LOGW("SendTranslateResult WriteStringVector failed");
594 return FAILED;
595 }
596
597 if (Remote()->SendRequest(SEND_TRANSLATE_RESULT_STR, data, reply, option) != ERR_NONE) {
598 LOGW("SendTranslateResult send request failed");
599 return REPLY_ERROR;
600 }
601 return NO_ERROR;
602 }
603
GetCurrentImagesShowing(const std::function<void (std::vector<std::pair<int32_t,std::shared_ptr<Media::PixelMap>>>)> & finishCallback)604 int32_t UIContentServiceProxy::GetCurrentImagesShowing(
605 const std::function<void(std::vector<std::pair<int32_t, std::shared_ptr<Media::PixelMap>>>)>& finishCallback)
606 {
607 MessageParcel data;
608 MessageParcel reply;
609 MessageOption option(MessageOption::TF_ASYNC);
610 if (!data.WriteInterfaceToken(GetDescriptor())) {
611 LOGW("GetCurrentImagesShowing write interface token failed");
612 return FAILED;
613 }
614 if (!data.WriteInt32(processId_)) {
615 LOGW("write processId failed");
616 return FAILED;
617 }
618 if (report_ == nullptr) {
619 LOGW("reportServiceStub is nullptr,connect is not execute");
620 return FAILED;
621 }
622 report_->RegisterGetShowingImageCallback(finishCallback);
623 if (Remote()->SendRequest(GET_CURRENT_SHOWING_IMAGE, data, reply, option) != ERR_NONE) {
624 LOGW("GetCurrentImagesShowing send request failed");
625 return REPLY_ERROR;
626 }
627 return NO_ERROR;
628 }
629
ExeAppAIFunction(const std::string & funcName,const std::string & params,const std::function<void (uint32_t)> & finishCallback)630 int32_t UIContentServiceProxy::ExeAppAIFunction(
631 const std::string& funcName, const std::string& params, const std::function<void(uint32_t)>& finishCallback)
632 {
633 MessageParcel data;
634 MessageParcel reply;
635 MessageOption option(MessageOption::TF_ASYNC);
636 if (!data.WriteInterfaceToken(GetDescriptor())) {
637 LOGW("ExeAppAIFunction write interface token failed");
638 return FAILED;
639 }
640 if (!data.WriteString(funcName) || !data.WriteString(params)) {
641 LOGW("ExeAppAIFunction write data failed");
642 return FAILED;
643 }
644 if (report_ == nullptr) {
645 LOGW("ExeAppAIFunction is nullptr,connect is not execute");
646 return FAILED;
647 }
648 report_->RegisterExeAppAIFunction(finishCallback);
649 if (Remote()->SendRequest(EXE_APP_AI_FUNCTION, data, reply, option) != ERR_NONE) {
650 LOGW("ExeAppAIFunction send request failed");
651 return REPLY_ERROR;
652 }
653 return NO_ERROR;
654 }
655 } // namespace OHOS::Ace
656