1 /*
2 * Copyright (c) 2021-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 <unistd.h>
17
18 #include "input_scene_board_judgement.h"
19 #include "infrared_frequency_info.h"
20 #include "message_option.h"
21 #include "mmi_log.h"
22 #include "multimodalinput_ipc_interface_code.h"
23 #include "multimodal_input_connect_def_parcel.h"
24 #include "multimodal_input_connect_define.h"
25 #include "multimodal_input_connect_proxy.h"
26 #include "pixel_map.h"
27 #include "string_ex.h"
28
29 #undef MMI_LOG_DOMAIN
30 #define MMI_LOG_DOMAIN MMI_LOG_SERVER
31 #undef MMI_LOG_TAG
32 #define MMI_LOG_TAG "MultimodalInputConnectProxy"
33
34 namespace OHOS {
35 namespace MMI {
36 namespace {
37 constexpr int32_t SPECIAL_KEY_SIZE { 3 };
38 constexpr int32_t SPECIAL_ARRAY_INDEX0 { 0 };
39 constexpr int32_t SPECIAL_ARRAY_INDEX1 { 1 };
40 constexpr int32_t SPECIAL_ARRAY_INDEX2 { 2 };
41 constexpr int32_t MAX_AXIS_INFO { 64 };
42
ParseInputDevice(MessageParcel & reply,std::shared_ptr<InputDevice> & inputDevice)43 int32_t ParseInputDevice(MessageParcel &reply, std::shared_ptr<InputDevice> &inputDevice)
44 {
45 CHKPR(inputDevice, RET_ERR);
46 int32_t value = 0;
47 READINT32(reply, value, IPC_PROXY_DEAD_OBJECT_ERR);
48 inputDevice->SetId(value);
49 READINT32(reply, value, IPC_PROXY_DEAD_OBJECT_ERR);
50 inputDevice->SetType(value);
51 std::string name;
52 READSTRING(reply, name, IPC_PROXY_DEAD_OBJECT_ERR);
53 inputDevice->SetName(name);
54 READINT32(reply, value, IPC_PROXY_DEAD_OBJECT_ERR);
55 inputDevice->SetBus(value);
56 READINT32(reply, value, IPC_PROXY_DEAD_OBJECT_ERR);
57 inputDevice->SetVersion(value);
58 READINT32(reply, value, IPC_PROXY_DEAD_OBJECT_ERR);
59 inputDevice->SetProduct(value);
60 READINT32(reply, value, IPC_PROXY_DEAD_OBJECT_ERR);
61 inputDevice->SetVendor(value);
62 std::string phys;
63 READSTRING(reply, phys, IPC_PROXY_DEAD_OBJECT_ERR);
64 inputDevice->SetPhys(phys);
65 std::string uniq;
66 READSTRING(reply, uniq, IPC_PROXY_DEAD_OBJECT_ERR);
67 inputDevice->SetUniq(uniq);
68 uint64_t caps;
69 READUINT64(reply, caps, IPC_PROXY_DEAD_OBJECT_ERR);
70 inputDevice->SetCapabilities(static_cast<unsigned long>(caps));
71
72 uint32_t size = 0;
73 READUINT32(reply, size, IPC_PROXY_DEAD_OBJECT_ERR);
74 InputDevice::AxisInfo axis;
75 for (uint32_t i = 0; i < size; ++i) {
76 int32_t val = 0;
77 READINT32(reply, val, IPC_PROXY_DEAD_OBJECT_ERR);
78 axis.SetMinimum(val);
79 READINT32(reply, val, IPC_PROXY_DEAD_OBJECT_ERR);
80 axis.SetMaximum(val);
81 READINT32(reply, val, IPC_PROXY_DEAD_OBJECT_ERR);
82 axis.SetAxisType(val);
83 READINT32(reply, val, IPC_PROXY_DEAD_OBJECT_ERR);
84 axis.SetFuzz(val);
85 READINT32(reply, val, IPC_PROXY_DEAD_OBJECT_ERR);
86 axis.SetFlat(val);
87 READINT32(reply, val, IPC_PROXY_DEAD_OBJECT_ERR);
88 axis.SetResolution(val);
89 inputDevice->AddAxisInfo(axis);
90 }
91 return RET_OK;
92 }
93 } // namespace
94
MultimodalInputConnectProxy(const sptr<IRemoteObject> & impl)95 MultimodalInputConnectProxy::MultimodalInputConnectProxy(const sptr<IRemoteObject> &impl)
96 : IRemoteProxy<IMultimodalInputConnect>(impl)
97 {
98 MMI_HILOGI("Construct MMI proxy");
99 }
100
~MultimodalInputConnectProxy()101 MultimodalInputConnectProxy::~MultimodalInputConnectProxy()
102 {
103 MMI_HILOGI("Destruct MMI proxy");
104 }
105
AllocSocketFd(const std::string & programName,const int32_t moduleType,int32_t & socketFd,int32_t & tokenType)106 int32_t MultimodalInputConnectProxy::AllocSocketFd(const std::string &programName,
107 const int32_t moduleType, int32_t &socketFd, int32_t &tokenType)
108 {
109 CALL_DEBUG_ENTER;
110 MessageParcel data;
111 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
112 MMI_HILOGE("Failed to write descriptor");
113 return ERR_INVALID_VALUE;
114 }
115
116 ConnectReqParcel req;
117 req.data.moduleId = moduleType;
118 req.data.clientName = programName;
119 if (!data.WriteParcelable(&req)) {
120 MMI_HILOGE("Failed to write programName");
121 return ERR_INVALID_VALUE;
122 }
123
124 MessageParcel reply;
125 MessageOption option;
126 sptr<IRemoteObject> remote = Remote();
127 CHKPR(remote, RET_ERR);
128 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::ALLOC_SOCKET_FD),
129 data, reply, option);
130 if (ret != RET_OK) {
131 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
132 return ret;
133 }
134 socketFd = reply.ReadFileDescriptor();
135 if (socketFd < RET_OK) {
136 MMI_HILOGE("Read file descriptor failed, fd:%{public}d", socketFd);
137 return IPC_PROXY_DEAD_OBJECT_ERR;
138 }
139 READINT32(reply, tokenType, IPC_PROXY_DEAD_OBJECT_ERR);
140 MMI_HILOGD("socketFd:%{public}d, tokenType:%{public}d", socketFd, tokenType);
141 return RET_OK;
142 }
143
AddInputEventFilter(sptr<IEventFilter> filter,int32_t filterId,int32_t priority,uint32_t deviceTags)144 int32_t MultimodalInputConnectProxy::AddInputEventFilter(sptr<IEventFilter> filter, int32_t filterId, int32_t priority,
145 uint32_t deviceTags)
146 {
147 CALL_DEBUG_ENTER;
148 CHKPR(filter, ERR_INVALID_VALUE);
149 MessageParcel data;
150 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
151 MMI_HILOGE("Failed to write descriptor");
152 return ERR_INVALID_VALUE;
153 }
154 if (!data.WriteRemoteObject(filter->AsObject().GetRefPtr())) {
155 MMI_HILOGE("Failed to write filter");
156 return ERR_INVALID_VALUE;
157 }
158 WRITEINT32(data, filterId, ERR_INVALID_VALUE);
159 WRITEINT32(data, priority, ERR_INVALID_VALUE);
160 WRITEUINT32(data, deviceTags, ERR_INVALID_VALUE);
161 MessageParcel reply;
162 MessageOption option;
163 sptr<IRemoteObject> remote = Remote();
164 CHKPR(remote, RET_ERR);
165 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
166 ADD_INPUT_EVENT_FILTER), data, reply, option);
167 if (ret != RET_OK) {
168 MMI_HILOGE("Send request message failed, ret:%{public}d", ret);
169 return ret;
170 }
171 return RET_OK;
172 }
173
RemoveInputEventFilter(int32_t filterId)174 int32_t MultimodalInputConnectProxy::RemoveInputEventFilter(int32_t filterId)
175 {
176 CALL_DEBUG_ENTER;
177 MessageParcel data;
178 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
179 MMI_HILOGE("Failed to write descriptor");
180 return ERR_INVALID_VALUE;
181 }
182 WRITEINT32(data, filterId, ERR_INVALID_VALUE);
183 MessageParcel reply;
184 MessageOption option;
185 sptr<IRemoteObject> remote = Remote();
186 CHKPR(remote, RET_ERR);
187 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
188 RMV_INPUT_EVENT_FILTER), data, reply, option);
189 if (ret != RET_OK) {
190 MMI_HILOGE("Send request message failed, ret:%{public}d", ret);
191 return ret;
192 }
193 return RET_OK;
194 }
195
SetMouseScrollRows(int32_t rows)196 int32_t MultimodalInputConnectProxy::SetMouseScrollRows(int32_t rows)
197 {
198 CALL_DEBUG_ENTER;
199 MessageParcel data;
200 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
201 MMI_HILOGE("Failed to write descriptor");
202 return ERR_INVALID_VALUE;
203 }
204
205 WRITEINT32(data, rows, ERR_INVALID_VALUE);
206
207 MessageParcel reply;
208 MessageOption option;
209 sptr<IRemoteObject> remote = Remote();
210 CHKPR(remote, RET_ERR);
211 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_MOUSE_SCROLL_ROWS),
212 data, reply, option);
213 if (ret != RET_OK) {
214 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
215 }
216 return ret;
217 }
218
SetCustomCursor(int32_t pid,int32_t windowId,int32_t focusX,int32_t focusY,void * pixelMap)219 int32_t MultimodalInputConnectProxy::SetCustomCursor(int32_t pid, int32_t windowId, int32_t focusX, int32_t focusY,
220 void* pixelMap) __attribute__((no_sanitize("cfi")))
221 {
222 CALL_DEBUG_ENTER;
223 CHKPR(pixelMap, ERR_INVALID_VALUE);
224 OHOS::Media::PixelMap* pixelMapPtr = static_cast<OHOS::Media::PixelMap*>(pixelMap);
225 if (pixelMapPtr->GetCapacity() == 0) {
226 MMI_HILOGE("pixelMap is empty");
227 return ERR_INVALID_VALUE;
228 }
229 MessageParcel data;
230 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
231 MMI_HILOGE("Failed to write descriptor");
232 return ERR_INVALID_VALUE;
233 }
234 WRITEINT32(data, pid, ERR_INVALID_VALUE);
235 WRITEINT32(data, windowId, ERR_INVALID_VALUE);
236 WRITEINT32(data, focusX, ERR_INVALID_VALUE);
237 WRITEINT32(data, focusY, ERR_INVALID_VALUE);
238 pixelMapPtr->Marshalling(data);
239
240 MessageParcel reply;
241 MessageOption option;
242 sptr<IRemoteObject> remote = Remote();
243 CHKPR(remote, RET_ERR);
244 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_CUSTOM_CURSOR),
245 data, reply, option);
246 if (ret != RET_OK) {
247 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
248 }
249 return ret;
250 }
251
SetMouseIcon(int32_t windowId,void * pixelMap)252 int32_t MultimodalInputConnectProxy::SetMouseIcon(int32_t windowId, void* pixelMap) __attribute__((no_sanitize("cfi")))
253 {
254 CALL_DEBUG_ENTER;
255 CHKPR(pixelMap, ERR_INVALID_VALUE);
256 OHOS::Media::PixelMap* pixelMapPtr = static_cast<OHOS::Media::PixelMap*>(pixelMap);
257 if (pixelMapPtr->GetCapacity() == 0) {
258 MMI_HILOGE("pixelMap is empty, we dont have to pass it to the server");
259 return ERR_INVALID_VALUE;
260 }
261 MessageParcel data;
262 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
263 MMI_HILOGE("Failed to write descriptor");
264 return ERR_INVALID_VALUE;
265 }
266 pixelMapPtr->Marshalling(data);
267 MMI_HILOGD("Send windowId:%{public}d", windowId);
268 WRITEINT32(data, windowId, ERR_INVALID_VALUE);
269
270 MessageParcel reply;
271 MessageOption option;
272 sptr<IRemoteObject> remote = Remote();
273 CHKPR(remote, RET_ERR);
274 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_MOUSE_ICON),
275 data, reply, option);
276 if (ret != RET_OK) {
277 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
278 }
279 return ret;
280 }
281
SetMouseHotSpot(int32_t pid,int32_t windowId,int32_t hotSpotX,int32_t hotSpotY)282 int32_t MultimodalInputConnectProxy::SetMouseHotSpot(int32_t pid, int32_t windowId, int32_t hotSpotX, int32_t hotSpotY)
283 {
284 CALL_DEBUG_ENTER;
285 MessageParcel data;
286 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
287 MMI_HILOGE("Failed to write descriptor");
288 return ERR_INVALID_VALUE;
289 }
290 WRITEINT32(data, pid, ERR_INVALID_VALUE);
291 WRITEINT32(data, windowId, ERR_INVALID_VALUE);
292 WRITEINT32(data, hotSpotX, ERR_INVALID_VALUE);
293 WRITEINT32(data, hotSpotY, ERR_INVALID_VALUE);
294 MessageParcel reply;
295 MessageOption option;
296 sptr<IRemoteObject> remote = Remote();
297 CHKPR(remote, RET_ERR);
298 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_MOUSE_HOT_SPOT),
299 data, reply, option);
300 if (ret != RET_OK) {
301 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
302 }
303 return ret;
304 }
305
GetMouseScrollRows(int32_t & rows)306 int32_t MultimodalInputConnectProxy::GetMouseScrollRows(int32_t &rows)
307 {
308 CALL_DEBUG_ENTER;
309 MessageParcel data;
310 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
311 MMI_HILOGE("Failed to write descriptor");
312 return ERR_INVALID_VALUE;
313 }
314 MessageParcel reply;
315 MessageOption option;
316 sptr<IRemoteObject> remote = Remote();
317 CHKPR(remote, RET_ERR);
318 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_MOUSE_SCROLL_ROWS),
319 data, reply, option);
320 if (ret != RET_OK) {
321 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
322 return ret;
323 }
324 READINT32(reply, rows, IPC_PROXY_DEAD_OBJECT_ERR);
325 return RET_OK;
326 }
327
SetPointerSize(int32_t size)328 int32_t MultimodalInputConnectProxy::SetPointerSize(int32_t size)
329 {
330 CALL_DEBUG_ENTER;
331 MessageParcel data;
332 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
333 MMI_HILOGE("Failed to write descriptor");
334 return ERR_INVALID_VALUE;
335 }
336
337 WRITEINT32(data, size, ERR_INVALID_VALUE);
338
339 MessageParcel reply;
340 MessageOption option;
341 sptr<IRemoteObject> remote = Remote();
342 CHKPR(remote, RET_ERR);
343 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_POINTER_SIZE),
344 data, reply, option);
345 if (ret != RET_OK) {
346 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
347 }
348 return ret;
349 }
350
SetNapStatus(int32_t pid,int32_t uid,std::string bundleName,int32_t napStatus)351 int32_t MultimodalInputConnectProxy::SetNapStatus(int32_t pid, int32_t uid, std::string bundleName, int32_t napStatus)
352 {
353 CALL_DEBUG_ENTER;
354 MessageParcel data;
355 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
356 MMI_HILOGE("Failed to write descriptor");
357 return ERR_INVALID_VALUE;
358 }
359
360 WRITEINT32(data, pid, ERR_INVALID_VALUE);
361 WRITEINT32(data, uid, ERR_INVALID_VALUE);
362 WRITESTRING(data, bundleName, ERR_INVALID_VALUE);
363 WRITEINT32(data, napStatus, ERR_INVALID_VALUE);
364
365 MessageParcel reply;
366 MessageOption option;
367 sptr<IRemoteObject> remote = Remote();
368 CHKPR(remote, RET_ERR);
369 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
370 SET_NAP_STATUS), data, reply, option);
371 if (ret != RET_OK) {
372 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
373 }
374 return ret;
375 }
376
GetPointerSize(int32_t & size)377 int32_t MultimodalInputConnectProxy::GetPointerSize(int32_t &size)
378 {
379 CALL_DEBUG_ENTER;
380 MessageParcel data;
381 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
382 MMI_HILOGE("Failed to write descriptor");
383 return ERR_INVALID_VALUE;
384 }
385 MessageParcel reply;
386 MessageOption option;
387 sptr<IRemoteObject> remote = Remote();
388 CHKPR(remote, RET_ERR);
389 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_POINTER_SIZE),
390 data, reply, option);
391 if (ret != RET_OK) {
392 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
393 return ret;
394 }
395 READINT32(reply, size, IPC_PROXY_DEAD_OBJECT_ERR);
396 return RET_OK;
397 }
398
GetCursorSurfaceId(uint64_t & surfaceId)399 int32_t MultimodalInputConnectProxy::GetCursorSurfaceId(uint64_t &surfaceId)
400 {
401 MessageParcel data;
402 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
403 MMI_HILOGE("Failed to write descriptor");
404 return ERR_INVALID_VALUE;
405 }
406 MessageParcel reply;
407 MessageOption option;
408 sptr<IRemoteObject> remote = Remote();
409 CHKPR(remote, RET_ERR);
410 auto ret = remote->SendRequest(
411 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_CURSOR_SURFACE_ID),
412 data, reply, option);
413 if (ret != RET_OK) {
414 MMI_HILOGE("SendRequest fail, error:%{public}d", ret);
415 return ret;
416 }
417 READUINT64(reply, surfaceId, IPC_PROXY_DEAD_OBJECT_ERR);
418 return RET_OK;
419 }
420
SetMousePrimaryButton(int32_t primaryButton)421 int32_t MultimodalInputConnectProxy::SetMousePrimaryButton(int32_t primaryButton)
422 {
423 CALL_DEBUG_ENTER;
424 MessageParcel data;
425 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
426 MMI_HILOGE("Failed to write descriptor");
427 return ERR_INVALID_VALUE;
428 }
429
430 WRITEINT32(data, primaryButton, ERR_INVALID_VALUE);
431
432 MessageParcel reply;
433 MessageOption option;
434 sptr<IRemoteObject> remote = Remote();
435 CHKPR(remote, RET_ERR);
436 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
437 SET_MOUSE_PRIMARY_BUTTON), data, reply, option);
438 if (ret != RET_OK) {
439 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
440 }
441 return ret;
442 }
443
GetMousePrimaryButton(int32_t & primaryButton)444 int32_t MultimodalInputConnectProxy::GetMousePrimaryButton(int32_t &primaryButton)
445 {
446 CALL_DEBUG_ENTER;
447 MessageParcel data;
448 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
449 MMI_HILOGE("Failed to write descriptor");
450 return ERR_INVALID_VALUE;
451 }
452 MessageParcel reply;
453 MessageOption option;
454 sptr<IRemoteObject> remote = Remote();
455 CHKPR(remote, RET_ERR);
456 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
457 GET_MOUSE_PRIMARY_BUTTON), data, reply, option);
458 if (ret != RET_OK) {
459 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
460 return ret;
461 }
462 READINT32(reply, primaryButton, IPC_PROXY_DEAD_OBJECT_ERR);
463 return RET_OK;
464 }
465
SetHoverScrollState(bool state)466 int32_t MultimodalInputConnectProxy::SetHoverScrollState(bool state)
467 {
468 CALL_DEBUG_ENTER;
469 MessageParcel data;
470 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
471 MMI_HILOGE("Failed to write descriptor");
472 return ERR_INVALID_VALUE;
473 }
474
475 WRITEBOOL(data, state, ERR_INVALID_VALUE);
476
477 MessageParcel reply;
478 MessageOption option;
479 sptr<IRemoteObject> remote = Remote();
480 CHKPR(remote, RET_ERR);
481 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
482 SET_HOVER_SCROLL_STATE), data, reply, option);
483 if (ret != RET_OK) {
484 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
485 }
486 return ret;
487 }
488
GetHoverScrollState(bool & state)489 int32_t MultimodalInputConnectProxy::GetHoverScrollState(bool &state)
490 {
491 CALL_DEBUG_ENTER;
492 MessageParcel data;
493 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
494 MMI_HILOGE("Failed to write descriptor");
495 return ERR_INVALID_VALUE;
496 }
497 MessageParcel reply;
498 MessageOption option;
499 sptr<IRemoteObject> remote = Remote();
500 CHKPR(remote, RET_ERR);
501 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
502 GET_HOVER_SCROLL_STATE), data, reply, option);
503 if (ret != RET_OK) {
504 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
505 return ret;
506 }
507 READBOOL(reply, state, IPC_PROXY_DEAD_OBJECT_ERR);
508 return RET_OK;
509 }
510
SetPointerVisible(bool visible,int32_t priority)511 int32_t MultimodalInputConnectProxy::SetPointerVisible(bool visible, int32_t priority)
512 {
513 CALL_DEBUG_ENTER;
514 MessageParcel data;
515 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
516 MMI_HILOGE("Failed to write descriptor");
517 return ERR_INVALID_VALUE;
518 }
519
520 WRITEBOOL(data, visible, ERR_INVALID_VALUE);
521 WRITEINT32(data, priority, ERR_INVALID_VALUE);
522
523 MessageParcel reply;
524 MessageOption option;
525 sptr<IRemoteObject> remote = Remote();
526 CHKPR(remote, RET_ERR);
527 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_POINTER_VISIBLE),
528 data, reply, option);
529 if (ret != RET_OK) {
530 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
531 }
532 return ret;
533 }
534
IsPointerVisible(bool & visible)535 int32_t MultimodalInputConnectProxy::IsPointerVisible(bool &visible)
536 {
537 CALL_DEBUG_ENTER;
538 MessageParcel data;
539 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
540 MMI_HILOGE("Failed to write descriptor");
541 return ERR_INVALID_VALUE;
542 }
543
544 MessageParcel reply;
545 MessageOption option;
546 sptr<IRemoteObject> remote = Remote();
547 CHKPR(remote, RET_ERR);
548 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::IS_POINTER_VISIBLE),
549 data, reply, option);
550 if (ret != RET_OK) {
551 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
552 return ret;
553 }
554 READBOOL(reply, visible, IPC_PROXY_DEAD_OBJECT_ERR);
555 return RET_OK;
556 }
557
MarkProcessed(int32_t eventType,int32_t eventId)558 int32_t MultimodalInputConnectProxy::MarkProcessed(int32_t eventType, int32_t eventId)
559 {
560 CALL_DEBUG_ENTER;
561 MessageParcel data;
562 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
563 MMI_HILOGE("Failed to write descriptor");
564 return ERR_INVALID_VALUE;
565 }
566 WRITEINT32(data, eventType, ERR_INVALID_VALUE);
567 WRITEINT32(data, eventId, ERR_INVALID_VALUE);
568
569 MessageParcel reply;
570 MessageOption option;
571 sptr<IRemoteObject> remote = Remote();
572 CHKPR(remote, RET_ERR);
573 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::MARK_PROCESSED),
574 data, reply, option);
575 if (ret != RET_OK) {
576 MMI_HILOGD("Send request fail, ret:%{public}d", ret);
577 return ret;
578 }
579 return RET_OK;
580 }
581
SetPointerColor(int32_t color)582 int32_t MultimodalInputConnectProxy::SetPointerColor(int32_t color)
583 {
584 CALL_DEBUG_ENTER;
585 MessageParcel data;
586 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
587 MMI_HILOGE("Failed to write descriptor");
588 return ERR_INVALID_VALUE;
589 }
590
591 WRITEINT32(data, color, ERR_INVALID_VALUE);
592
593 MessageParcel reply;
594 MessageOption option;
595 sptr<IRemoteObject> remote = Remote();
596 CHKPR(remote, RET_ERR);
597 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_POINTER_COLOR),
598 data, reply, option);
599 if (ret != RET_OK) {
600 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
601 }
602 return ret;
603 }
604
GetPointerColor(int32_t & color)605 int32_t MultimodalInputConnectProxy::GetPointerColor(int32_t &color)
606 {
607 CALL_DEBUG_ENTER;
608 MessageParcel data;
609 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
610 MMI_HILOGE("Failed to write descriptor");
611 return ERR_INVALID_VALUE;
612 }
613 MessageParcel reply;
614 MessageOption option;
615 sptr<IRemoteObject> remote = Remote();
616 CHKPR(remote, RET_ERR);
617 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_POINTER_COLOR),
618 data, reply, option);
619 if (ret != RET_OK) {
620 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
621 return ret;
622 }
623 READINT32(reply, color, IPC_PROXY_DEAD_OBJECT_ERR);
624 return RET_OK;
625 }
626
SetPointerSpeed(int32_t speed)627 int32_t MultimodalInputConnectProxy::SetPointerSpeed(int32_t speed)
628 {
629 CALL_DEBUG_ENTER;
630 MessageParcel data;
631 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
632 MMI_HILOGE("Failed to write descriptor");
633 return ERR_INVALID_VALUE;
634 }
635 WRITEINT32(data, speed, ERR_INVALID_VALUE);
636 MessageParcel reply;
637 MessageOption option;
638 sptr<IRemoteObject> remote = Remote();
639 CHKPR(remote, RET_ERR);
640 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_POINTER_SPEED),
641 data, reply, option);
642 if (ret != RET_OK) {
643 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
644 }
645 return ret;
646 }
647
GetPointerSpeed(int32_t & speed)648 int32_t MultimodalInputConnectProxy::GetPointerSpeed(int32_t &speed)
649 {
650 CALL_DEBUG_ENTER;
651 MessageParcel data;
652 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
653 MMI_HILOGE("Failed to write descriptor");
654 return ERR_INVALID_VALUE;
655 }
656 MessageParcel reply;
657 MessageOption option;
658 sptr<IRemoteObject> remote = Remote();
659 CHKPR(remote, RET_ERR);
660 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_POINTER_SPEED),
661 data, reply, option);
662 if (ret != RET_OK) {
663 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
664 return ret;
665 }
666 READINT32(reply, speed, IPC_PROXY_DEAD_OBJECT_ERR);
667 return RET_OK;
668 }
669
NotifyNapOnline()670 int32_t MultimodalInputConnectProxy::NotifyNapOnline()
671 {
672 CALL_DEBUG_ENTER;
673 MessageParcel data;
674 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
675 MMI_HILOGE("Failed to write descriptor");
676 return RET_ERR;
677 }
678 MessageParcel reply;
679 MessageOption option;
680 sptr<IRemoteObject> remote = Remote();
681 CHKPR(remote, RET_ERR);
682 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::NOTIFY_NAP_ONLINE),
683 data, reply, option);
684 if (ret != RET_OK) {
685 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
686 }
687 return ret;
688 }
689
RemoveInputEventObserver()690 int32_t MultimodalInputConnectProxy::RemoveInputEventObserver()
691 {
692 CALL_DEBUG_ENTER;
693 MessageParcel data;
694 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
695 MMI_HILOGE("Failed to write descriptor");
696 return RET_ERR;
697 }
698 MessageParcel reply;
699 MessageOption option;
700 sptr<IRemoteObject> remote = Remote();
701 CHKPR(remote, RET_ERR);
702 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
703 RMV_INPUT_EVENT_OBSERVER), data, reply, option);
704 if (ret != RET_OK) {
705 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
706 }
707 return ret;
708 }
709
SetPointerStyle(int32_t windowId,PointerStyle pointerStyle,bool isUiExtension)710 int32_t MultimodalInputConnectProxy::SetPointerStyle(int32_t windowId, PointerStyle pointerStyle, bool isUiExtension)
711 {
712 CALL_DEBUG_ENTER;
713 MessageParcel data;
714 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
715 MMI_HILOGE("Failed to write descriptor");
716 return RET_ERR;
717 }
718
719 WRITEINT32(data, windowId, RET_ERR);
720 WRITEINT32(data, pointerStyle.size, RET_ERR);
721 WRITEINT32(data, pointerStyle.color, RET_ERR);
722 WRITEINT32(data, pointerStyle.id, RET_ERR);
723 WRITEBOOL(data, isUiExtension, RET_ERR);
724
725 MessageParcel reply;
726 MessageOption option;
727 sptr<IRemoteObject> remote = Remote();
728 CHKPR(remote, RET_ERR);
729 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_POINTER_STYLE),
730 data, reply, option);
731 if (ret != RET_OK) {
732 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
733 }
734 return ret;
735 }
736
ClearWindowPointerStyle(int32_t pid,int32_t windowId)737 int32_t MultimodalInputConnectProxy::ClearWindowPointerStyle(int32_t pid, int32_t windowId)
738 {
739 CALL_DEBUG_ENTER;
740 MessageParcel data;
741 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
742 MMI_HILOGE("Failed to write descriptor");
743 return RET_ERR;
744 }
745
746 WRITEINT32(data, pid, RET_ERR);
747 WRITEINT32(data, windowId, RET_ERR);
748
749 MessageParcel reply;
750 MessageOption option;
751 sptr<IRemoteObject> remote = Remote();
752 CHKPR(remote, RET_ERR);
753 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::CLEAN_WIDNOW_STYLE),
754 data, reply, option);
755 if (ret != RET_OK) {
756 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
757 }
758 return ret;
759 }
760
GetPointerStyle(int32_t windowId,PointerStyle & pointerStyle,bool isUiExtension)761 int32_t MultimodalInputConnectProxy::GetPointerStyle(int32_t windowId, PointerStyle &pointerStyle, bool isUiExtension)
762 {
763 CALL_DEBUG_ENTER;
764 MessageParcel data;
765 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
766 MMI_HILOGE("Failed to write descriptor");
767 return RET_ERR;
768 }
769 WRITEINT32(data, windowId, RET_ERR);
770 WRITEBOOL(data, isUiExtension, RET_ERR);
771 MessageParcel reply;
772 MessageOption option;
773 sptr<IRemoteObject> remote = Remote();
774 CHKPR(remote, RET_ERR);
775 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_POINTER_STYLE),
776 data, reply, option);
777 if (ret != RET_OK) {
778 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
779 return ret;
780 }
781 READINT32(reply, pointerStyle.size, IPC_PROXY_DEAD_OBJECT_ERR);
782 READINT32(reply, pointerStyle.color, IPC_PROXY_DEAD_OBJECT_ERR);
783 READINT32(reply, pointerStyle.id, IPC_PROXY_DEAD_OBJECT_ERR);
784 READINT32(reply, pointerStyle.options, IPC_PROXY_DEAD_OBJECT_ERR);
785 return RET_OK;
786 }
787
RegisterDevListener()788 int32_t MultimodalInputConnectProxy::RegisterDevListener()
789 {
790 MessageParcel data;
791 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
792 MMI_HILOGE("Failed to write descriptor");
793 return ERR_INVALID_VALUE;
794 }
795
796 MessageParcel reply;
797 MessageOption option;
798 sptr<IRemoteObject> remote = Remote();
799 CHKPR(remote, RET_ERR);
800 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::REGISTER_DEV_MONITOR),
801 data, reply, option);
802 if (ret != RET_OK) {
803 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
804 }
805 return ret;
806 }
807
UnregisterDevListener()808 int32_t MultimodalInputConnectProxy::UnregisterDevListener()
809 {
810 MessageParcel data;
811 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
812 MMI_HILOGE("Failed to write descriptor");
813 return ERR_INVALID_VALUE;
814 }
815
816 MessageParcel reply;
817 MessageOption option;
818 sptr<IRemoteObject> remote = Remote();
819 CHKPR(remote, RET_ERR);
820 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
821 UNREGISTER_DEV_MONITOR), data, reply, option);
822 if (ret != RET_OK) {
823 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
824 }
825 return ret;
826 }
827
SupportKeys(int32_t deviceId,std::vector<int32_t> & keys,std::vector<bool> & keystroke)828 int32_t MultimodalInputConnectProxy::SupportKeys(int32_t deviceId, std::vector<int32_t> &keys,
829 std::vector<bool> &keystroke)
830 {
831 CALL_DEBUG_ENTER;
832 MessageParcel data;
833 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
834 MMI_HILOGE("Failed to write descriptor");
835 return RET_ERR;
836 }
837 WRITEINT32(data, deviceId);
838 WRITEINT32(data, static_cast<int32_t>(keys.size()));
839 for (const auto &item : keys) {
840 WRITEINT32(data, item);
841 }
842
843 MessageParcel reply;
844 MessageOption option;
845 sptr<IRemoteObject> remote = Remote();
846 CHKPR(remote, RET_ERR);
847 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SUPPORT_KEYS),
848 data, reply, option);
849 if (ret != RET_OK) {
850 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
851 return ret;
852 }
853 if (!reply.ReadBoolVector(&keystroke)) {
854 MMI_HILOGE("Read ids failed");
855 return RET_ERR;
856 }
857 MMI_HILOGE("keystroke size:%{public}zu", keystroke.size());
858 return RET_OK;
859 }
860
GetDeviceIds(std::vector<int32_t> & ids)861 int32_t MultimodalInputConnectProxy::GetDeviceIds(std::vector<int32_t> &ids)
862 {
863 CALL_DEBUG_ENTER;
864 MessageParcel data;
865 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
866 MMI_HILOGE("Failed to write descriptor");
867 return RET_ERR;
868 }
869 MessageParcel reply;
870 MessageOption option;
871 sptr<IRemoteObject> remote = Remote();
872 CHKPR(remote, RET_ERR);
873 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_DEVICE_IDS),
874 data, reply, option);
875 if (ret != RET_OK) {
876 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
877 return ret;
878 }
879 if (!reply.ReadInt32Vector(&ids)) {
880 MMI_HILOGE("Read vector failed");
881 return RET_ERR;
882 }
883 MMI_HILOGD("ids size:%{public}zu", ids.size());
884 return RET_OK;
885 }
886
GetDevice(int32_t deviceId,std::shared_ptr<InputDevice> & inputDevice)887 int32_t MultimodalInputConnectProxy::GetDevice(int32_t deviceId, std::shared_ptr<InputDevice> &inputDevice)
888 {
889 CALL_DEBUG_ENTER;
890 MessageParcel data;
891 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
892 MMI_HILOGE("Failed to write descriptor");
893 return RET_ERR;
894 }
895 WRITEINT32(data, deviceId);
896 MessageParcel reply;
897 MessageOption option;
898 sptr<IRemoteObject> remote = Remote();
899 CHKPR(remote, RET_ERR);
900 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_DEVICE),
901 data, reply, option);
902 if (ret != RET_OK) {
903 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
904 return ret;
905 }
906 ret = ParseInputDevice(reply, inputDevice);
907 if (ret != RET_OK) {
908 MMI_HILOGE("ParseInputDevice failed");
909 return RET_ERR;
910 }
911 return RET_OK;
912 }
913
GetKeyboardType(int32_t deviceId,int32_t & keyboardType)914 int32_t MultimodalInputConnectProxy::GetKeyboardType(int32_t deviceId, int32_t &keyboardType)
915 {
916 CALL_DEBUG_ENTER;
917 MessageParcel data;
918 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
919 MMI_HILOGE("Failed to write descriptor");
920 return RET_ERR;
921 }
922 WRITEINT32(data, deviceId);
923 MessageParcel reply;
924 MessageOption option;
925 sptr<IRemoteObject> remote = Remote();
926 CHKPR(remote, RET_ERR);
927 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_KEYBOARD_TYPE),
928 data, reply, option);
929 if (ret != RET_OK) {
930 MMI_HILOGD("Send request failed, ret:%{public}d", ret);
931 return ret;
932 }
933 READINT32(reply, keyboardType, IPC_PROXY_DEAD_OBJECT_ERR);
934 return RET_OK;
935 }
936
SetKeyboardRepeatDelay(int32_t delay)937 int32_t MultimodalInputConnectProxy::SetKeyboardRepeatDelay(int32_t delay)
938 {
939 CALL_DEBUG_ENTER;
940 MessageParcel data;
941 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
942 MMI_HILOGE("Failed to write descriptor");
943 return ERR_INVALID_VALUE;
944 }
945 WRITEINT32(data, delay, ERR_INVALID_VALUE);
946 MessageParcel reply;
947 MessageOption option;
948 sptr<IRemoteObject> remote = Remote();
949 CHKPR(remote, RET_ERR);
950 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
951 SET_KEYBOARD_REPEAT_DELAY), data, reply, option);
952 if (ret != RET_OK) {
953 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
954 }
955 return ret;
956 }
957
SetKeyboardRepeatRate(int32_t rate)958 int32_t MultimodalInputConnectProxy::SetKeyboardRepeatRate(int32_t rate)
959 {
960 CALL_DEBUG_ENTER;
961 MessageParcel data;
962 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
963 MMI_HILOGE("Failed to write descriptor");
964 return ERR_INVALID_VALUE;
965 }
966 WRITEINT32(data, rate, ERR_INVALID_VALUE);
967 MessageParcel reply;
968 MessageOption option;
969 sptr<IRemoteObject> remote = Remote();
970 CHKPR(remote, RET_ERR);
971 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
972 SET_KEYBOARD_REPEAT_RATE), data, reply, option);
973 if (ret != RET_OK) {
974 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
975 }
976 return ret;
977 }
978
GetKeyboardRepeatDelay(int32_t & delay)979 int32_t MultimodalInputConnectProxy::GetKeyboardRepeatDelay(int32_t &delay)
980 {
981 CALL_DEBUG_ENTER;
982 MessageParcel data;
983 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
984 MMI_HILOGE("Failed to write descriptor");
985 return ERR_INVALID_VALUE;
986 }
987 MessageParcel reply;
988 MessageOption option;
989 sptr<IRemoteObject> remote = Remote();
990 CHKPR(remote, RET_ERR);
991 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
992 GET_KEYBOARD_REPEAT_DELAY), data, reply, option);
993 if (ret != RET_OK) {
994 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
995 return ret;
996 }
997 READINT32(reply, delay, IPC_PROXY_DEAD_OBJECT_ERR);
998 return RET_OK;
999 }
1000
GetKeyboardRepeatRate(int32_t & rate)1001 int32_t MultimodalInputConnectProxy::GetKeyboardRepeatRate(int32_t &rate)
1002 {
1003 CALL_DEBUG_ENTER;
1004 MessageParcel data;
1005 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1006 MMI_HILOGE("Failed to write descriptor");
1007 return ERR_INVALID_VALUE;
1008 }
1009 MessageParcel reply;
1010 MessageOption option;
1011 sptr<IRemoteObject> remote = Remote();
1012 CHKPR(remote, RET_ERR);
1013 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1014 GET_KEYBOARD_REPEAT_RATE), data, reply, option);
1015 if (ret != RET_OK) {
1016 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1017 return ret;
1018 }
1019 READINT32(reply, rate, IPC_PROXY_DEAD_OBJECT_ERR);
1020 return RET_OK;
1021 }
1022
AddInputHandler(InputHandlerType handlerType,HandleEventType eventType,int32_t priority,uint32_t deviceTags)1023 int32_t MultimodalInputConnectProxy::AddInputHandler(InputHandlerType handlerType,
1024 HandleEventType eventType, int32_t priority, uint32_t deviceTags)
1025 {
1026 CALL_DEBUG_ENTER;
1027 MessageParcel data;
1028 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1029 MMI_HILOGE("Failed to write descriptor");
1030 return ERR_INVALID_VALUE;
1031 }
1032 WRITEINT32(data, handlerType, ERR_INVALID_VALUE);
1033 WRITEUINT32(data, eventType, ERR_INVALID_VALUE);
1034 WRITEINT32(data, priority, ERR_INVALID_VALUE);
1035 WRITEUINT32(data, deviceTags, ERR_INVALID_VALUE);
1036 MessageParcel reply;
1037 MessageOption option;
1038 sptr<IRemoteObject> remote = Remote();
1039 CHKPR(remote, RET_ERR);
1040 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::ADD_INPUT_HANDLER),
1041 data, reply, option);
1042 if (ret != RET_OK) {
1043 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1044 }
1045 return ret;
1046 }
1047
RemoveInputHandler(InputHandlerType handlerType,HandleEventType eventType,int32_t priority,uint32_t deviceTags)1048 int32_t MultimodalInputConnectProxy::RemoveInputHandler(InputHandlerType handlerType,
1049 HandleEventType eventType, int32_t priority, uint32_t deviceTags)
1050 {
1051 CALL_DEBUG_ENTER;
1052 MessageParcel data;
1053 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1054 MMI_HILOGE("Failed to write descriptor");
1055 return ERR_INVALID_VALUE;
1056 }
1057 WRITEINT32(data, handlerType, ERR_INVALID_VALUE);
1058 WRITEUINT32(data, eventType, ERR_INVALID_VALUE);
1059 WRITEINT32(data, priority, ERR_INVALID_VALUE);
1060 WRITEUINT32(data, eventType, ERR_INVALID_VALUE);
1061 MessageParcel reply;
1062 MessageOption option;
1063 sptr<IRemoteObject> remote = Remote();
1064 CHKPR(remote, RET_ERR);
1065 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::REMOVE_INPUT_HANDLER),
1066 data, reply, option);
1067 if (ret != RET_OK) {
1068 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1069 }
1070 return ret;
1071 }
1072
AddPreInputHandler(int32_t handlerId,HandleEventType eventType,std::vector<int32_t> keys)1073 int32_t MultimodalInputConnectProxy::AddPreInputHandler(
1074 int32_t handlerId, HandleEventType eventType, std::vector<int32_t> keys)
1075 {
1076 CALL_DEBUG_ENTER;
1077 MessageParcel data;
1078 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1079 MMI_HILOGE("Failed to write descriptor");
1080 return ERR_INVALID_VALUE;
1081 }
1082 WRITEINT32(data, handlerId, ERR_INVALID_VALUE);
1083 WRITEINT32(data, eventType, ERR_INVALID_VALUE);
1084 WRITEINT32(data, static_cast<int32_t>(keys.size()), ERR_INVALID_VALUE);
1085 for (const auto &item :keys) {
1086 WRITEINT32(data, item);
1087 }
1088 MessageParcel reply;
1089 MessageOption option;
1090 sptr<IRemoteObject> remote = Remote();
1091 CHKPR(remote, RET_ERR);
1092 int32_t ret = remote->SendRequest(
1093 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::ADD_PRE_INPUT_HANDLER), data, reply, option);
1094 if (ret != RET_OK) {
1095 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1096 }
1097 return ret;
1098 }
1099
RemovePreInputHandler(int32_t handlerId)1100 int32_t MultimodalInputConnectProxy::RemovePreInputHandler(int32_t handlerId)
1101 {
1102 CALL_DEBUG_ENTER;
1103 MessageParcel data;
1104 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1105 MMI_HILOGE("Failed to write descriptor");
1106 return ERR_INVALID_VALUE;
1107 }
1108 WRITEINT32(data, handlerId, ERR_INVALID_VALUE);
1109 MessageParcel reply;
1110 MessageOption option;
1111 sptr<IRemoteObject> remote = Remote();
1112 CHKPR(remote, RET_ERR);
1113 int32_t ret = remote->SendRequest(
1114 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::REMOVE_PRE_INPUT_HANDLER), data, reply, option);
1115 if (ret != RET_OK) {
1116 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1117 }
1118 return ret;
1119 }
1120
MarkEventConsumed(int32_t eventId)1121 int32_t MultimodalInputConnectProxy::MarkEventConsumed(int32_t eventId)
1122 {
1123 CALL_DEBUG_ENTER;
1124 MessageParcel data;
1125 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1126 MMI_HILOGE("Failed to write descriptor");
1127 return ERR_INVALID_VALUE;
1128 }
1129 WRITEINT32(data, eventId, ERR_INVALID_VALUE);
1130 MessageParcel reply;
1131 MessageOption option;
1132 sptr<IRemoteObject> remote = Remote();
1133 CHKPR(remote, RET_ERR);
1134 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::MARK_EVENT_CONSUMED),
1135 data, reply, option);
1136 if (ret != RET_OK) {
1137 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1138 }
1139 return ret;
1140 }
1141
MoveMouseEvent(int32_t offsetX,int32_t offsetY)1142 int32_t MultimodalInputConnectProxy::MoveMouseEvent(int32_t offsetX, int32_t offsetY)
1143 {
1144 CALL_DEBUG_ENTER;
1145 MessageParcel data;
1146 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1147 MMI_HILOGE("Failed to write descriptor");
1148 return ERR_INVALID_VALUE;
1149 }
1150 WRITEINT32(data, offsetX, ERR_INVALID_VALUE);
1151 WRITEINT32(data, offsetY, ERR_INVALID_VALUE);
1152
1153 MessageParcel reply;
1154 MessageOption option;
1155 sptr<IRemoteObject> remote = Remote();
1156 CHKPR(remote, RET_ERR);
1157 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::MOVE_MOUSE),
1158 data, reply, option);
1159 if (ret != RET_OK) {
1160 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1161 }
1162 return ret;
1163 }
1164
InjectKeyEvent(const std::shared_ptr<KeyEvent> keyEvent,bool isNativeInject)1165 int32_t MultimodalInputConnectProxy::InjectKeyEvent(const std::shared_ptr<KeyEvent> keyEvent, bool isNativeInject)
1166 {
1167 CALL_DEBUG_ENTER;
1168 CHKPR(keyEvent, ERR_INVALID_VALUE);
1169 MessageParcel data;
1170 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1171 MMI_HILOGE("Failed to write descriptor");
1172 return ERR_INVALID_VALUE;
1173 }
1174 if (!keyEvent->WriteToParcel(data)) {
1175 MMI_HILOGE("Failed to write inject event");
1176 return ERR_INVALID_VALUE;
1177 }
1178 WRITEBOOL(data, isNativeInject, ERR_INVALID_VALUE);
1179 MessageParcel reply;
1180 MessageOption option;
1181 sptr<IRemoteObject> remote = Remote();
1182 CHKPR(remote, RET_ERR);
1183 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::INJECT_KEY_EVENT),
1184 data, reply, option);
1185 if (ret != RET_OK) {
1186 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1187 }
1188 return ret;
1189 }
1190
SubscribeKeyEvent(int32_t subscribeId,const std::shared_ptr<KeyOption> keyOption)1191 int32_t MultimodalInputConnectProxy::SubscribeKeyEvent(int32_t subscribeId, const std::shared_ptr<KeyOption> keyOption)
1192 {
1193 CALL_DEBUG_ENTER;
1194 CHKPR(keyOption, ERR_INVALID_VALUE);
1195
1196 MessageParcel data;
1197 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1198 MMI_HILOGE("Failed to write descriptor");
1199 return ERR_INVALID_VALUE;
1200 }
1201 WRITEINT32(data, subscribeId, ERR_INVALID_VALUE);
1202 if (!keyOption->WriteToParcel(data)) {
1203 MMI_HILOGE("Failed to write key option");
1204 return ERR_INVALID_VALUE;
1205 }
1206
1207 MessageParcel reply;
1208 MessageOption option;
1209 sptr<IRemoteObject> remote = Remote();
1210 CHKPR(remote, RET_ERR);
1211 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SUBSCRIBE_KEY_EVENT),
1212 data, reply, option);
1213 if (ret != RET_OK) {
1214 MMI_HILOGE("Send request failed, result:%{public}d", ret);
1215 }
1216 return ret;
1217 }
1218
UnsubscribeKeyEvent(int32_t subscribeId)1219 int32_t MultimodalInputConnectProxy::UnsubscribeKeyEvent(int32_t subscribeId)
1220 {
1221 CALL_DEBUG_ENTER;
1222 MessageParcel data;
1223 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1224 MMI_HILOGE("Failed to write descriptor");
1225 return ERR_INVALID_VALUE;
1226 }
1227 WRITEINT32(data, subscribeId, ERR_INVALID_VALUE);
1228
1229 MessageParcel reply;
1230 MessageOption option;
1231 sptr<IRemoteObject> remote = Remote();
1232 CHKPR(remote, RET_ERR);
1233 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::UNSUBSCRIBE_KEY_EVENT),
1234 data, reply, option);
1235 if (ret != RET_OK) {
1236 MMI_HILOGE("Send request failed, result:%{public}d", ret);
1237 }
1238 return ret;
1239 }
1240
SubscribeSwitchEvent(int32_t subscribeId,int32_t switchType)1241 int32_t MultimodalInputConnectProxy::SubscribeSwitchEvent(int32_t subscribeId, int32_t switchType)
1242 {
1243 CALL_DEBUG_ENTER;
1244 MessageParcel data;
1245 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1246 MMI_HILOGE("Failed to write descriptor");
1247 return ERR_INVALID_VALUE;
1248 }
1249 WRITEINT32(data, subscribeId, ERR_INVALID_VALUE);
1250 WRITEINT32(data, switchType, ERR_INVALID_VALUE);
1251
1252 MessageParcel reply;
1253 MessageOption option;
1254 sptr<IRemoteObject> remote = Remote();
1255 CHKPR(remote, RET_ERR);
1256 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1257 SUBSCRIBE_SWITCH_EVENT), data, reply, option);
1258 if (ret != RET_OK) {
1259 MMI_HILOGE("Send request failed, result:%{public}d", ret);
1260 }
1261 return ret;
1262 }
1263
UnsubscribeSwitchEvent(int32_t subscribeId)1264 int32_t MultimodalInputConnectProxy::UnsubscribeSwitchEvent(int32_t subscribeId)
1265 {
1266 CALL_DEBUG_ENTER;
1267 MessageParcel data;
1268 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1269 MMI_HILOGE("Failed to write descriptor");
1270 return ERR_INVALID_VALUE;
1271 }
1272 WRITEINT32(data, subscribeId, ERR_INVALID_VALUE);
1273
1274 MessageParcel reply;
1275 MessageOption option;
1276 sptr<IRemoteObject> remote = Remote();
1277 CHKPR(remote, RET_ERR);
1278 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1279 UNSUBSCRIBE_SWITCH_EVENT), data, reply, option);
1280 if (ret != RET_OK) {
1281 MMI_HILOGE("Send request failed, result:%{public}d", ret);
1282 }
1283 return ret;
1284 }
1285
InjectPointerEvent(const std::shared_ptr<PointerEvent> pointerEvent,bool isNativeInject)1286 int32_t MultimodalInputConnectProxy::InjectPointerEvent(const std::shared_ptr<PointerEvent> pointerEvent,
1287 bool isNativeInject)
1288 {
1289 CHKPR(pointerEvent, ERR_INVALID_VALUE);
1290 MessageParcel data;
1291 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1292 MMI_HILOGE("Failed to write descriptor");
1293 return ERR_INVALID_VALUE;
1294 }
1295 if (!pointerEvent->WriteToParcel(data)) {
1296 MMI_HILOGE("Failed to write inject point event");
1297 return ERR_INVALID_VALUE;
1298 }
1299 WRITEBOOL(data, isNativeInject, ERR_INVALID_VALUE);
1300 MessageParcel reply;
1301 MessageOption option;
1302 sptr<IRemoteObject> remote = Remote();
1303 CHKPR(remote, RET_ERR);
1304 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::INJECT_POINTER_EVENT),
1305 data, reply, option);
1306 if (ret != RET_OK) {
1307 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1308 }
1309 return ret;
1310 }
1311
SetAnrObserver()1312 int32_t MultimodalInputConnectProxy::SetAnrObserver()
1313 {
1314 CALL_DEBUG_ENTER;
1315 MessageParcel data;
1316 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1317 MMI_HILOGE("Failed to write descriptor");
1318 return ERR_INVALID_VALUE;
1319 }
1320 MessageParcel reply;
1321 MessageOption option;
1322 sptr<IRemoteObject> remote = Remote();
1323 CHKPR(remote, RET_ERR);
1324 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_ANR_OBSERVER),
1325 data, reply, option);
1326 if (ret != RET_OK) {
1327 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1328 }
1329 return ret;
1330 }
1331
GetDisplayBindInfo(DisplayBindInfos & infos)1332 int32_t MultimodalInputConnectProxy::GetDisplayBindInfo(DisplayBindInfos &infos)
1333 {
1334 CALL_DEBUG_ENTER;
1335 MessageParcel data;
1336 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1337 MMI_HILOGE("Failed to write descriptor");
1338 return ERR_INVALID_VALUE;
1339 }
1340 MessageParcel reply;
1341 MessageOption option;
1342 sptr<IRemoteObject> remote = Remote();
1343 CHKPR(remote, RET_ERR);
1344 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_DISPLAY_BIND_INFO),
1345 data, reply, option);
1346 if (ret != RET_OK) {
1347 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1348 return ret;
1349 }
1350 int32_t size = 0;
1351 READINT32(reply, size, ERR_INVALID_VALUE);
1352 infos.reserve(size);
1353 for (int32_t i = 0; i < size; ++i) {
1354 DisplayBindInfo info;
1355 READINT32(reply, info.inputDeviceId, ERR_INVALID_VALUE);
1356 READSTRING(reply, info.inputDeviceName, ERR_INVALID_VALUE);
1357 READINT32(reply, info.displayId, ERR_INVALID_VALUE);
1358 READSTRING(reply, info.displayName, ERR_INVALID_VALUE);
1359 infos.push_back(info);
1360 }
1361 return RET_OK;
1362 }
1363
GetAllMmiSubscribedEvents(std::map<std::tuple<int32_t,int32_t,std::string>,int32_t> & datas)1364 int32_t MultimodalInputConnectProxy::GetAllMmiSubscribedEvents(std::map<std::tuple<int32_t, int32_t, std::string>,
1365 int32_t> &datas)
1366 {
1367 CALL_DEBUG_ENTER;
1368 MessageParcel data;
1369 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1370 MMI_HILOGE("Failed to write descriptor");
1371 return ERR_INVALID_VALUE;
1372 }
1373 MessageParcel reply;
1374 MessageOption option;
1375 sptr<IRemoteObject> remote = Remote();
1376 CHKPR(remote, RET_ERR);
1377 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1378 GET_ALL_NAPSTATUS_DATA), data, reply, option);
1379 if (ret != RET_OK) {
1380 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1381 return ret;
1382 }
1383 int32_t size = 0;
1384 READINT32(reply, size, ERR_INVALID_VALUE);
1385 for (int32_t i = 0; i < size; ++i) {
1386 NapProcess::NapStatusData data;
1387 int32_t syncState = 0;
1388 READINT32(reply, data.pid, ERR_INVALID_VALUE);
1389 READINT32(reply, data.uid, ERR_INVALID_VALUE);
1390 READSTRING(reply, data.bundleName, ERR_INVALID_VALUE);
1391 READINT32(reply, syncState, ERR_INVALID_VALUE);
1392 std::tuple<int32_t, int32_t, std::string> tuple(data.pid, data.uid, data.bundleName);
1393 datas.emplace(tuple, syncState);
1394 }
1395 return RET_OK;
1396 }
1397
SetDisplayBind(int32_t deviceId,int32_t displayId,std::string & msg)1398 int32_t MultimodalInputConnectProxy::SetDisplayBind(int32_t deviceId, int32_t displayId, std::string &msg)
1399 {
1400 CALL_DEBUG_ENTER;
1401 MessageParcel data;
1402 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1403 MMI_HILOGE("Failed to write descriptor");
1404 return ERR_INVALID_VALUE;
1405 }
1406
1407 WRITEINT32(data, deviceId, ERR_INVALID_VALUE);
1408 WRITEINT32(data, displayId, ERR_INVALID_VALUE);
1409
1410 MessageParcel reply;
1411 MessageOption option;
1412 sptr<IRemoteObject> remote = Remote();
1413 CHKPR(remote, RET_ERR);
1414 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_DISPLAY_BIND),
1415 data, reply, option);
1416 if (ret != RET_OK) {
1417 MMI_HILOGE("Send request fail, result:%{public}d", ret);
1418 }
1419 return ret;
1420 }
1421
GetWindowPid(int32_t windowId)1422 int32_t MultimodalInputConnectProxy::GetWindowPid(int32_t windowId)
1423 {
1424 CALL_DEBUG_ENTER;
1425 MessageParcel data;
1426 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1427 MMI_HILOGE("Failed to write descriptor");
1428 return ERR_INVALID_VALUE;
1429 }
1430
1431 WRITEINT32(data, windowId, ERR_INVALID_VALUE);
1432
1433 MessageParcel reply;
1434 MessageOption option;
1435 sptr<IRemoteObject> remote = Remote();
1436 CHKPR(remote, RET_ERR);
1437 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_WINDOW_PID),
1438 data, reply, option);
1439 if (ret != RET_OK) {
1440 MMI_HILOGE("Send request fail, result:%{public}d", ret);
1441 return ret;
1442 }
1443 int32_t windowPid = INVALID_PID;
1444 READINT32(reply, windowPid, ERR_INVALID_VALUE);
1445 return windowPid;
1446 }
1447
GetFunctionKeyState(int32_t funcKey,bool & state)1448 int32_t MultimodalInputConnectProxy::GetFunctionKeyState(int32_t funcKey, bool &state)
1449 {
1450 CALL_DEBUG_ENTER;
1451 MessageParcel data;
1452 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1453 MMI_HILOGE("Failed to write descriptor");
1454 return ERR_INVALID_VALUE;
1455 }
1456 MessageParcel reply;
1457 MessageOption option;
1458 WRITEINT32(data, funcKey, ERR_INVALID_VALUE);
1459 sptr<IRemoteObject> remote = Remote();
1460 CHKPR(remote, RET_ERR);
1461 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1462 GET_FUNCTION_KEY_STATE), data, reply, option);
1463 if (ret != RET_OK) {
1464 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1465 return ret;
1466 }
1467 READBOOL(reply, state, ERR_INVALID_VALUE);
1468 return RET_OK;
1469 }
1470
SetFunctionKeyState(int32_t funcKey,bool enable)1471 int32_t MultimodalInputConnectProxy::SetFunctionKeyState(int32_t funcKey, bool enable)
1472 {
1473 CALL_DEBUG_ENTER;
1474 MessageParcel data;
1475 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1476 MMI_HILOGE("Failed to write descriptor");
1477 return ERR_INVALID_VALUE;
1478 }
1479 MessageParcel reply;
1480 MessageOption option;
1481 WRITEINT32(data, funcKey, ERR_INVALID_VALUE);
1482 WRITEBOOL(data, enable, ERR_INVALID_VALUE);
1483 sptr<IRemoteObject> remote = Remote();
1484 CHKPR(remote, RET_ERR);
1485 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1486 SET_FUNCTION_KEY_STATE), data, reply, option);
1487 if (ret != RET_OK) {
1488 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1489 }
1490 return ret;
1491 }
1492
SetPointerLocation(int32_t x,int32_t y)1493 int32_t MultimodalInputConnectProxy::SetPointerLocation(int32_t x, int32_t y)
1494 {
1495 CALL_DEBUG_ENTER;
1496 MessageParcel data;
1497 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1498 MMI_HILOGE("Failed to write descriptor");
1499 return ERR_INVALID_VALUE;
1500 }
1501 MessageParcel reply;
1502 MessageOption option;
1503 WRITEINT32(data, x, ERR_INVALID_VALUE);
1504 WRITEINT32(data, y, ERR_INVALID_VALUE);
1505 sptr<IRemoteObject> remote = Remote();
1506 CHKPR(remote, RET_ERR);
1507 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_POINTER_LOCATION),
1508 data, reply, option);
1509 if (ret != RET_OK) {
1510 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1511 }
1512 return ret;
1513 }
1514
SetMouseCaptureMode(int32_t windowId,bool isCaptureMode)1515 int32_t MultimodalInputConnectProxy::SetMouseCaptureMode(int32_t windowId, bool isCaptureMode)
1516 {
1517 CALL_DEBUG_ENTER;
1518 MessageParcel data;
1519 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1520 MMI_HILOGE("Failed to write descriptor");
1521 return ERR_INVALID_VALUE;
1522 }
1523 WRITEINT32(data, windowId, ERR_INVALID_VALUE);
1524 WRITEBOOL(data, isCaptureMode, ERR_INVALID_VALUE);
1525 MessageParcel reply;
1526 MessageOption option;
1527 sptr<IRemoteObject> remote = Remote();
1528 CHKPR(remote, RET_ERR);
1529 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_CAPTURE_MODE),
1530 data, reply, option);
1531 if (ret != RET_OK) {
1532 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
1533 }
1534 return ret;
1535 }
1536
AppendExtraData(const ExtraData & extraData)1537 int32_t MultimodalInputConnectProxy::AppendExtraData(const ExtraData& extraData)
1538 {
1539 CALL_DEBUG_ENTER;
1540 MessageParcel data;
1541 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1542 MMI_HILOGE("Failed to write descriptor");
1543 return ERR_INVALID_VALUE;
1544 }
1545 WRITEBOOL(data, extraData.appended, ERR_INVALID_VALUE);
1546 WRITEINT32(data, static_cast<int32_t>(extraData.buffer.size()));
1547 for (const auto &item : extraData.buffer) {
1548 WRITEUINT8(data, item);
1549 }
1550 WRITEINT32(data, extraData.sourceType, ERR_INVALID_VALUE);
1551 WRITEINT32(data, extraData.pointerId, ERR_INVALID_VALUE);
1552 WRITEINT32(data, extraData.pullId, ERR_INVALID_VALUE);
1553 MessageParcel reply;
1554 MessageOption option;
1555 sptr<IRemoteObject> remote = Remote();
1556 CHKPR(remote, RET_ERR);
1557 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::APPEND_EXTRA_DATA),
1558 data, reply, option);
1559 if (ret != RET_OK) {
1560 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
1561 }
1562 return ret;
1563 }
1564
EnableCombineKey(bool enable)1565 int32_t MultimodalInputConnectProxy::EnableCombineKey(bool enable)
1566 {
1567 CALL_DEBUG_ENTER;
1568 MessageParcel data;
1569 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1570 MMI_HILOGE("Failed to write descriptor");
1571 return ERR_INVALID_VALUE;
1572 }
1573 WRITEBOOL(data, enable, ERR_INVALID_VALUE);
1574 MessageParcel reply;
1575 MessageOption option;
1576 sptr<IRemoteObject> remote = Remote();
1577 CHKPR(remote, RET_ERR);
1578 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::ENABLE_COMBINE_KEY),
1579 data, reply, option);
1580 if (ret != RET_OK) {
1581 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
1582 }
1583 return ret;
1584 }
1585
EnableInputDevice(bool enable)1586 int32_t MultimodalInputConnectProxy::EnableInputDevice(bool enable)
1587 {
1588 CALL_DEBUG_ENTER;
1589 MessageParcel data;
1590 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1591 MMI_HILOGE("Failed to write descriptor");
1592 return ERR_INVALID_VALUE;
1593 }
1594 WRITEBOOL(data, enable, ERR_INVALID_VALUE);
1595 MessageParcel reply;
1596 MessageOption option;
1597 sptr<IRemoteObject> remote = Remote();
1598 CHKPR(remote, RET_ERR);
1599 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::ENABLE_INPUT_DEVICE),
1600 data, reply, option);
1601 if (ret != RET_OK) {
1602 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
1603 }
1604 return ret;
1605 }
1606
SetKeyDownDuration(const std::string & businessId,int32_t delay)1607 int32_t MultimodalInputConnectProxy::SetKeyDownDuration(const std::string &businessId, int32_t delay)
1608 {
1609 CALL_DEBUG_ENTER;
1610 MessageParcel data;
1611 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1612 MMI_HILOGE("Failed to write descriptor");
1613 return ERR_INVALID_VALUE;
1614 }
1615 WRITESTRING(data, businessId, ERR_INVALID_VALUE);
1616 WRITEINT32(data, delay, ERR_INVALID_VALUE);
1617 MessageParcel reply;
1618 MessageOption option;
1619 sptr<IRemoteObject> remote = Remote();
1620 CHKPR(remote, RET_ERR);
1621 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_KEY_DOWN_DURATION),
1622 data, reply, option);
1623 if (ret != RET_OK) {
1624 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1625 }
1626 return ret;
1627 }
1628
SetTouchpadBoolData(bool switchFlag,int32_t type)1629 int32_t MultimodalInputConnectProxy::SetTouchpadBoolData(bool switchFlag, int32_t type)
1630 {
1631 CALL_DEBUG_ENTER;
1632 MessageParcel data;
1633 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1634 MMI_HILOGE("Failed to write descriptor");
1635 return ERR_INVALID_VALUE;
1636 }
1637
1638 WRITEBOOL(data, switchFlag, ERR_INVALID_VALUE);
1639
1640 MessageParcel reply;
1641 MessageOption option;
1642 sptr<IRemoteObject> remote = Remote();
1643 CHKPR(remote, RET_ERR);
1644 int32_t ret = remote->SendRequest(type, data, reply, option);
1645 if (ret != RET_OK) {
1646 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1647 }
1648 return ret;
1649 }
1650
GetTouchpadBoolData(bool & switchFlag,int32_t type)1651 int32_t MultimodalInputConnectProxy::GetTouchpadBoolData(bool &switchFlag, int32_t type)
1652 {
1653 CALL_DEBUG_ENTER;
1654 MessageParcel data;
1655 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1656 MMI_HILOGE("Failed to write descriptor");
1657 return ERR_INVALID_VALUE;
1658 }
1659 MessageParcel reply;
1660 MessageOption option;
1661 sptr<IRemoteObject> remote = Remote();
1662 CHKPR(remote, RET_ERR);
1663 int32_t ret = remote->SendRequest(type, data, reply, option);
1664 if (ret != RET_OK) {
1665 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1666 return ret;
1667 }
1668 READBOOL(reply, switchFlag, IPC_PROXY_DEAD_OBJECT_ERR);
1669 return RET_OK;
1670 }
1671
SetTouchpadInt32Data(int32_t value,int32_t type)1672 int32_t MultimodalInputConnectProxy::SetTouchpadInt32Data(int32_t value, int32_t type)
1673 {
1674 CALL_DEBUG_ENTER;
1675 MessageParcel data;
1676 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1677 MMI_HILOGE("Failed to write descriptor");
1678 return ERR_INVALID_VALUE;
1679 }
1680
1681 WRITEINT32(data, value, ERR_INVALID_VALUE);
1682
1683 MessageParcel reply;
1684 MessageOption option;
1685 sptr<IRemoteObject> remote = Remote();
1686 CHKPR(remote, RET_ERR);
1687 int32_t ret = remote->SendRequest(type, data, reply, option);
1688 if (ret != RET_OK) {
1689 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1690 }
1691 return ret;
1692 }
1693
GetTouchpadInt32Data(int32_t & value,int32_t type)1694 int32_t MultimodalInputConnectProxy::GetTouchpadInt32Data(int32_t &value, int32_t type)
1695 {
1696 CALL_DEBUG_ENTER;
1697 MessageParcel data;
1698 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1699 MMI_HILOGE("Failed to write descriptor");
1700 return ERR_INVALID_VALUE;
1701 }
1702 MessageParcel reply;
1703 MessageOption option;
1704 sptr<IRemoteObject> remote = Remote();
1705 CHKPR(remote, RET_ERR);
1706 int32_t ret = remote->SendRequest(type, data, reply, option);
1707 if (ret != RET_OK) {
1708 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1709 return ret;
1710 }
1711 READINT32(reply, value, IPC_PROXY_DEAD_OBJECT_ERR);
1712 return RET_OK;
1713 }
1714
SetTouchpadScrollSwitch(bool switchFlag)1715 int32_t MultimodalInputConnectProxy::SetTouchpadScrollSwitch(bool switchFlag)
1716 {
1717 return SetTouchpadBoolData(switchFlag, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1718 SET_TP_SCROLL_SWITCH));
1719 }
1720
GetTouchpadScrollSwitch(bool & switchFlag)1721 int32_t MultimodalInputConnectProxy::GetTouchpadScrollSwitch(bool &switchFlag)
1722 {
1723 return GetTouchpadBoolData(switchFlag, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1724 GET_TP_SCROLL_SWITCH));
1725 }
1726
SetTouchpadScrollDirection(bool state)1727 int32_t MultimodalInputConnectProxy::SetTouchpadScrollDirection(bool state)
1728 {
1729 return SetTouchpadBoolData(state, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1730 SET_TP_SCROLL_DIRECT_SWITCH));
1731 }
1732
GetTouchpadScrollDirection(bool & switchFlag)1733 int32_t MultimodalInputConnectProxy::GetTouchpadScrollDirection(bool &switchFlag)
1734 {
1735 return GetTouchpadBoolData(switchFlag, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1736 GET_TP_SCROLL_DIRECT_SWITCH));
1737 }
1738
SetTouchpadTapSwitch(bool switchFlag)1739 int32_t MultimodalInputConnectProxy::SetTouchpadTapSwitch(bool switchFlag)
1740 {
1741 return SetTouchpadBoolData(switchFlag, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1742 SET_TP_TAP_SWITCH));
1743 }
1744
GetTouchpadTapSwitch(bool & switchFlag)1745 int32_t MultimodalInputConnectProxy::GetTouchpadTapSwitch(bool &switchFlag)
1746 {
1747 return GetTouchpadBoolData(switchFlag, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1748 GET_TP_TAP_SWITCH));
1749 }
1750
SetTouchpadPointerSpeed(int32_t speed)1751 int32_t MultimodalInputConnectProxy::SetTouchpadPointerSpeed(int32_t speed)
1752 {
1753 return SetTouchpadInt32Data(speed, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1754 SET_TP_POINTER_SPEED));
1755 }
1756
GetTouchpadPointerSpeed(int32_t & speed)1757 int32_t MultimodalInputConnectProxy::GetTouchpadPointerSpeed(int32_t &speed)
1758 {
1759 return GetTouchpadInt32Data(speed, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1760 GET_TP_POINTER_SPEED));
1761 }
1762
SetTouchpadPinchSwitch(bool switchFlag)1763 int32_t MultimodalInputConnectProxy::SetTouchpadPinchSwitch(bool switchFlag)
1764 {
1765 return SetTouchpadBoolData(switchFlag, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1766 SET_TP_PINCH_SWITCH));
1767 }
1768
GetTouchpadPinchSwitch(bool & switchFlag)1769 int32_t MultimodalInputConnectProxy::GetTouchpadPinchSwitch(bool &switchFlag)
1770 {
1771 return GetTouchpadBoolData(switchFlag, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1772 GET_TP_PINCH_SWITCH));
1773 }
1774
SetTouchpadSwipeSwitch(bool switchFlag)1775 int32_t MultimodalInputConnectProxy::SetTouchpadSwipeSwitch(bool switchFlag)
1776 {
1777 return SetTouchpadBoolData(switchFlag, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1778 SET_TP_SWIPE_SWITCH));
1779 }
1780
GetTouchpadSwipeSwitch(bool & switchFlag)1781 int32_t MultimodalInputConnectProxy::GetTouchpadSwipeSwitch(bool &switchFlag)
1782 {
1783 return GetTouchpadBoolData(switchFlag, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1784 GET_TP_SWIPE_SWITCH));
1785 }
1786
SetTouchpadRightClickType(int32_t type)1787 int32_t MultimodalInputConnectProxy::SetTouchpadRightClickType(int32_t type)
1788 {
1789 return SetTouchpadInt32Data(type, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1790 SET_TP_RIGHT_CLICK_TYPE));
1791 }
1792
GetTouchpadRightClickType(int32_t & type)1793 int32_t MultimodalInputConnectProxy::GetTouchpadRightClickType(int32_t &type)
1794 {
1795 return GetTouchpadInt32Data(type, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1796 GET_TP_RIGHT_CLICK_TYPE));
1797 }
1798
SetTouchpadRotateSwitch(bool rotateSwitch)1799 int32_t MultimodalInputConnectProxy::SetTouchpadRotateSwitch(bool rotateSwitch)
1800 {
1801 return SetTouchpadBoolData(rotateSwitch, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1802 SET_TP_ROTATE_SWITCH));
1803 }
1804
GetTouchpadRotateSwitch(bool & rotateSwitch)1805 int32_t MultimodalInputConnectProxy::GetTouchpadRotateSwitch(bool &rotateSwitch)
1806 {
1807 return GetTouchpadBoolData(rotateSwitch, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1808 GET_TP_ROTATE_SWITCH));
1809 }
1810
SetTouchpadDoubleTapAndDragState(bool switchFlag)1811 int32_t MultimodalInputConnectProxy::SetTouchpadDoubleTapAndDragState(bool switchFlag)
1812 {
1813 return SetTouchpadBoolData(switchFlag, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1814 SET_DOUBLE_TAP_DRAG_STATE));
1815 }
1816
GetTouchpadDoubleTapAndDragState(bool & switchFlag)1817 int32_t MultimodalInputConnectProxy::GetTouchpadDoubleTapAndDragState(bool &switchFlag)
1818 {
1819 return GetTouchpadBoolData(switchFlag, static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1820 GET_DOUBLE_TAP_DRAG_STATE));
1821 }
1822
SetShieldStatus(int32_t shieldMode,bool isShield)1823 int32_t MultimodalInputConnectProxy::SetShieldStatus(int32_t shieldMode, bool isShield)
1824 {
1825 CALL_DEBUG_ENTER;
1826 MessageParcel data;
1827 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1828 MMI_HILOGE("Failed to write descriptor");
1829 return ERR_INVALID_VALUE;
1830 }
1831
1832 WRITEINT32(data, shieldMode, ERR_INVALID_VALUE);
1833 WRITEBOOL(data, isShield, ERR_INVALID_VALUE);
1834
1835 MessageParcel reply;
1836 MessageOption option;
1837 sptr<IRemoteObject> remote = Remote();
1838 CHKPR(remote, RET_ERR);
1839 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_SHIELD_STATUS),
1840 data, reply, option);
1841 if (ret != RET_OK) {
1842 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1843 }
1844 return ret;
1845 }
1846
GetShieldStatus(int32_t shieldMode,bool & isShield)1847 int32_t MultimodalInputConnectProxy::GetShieldStatus(int32_t shieldMode, bool &isShield)
1848 {
1849 CALL_DEBUG_ENTER;
1850 MessageParcel data;
1851 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1852 MMI_HILOGE("Failed to write descriptor");
1853 return ERR_INVALID_VALUE;
1854 }
1855 MessageParcel reply;
1856 MessageOption option;
1857 WRITEINT32(data, shieldMode, ERR_INVALID_VALUE);
1858 sptr<IRemoteObject> remote = Remote();
1859 CHKPR(remote, RET_ERR);
1860 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::
1861 GET_SHIELD_STATUS), data, reply, option);
1862 if (ret != RET_OK) {
1863 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1864 return ret;
1865 }
1866 READBOOL(reply, isShield, ERR_INVALID_VALUE);
1867 return RET_OK;
1868 }
1869
GetKeyState(std::vector<int32_t> & pressedKeys,std::map<int32_t,int32_t> & specialKeysState)1870 int32_t MultimodalInputConnectProxy::GetKeyState(std::vector<int32_t> &pressedKeys,
1871 std::map<int32_t, int32_t> &specialKeysState)
1872 {
1873 CALL_DEBUG_ENTER;
1874 MessageParcel data;
1875 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1876 MMI_HILOGE("Failed to write descriptor");
1877 return RET_ERR;
1878 }
1879 MessageParcel reply;
1880 MessageOption option;
1881 sptr<IRemoteObject> remote = Remote();
1882 CHKPR(remote, RET_ERR);
1883 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_KEY_STATE),
1884 data, reply, option);
1885 if (ret != RET_OK) {
1886 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1887 return ret;
1888 }
1889 if (!reply.ReadInt32Vector(&pressedKeys)) {
1890 MMI_HILOGE("Read vector failed");
1891 return RET_ERR;
1892 }
1893 MMI_HILOGD("pressedKeys size:%{public}zu", pressedKeys.size());
1894 std::vector<int32_t> specialKeysStateTmp;
1895 if (!reply.ReadInt32Vector(&specialKeysStateTmp)) {
1896 MMI_HILOGE("Read vector failed");
1897 return RET_ERR;
1898 }
1899 if (specialKeysStateTmp.size() != SPECIAL_KEY_SIZE) {
1900 MMI_HILOGE("The number of special key is not three");
1901 return RET_ERR;
1902 }
1903 specialKeysState[KeyEvent::KEYCODE_CAPS_LOCK] = specialKeysStateTmp[SPECIAL_ARRAY_INDEX0];
1904 specialKeysState[KeyEvent::KEYCODE_SCROLL_LOCK] = specialKeysStateTmp[SPECIAL_ARRAY_INDEX1];
1905 specialKeysState[KeyEvent::KEYCODE_NUM_LOCK] = specialKeysStateTmp[SPECIAL_ARRAY_INDEX2];
1906 return RET_OK;
1907 }
1908
Authorize(bool isAuthorize)1909 int32_t MultimodalInputConnectProxy::Authorize(bool isAuthorize)
1910 {
1911 CALL_DEBUG_ENTER;
1912 MessageParcel data;
1913 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1914 MMI_HILOGE("Failed to write descriptor");
1915 return ERR_INVALID_VALUE;
1916 }
1917 WRITEBOOL(data, isAuthorize, ERR_INVALID_VALUE);
1918 MessageParcel reply;
1919 MessageOption option;
1920 sptr<IRemoteObject> remote = Remote();
1921 CHKPR(remote, RET_ERR);
1922 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::NATIVE_AUTHORIZE),
1923 data, reply, option);
1924 if (ret != RET_OK) {
1925 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1926 }
1927 return ret;
1928 }
1929
CancelInjection()1930 int32_t MultimodalInputConnectProxy::CancelInjection()
1931 {
1932 CALL_DEBUG_ENTER;
1933 MessageParcel data;
1934 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1935 MMI_HILOGE("Failed to write descriptor");
1936 return ERR_INVALID_VALUE;
1937 }
1938 MessageParcel reply;
1939 MessageOption option;
1940 sptr<IRemoteObject> remote = Remote();
1941 CHKPR(remote, RET_ERR);
1942 int32_t ret = remote->SendRequest(
1943 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::NATIVE_CANCEL_INJECTION), data, reply, option);
1944 if (ret != RET_OK) {
1945 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
1946 }
1947 return ret;
1948 }
1949
SetPixelMapData(int32_t infoId,void * pixelMap)1950 int32_t MultimodalInputConnectProxy::SetPixelMapData(int32_t infoId, void* pixelMap)
1951 __attribute__((no_sanitize("cfi")))
1952 {
1953 CALL_DEBUG_ENTER;
1954 if (infoId < 0 || pixelMap == nullptr) {
1955 MMI_HILOGE("Invalid infoId or pixelMap");
1956 return RET_ERR;
1957 }
1958 OHOS::Media::PixelMap* pixelMapPtr = static_cast<OHOS::Media::PixelMap*>(pixelMap);
1959 if (pixelMapPtr->GetCapacity() == 0) {
1960 MMI_HILOGE("pixelMap is empty");
1961 return RET_ERR;
1962 }
1963 MMI_HILOGD("byteCount:%{public}d, width:%{public}d, height:%{public}d",
1964 pixelMapPtr->GetByteCount(), pixelMapPtr->GetWidth(), pixelMapPtr->GetHeight());
1965
1966 MessageParcel data;
1967 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1968 MMI_HILOGE("Failed to write descriptor");
1969 return ERR_INVALID_VALUE;
1970 }
1971 WRITEINT32(data, infoId, ERR_INVALID_VALUE);
1972 pixelMapPtr->Marshalling(data);
1973
1974 MessageParcel reply;
1975 MessageOption option;
1976 sptr<IRemoteObject> remote = Remote();
1977 CHKPR(remote, RET_ERR);
1978 int32_t ret = remote->SendRequest(
1979 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_PIXEL_MAP_DATA), data, reply, option);
1980 if (ret != RET_OK) {
1981 MMI_HILOGE("Failed to send request, ret:%{public}d", ret);
1982 }
1983 return ret;
1984 }
1985
HasIrEmitter(bool & hasIrEmitter)1986 int32_t MultimodalInputConnectProxy::HasIrEmitter(bool &hasIrEmitter)
1987 {
1988 CALL_DEBUG_ENTER;
1989 MessageParcel data;
1990 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
1991 MMI_HILOGE("Failed to write descriptor");
1992 return ERR_INVALID_VALUE;
1993 }
1994 MessageParcel reply;
1995 MessageOption option;
1996 sptr<IRemoteObject> remote = Remote();
1997 CHKPR(remote, RET_ERR);
1998 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::NATIVE_INFRARED_OWN),
1999 data, reply, option);
2000 READBOOL(reply, hasIrEmitter, IPC_PROXY_DEAD_OBJECT_ERR);
2001 if (ret != RET_OK) {
2002 MMI_HILOGE("MultimodalInputConnectProxy::HasIrEmitter Send request fail, ret:%{public}d", ret);
2003 return ret;
2004 }
2005 return RET_OK;
2006 }
2007
GetInfraredFrequencies(std::vector<InfraredFrequency> & requencys)2008 int32_t MultimodalInputConnectProxy::GetInfraredFrequencies(std::vector<InfraredFrequency>& requencys)
2009 {
2010 CALL_DEBUG_ENTER;
2011 MessageParcel data;
2012 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2013 MMI_HILOGE("Failed to write descriptor");
2014 return ERR_INVALID_VALUE;
2015 }
2016 MessageParcel reply;
2017 MessageOption option;
2018 sptr<IRemoteObject> remote = Remote();
2019 CHKPR(remote, RET_ERR);
2020 int32_t ret = remote->SendRequest(static_cast<uint32_t>(
2021 MultimodalinputConnectInterfaceCode::NATIVE_INFRARED_FREQUENCY),
2022 data, reply, option);
2023 if (ret != RET_OK) {
2024 MMI_HILOGE("MultimodalInputConnectProxy::GetInfraredFrequencies Send request fail, ret:%{public}d", ret);
2025 return ret;
2026 }
2027 int64_t number;
2028 READINT64(reply, number, IPC_PROXY_DEAD_OBJECT_ERR);
2029 int64_t min = 0;
2030 int64_t max = 0;
2031 for (int32_t i = 0; i < number; i++) {
2032 READINT64(reply, max);
2033 READINT64(reply, min);
2034 InfraredFrequency item;
2035 item.max_ = max;
2036 item.min_ = min;
2037 requencys.push_back(item);
2038 }
2039 return ret;
2040 }
2041
TransmitInfrared(int64_t number,std::vector<int64_t> & pattern)2042 int32_t MultimodalInputConnectProxy::TransmitInfrared(int64_t number, std::vector<int64_t>& pattern)
2043 {
2044 CALL_DEBUG_ENTER;
2045 MessageParcel data;
2046 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2047 MMI_HILOGE("Failed to write descriptor");
2048 return ERR_INVALID_VALUE;
2049 }
2050 WRITEINT64(data, number, ERR_INVALID_VALUE);
2051 WRITEINT32(data, static_cast<int64_t>(pattern.size()), ERR_INVALID_VALUE);
2052 for (const auto &item : pattern) {
2053 WRITEINT64(data, item);
2054 }
2055 MessageParcel reply;
2056 MessageOption option;
2057 sptr<IRemoteObject> remote = Remote();
2058 CHKPR(remote, RET_ERR);
2059 int32_t ret = remote->SendRequest(static_cast<uint32_t>(
2060 MultimodalinputConnectInterfaceCode::NATIVE_CANCEL_TRANSMIT),
2061 data, reply, option);
2062 if (ret != RET_OK) {
2063 MMI_HILOGE("MultimodalInputConnectProxy::TransmitInfrared Send request fail, ret:%{public}d", ret);
2064 return ret;
2065 }
2066 return RET_OK;
2067 }
2068
SetCurrentUser(int32_t userId)2069 int32_t MultimodalInputConnectProxy::SetCurrentUser(int32_t userId)
2070 {
2071 CALL_DEBUG_ENTER;
2072 MessageParcel data;
2073 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2074 MMI_HILOGE("Failed to write descriptor");
2075 return ERR_INVALID_VALUE;
2076 }
2077 WRITEINT32(data, userId, ERR_INVALID_VALUE);
2078 MessageParcel reply;
2079 MessageOption option;
2080 sptr<IRemoteObject> remote = Remote();
2081 CHKPR(remote, RET_ERR);
2082 int32_t ret = remote->SendRequest(
2083 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_CURRENT_USERID), data, reply, option);
2084 if (ret != RET_OK) {
2085 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
2086 return ret;
2087 }
2088 return RET_OK;
2089 }
2090
AddVirtualInputDevice(std::shared_ptr<InputDevice> device,int32_t & deviceId)2091 int32_t MultimodalInputConnectProxy::AddVirtualInputDevice(std::shared_ptr<InputDevice> device, int32_t &deviceId)
2092 {
2093 CALL_DEBUG_ENTER;
2094 CHKPR(device, ERROR_NULL_POINTER);
2095 MessageParcel data;
2096 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2097 MMI_HILOGE("Failed to write descriptor");
2098 return ERR_INVALID_VALUE;
2099 }
2100 auto axisInfo = device->GetAxisInfo();
2101 if (axisInfo.size() > MAX_AXIS_INFO) {
2102 return RET_ERR;
2103 }
2104 WRITEINT32(data, device->GetId(), IPC_STUB_WRITE_PARCEL_ERR);
2105 WRITEINT32(data, device->GetType(), IPC_STUB_WRITE_PARCEL_ERR);
2106 WRITESTRING(data, device->GetName(), IPC_STUB_WRITE_PARCEL_ERR);
2107 WRITEINT32(data, device->GetBus(), IPC_STUB_WRITE_PARCEL_ERR);
2108 WRITEINT32(data, device->GetVersion(), IPC_STUB_WRITE_PARCEL_ERR);
2109 WRITEINT32(data, device->GetProduct(), IPC_STUB_WRITE_PARCEL_ERR);
2110 WRITEINT32(data, device->GetVendor(), IPC_STUB_WRITE_PARCEL_ERR);
2111 WRITESTRING(data, device->GetPhys(), IPC_STUB_WRITE_PARCEL_ERR);
2112 WRITESTRING(data, device->GetUniq(), IPC_STUB_WRITE_PARCEL_ERR);
2113 WRITEUINT64(data, static_cast<uint64_t>(device->GetCapabilities()), IPC_STUB_WRITE_PARCEL_ERR);
2114 WRITEUINT32(data, static_cast<uint32_t>(axisInfo.size()), IPC_STUB_WRITE_PARCEL_ERR);
2115 for (const auto &item : axisInfo) {
2116 WRITEINT32(data, item.GetMinimum(), IPC_STUB_WRITE_PARCEL_ERR);
2117 WRITEINT32(data, item.GetMaximum(), IPC_STUB_WRITE_PARCEL_ERR);
2118 WRITEINT32(data, item.GetAxisType(), IPC_STUB_WRITE_PARCEL_ERR);
2119 WRITEINT32(data, item.GetFuzz(), IPC_STUB_WRITE_PARCEL_ERR);
2120 WRITEINT32(data, item.GetFlat(), IPC_STUB_WRITE_PARCEL_ERR);
2121 WRITEINT32(data, item.GetResolution(), IPC_STUB_WRITE_PARCEL_ERR);
2122 }
2123 sptr<IRemoteObject> remote = Remote();
2124 CHKPR(remote, RET_ERR);
2125 MessageParcel reply;
2126 MessageOption option;
2127 int32_t ret = remote->SendRequest(
2128 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::ADD_VIRTUAL_INPUT_DEVICE), data, reply, option);
2129 if (ret != RET_OK) {
2130 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
2131 return RET_ERR;
2132 }
2133 READINT32(reply, deviceId, IPC_PROXY_DEAD_OBJECT_ERR);
2134 return ret;
2135 }
2136
RemoveVirtualInputDevice(int32_t deviceId)2137 int32_t MultimodalInputConnectProxy::RemoveVirtualInputDevice(int32_t deviceId)
2138 {
2139 CALL_DEBUG_ENTER;
2140 MessageParcel data;
2141 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2142 MMI_HILOGE("Failed to write descriptor");
2143 return ERR_INVALID_VALUE;
2144 }
2145 WRITEINT32(data, deviceId, ERR_INVALID_VALUE);
2146 MessageParcel reply;
2147 MessageOption option;
2148 sptr<IRemoteObject> remote = Remote();
2149 CHKPR(remote, RET_ERR);
2150 int32_t ret = remote->SendRequest(
2151 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::REMOVE_VIRTUAL_INPUT_DEVICE), data, reply, option);
2152 if (ret != RET_OK) {
2153 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
2154 return ret;
2155 }
2156 READINT32(reply, ret, IPC_PROXY_DEAD_OBJECT_ERR);
2157 return ret;
2158 }
2159
EnableHardwareCursorStats(bool enable)2160 int32_t MultimodalInputConnectProxy::EnableHardwareCursorStats(bool enable)
2161 {
2162 CALL_DEBUG_ENTER;
2163 MessageParcel data;
2164 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2165 MMI_HILOGE("Failed to write descriptor");
2166 return ERR_INVALID_VALUE;
2167 }
2168
2169 WRITEBOOL(data, enable, ERR_INVALID_VALUE);
2170
2171 MessageParcel reply;
2172 MessageOption option;
2173 sptr<IRemoteObject> remote = Remote();
2174 CHKPR(remote, RET_ERR);
2175 int32_t ret = remote->SendRequest(
2176 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::ENABLE_HARDWARE_CURSOR_STATS), data, reply, option);
2177 if (ret != RET_OK) {
2178 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
2179 }
2180 return ret;
2181 }
2182
GetHardwareCursorStats(uint32_t & frameCount,uint32_t & vsyncCount)2183 int32_t MultimodalInputConnectProxy::GetHardwareCursorStats(uint32_t &frameCount, uint32_t &vsyncCount)
2184 {
2185 CALL_DEBUG_ENTER;
2186 MessageParcel data;
2187 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2188 MMI_HILOGE("Failed to write descriptor");
2189 return ERR_INVALID_VALUE;
2190 }
2191 MessageParcel reply;
2192 MessageOption option;
2193 sptr<IRemoteObject> remote = Remote();
2194 CHKPR(remote, RET_ERR);
2195 int32_t ret = remote->SendRequest(
2196 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_HARDWARE_CURSOR_STATS), data, reply, option);
2197 if (ret != RET_OK) {
2198 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
2199 return ret;
2200 }
2201 READUINT32(reply, frameCount, IPC_PROXY_DEAD_OBJECT_ERR);
2202 READUINT32(reply, vsyncCount, IPC_PROXY_DEAD_OBJECT_ERR);
2203 return ret;
2204 }
2205
2206 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
GetPointerSnapshot(void * pixelMapPtr)2207 int32_t MultimodalInputConnectProxy::GetPointerSnapshot(void *pixelMapPtr)
2208 {
2209 CALL_DEBUG_ENTER;
2210 CHKPR(pixelMapPtr, ERR_INVALID_VALUE);
2211 std::shared_ptr<Media::PixelMap> *newPixelMapPtr = static_cast<std::shared_ptr<Media::PixelMap> *>(pixelMapPtr);
2212 MessageParcel data;
2213 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2214 MMI_HILOGE("Failed to write descriptor");
2215 return ERR_INVALID_VALUE;
2216 }
2217 MessageParcel reply;
2218 MessageOption option;
2219 sptr<IRemoteObject> remote = Remote();
2220 CHKPR(remote, RET_ERR);
2221 int32_t ret = remote->SendRequest(
2222 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_POINTER_SNAPSHOT), data, reply, option);
2223 if (ret != RET_OK) {
2224 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
2225 }
2226 (*newPixelMapPtr).reset(Media::PixelMap::Unmarshalling(reply));
2227 CHKPR(*newPixelMapPtr, RET_ERR);
2228 return ret;
2229 }
2230 #endif // OHOS_BUILD_ENABLE_MAGICCURSOR
2231
2232 #ifdef OHOS_BUILD_ENABLE_ANCO
AncoAddChannel(sptr<IAncoChannel> channel)2233 int32_t MultimodalInputConnectProxy::AncoAddChannel(sptr<IAncoChannel> channel)
2234 {
2235 CALL_DEBUG_ENTER;
2236 MessageParcel data;
2237 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2238 MMI_HILOGE("Failed to write descriptor");
2239 return ERR_INVALID_VALUE;
2240 }
2241 if (!data.WriteRemoteObject(channel->AsObject())) {
2242 MMI_HILOGE("Failed to write IRemoteObject");
2243 return ERR_INVALID_VALUE;
2244 }
2245 MessageParcel reply;
2246 MessageOption option;
2247 sptr<IRemoteObject> remote = Remote();
2248 CHKPR(remote, RET_ERR);
2249 int32_t ret = remote->SendRequest(
2250 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::ADD_ANCO_CHANNEL), data, reply, option);
2251 if (ret != RET_OK) {
2252 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
2253 return ret;
2254 }
2255 READINT32(reply, ret, IPC_PROXY_DEAD_OBJECT_ERR);
2256 return ret;
2257 }
2258
AncoRemoveChannel(sptr<IAncoChannel> channel)2259 int32_t MultimodalInputConnectProxy::AncoRemoveChannel(sptr<IAncoChannel> channel)
2260 {
2261 CALL_DEBUG_ENTER;
2262 MessageParcel data;
2263 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2264 MMI_HILOGE("Failed to write descriptor");
2265 return ERR_INVALID_VALUE;
2266 }
2267 if (!data.WriteRemoteObject(channel->AsObject())) {
2268 MMI_HILOGE("Failed to write IRemoteObject");
2269 return ERR_INVALID_VALUE;
2270 }
2271 MessageParcel reply;
2272 MessageOption option;
2273 sptr<IRemoteObject> remote = Remote();
2274 CHKPR(remote, RET_ERR);
2275 int32_t ret = remote->SendRequest(
2276 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::REMOVE_ANCO_CHANNEL), data, reply, option);
2277 if (ret != RET_OK) {
2278 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
2279 return ret;
2280 }
2281 READINT32(reply, ret, IPC_PROXY_DEAD_OBJECT_ERR);
2282 return ret;
2283 }
2284 #endif // OHOS_BUILD_ENABLE_ANCO
2285
TransferBinderClientSrv(const sptr<IRemoteObject> & binderClientObject)2286 int32_t MultimodalInputConnectProxy::TransferBinderClientSrv(const sptr<IRemoteObject> &binderClientObject)
2287 {
2288 CALL_DEBUG_ENTER;
2289 MessageParcel data;
2290 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2291 MMI_HILOGE("Failed to write descriptor");
2292 return ERR_INVALID_VALUE;
2293 }
2294 MessageParcel reply;
2295 MessageOption option;
2296 WRITEREMOTEOBJECT(data, binderClientObject, ERR_INVALID_VALUE);
2297 sptr<IRemoteObject> remote = Remote();
2298 CHKPR(remote, RET_ERR);
2299 int32_t ret = remote->SendRequest(
2300 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::TRANSFER_BINDER_CLIENT_SERVICE),
2301 data, reply, option);
2302 if (ret != RET_OK) {
2303 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
2304 return ret;
2305 }
2306 READINT32(reply, ret, IPC_PROXY_DEAD_OBJECT_ERR);
2307 return ret;
2308 }
2309
SkipPointerLayer(bool isSkip)2310 int32_t MultimodalInputConnectProxy::SkipPointerLayer(bool isSkip)
2311 {
2312 CALL_DEBUG_ENTER;
2313 MessageParcel data;
2314 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2315 MMI_HILOGE("Failed to write descriptor");
2316 return ERR_INVALID_VALUE;
2317 }
2318 MessageParcel reply;
2319 MessageOption option;
2320 WRITEBOOL(data, isSkip, ERR_INVALID_VALUE);
2321 sptr<IRemoteObject> remote = Remote();
2322 CHKPR(remote, RET_ERR);
2323 int32_t ret = remote->SendRequest(
2324 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SKIP_POINTER_LAYER),
2325 data, reply, option);
2326 if (ret != RET_OK) {
2327 MMI_HILOGE("Send request fail, ret:%{public}d", ret);
2328 return ret;
2329 }
2330 READINT32(reply, ret, IPC_PROXY_DEAD_OBJECT_ERR);
2331 return ret;
2332 }
2333
GetIntervalSinceLastInput(int64_t & timeInterval)2334 int32_t MultimodalInputConnectProxy::GetIntervalSinceLastInput(int64_t &timeInterval)
2335 {
2336 CALL_DEBUG_ENTER;
2337 MessageParcel data;
2338 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2339 MMI_HILOGE("Failed to write descriptor");
2340 return ERR_INVALID_VALUE;
2341 }
2342 MessageParcel reply;
2343 MessageOption option;
2344 sptr<IRemoteObject> remote = Remote();
2345 CHKPR(remote, RET_ERR);
2346 int32_t ret = remote->SendRequest(static_cast<uint32_t>(
2347 MultimodalinputConnectInterfaceCode::GET_SYSTEM_EVENT_TIME_INTERVAL), data, reply, option);
2348 if (ret != RET_OK) {
2349 MMI_HILOGE("MultimodalInputConnectProxy::GetTouchpadThree Send request fail, ret:%{public}d", ret);
2350 } else {
2351 READINT64(reply, timeInterval);
2352 }
2353 return ret;
2354 }
2355
ShiftAppPointerEvent(const ShiftWindowParam & param,bool autoGenDown)2356 int32_t MultimodalInputConnectProxy::ShiftAppPointerEvent(const ShiftWindowParam ¶m, bool autoGenDown)
2357 {
2358 CALL_DEBUG_ENTER;
2359 MessageParcel data;
2360 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2361 MMI_HILOGE("Failed to write descriptor");
2362 return ERR_INVALID_VALUE;
2363 }
2364 WRITEINT32(data, param.sourceWindowId, ERR_INVALID_VALUE);
2365 WRITEINT32(data, param.targetWindowId, ERR_INVALID_VALUE);
2366 WRITEINT32(data, param.x, ERR_INVALID_VALUE);
2367 WRITEINT32(data, param.y, ERR_INVALID_VALUE);
2368 WRITEBOOL(data, autoGenDown, ERR_INVALID_VALUE);
2369 MessageParcel reply;
2370 MessageOption option;
2371 sptr<IRemoteObject> remote = Remote();
2372 CHKPR(remote, RET_ERR);
2373 int32_t ret = remote->SendRequest(
2374 static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SHIFT_APP_POINTER_EVENT),
2375 data, reply, option);
2376 if (ret != RET_OK) {
2377 MMI_HILOGE("MultimodalInputConnectProxy::ShiftAppPointerEvent Send request fail, ret:%{public}d", ret);
2378 return ret;
2379 }
2380 return RET_OK;
2381 }
2382
SetCustomCursor(int32_t windowId,CustomCursor cursor,CursorOptions options)2383 int32_t MultimodalInputConnectProxy::SetCustomCursor(int32_t windowId, CustomCursor cursor,
2384 CursorOptions options) __attribute__((no_sanitize("cfi")))
2385 {
2386 CALL_DEBUG_ENTER;
2387 CHKPR(cursor.pixelMap, RET_ERR);
2388 OHOS::Media::PixelMap* pixelMapPtr = static_cast<OHOS::Media::PixelMap*>(cursor.pixelMap);
2389 CHKPR(pixelMapPtr, RET_ERR);
2390 if (pixelMapPtr->GetCapacity() == 0) {
2391 MMI_HILOGE("pixelMap is empty");
2392 return ERR_INVALID_VALUE;
2393 }
2394 MessageParcel data;
2395 if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) {
2396 MMI_HILOGE("Failed to write descriptor");
2397 return ERR_INVALID_VALUE;
2398 }
2399 WRITEINT32(data, windowId, ERR_INVALID_VALUE);
2400 pixelMapPtr->Marshalling(data);
2401 WRITEINT32(data, cursor.focusX, ERR_INVALID_VALUE);
2402 WRITEINT32(data, cursor.focusY, ERR_INVALID_VALUE);
2403 WRITEBOOL(data, options.followSystem, ERR_INVALID_VALUE);
2404
2405 MessageParcel reply;
2406 MessageOption option;
2407 sptr<IRemoteObject> remote = Remote();
2408 CHKPR(remote, RET_ERR);
2409 int32_t ret =
2410 remote->SendRequest(static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_CUSTOM_MOUSE_CURSOR),
2411 data, reply, option);
2412 if (ret != RET_OK) {
2413 MMI_HILOGE("Send request failed, ret:%{public}d", ret);
2414 } else {
2415 READINT32(reply, ret);
2416 }
2417 return ret;
2418 }
2419 } // namespace MMI
2420 } // namespace OHOS
2421