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