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