• 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 "multimodalinput_ipc_interface_code.h"
17 #include "multimodal_input_connect_stub.h"
18 
19 #include <sys/types.h>
20 #include <sys/socket.h>
21 #include <unistd.h>
22 
23 #include "string_ex.h"
24 
25 #include "error_multimodal.h"
26 #include "multimodal_input_connect_def_parcel.h"
27 #include "permission_helper.h"
28 #include "pixel_map.h"
29 #include "time_cost_chk.h"
30 
31 namespace OHOS {
32 namespace MMI {
33 namespace {
34 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "MultimodalInputConnectStub" };
35 using ConnFunc = int32_t (MultimodalInputConnectStub::*)(MessageParcel& data, MessageParcel& reply);
36 } // namespace
37 const int32_t MAX_BUFFER_SIZE = 1000000;
38 const int32_t DEFAULT_POINTER_COLOR = 0x000000;
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)39 int32_t MultimodalInputConnectStub::OnRemoteRequest(uint32_t code, MessageParcel& data,
40     MessageParcel& reply, MessageOption& option)
41 {
42     int32_t pid = GetCallingPid();
43     TimeCostChk chk("IPC-OnRemoteRequest", "overtime 300(us)", MAX_OVER_TIME, pid,
44         static_cast<int64_t>(code));
45     MMI_HILOGD("RemoteRequest code:%{public}d tid:%{public}" PRIu64 " pid:%{public}d", code, GetThisThreadId(), pid);
46 
47     std::u16string descriptor = data.ReadInterfaceToken();
48     if (descriptor != IMultimodalInputConnect::GetDescriptor()) {
49         MMI_HILOGE("Get unexpect descriptor:%{public}s", Str16ToStr8(descriptor).c_str());
50         return ERR_INVALID_STATE;
51     }
52     switch (code) {
53         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::ALLOC_SOCKET_FD):
54             return StubHandleAllocSocketFd(data, reply);
55             break;
56         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::ADD_INPUT_EVENT_FILTER):
57             return StubAddInputEventFilter(data, reply);
58             break;
59         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::RMV_INPUT_EVENT_FILTER):
60             return StubRemoveInputEventFilter(data, reply);
61             break;
62         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_MOUSE_SCROLL_ROWS):
63             return StubSetMouseScrollRows(data, reply);
64             break;
65         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_MOUSE_SCROLL_ROWS):
66             return StubGetMouseScrollRows(data, reply);
67             break;
68         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_POINTER_SIZE):
69             return StubSetPointerSize(data, reply);
70             break;
71         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_POINTER_SIZE):
72             return StubGetPointerSize(data, reply);
73             break;
74         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_MOUSE_ICON):
75             return StubSetMouseIcon(data, reply);
76             break;
77         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_MOUSE_PRIMARY_BUTTON):
78             return StubSetMousePrimaryButton(data, reply);
79             break;
80         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_MOUSE_PRIMARY_BUTTON):
81             return StubGetMousePrimaryButton(data, reply);
82             break;
83         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_HOVER_SCROLL_STATE):
84             return StubSetHoverScrollState(data, reply);
85             break;
86         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_HOVER_SCROLL_STATE):
87             return StubGetHoverScrollState(data, reply);
88             break;
89         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_POINTER_VISIBLE):
90             return StubSetPointerVisible(data, reply);
91             break;
92         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_POINTER_STYLE):
93             return StubSetPointerStyle(data, reply);
94             break;
95         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_POINTER_STYLE):
96             return StubGetPointerStyle(data, reply);
97             break;
98         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::IS_POINTER_VISIBLE):
99             return StubIsPointerVisible(data, reply);
100             break;
101         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::REGISTER_DEV_MONITOR):
102             return StubRegisterInputDeviceMonitor(data, reply);
103             break;
104         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::UNREGISTER_DEV_MONITOR):
105             return StubUnregisterInputDeviceMonitor(data, reply);
106             break;
107         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_DEVICE_IDS):
108             return StubGetDeviceIds(data, reply);
109             break;
110         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_DEVICE):
111             return StubGetDevice(data, reply);
112             break;
113         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SUPPORT_KEYS):
114             return StubSupportKeys(data, reply);
115             break;
116         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_KEYBOARD_TYPE):
117             return StubGetKeyboardType(data, reply);
118             break;
119         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_POINTER_COLOR):
120             return StubSetPointerColor(data, reply);
121             break;
122         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_POINTER_COLOR):
123             return StubGetPointerColor(data, reply);
124             break;
125         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_POINTER_SPEED):
126             return StubSetPointerSpeed(data, reply);
127             break;
128         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_POINTER_SPEED):
129             return StubGetPointerSpeed(data, reply);
130             break;
131         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SUBSCRIBE_KEY_EVENT):
132             return StubSubscribeKeyEvent(data, reply);
133             break;
134         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::UNSUBSCRIBE_KEY_EVENT):
135             return StubUnsubscribeKeyEvent(data, reply);
136             break;
137         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SUBSCRIBE_SWITCH_EVENT):
138             return StubSubscribeSwitchEvent(data, reply);
139             break;
140         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::UNSUBSCRIBE_SWITCH_EVENT):
141             return StubUnsubscribeSwitchEvent(data, reply);
142             break;
143         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::MARK_PROCESSED):
144             return StubMarkProcessed(data, reply);
145             break;
146         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::ADD_INPUT_HANDLER):
147             return StubAddInputHandler(data, reply);
148             break;
149         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::REMOVE_INPUT_HANDLER):
150             return StubRemoveInputHandler(data, reply);
151             break;
152         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::MARK_EVENT_CONSUMED):
153             return StubMarkEventConsumed(data, reply);
154             break;
155         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::MOVE_MOUSE):
156             return StubMoveMouseEvent(data, reply);
157             break;
158         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::INJECT_KEY_EVENT):
159             return StubInjectKeyEvent(data, reply);
160             break;
161         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::INJECT_POINTER_EVENT):
162             return StubInjectPointerEvent(data, reply);
163             break;
164         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_ANR_OBSERVER):
165             return StubSetAnrListener(data, reply);
166             break;
167         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_DISPLAY_BIND_INFO):
168             return StubGetDisplayBindInfo(data, reply);
169             break;
170         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_DISPLAY_BIND):
171             return StubSetDisplayBind(data, reply);
172             break;
173         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_FUNCTION_KEY_STATE):
174             return StubGetFunctionKeyState(data, reply);
175             break;
176         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_FUNCTION_KEY_STATE):
177             return StubSetFunctionKeyState(data, reply);
178             break;
179         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_POINTER_LOCATION):
180             return StubSetPointerLocation(data, reply);
181             break;
182         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_CAPTURE_MODE):
183             return StubSetMouseCaptureMode(data, reply);
184             break;
185         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_WINDOW_PID):
186             return StubGetWindowPid(data, reply);
187             break;
188         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::APPEND_EXTRA_DATA):
189             return StubAppendExtraData(data, reply);
190             break;
191         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::ENABLE_INPUT_DEVICE):
192             return StubEnableInputDevice(data, reply);
193             break;
194         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_KEY_DOWN_DURATION):
195             return StubSetKeyDownDuration(data, reply);
196             break;
197         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_TP_SCROLL_SWITCH):
198             return StubSetTouchpadScrollSwitch(data, reply);
199             break;
200         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_TP_SCROLL_SWITCH):
201             return StubGetTouchpadScrollSwitch(data, reply);
202             break;
203         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_TP_SCROLL_DIRECT_SWITCH):
204             return StubSetTouchpadScrollDirection(data, reply);
205             break;
206         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_TP_SCROLL_DIRECT_SWITCH):
207             return StubGetTouchpadScrollDirection(data, reply);
208             break;
209         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_TP_TAP_SWITCH):
210             return StubSetTouchpadTapSwitch(data, reply);
211             break;
212         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_TP_TAP_SWITCH):
213             return StubGetTouchpadTapSwitch(data, reply);
214             break;
215         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_TP_POINTER_SPEED):
216             return StubSetTouchpadPointerSpeed(data, reply);
217             break;
218         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_TP_POINTER_SPEED):
219             return StubGetTouchpadPointerSpeed(data, reply);
220             break;
221         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_KEYBOARD_REPEAT_DELAY):
222             return StubSetKeyboardRepeatDelay(data, reply);
223             break;
224         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_KEYBOARD_REPEAT_RATE):
225             return StubSetKeyboardRepeatRate(data, reply);
226             break;
227         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_TP_PINCH_SWITCH):
228             return StubSetTouchpadPinchSwitch(data, reply);
229             break;
230         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_TP_PINCH_SWITCH):
231             return StubGetTouchpadPinchSwitch(data, reply);
232             break;
233         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_TP_SWIPE_SWITCH):
234             return StubSetTouchpadSwipeSwitch(data, reply);
235             break;
236         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_TP_SWIPE_SWITCH):
237             return StubGetTouchpadSwipeSwitch(data, reply);
238             break;
239         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_TP_RIGHT_CLICK_TYPE):
240             return StubSetTouchpadRightClickType(data, reply);
241             break;
242         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_TP_RIGHT_CLICK_TYPE):
243             return StubGetTouchpadRightClickType(data, reply);
244             break;
245         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_KEYBOARD_REPEAT_DELAY):
246             return StubGetKeyboardRepeatDelay(data, reply);
247             break;
248         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::GET_KEYBOARD_REPEAT_RATE):
249             return StubGetKeyboardRepeatRate(data, reply);
250             break;
251         case static_cast<uint32_t>(MultimodalinputConnectInterfaceCode::SET_MOUSE_HOT_SPOT):
252             return StubSetMouseHotSpot(data, reply);
253             break;
254         default: {
255             MMI_HILOGE("Unknown code:%{public}u, go switch default", code);
256             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
257         }
258     }
259     return RET_ERR;
260 }
261 
StubHandleAllocSocketFd(MessageParcel & data,MessageParcel & reply)262 int32_t MultimodalInputConnectStub::StubHandleAllocSocketFd(MessageParcel& data, MessageParcel& reply)
263 {
264     int32_t pid = GetCallingPid();
265     if (!IsRunning()) {
266         MMI_HILOGE("Service is not running. pid:%{public}d, go switch default", pid);
267         return MMISERVICE_NOT_RUNNING;
268     }
269     sptr<ConnectReqParcel> req = data.ReadParcelable<ConnectReqParcel>();
270     CHKPR(req, ERROR_NULL_POINTER);
271     MMI_HILOGD("clientName:%{public}s,moduleId:%{public}d", req->data.clientName.c_str(), req->data.moduleId);
272 
273     int32_t clientFd = INVALID_SOCKET_FD;
274     int32_t tokenType = PerHelper->GetTokenType();
275     int32_t ret = AllocSocketFd(req->data.clientName, req->data.moduleId, clientFd, tokenType);
276     if (ret != RET_OK) {
277         MMI_HILOGE("AllocSocketFd failed pid:%{public}d, go switch default", pid);
278         if (clientFd >= 0) {
279             close(clientFd);
280         }
281         return ret;
282     }
283 
284     if (!reply.WriteFileDescriptor(clientFd)) {
285         MMI_HILOGE("Write file descriptor failed");
286         return IPC_STUB_WRITE_PARCEL_ERR;
287     }
288 
289     WRITEINT32(reply, tokenType, IPC_STUB_WRITE_PARCEL_ERR);
290     MMI_HILOGI("Send clientFd to client, clientFd:%{public}d, tokenType:%{public}d", clientFd, tokenType);
291     close(clientFd);
292     return RET_OK;
293 }
294 
StubAddInputEventFilter(MessageParcel & data,MessageParcel & reply)295 int32_t MultimodalInputConnectStub::StubAddInputEventFilter(MessageParcel& data, MessageParcel& reply)
296 {
297     CALL_DEBUG_ENTER;
298     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_CORE)) {
299         MMI_HILOGE("Permission check failed");
300         return CHECK_PERMISSION_FAIL;
301     }
302 
303     sptr<IRemoteObject> client = data.ReadRemoteObject();
304     CHKPR(client, ERR_INVALID_VALUE);
305     sptr<IEventFilter> filter = iface_cast<IEventFilter>(client);
306     CHKPR(filter, ERROR_NULL_POINTER);
307     int32_t filterId = -1;
308     READINT32(data, filterId, IPC_PROXY_DEAD_OBJECT_ERR);
309     int32_t priority = 0;
310     READINT32(data, priority, IPC_PROXY_DEAD_OBJECT_ERR);
311     uint32_t deviceTags = 0;
312     READUINT32(data, deviceTags, IPC_PROXY_DEAD_OBJECT_ERR);
313     int32_t ret = AddInputEventFilter(filter, filterId, priority, deviceTags);
314     if (ret != RET_OK) {
315         MMI_HILOGE("Call AddInputEventFilter failed ret:%{public}d", ret);
316         return ret;
317     }
318     MMI_HILOGD("Success pid:%{public}d", GetCallingPid());
319     return RET_OK;
320 }
321 
StubRemoveInputEventFilter(MessageParcel & data,MessageParcel & reply)322 int32_t MultimodalInputConnectStub::StubRemoveInputEventFilter(MessageParcel& data, MessageParcel& reply)
323 {
324     CALL_DEBUG_ENTER;
325     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_CORE)) {
326         MMI_HILOGE("Permission check failed");
327         return CHECK_PERMISSION_FAIL;
328     }
329     int32_t filterId = -1;
330     READINT32(data, filterId, IPC_PROXY_DEAD_OBJECT_ERR);
331     int32_t ret = RemoveInputEventFilter(filterId);
332     if (ret != RET_OK) {
333         MMI_HILOGE("Call RemoveInputEventFilter failed ret:%{public}d", ret);
334         return ret;
335     }
336     MMI_HILOGD("Success pid:%{public}d", GetCallingPid());
337     return RET_OK;
338 }
339 
StubSetMouseScrollRows(MessageParcel & data,MessageParcel & reply)340 int32_t MultimodalInputConnectStub::StubSetMouseScrollRows(MessageParcel& data, MessageParcel& reply)
341 {
342     CALL_DEBUG_ENTER;
343     if (!IsRunning()) {
344         MMI_HILOGE("Service is not running");
345         return MMISERVICE_NOT_RUNNING;
346     }
347 
348     if (!PerHelper->VerifySystemApp()) {
349         MMI_HILOGE("verify system APP failed");
350         return ERROR_NOT_SYSAPI;
351     }
352 
353     int32_t rows = 3; // the initial number of scrolling rows is 3.
354     READINT32(data, rows, IPC_PROXY_DEAD_OBJECT_ERR);
355     int32_t ret = SetMouseScrollRows(rows);
356     if (ret != RET_OK) {
357         MMI_HILOGE("Call SetMouseScrollRows failed ret:%{public}d", ret);
358         return ret;
359     }
360     MMI_HILOGD("Success rows:%{public}d, pid:%{public}d", rows, GetCallingPid());
361     return RET_OK;
362 }
363 
StubSetMouseIcon(MessageParcel & data,MessageParcel & reply)364 int32_t MultimodalInputConnectStub::StubSetMouseIcon(MessageParcel& data, MessageParcel& reply)
365 {
366     CALL_DEBUG_ENTER;
367     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_CORE)) {
368         MMI_HILOGE("Permission check failed");
369         return CHECK_PERMISSION_FAIL;
370     }
371     if (!IsRunning()) {
372         MMI_HILOGE("Service is not running");
373         return MMISERVICE_NOT_RUNNING;
374     }
375     int32_t size = 0;
376     int32_t windowId = 0;
377     READINT32(data, size, IPC_PROXY_DEAD_OBJECT_ERR);
378     MMI_HILOGD("reading size of the tlv count %{public}d", size);
379     if (size > MAX_BUFFER_SIZE || size <= 0) {
380         MMI_HILOGE("Append extra data failed, buffer is oversize:%{public}d", size);
381         return RET_ERR;
382     }
383     std::vector<uint8_t> buff(size, 0);
384     for (int i = 0; i < size; i++) {
385         READUINT8(data, buff[i], IPC_PROXY_DEAD_OBJECT_ERR);
386     }
387     READINT32(data, windowId, IPC_PROXY_DEAD_OBJECT_ERR);
388     MMI_HILOGD("reading windowid the tlv count %{public}d", windowId);
389 
390     OHOS::Media::PixelMap* pixelMap = OHOS::Media::PixelMap::DecodeTlv(buff);
391     if (pixelMap == nullptr) {
392         MMI_HILOGE("pixelMap is nullptr! server cannot recive the resource!");
393         return RET_ERR;
394     }
395     if (windowId <= 0) {
396         MMI_HILOGE("windowId is invalid, get value %{public}d", windowId);
397         return RET_ERR;
398     }
399     int32_t ret = SetMouseIcon(windowId, (void*)pixelMap);
400     if (ret != RET_OK) {
401         MMI_HILOGE("Call SetMouseIcon failed ret:%{public}d", ret);
402         return ret;
403     }
404     return RET_OK;
405 }
406 
StubSetMouseHotSpot(MessageParcel & data,MessageParcel & reply)407 int32_t MultimodalInputConnectStub::StubSetMouseHotSpot(MessageParcel& data, MessageParcel& reply)
408 {
409     CALL_DEBUG_ENTER;
410     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_CORE)) {
411         MMI_HILOGE("Permission check failed");
412         return CHECK_PERMISSION_FAIL;
413     }
414     if (!IsRunning()) {
415         MMI_HILOGE("Service is not running");
416         return MMISERVICE_NOT_RUNNING;
417     }
418     int32_t windowId = 0;
419     READINT32(data, windowId, IPC_PROXY_DEAD_OBJECT_ERR);
420     if (windowId <= 0) {
421         MMI_HILOGE("windowId is invalid, get value %{public}d", windowId);
422         return RET_ERR;
423     }
424     int32_t hotSpotX = 0;
425     READINT32(data, hotSpotX, IPC_PROXY_DEAD_OBJECT_ERR);
426     int32_t hotSpotY = 0;
427     READINT32(data, hotSpotY, IPC_PROXY_DEAD_OBJECT_ERR);
428     int32_t ret = SetMouseHotSpot(windowId, hotSpotX, hotSpotY);
429     if (ret != RET_OK) {
430         MMI_HILOGE("Call SetMouseHotSpot failed ret:%{public}d", ret);
431         return ret;
432     }
433     return RET_OK;
434 }
435 
StubGetMouseScrollRows(MessageParcel & data,MessageParcel & reply)436 int32_t MultimodalInputConnectStub::StubGetMouseScrollRows(MessageParcel& data, MessageParcel& reply)
437 {
438     CALL_DEBUG_ENTER;
439     if (!IsRunning()) {
440         MMI_HILOGE("Service is not running");
441         return MMISERVICE_NOT_RUNNING;
442     }
443 
444     if (!PerHelper->VerifySystemApp()) {
445         MMI_HILOGE("verify system APP failed");
446         return ERROR_NOT_SYSAPI;
447     }
448 
449     int32_t rows = 3; // the initial number of scrolling rows is 3.
450     int32_t ret = GetMouseScrollRows(rows);
451     if (ret != RET_OK) {
452         MMI_HILOGE("Call GetMouseScrollRows failed ret:%{public}d", ret);
453         return ret;
454     }
455     WRITEINT32(reply, rows, IPC_STUB_WRITE_PARCEL_ERR);
456     MMI_HILOGD("mouse scroll rows:%{public}d, ret:%{public}d", rows, ret);
457     return RET_OK;
458 }
459 
StubSetPointerSize(MessageParcel & data,MessageParcel & reply)460 int32_t MultimodalInputConnectStub::StubSetPointerSize(MessageParcel& data, MessageParcel& reply)
461 {
462     CALL_DEBUG_ENTER;
463     if (!IsRunning()) {
464         MMI_HILOGE("Service is not running");
465         return MMISERVICE_NOT_RUNNING;
466     }
467 
468     if (!PerHelper->VerifySystemApp()) {
469         MMI_HILOGE("verify system APP failed");
470         return ERROR_NOT_SYSAPI;
471     }
472 
473     int32_t size = 1; // the initial pointer size is 1.
474     READINT32(data, size, IPC_PROXY_DEAD_OBJECT_ERR);
475     int32_t ret = SetPointerSize(size);
476     if (ret != RET_OK) {
477         MMI_HILOGE("Call SetPointerSize failed ret:%{public}d", ret);
478         return ret;
479     }
480     MMI_HILOGD("Success size:%{public}d, pid:%{public}d", size, GetCallingPid());
481     return RET_OK;
482 }
483 
StubGetPointerSize(MessageParcel & data,MessageParcel & reply)484 int32_t MultimodalInputConnectStub::StubGetPointerSize(MessageParcel& data, MessageParcel& reply)
485 {
486     CALL_DEBUG_ENTER;
487     if (!IsRunning()) {
488         MMI_HILOGE("Service is not running");
489         return MMISERVICE_NOT_RUNNING;
490     }
491 
492     if (!PerHelper->VerifySystemApp()) {
493         MMI_HILOGE("verify system APP failed");
494         return ERROR_NOT_SYSAPI;
495     }
496 
497     int32_t size = 1; // the initial pointer size is 1.
498     int32_t ret = GetPointerSize(size);
499     if (ret != RET_OK) {
500         MMI_HILOGE("Call GetPoinerSize failed ret:%{public}d", ret);
501         return ret;
502     }
503     WRITEINT32(reply, size, IPC_STUB_WRITE_PARCEL_ERR);
504     MMI_HILOGD("pointer size:%{public}d, ret:%{public}d", size, ret);
505     return RET_OK;
506 }
507 
StubSetMousePrimaryButton(MessageParcel & data,MessageParcel & reply)508 int32_t MultimodalInputConnectStub::StubSetMousePrimaryButton(MessageParcel& data, MessageParcel& reply)
509 {
510     CALL_DEBUG_ENTER;
511     if (!PerHelper->VerifySystemApp()) {
512         MMI_HILOGE("verify system APP failed");
513         return ERROR_NOT_SYSAPI;
514     }
515 
516     int32_t primaryButton = -1;
517     READINT32(data, primaryButton, IPC_PROXY_DEAD_OBJECT_ERR);
518     int32_t ret = SetMousePrimaryButton(primaryButton);
519     if (ret != RET_OK) {
520         MMI_HILOGE("Call SetMousePrimaryButton failed ret:%{public}d", ret);
521         return ret;
522     }
523     MMI_HILOGD("Success primaryButton:%{public}d,pid:%{public}d", primaryButton, GetCallingPid());
524     return RET_OK;
525 }
526 
StubGetMousePrimaryButton(MessageParcel & data,MessageParcel & reply)527 int32_t MultimodalInputConnectStub::StubGetMousePrimaryButton(MessageParcel& data, MessageParcel& reply)
528 {
529     CALL_DEBUG_ENTER;
530     if (!PerHelper->VerifySystemApp()) {
531         MMI_HILOGE("verify system APP failed");
532         return ERROR_NOT_SYSAPI;
533     }
534 
535     int32_t primaryButton = -1;
536     int32_t ret = GetMousePrimaryButton(primaryButton);
537     if (ret != RET_OK) {
538         MMI_HILOGE("Call GetMousePrimaryButton failed ret:%{public}d", ret);
539         return ret;
540     }
541     WRITEINT32(reply, primaryButton, IPC_STUB_WRITE_PARCEL_ERR);
542     MMI_HILOGD("mouse primaryButton:%{public}d,ret:%{public}d", primaryButton, ret);
543     return RET_OK;
544 }
545 
StubSetHoverScrollState(MessageParcel & data,MessageParcel & reply)546 int32_t MultimodalInputConnectStub::StubSetHoverScrollState(MessageParcel& data, MessageParcel& reply)
547 {
548     CALL_DEBUG_ENTER;
549     if (!PerHelper->VerifySystemApp()) {
550         MMI_HILOGE("verify system APP failed");
551         return ERROR_NOT_SYSAPI;
552     }
553 
554     bool state = true;
555     READBOOL(data, state, IPC_PROXY_DEAD_OBJECT_ERR);
556     int32_t ret = SetHoverScrollState(state);
557     if (ret != RET_OK) {
558         MMI_HILOGE("Call SetHoverScrollState failed, ret:%{public}d", ret);
559         return ret;
560     }
561     MMI_HILOGD("Success state:%{public}d, pid:%{public}d", state, GetCallingPid());
562     return RET_OK;
563 }
564 
StubGetHoverScrollState(MessageParcel & data,MessageParcel & reply)565 int32_t MultimodalInputConnectStub::StubGetHoverScrollState(MessageParcel& data, MessageParcel& reply)
566 {
567     CALL_DEBUG_ENTER;
568     if (!PerHelper->VerifySystemApp()) {
569         MMI_HILOGE("verify system APP failed");
570         return ERROR_NOT_SYSAPI;
571     }
572 
573     bool state = true;
574     int32_t ret = GetHoverScrollState(state);
575     if (ret != RET_OK) {
576         MMI_HILOGE("Call GetHoverScrollState failed, ret:%{public}d", ret);
577         return ret;
578     }
579     WRITEBOOL(reply, state, IPC_STUB_WRITE_PARCEL_ERR);
580     MMI_HILOGD("mouse hover scroll state:%{public}d, ret:%{public}d", state, ret);
581     return RET_OK;
582 }
583 
StubSetPointerVisible(MessageParcel & data,MessageParcel & reply)584 int32_t MultimodalInputConnectStub::StubSetPointerVisible(MessageParcel& data, MessageParcel& reply)
585 {
586     CALL_DEBUG_ENTER;
587     bool visible = false;
588     READBOOL(data, visible, IPC_PROXY_DEAD_OBJECT_ERR);
589     int32_t ret = SetPointerVisible(visible);
590     if (ret != RET_OK) {
591         MMI_HILOGE("Call SetPointerVisible failed ret:%{public}d", ret);
592         return ret;
593     }
594     MMI_HILOGD("Success visible:%{public}d,pid:%{public}d", visible, GetCallingPid());
595     return RET_OK;
596 }
597 
StubIsPointerVisible(MessageParcel & data,MessageParcel & reply)598 int32_t MultimodalInputConnectStub::StubIsPointerVisible(MessageParcel& data, MessageParcel& reply)
599 {
600     CALL_DEBUG_ENTER;
601     bool visible = false;
602     int32_t ret = IsPointerVisible(visible);
603     if (ret != RET_OK) {
604         MMI_HILOGE("Call IsPointerVisible failed ret:%{public}d", ret);
605         return ret;
606     }
607     WRITEBOOL(reply, visible, IPC_STUB_WRITE_PARCEL_ERR);
608     MMI_HILOGD("visible:%{public}d,ret:%{public}d,pid:%{public}d", visible, ret, GetCallingPid());
609     return RET_OK;
610 }
611 
StubMarkProcessed(MessageParcel & data,MessageParcel & reply)612 int32_t MultimodalInputConnectStub::StubMarkProcessed(MessageParcel& data, MessageParcel& reply)
613 {
614     CALL_DEBUG_ENTER;
615     if (!IsRunning()) {
616         MMI_HILOGE("Service is not running");
617     }
618     int32_t eventType;
619     READINT32(data, eventType, IPC_PROXY_DEAD_OBJECT_ERR);
620     int32_t eventId;
621     READINT32(data, eventId, IPC_PROXY_DEAD_OBJECT_ERR);
622     int32_t ret = MarkProcessed(eventType, eventId);
623     if (ret != RET_OK) {
624         MMI_HILOGE("MarkProcessed failed, ret:%{public}d", ret);
625         return ret;
626     }
627     return RET_OK;
628 }
629 
StubSetPointerColor(MessageParcel & data,MessageParcel & reply)630 int32_t MultimodalInputConnectStub::StubSetPointerColor(MessageParcel& data, MessageParcel& reply)
631 {
632     CALL_DEBUG_ENTER;
633     if (!IsRunning()) {
634         MMI_HILOGE("Service is not running");
635         return MMISERVICE_NOT_RUNNING;
636     }
637 
638     if (!PerHelper->VerifySystemApp()) {
639         MMI_HILOGE("verify system APP failed");
640         return ERROR_NOT_SYSAPI;
641     }
642 
643     int32_t color = DEFAULT_POINTER_COLOR;
644     READINT32(data, color, IPC_PROXY_DEAD_OBJECT_ERR);
645     int32_t ret = SetPointerColor(color);
646     if (ret != RET_OK) {
647         MMI_HILOGE("Call SetPointerColor failed ret:%{public}d", ret);
648         return ret;
649     }
650     MMI_HILOGD("Success color:%{public}d, pid:%{public}d", color, GetCallingPid());
651     return RET_OK;
652 }
653 
StubGetPointerColor(MessageParcel & data,MessageParcel & reply)654 int32_t MultimodalInputConnectStub::StubGetPointerColor(MessageParcel& data, MessageParcel& reply)
655 {
656     CALL_DEBUG_ENTER;
657     if (!IsRunning()) {
658         MMI_HILOGE("Service is not running");
659         return MMISERVICE_NOT_RUNNING;
660     }
661 
662     if (!PerHelper->VerifySystemApp()) {
663         MMI_HILOGE("verify system APP failed");
664         return ERROR_NOT_SYSAPI;
665     }
666 
667     int32_t color = DEFAULT_POINTER_COLOR;
668     int32_t ret = GetPointerColor(color);
669     if (ret != RET_OK) {
670         MMI_HILOGE("Call GetPointerColor failed ret:%{public}d", ret);
671         return ret;
672     }
673     WRITEINT32(reply, color, IPC_STUB_WRITE_PARCEL_ERR);
674     MMI_HILOGD("pointer color:%{public}d, ret:%{public}d", color, ret);
675     return RET_OK;
676 }
677 
StubSetPointerSpeed(MessageParcel & data,MessageParcel & reply)678 int32_t MultimodalInputConnectStub::StubSetPointerSpeed(MessageParcel& data, MessageParcel& reply)
679 {
680     CALL_DEBUG_ENTER;
681     if (!PerHelper->VerifySystemApp()) {
682         MMI_HILOGE("verify system APP failed");
683         return ERROR_NOT_SYSAPI;
684     }
685 
686     int32_t speed;
687     READINT32(data, speed, IPC_PROXY_DEAD_OBJECT_ERR);
688     int32_t ret = SetPointerSpeed(speed);
689     if (ret != RET_OK) {
690         MMI_HILOGE("Set pointer speed failed ret:%{public}d", ret);
691         return RET_ERR;
692     }
693     return RET_OK;
694 }
695 
StubGetPointerSpeed(MessageParcel & data,MessageParcel & reply)696 int32_t MultimodalInputConnectStub::StubGetPointerSpeed(MessageParcel& data, MessageParcel& reply)
697 {
698     CALL_DEBUG_ENTER;
699     if (!PerHelper->VerifySystemApp()) {
700         MMI_HILOGE("verify system APP failed");
701         return ERROR_NOT_SYSAPI;
702     }
703 
704     int32_t speed;
705     int32_t ret = GetPointerSpeed(speed);
706     if (ret != RET_OK) {
707         MMI_HILOGE("Call get pointer speed failed ret:%{public}d", ret);
708         return RET_ERR;
709     }
710     WRITEINT32(reply, speed, IPC_STUB_WRITE_PARCEL_ERR);
711     MMI_HILOGD("Pointer speed:%{public}d,ret:%{public}d", speed, ret);
712     return RET_OK;
713 }
714 
StubSetPointerStyle(MessageParcel & data,MessageParcel & reply)715 int32_t MultimodalInputConnectStub::StubSetPointerStyle(MessageParcel& data, MessageParcel& reply)
716 {
717     CALL_DEBUG_ENTER;
718     int32_t windowId;
719     READINT32(data, windowId, RET_ERR);
720     PointerStyle pointerStyle;
721     READINT32(data, pointerStyle.size, RET_ERR);
722     READUINT8(data, pointerStyle.color.r, RET_ERR);
723     READUINT8(data, pointerStyle.color.g, RET_ERR);
724     READUINT8(data, pointerStyle.color.b, RET_ERR);
725     READINT32(data, pointerStyle.id, RET_ERR);
726     int32_t ret = SetPointerStyle(windowId, pointerStyle);
727     if (ret != RET_OK) {
728         MMI_HILOGE("Call SetPointerStyle failed ret:%{public}d", ret);
729         return ret;
730     }
731     MMI_HILOGD("Successfully set window:%{public}d, icon:%{public}d", windowId, pointerStyle.id);
732     return RET_OK;
733 }
734 
StubGetPointerStyle(MessageParcel & data,MessageParcel & reply)735 int32_t MultimodalInputConnectStub::StubGetPointerStyle(MessageParcel& data, MessageParcel& reply)
736 {
737     CALL_DEBUG_ENTER;
738     int32_t windowId;
739     READINT32(data, windowId, RET_ERR);
740     PointerStyle pointerStyle;
741     int32_t ret = GetPointerStyle(windowId, pointerStyle);
742     if (ret != RET_OK) {
743         MMI_HILOGE("Call GetPointerStyle failed ret:%{public}d", ret);
744         return ret;
745     }
746     WRITEINT32(reply, pointerStyle.size, RET_ERR);
747     WRITEUINT8(reply, pointerStyle.color.r, RET_ERR);
748     WRITEUINT8(reply, pointerStyle.color.g, RET_ERR);
749     WRITEUINT8(reply, pointerStyle.color.b, RET_ERR);
750     WRITEINT32(reply, pointerStyle.id, RET_ERR);
751     MMI_HILOGD("Successfully get window:%{public}d, icon:%{public}d", windowId, pointerStyle.id);
752     return RET_OK;
753 }
754 
StubSupportKeys(MessageParcel & data,MessageParcel & reply)755 int32_t MultimodalInputConnectStub::StubSupportKeys(MessageParcel& data, MessageParcel& reply)
756 {
757     CALL_DEBUG_ENTER;
758     int32_t deviceId = -1;
759     READINT32(data, deviceId, IPC_PROXY_DEAD_OBJECT_ERR);
760     int32_t size = 0;
761     READINT32(data, size, IPC_PROXY_DEAD_OBJECT_ERR);
762     if (size < 0 || size > ExtraData::MAX_BUFFER_SIZE) {
763         MMI_HILOGE("Invalid size: %{public}d", size);
764         return RET_ERR;
765     }
766     std::vector<int32_t> keys;
767     int32_t key = 0;
768     for (int32_t i = 0; i < size; ++i) {
769         READINT32(data, key, IPC_PROXY_DEAD_OBJECT_ERR);
770         keys.push_back(key);
771     }
772     std::vector<bool> keystroke;
773     int32_t ret = SupportKeys(deviceId, keys, keystroke);
774     if (ret != RET_OK) {
775         MMI_HILOGE("Call SupportKeys failed ret:%{public}d", ret);
776         return RET_ERR;
777     }
778     if (!reply.WriteBoolVector(keystroke)) {
779         MMI_HILOGE("Write keyStroke failed");
780         return RET_ERR;
781     }
782     return ret;
783 }
784 
StubGetDeviceIds(MessageParcel & data,MessageParcel & reply)785 int32_t MultimodalInputConnectStub::StubGetDeviceIds(MessageParcel& data, MessageParcel& reply)
786 {
787     CALL_DEBUG_ENTER;
788     std::vector<int32_t> ids;
789     int32_t ret = GetDeviceIds(ids);
790     if (ret != RET_OK) {
791         MMI_HILOGE("Call GetDeviceIds failed ret:%{public}d", ret);
792         return RET_ERR;
793     }
794     if (!reply.WriteInt32Vector(ids)) {
795         MMI_HILOGE("Write ids failed");
796         return RET_ERR;
797     }
798     return ret;
799 }
800 
StubGetDevice(MessageParcel & data,MessageParcel & reply)801 int32_t MultimodalInputConnectStub::StubGetDevice(MessageParcel& data, MessageParcel& reply)
802 {
803     CALL_DEBUG_ENTER;
804     int32_t deviceId = -1;
805     READINT32(data, deviceId, IPC_PROXY_DEAD_OBJECT_ERR);
806     std::shared_ptr<InputDevice> inputDevice = std::make_shared<InputDevice>();
807     int32_t ret = GetDevice(deviceId, inputDevice);
808     if (ret != RET_OK) {
809         MMI_HILOGE("Call GetDevice failed ret:%{public}d", ret);
810         return RET_ERR;
811     }
812     WRITEINT32(reply, inputDevice->GetId(), IPC_STUB_WRITE_PARCEL_ERR);
813     WRITEINT32(reply, inputDevice->GetType(), IPC_STUB_WRITE_PARCEL_ERR);
814     WRITESTRING(reply, inputDevice->GetName(), IPC_STUB_WRITE_PARCEL_ERR);
815     WRITEINT32(reply, inputDevice->GetBus(), IPC_STUB_WRITE_PARCEL_ERR);
816     WRITEINT32(reply, inputDevice->GetVersion(), IPC_STUB_WRITE_PARCEL_ERR);
817     WRITEINT32(reply, inputDevice->GetProduct(), IPC_STUB_WRITE_PARCEL_ERR);
818     WRITEINT32(reply, inputDevice->GetVendor(), IPC_STUB_WRITE_PARCEL_ERR);
819     WRITESTRING(reply, inputDevice->GetPhys(), IPC_STUB_WRITE_PARCEL_ERR);
820     WRITESTRING(reply, inputDevice->GetUniq(), IPC_STUB_WRITE_PARCEL_ERR);
821     WRITEUINT64(reply, static_cast<uint64_t>(inputDevice->GetCapabilities()), IPC_STUB_WRITE_PARCEL_ERR);
822     WRITEUINT32(reply, static_cast<uint32_t>(inputDevice->GetAxisInfo().size()), IPC_STUB_WRITE_PARCEL_ERR);
823     for (const auto &item : inputDevice->GetAxisInfo()) {
824         WRITEINT32(reply, item.GetMinimum(), IPC_STUB_WRITE_PARCEL_ERR);
825         WRITEINT32(reply, item.GetMaximum(), IPC_STUB_WRITE_PARCEL_ERR);
826         WRITEINT32(reply, item.GetAxisType(), IPC_STUB_WRITE_PARCEL_ERR);
827         WRITEINT32(reply, item.GetFuzz(), IPC_STUB_WRITE_PARCEL_ERR);
828         WRITEINT32(reply, item.GetFlat(), IPC_STUB_WRITE_PARCEL_ERR);
829         WRITEINT32(reply, item.GetResolution(), IPC_STUB_WRITE_PARCEL_ERR);
830     }
831     return RET_OK;
832 }
833 
StubRegisterInputDeviceMonitor(MessageParcel & data,MessageParcel & reply)834 int32_t MultimodalInputConnectStub::StubRegisterInputDeviceMonitor(MessageParcel& data, MessageParcel& reply)
835 {
836     CALL_DEBUG_ENTER;
837     int32_t ret = RegisterDevListener();
838     if (ret != RET_OK) {
839         MMI_HILOGE("Call RegisterInputDeviceMonitor failed ret:%{public}d", ret);
840     }
841     return ret;
842 }
843 
StubUnregisterInputDeviceMonitor(MessageParcel & data,MessageParcel & reply)844 int32_t MultimodalInputConnectStub::StubUnregisterInputDeviceMonitor(MessageParcel& data, MessageParcel& reply)
845 {
846     CALL_DEBUG_ENTER;
847     int32_t ret = UnregisterDevListener();
848     if (ret != RET_OK) {
849         MMI_HILOGE("Call UnregisterInputDeviceMonitor failed ret:%{public}d", ret);
850     }
851     return ret;
852 }
853 
StubGetKeyboardType(MessageParcel & data,MessageParcel & reply)854 int32_t MultimodalInputConnectStub::StubGetKeyboardType(MessageParcel& data, MessageParcel& reply)
855 {
856     CALL_DEBUG_ENTER;
857     int32_t deviceId = -1;
858     READINT32(data, deviceId, IPC_PROXY_DEAD_OBJECT_ERR);
859     int32_t keyboardType = 0;
860     int32_t ret = GetKeyboardType(deviceId, keyboardType);
861     if (ret != RET_OK) {
862         MMI_HILOGE("Call GetKeyboardType failed ret:%{public}d", ret);
863         return RET_ERR;
864     }
865     WRITEINT32(reply, keyboardType, IPC_STUB_WRITE_PARCEL_ERR);
866     return ret;
867 }
868 
StubAddInputHandler(MessageParcel & data,MessageParcel & reply)869 int32_t MultimodalInputConnectStub::StubAddInputHandler(MessageParcel& data, MessageParcel& reply)
870 {
871     CALL_DEBUG_ENTER;
872     if (!PerHelper->VerifySystemApp()) {
873         MMI_HILOGE("verify system APP failed");
874         return ERROR_NOT_SYSAPI;
875     }
876 
877     if (!IsRunning()) {
878         MMI_HILOGE("Service is not running");
879         return MMISERVICE_NOT_RUNNING;
880     }
881     int32_t handlerType;
882     READINT32(data, handlerType, IPC_PROXY_DEAD_OBJECT_ERR);
883     if ((handlerType == InputHandlerType::INTERCEPTOR) &&
884         (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE))) {
885         MMI_HILOGE("Interceptor permission check failed");
886         return CHECK_PERMISSION_FAIL;
887     }
888     if ((handlerType == InputHandlerType::MONITOR) && (!PerHelper->CheckMonitor())) {
889         MMI_HILOGE("Monitor permission check failed");
890         return ERROR_NO_PERMISSION;
891     }
892     uint32_t eventType;
893     READUINT32(data, eventType, IPC_PROXY_DEAD_OBJECT_ERR);
894     int32_t priority;
895     READINT32(data, priority, IPC_PROXY_DEAD_OBJECT_ERR);
896     int32_t deviceTags;
897     READINT32(data, deviceTags, IPC_PROXY_DEAD_OBJECT_ERR);
898     int32_t ret = AddInputHandler(static_cast<InputHandlerType>(handlerType), eventType, priority,
899         deviceTags);
900     if (ret != RET_OK) {
901         MMI_HILOGE("Call AddInputHandler failed ret:%{public}d", ret);
902         return ret;
903     }
904     return RET_OK;
905 }
906 
StubRemoveInputHandler(MessageParcel & data,MessageParcel & reply)907 int32_t MultimodalInputConnectStub::StubRemoveInputHandler(MessageParcel& data, MessageParcel& reply)
908 {
909     CALL_DEBUG_ENTER;
910     if (!PerHelper->VerifySystemApp()) {
911         MMI_HILOGE("verify system APP failed");
912         return ERROR_NOT_SYSAPI;
913     }
914 
915     if (!IsRunning()) {
916         MMI_HILOGE("Service is not running");
917         return MMISERVICE_NOT_RUNNING;
918     }
919     int32_t handlerType;
920     READINT32(data, handlerType, IPC_PROXY_DEAD_OBJECT_ERR);
921     if ((handlerType == InputHandlerType::INTERCEPTOR) &&
922         (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE))) {
923         MMI_HILOGE("Interceptor permission check failed");
924         return CHECK_PERMISSION_FAIL;
925     }
926     if ((handlerType == InputHandlerType::MONITOR) && (!PerHelper->CheckMonitor())) {
927         MMI_HILOGE("Monitor permission check failed");
928         return CHECK_PERMISSION_FAIL;
929     }
930     uint32_t eventType;
931     READUINT32(data, eventType, IPC_PROXY_DEAD_OBJECT_ERR);
932     int32_t priority;
933     READINT32(data, priority, IPC_PROXY_DEAD_OBJECT_ERR);
934     int32_t deviceTags;
935     READINT32(data, deviceTags, IPC_PROXY_DEAD_OBJECT_ERR);
936     int32_t ret = RemoveInputHandler(static_cast<InputHandlerType>(handlerType), eventType, priority,
937         deviceTags);
938     if (ret != RET_OK) {
939         MMI_HILOGE("Call RemoveInputHandler failed ret:%{public}d", ret);
940         return ret;
941     }
942     return RET_OK;
943 }
944 
StubMarkEventConsumed(MessageParcel & data,MessageParcel & reply)945 int32_t MultimodalInputConnectStub::StubMarkEventConsumed(MessageParcel& data, MessageParcel& reply)
946 {
947     CALL_DEBUG_ENTER;
948     if (!PerHelper->CheckMonitor()) {
949         MMI_HILOGE("Permission check failed");
950         return CHECK_PERMISSION_FAIL;
951     }
952 
953     if (!IsRunning()) {
954         MMI_HILOGE("Service is not running");
955         return MMISERVICE_NOT_RUNNING;
956     }
957     int32_t eventId;
958     READINT32(data, eventId, IPC_PROXY_DEAD_OBJECT_ERR);
959     int32_t ret = MarkEventConsumed(eventId);
960     if (ret != RET_OK) {
961         MMI_HILOGE("Call MarkEventConsumed failed ret:%{public}d", ret);
962         return ret;
963     }
964     return RET_OK;
965 }
966 
StubSubscribeKeyEvent(MessageParcel & data,MessageParcel & reply)967 int32_t MultimodalInputConnectStub::StubSubscribeKeyEvent(MessageParcel& data, MessageParcel& reply)
968 {
969     CALL_DEBUG_ENTER;
970     if (!PerHelper->VerifySystemApp()) {
971         MMI_HILOGE("verify system APP failed");
972         return ERROR_NOT_SYSAPI;
973     }
974 
975     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
976         MMI_HILOGE("Permission check failed");
977         return CHECK_PERMISSION_FAIL;
978     }
979 
980     if (!IsRunning()) {
981         MMI_HILOGE("Service is not running");
982         return MMISERVICE_NOT_RUNNING;
983     }
984 
985     int32_t subscribeId;
986     READINT32(data, subscribeId, IPC_PROXY_DEAD_OBJECT_ERR);
987 
988     auto keyOption = std::make_shared<KeyOption>();
989     if (!keyOption->ReadFromParcel(data)) {
990         MMI_HILOGE("Read keyOption failed");
991         return IPC_PROXY_DEAD_OBJECT_ERR;
992     }
993     int32_t ret = SubscribeKeyEvent(subscribeId, keyOption);
994     if (ret != RET_OK) {
995         MMI_HILOGE("SubscribeKeyEvent failed, ret:%{public}d", ret);
996         return ret;
997     }
998     return RET_OK;
999 }
1000 
StubUnsubscribeKeyEvent(MessageParcel & data,MessageParcel & reply)1001 int32_t MultimodalInputConnectStub::StubUnsubscribeKeyEvent(MessageParcel& data, MessageParcel& reply)
1002 {
1003     CALL_DEBUG_ENTER;
1004     if (!PerHelper->VerifySystemApp()) {
1005         MMI_HILOGE("verify system APP failed");
1006         return ERROR_NOT_SYSAPI;
1007     }
1008 
1009     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
1010         MMI_HILOGE("Permission check failed");
1011         return CHECK_PERMISSION_FAIL;
1012     }
1013 
1014     if (!IsRunning()) {
1015         MMI_HILOGE("Service is not running");
1016         return MMISERVICE_NOT_RUNNING;
1017     }
1018 
1019     int32_t subscribeId;
1020     READINT32(data, subscribeId, IPC_PROXY_DEAD_OBJECT_ERR);
1021 
1022     int32_t ret = UnsubscribeKeyEvent(subscribeId);
1023     if (ret != RET_OK) {
1024         MMI_HILOGE("UnsubscribeKeyEvent failed, ret:%{public}d", ret);
1025         return ret;
1026     }
1027     return RET_OK;
1028 }
1029 
StubSubscribeSwitchEvent(MessageParcel & data,MessageParcel & reply)1030 int32_t MultimodalInputConnectStub::StubSubscribeSwitchEvent(MessageParcel& data, MessageParcel& reply)
1031 {
1032     CALL_DEBUG_ENTER;
1033     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
1034         MMI_HILOGE("Permission check failed");
1035         return CHECK_PERMISSION_FAIL;
1036     }
1037 
1038     if (!IsRunning()) {
1039         MMI_HILOGE("Service is not running");
1040         return MMISERVICE_NOT_RUNNING;
1041     }
1042 
1043     int32_t subscribeId;
1044     READINT32(data, subscribeId, IPC_PROXY_DEAD_OBJECT_ERR);
1045 
1046     int32_t ret = SubscribeSwitchEvent(subscribeId);
1047     if (ret != RET_OK) {
1048         MMI_HILOGE("SubscribeSwitchEvent failed, ret:%{public}d", ret);
1049     }
1050     return ret;
1051 }
1052 
StubUnsubscribeSwitchEvent(MessageParcel & data,MessageParcel & reply)1053 int32_t MultimodalInputConnectStub::StubUnsubscribeSwitchEvent(MessageParcel& data, MessageParcel& reply)
1054 {
1055     CALL_DEBUG_ENTER;
1056     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
1057         MMI_HILOGE("Permission check failed");
1058         return CHECK_PERMISSION_FAIL;
1059     }
1060 
1061     if (!IsRunning()) {
1062         MMI_HILOGE("Service is not running");
1063         return MMISERVICE_NOT_RUNNING;
1064     }
1065 
1066     int32_t subscribeId;
1067     READINT32(data, subscribeId, IPC_PROXY_DEAD_OBJECT_ERR);
1068 
1069     int32_t ret = UnsubscribeSwitchEvent(subscribeId);
1070     if (ret != RET_OK) {
1071         MMI_HILOGE("UnsubscribeSwitchEvent failed, ret:%{public}d", ret);
1072     }
1073     return ret;
1074 }
1075 
StubMoveMouseEvent(MessageParcel & data,MessageParcel & reply)1076 int32_t MultimodalInputConnectStub::StubMoveMouseEvent(MessageParcel& data, MessageParcel& reply)
1077 {
1078     CALL_DEBUG_ENTER;
1079     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
1080         MMI_HILOGE("Permission check failed");
1081         return CHECK_PERMISSION_FAIL;
1082     }
1083 
1084     if (!IsRunning()) {
1085         MMI_HILOGE("Service is not running");
1086         return MMISERVICE_NOT_RUNNING;
1087     }
1088     int32_t offsetX;
1089     READINT32(data, offsetX, IPC_PROXY_DEAD_OBJECT_ERR);
1090     int32_t offsetY;
1091     READINT32(data, offsetY, IPC_PROXY_DEAD_OBJECT_ERR);
1092 
1093     int32_t ret = MoveMouseEvent(offsetX, offsetY);
1094     if (ret != RET_OK) {
1095         MMI_HILOGE("MoveMouseEvent failed, ret:%{public}d", ret);
1096         return ret;
1097     }
1098     return RET_OK;
1099 }
1100 
StubInjectKeyEvent(MessageParcel & data,MessageParcel & reply)1101 int32_t MultimodalInputConnectStub::StubInjectKeyEvent(MessageParcel& data, MessageParcel& reply)
1102 {
1103     CALL_DEBUG_ENTER;
1104     if (!PerHelper->VerifySystemApp()) {
1105         MMI_HILOGE("verify system APP failed");
1106         return ERROR_NOT_SYSAPI;
1107     }
1108 
1109     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
1110         MMI_HILOGE("Permission check failed");
1111         return CHECK_PERMISSION_FAIL;
1112     }
1113     if (!IsRunning()) {
1114         MMI_HILOGE("Service is not running");
1115         return MMISERVICE_NOT_RUNNING;
1116     }
1117     auto event = KeyEvent::Create();
1118     CHKPR(event, ERROR_NULL_POINTER);
1119     if (!event->ReadFromParcel(data)) {
1120         MMI_HILOGE("Read Key Event failed");
1121         return IPC_PROXY_DEAD_OBJECT_ERR;
1122     }
1123     event->UpdateId();
1124     int32_t ret = InjectKeyEvent(event);
1125     if (ret != RET_OK) {
1126         MMI_HILOGE("InjectKeyEvent failed, ret:%{public}d", ret);
1127         return ret;
1128     }
1129     return RET_OK;
1130 }
1131 
StubInjectPointerEvent(MessageParcel & data,MessageParcel & reply)1132 int32_t MultimodalInputConnectStub::StubInjectPointerEvent(MessageParcel& data, MessageParcel& reply)
1133 {
1134     CALL_DEBUG_ENTER;
1135     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
1136         MMI_HILOGE("Permission check failed");
1137         return CHECK_PERMISSION_FAIL;
1138     }
1139     if (!IsRunning()) {
1140         MMI_HILOGE("Service is not running");
1141         return MMISERVICE_NOT_RUNNING;
1142     }
1143     auto pointerEvent = PointerEvent::Create();
1144     CHKPR(pointerEvent, ERROR_NULL_POINTER);
1145     if (!pointerEvent->ReadFromParcel(data)) {
1146         MMI_HILOGE("Read Pointer Event failed");
1147         return IPC_PROXY_DEAD_OBJECT_ERR;
1148     }
1149     int32_t ret = InjectPointerEvent(pointerEvent);
1150     if (ret != RET_OK) {
1151         MMI_HILOGE("Call InjectPointerEvent failed ret:%{public}d", ret);
1152         return ret;
1153     }
1154     return RET_OK;
1155 }
1156 
StubSetAnrListener(MessageParcel & data,MessageParcel & reply)1157 int32_t MultimodalInputConnectStub::StubSetAnrListener(MessageParcel& data, MessageParcel& reply)
1158 {
1159     CALL_DEBUG_ENTER;
1160     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
1161         MMI_HILOGE("Permission check failed");
1162         return CHECK_PERMISSION_FAIL;
1163     }
1164     if (!IsRunning()) {
1165         MMI_HILOGE("Service is not running");
1166         return MMISERVICE_NOT_RUNNING;
1167     }
1168     int32_t ret = SetAnrObserver();
1169     if (ret != RET_OK) {
1170         MMI_HILOGE("Call SetAnrObserver failed, ret:%{public}d", ret);
1171     }
1172     return ret;
1173 }
1174 
1175 
StubGetDisplayBindInfo(MessageParcel & data,MessageParcel & reply)1176 int32_t MultimodalInputConnectStub::StubGetDisplayBindInfo(MessageParcel& data, MessageParcel& reply)
1177 {
1178     CALL_DEBUG_ENTER;
1179     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
1180         MMI_HILOGE("Permission check failed");
1181         return CHECK_PERMISSION_FAIL;
1182     }
1183     if (!IsRunning()) {
1184         MMI_HILOGE("Service is not running");
1185         return MMISERVICE_NOT_RUNNING;
1186     }
1187     DisplayBindInfos infos;
1188     int32_t ret = GetDisplayBindInfo(infos);
1189     if (ret != RET_OK) {
1190         MMI_HILOGE("Call GetDisplayBindInfo failed, ret:%{public}d", ret);
1191         return ret;
1192     }
1193     int32_t size = static_cast<int32_t>(infos.size());
1194     WRITEINT32(reply, size, ERR_INVALID_VALUE);
1195     infos.reserve(size);
1196     for (const auto &info : infos) {
1197         WRITEINT32(reply, info.inputDeviceId, ERR_INVALID_VALUE);
1198         WRITESTRING(reply, info.inputDeviceName, ERR_INVALID_VALUE);
1199         WRITEINT32(reply, info.displayId, ERR_INVALID_VALUE);
1200         WRITESTRING(reply, info.displayName, ERR_INVALID_VALUE);
1201     }
1202     return RET_OK;
1203 }
1204 
StubSetDisplayBind(MessageParcel & data,MessageParcel & reply)1205 int32_t MultimodalInputConnectStub::StubSetDisplayBind(MessageParcel& data, MessageParcel& reply)
1206 {
1207     CALL_DEBUG_ENTER;
1208     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
1209         MMI_HILOGE("Permission check failed");
1210         return CHECK_PERMISSION_FAIL;
1211     }
1212     if (!IsRunning()) {
1213         MMI_HILOGE("Service is not running");
1214         return MMISERVICE_NOT_RUNNING;
1215     }
1216     int32_t inputDeviceId = -1;
1217     READINT32(data, inputDeviceId, ERR_INVALID_VALUE);
1218     int32_t displayId = -1;
1219     READINT32(data, displayId, ERR_INVALID_VALUE);
1220     std::string msg;
1221     int32_t ret = SetDisplayBind(inputDeviceId, displayId, msg);
1222     if (ret != RET_OK) {
1223         MMI_HILOGE("Call SetDisplayBind failed, ret:%{public}d", ret);
1224     }
1225     WRITESTRING(reply, msg, ERR_INVALID_VALUE);
1226     return ret;
1227 }
1228 
StubGetFunctionKeyState(MessageParcel & data,MessageParcel & reply)1229 int32_t MultimodalInputConnectStub::StubGetFunctionKeyState(MessageParcel &data, MessageParcel &reply)
1230 {
1231     CALL_DEBUG_ENTER;
1232     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
1233         MMI_HILOGE("Permission check failed");
1234         return CHECK_PERMISSION_FAIL;
1235     }
1236     if (!IsRunning()) {
1237         MMI_HILOGE("Service is not running");
1238         return MMISERVICE_NOT_RUNNING;
1239     }
1240 
1241     int32_t funcKey { 0 };
1242     bool state  { false };
1243     READINT32(data, funcKey, IPC_PROXY_DEAD_OBJECT_ERR);
1244     int32_t ret = GetFunctionKeyState(funcKey, state);
1245     if (ret != RET_OK) {
1246         MMI_HILOGE("Call GetKeyboardEnableState failed ret:%{public}d", ret);
1247         return ret;
1248     }
1249 
1250     WRITEBOOL(reply, state, IPC_PROXY_DEAD_OBJECT_ERR);
1251     return RET_OK;
1252 }
1253 
StubSetFunctionKeyState(MessageParcel & data,MessageParcel & reply)1254 int32_t MultimodalInputConnectStub::StubSetFunctionKeyState(MessageParcel &data, MessageParcel &reply)
1255 {
1256     CALL_DEBUG_ENTER;
1257     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
1258         MMI_HILOGE("Permission check failed");
1259         return CHECK_PERMISSION_FAIL;
1260     }
1261     if (!IsRunning()) {
1262         MMI_HILOGE("Service is not running");
1263         return MMISERVICE_NOT_RUNNING;
1264     }
1265 
1266     int32_t funcKey { 0 };
1267     bool enable  { false };
1268     READINT32(data, funcKey, IPC_PROXY_DEAD_OBJECT_ERR);
1269     READBOOL(data, enable, IPC_PROXY_DEAD_OBJECT_ERR);
1270     int32_t ret = SetFunctionKeyState(funcKey, enable);
1271     if (ret != RET_OK) {
1272         MMI_HILOGE("Call SetFunctionKeyState failed ret:%{public}d", ret);
1273     }
1274     return ret;
1275 }
1276 
StubSetPointerLocation(MessageParcel & data,MessageParcel & reply)1277 int32_t MultimodalInputConnectStub::StubSetPointerLocation(MessageParcel &data, MessageParcel &reply)
1278 {
1279     CALL_DEBUG_ENTER;
1280     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
1281         MMI_HILOGE("Permission check failed");
1282         return CHECK_PERMISSION_FAIL;
1283     }
1284     if (!IsRunning()) {
1285         MMI_HILOGE("Service is not running");
1286         return MMISERVICE_NOT_RUNNING;
1287     }
1288 
1289     int32_t x = 0;
1290     int32_t y = 0;
1291     READINT32(data, x, IPC_PROXY_DEAD_OBJECT_ERR);
1292     READINT32(data, y, IPC_PROXY_DEAD_OBJECT_ERR);
1293     int32_t ret = SetPointerLocation(x, y);
1294     if (ret != RET_OK) {
1295         MMI_HILOGE("Call SetFunctionKeyState failed ret:%{public}d", ret);
1296     }
1297     return ret;
1298 }
1299 
StubSetMouseCaptureMode(MessageParcel & data,MessageParcel & reply)1300 int32_t MultimodalInputConnectStub::StubSetMouseCaptureMode(MessageParcel& data, MessageParcel& reply)
1301 {
1302     CALL_DEBUG_ENTER;
1303     int32_t windowId = -1;
1304     bool isCaptureMode = false;
1305     READINT32(data, windowId, IPC_PROXY_DEAD_OBJECT_ERR);
1306     READBOOL(data, isCaptureMode, IPC_PROXY_DEAD_OBJECT_ERR);
1307     int32_t ret = SetMouseCaptureMode(windowId, isCaptureMode);
1308     if (ret != RET_OK) {
1309         MMI_HILOGE("Fail to call SetMouseCaptureMode, ret:%{public}d", ret);
1310     }
1311     return ret;
1312 }
1313 
StubGetWindowPid(MessageParcel & data,MessageParcel & reply)1314 int32_t MultimodalInputConnectStub::StubGetWindowPid(MessageParcel& data, MessageParcel& reply)
1315 {
1316     CALL_DEBUG_ENTER;
1317     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
1318         MMI_HILOGE("Permission check failed");
1319         return CHECK_PERMISSION_FAIL;
1320     }
1321     if (!IsRunning()) {
1322         MMI_HILOGE("Service is not running");
1323         return MMISERVICE_NOT_RUNNING;
1324     }
1325 
1326     int32_t windowId = 0;
1327     READINT32(data, windowId, IPC_PROXY_DEAD_OBJECT_ERR);
1328     int32_t ret = GetWindowPid(windowId);
1329     if (ret == RET_ERR) {
1330         MMI_HILOGE("Get window pid failed");
1331     }
1332     WRITEINT32(reply, ret, ERR_INVALID_VALUE);
1333     return RET_OK;
1334 }
1335 
StubAppendExtraData(MessageParcel & data,MessageParcel & reply)1336 int32_t MultimodalInputConnectStub::StubAppendExtraData(MessageParcel& data, MessageParcel& reply)
1337 {
1338     CALL_DEBUG_ENTER;
1339     if (!IsRunning()) {
1340         MMI_HILOGE("Service is not running");
1341         return MMISERVICE_NOT_RUNNING;
1342     }
1343     ExtraData extraData;
1344     READBOOL(data, extraData.appended, IPC_PROXY_DEAD_OBJECT_ERR);
1345     int32_t size = 0;
1346     READINT32(data, size, IPC_PROXY_DEAD_OBJECT_ERR);
1347     if (size > ExtraData::MAX_BUFFER_SIZE) {
1348         MMI_HILOGE("Append extra data failed, buffer is oversize:%{public}d", size);
1349         return ERROR_OVER_SIZE_BUFFER;
1350     }
1351     uint8_t buffer = 0;
1352     for (int32_t i = 0; i < size; ++i) {
1353         READUINT8(data, buffer, IPC_PROXY_DEAD_OBJECT_ERR);
1354         extraData.buffer.push_back(buffer);
1355     }
1356     READINT32(data, extraData.sourceType, IPC_PROXY_DEAD_OBJECT_ERR);
1357     READINT32(data, extraData.pointerId, IPC_PROXY_DEAD_OBJECT_ERR);
1358     int32_t ret = AppendExtraData(extraData);
1359     if (ret != RET_OK) {
1360         MMI_HILOGE("Fail to call AppendExtraData, ret:%{public}d", ret);
1361     }
1362     return ret;
1363 }
1364 
StubEnableInputDevice(MessageParcel & data,MessageParcel & reply)1365 int32_t MultimodalInputConnectStub::StubEnableInputDevice(MessageParcel& data, MessageParcel& reply)
1366 {
1367     CALL_DEBUG_ENTER;
1368     if (!IsRunning()) {
1369         MMI_HILOGE("Service is not running");
1370         return MMISERVICE_NOT_RUNNING;
1371     }
1372     bool enable;
1373     READBOOL(data, enable, IPC_PROXY_DEAD_OBJECT_ERR);
1374     int32_t ret = EnableInputDevice(enable);
1375     if (ret != RET_OK) {
1376         MMI_HILOGE("Call EnableInputDevice failed, ret:%{public}d", ret);
1377     }
1378     return ret;
1379 }
1380 
StubSetKeyDownDuration(MessageParcel & data,MessageParcel & reply)1381 int32_t MultimodalInputConnectStub::StubSetKeyDownDuration(MessageParcel& data, MessageParcel& reply)
1382 {
1383     CALL_DEBUG_ENTER;
1384     if (!PerHelper->VerifySystemApp()) {
1385         MMI_HILOGE("verify system APP failed");
1386         return ERROR_NOT_SYSAPI;
1387     }
1388 
1389     if (!PerHelper->CheckPermission(PermissionHelper::APL_SYSTEM_BASIC_CORE)) {
1390         MMI_HILOGE("Permission check failed");
1391         return CHECK_PERMISSION_FAIL;
1392     }
1393     if (!IsRunning()) {
1394         MMI_HILOGE("Service is not running");
1395         return MMISERVICE_NOT_RUNNING;
1396     }
1397     std::string businessId;
1398     READSTRING(data, businessId, IPC_PROXY_DEAD_OBJECT_ERR);
1399     int32_t delay;
1400     READINT32(data, delay, IPC_PROXY_DEAD_OBJECT_ERR);
1401     int32_t ret = SetKeyDownDuration(businessId, delay);
1402     if (ret != RET_OK) {
1403         MMI_HILOGE("Set key down duration failed ret:%{public}d", ret);
1404         return ret;
1405     }
1406     return RET_OK;
1407 }
1408 
VerifyTouchPadSetting(void)1409 int32_t MultimodalInputConnectStub::VerifyTouchPadSetting(void)
1410 {
1411     if (!IsRunning()) {
1412         MMI_HILOGE("Service is not running");
1413         return MMISERVICE_NOT_RUNNING;
1414     }
1415 
1416     if (!PerHelper->VerifySystemApp()) {
1417         MMI_HILOGE("Verify system APP failed");
1418         return ERROR_NOT_SYSAPI;
1419     }
1420 
1421     return RET_OK;
1422 }
1423 
StubSetTouchpadScrollSwitch(MessageParcel & data,MessageParcel & reply)1424 int32_t MultimodalInputConnectStub::StubSetTouchpadScrollSwitch(MessageParcel& data, MessageParcel& reply)
1425 {
1426     CALL_DEBUG_ENTER;
1427     int32_t ret = VerifyTouchPadSetting();
1428     if (ret != RET_OK) {
1429         MMI_HILOGE("Verify touchpad setting failed.");
1430         return ret;
1431     }
1432 
1433     bool switchFlag = true;
1434     READBOOL(data, switchFlag, IPC_PROXY_DEAD_OBJECT_ERR);
1435     ret = SetTouchpadScrollSwitch(switchFlag);
1436     if (ret != RET_OK) {
1437         MMI_HILOGE("Set touchpad scroll switch failed ret:%{public}d", ret);
1438         return ret;
1439     }
1440     return RET_OK;
1441 }
1442 
StubGetTouchpadScrollSwitch(MessageParcel & data,MessageParcel & reply)1443 int32_t MultimodalInputConnectStub::StubGetTouchpadScrollSwitch(MessageParcel& data, MessageParcel& reply)
1444 {
1445     CALL_DEBUG_ENTER;
1446     int32_t ret = VerifyTouchPadSetting();
1447     if (ret != RET_OK) {
1448         MMI_HILOGE("Verify touchpad setting failed.");
1449         return ret;
1450     }
1451 
1452     bool switchFlag = true;
1453     ret = GetTouchpadScrollSwitch(switchFlag);
1454     if (ret != RET_OK) {
1455         MMI_HILOGE("Call GetTouchpadScrollSwitch failed ret:%{public}d", ret);
1456         return ret;
1457     }
1458     WRITEBOOL(reply, switchFlag, IPC_STUB_WRITE_PARCEL_ERR);
1459     MMI_HILOGD("Touchpad scroll switch :%{public}d, ret:%{public}d", switchFlag, ret);
1460     return RET_OK;
1461 }
1462 
StubSetTouchpadScrollDirection(MessageParcel & data,MessageParcel & reply)1463 int32_t MultimodalInputConnectStub::StubSetTouchpadScrollDirection(MessageParcel& data, MessageParcel& reply)
1464 {
1465     CALL_DEBUG_ENTER;
1466     int32_t ret = VerifyTouchPadSetting();
1467     if (ret != RET_OK) {
1468         MMI_HILOGE("Verify touchpad setting failed.");
1469         return ret;
1470     }
1471 
1472     bool state = true;
1473     READBOOL(data, state, IPC_PROXY_DEAD_OBJECT_ERR);
1474     ret = SetTouchpadScrollDirection(state);
1475     if (ret != RET_OK) {
1476         MMI_HILOGE("Set touchpad scroll direction switch failed ret:%{public}d", ret);
1477         return ret;
1478     }
1479     return RET_OK;
1480 }
1481 
StubGetTouchpadScrollDirection(MessageParcel & data,MessageParcel & reply)1482 int32_t MultimodalInputConnectStub::StubGetTouchpadScrollDirection(MessageParcel& data, MessageParcel& reply)
1483 {
1484     CALL_DEBUG_ENTER;
1485     int32_t ret = VerifyTouchPadSetting();
1486     if (ret != RET_OK) {
1487         MMI_HILOGE("Verify touchpad setting failed.");
1488         return ret;
1489     }
1490 
1491     bool state = true;
1492     ret = GetTouchpadScrollDirection(state);
1493     if (ret != RET_OK) {
1494         MMI_HILOGE("Call GetTouchpadScrollDirection failed ret:%{public}d", ret);
1495         return ret;
1496     }
1497     WRITEBOOL(reply, state, IPC_STUB_WRITE_PARCEL_ERR);
1498     MMI_HILOGD("Touchpad scroll direction switch :%{public}d, ret:%{public}d", state, ret);
1499     return RET_OK;
1500 }
1501 
StubSetTouchpadTapSwitch(MessageParcel & data,MessageParcel & reply)1502 int32_t MultimodalInputConnectStub::StubSetTouchpadTapSwitch(MessageParcel& data, MessageParcel& reply)
1503 {
1504     CALL_DEBUG_ENTER;
1505     int32_t ret = VerifyTouchPadSetting();
1506     if (ret != RET_OK) {
1507         MMI_HILOGE("Verify touchpad setting failed.");
1508         return ret;
1509     }
1510 
1511     bool switchFlag = true;
1512     READBOOL(data, switchFlag, IPC_PROXY_DEAD_OBJECT_ERR);
1513     ret = SetTouchpadTapSwitch(switchFlag);
1514     if (ret != RET_OK) {
1515         MMI_HILOGE("Set touchpad tap switch failed ret:%{public}d", ret);
1516         return ret;
1517     }
1518     return RET_OK;
1519 }
1520 
StubGetTouchpadTapSwitch(MessageParcel & data,MessageParcel & reply)1521 int32_t MultimodalInputConnectStub::StubGetTouchpadTapSwitch(MessageParcel& data, MessageParcel& reply)
1522 {
1523     CALL_DEBUG_ENTER;
1524     int32_t ret = VerifyTouchPadSetting();
1525     if (ret != RET_OK) {
1526         MMI_HILOGE("Verify touchpad setting failed.");
1527         return ret;
1528     }
1529 
1530     bool switchFlag = true;
1531     ret = GetTouchpadTapSwitch(switchFlag);
1532     if (ret != RET_OK) {
1533         MMI_HILOGE("Call GetTouchpadTapSwitch failed ret:%{public}d", ret);
1534         return ret;
1535     }
1536     WRITEBOOL(reply, switchFlag, IPC_STUB_WRITE_PARCEL_ERR);
1537     MMI_HILOGD("Touchpad tap switch :%{public}d, ret:%{public}d", switchFlag, ret);
1538     return RET_OK;
1539 }
1540 
StubSetTouchpadPointerSpeed(MessageParcel & data,MessageParcel & reply)1541 int32_t MultimodalInputConnectStub::StubSetTouchpadPointerSpeed(MessageParcel& data, MessageParcel& reply)
1542 {
1543     CALL_DEBUG_ENTER;
1544     int32_t ret = VerifyTouchPadSetting();
1545     if (ret != RET_OK) {
1546         MMI_HILOGE("Verify touchpad setting failed.");
1547         return ret;
1548     }
1549 
1550     int32_t speed = 1;
1551     READINT32(data, speed, IPC_PROXY_DEAD_OBJECT_ERR);
1552     ret = SetTouchpadPointerSpeed(speed);
1553     if (ret != RET_OK) {
1554         MMI_HILOGE("Set touchpad pointer speed failed ret:%{public}d", ret);
1555         return ret;
1556     }
1557     return RET_OK;
1558 }
1559 
StubGetTouchpadPointerSpeed(MessageParcel & data,MessageParcel & reply)1560 int32_t MultimodalInputConnectStub::StubGetTouchpadPointerSpeed(MessageParcel& data, MessageParcel& reply)
1561 {
1562     CALL_DEBUG_ENTER;
1563     int32_t ret = VerifyTouchPadSetting();
1564     if (ret != RET_OK) {
1565         MMI_HILOGE("Verify touchpad setting failed.");
1566         return ret;
1567     }
1568 
1569     int32_t speed = 1;
1570     ret = GetTouchpadPointerSpeed(speed);
1571     if (ret != RET_OK) {
1572         MMI_HILOGE("Call GetTouchpadPointerSpeed failed ret:%{public}d", ret);
1573         return ret;
1574     }
1575     WRITEINT32(reply, speed, IPC_STUB_WRITE_PARCEL_ERR);
1576     MMI_HILOGD("Touchpad pointer speed :%{public}d, ret:%{public}d", speed, ret);
1577     return RET_OK;
1578 }
1579 
StubSetKeyboardRepeatDelay(MessageParcel & data,MessageParcel & reply)1580 int32_t MultimodalInputConnectStub::StubSetKeyboardRepeatDelay(MessageParcel& data, MessageParcel& reply)
1581 {
1582     CALL_DEBUG_ENTER;
1583     if (!IsRunning()) {
1584         MMI_HILOGE("Service is not running");
1585         return MMISERVICE_NOT_RUNNING;
1586     }
1587     if (!PerHelper->VerifySystemApp()) {
1588         MMI_HILOGE("Verify system APP failed");
1589         return ERROR_NOT_SYSAPI;
1590     }
1591     int32_t delay;
1592     READINT32(data, delay, IPC_PROXY_DEAD_OBJECT_ERR);
1593     int32_t ret = SetKeyboardRepeatDelay(delay);
1594     if (ret != RET_OK) {
1595         MMI_HILOGE("Set keyboard repeat delay failed ret:%{public}d", ret);
1596         return RET_ERR;
1597     }
1598     return RET_OK;
1599 }
1600 
StubSetKeyboardRepeatRate(MessageParcel & data,MessageParcel & reply)1601 int32_t MultimodalInputConnectStub::StubSetKeyboardRepeatRate(MessageParcel& data, MessageParcel& reply)
1602 {
1603     CALL_DEBUG_ENTER;
1604     if (!IsRunning()) {
1605         MMI_HILOGE("Service is not running");
1606         return MMISERVICE_NOT_RUNNING;
1607     }
1608     if (!PerHelper->VerifySystemApp()) {
1609         MMI_HILOGE("Verify system APP failed");
1610         return ERROR_NOT_SYSAPI;
1611     }
1612     int32_t rate;
1613     READINT32(data, rate, IPC_PROXY_DEAD_OBJECT_ERR);
1614     int32_t ret = SetKeyboardRepeatRate(rate);
1615     if (ret != RET_OK) {
1616         MMI_HILOGE("Set keyboard repeat rate failed ret:%{public}d", ret);
1617         return RET_ERR;
1618     }
1619     return RET_OK;
1620 }
1621 
StubGetKeyboardRepeatDelay(MessageParcel & data,MessageParcel & reply)1622 int32_t MultimodalInputConnectStub::StubGetKeyboardRepeatDelay(MessageParcel& data, MessageParcel& reply)
1623 {
1624     CALL_DEBUG_ENTER;
1625     if (!IsRunning()) {
1626         MMI_HILOGE("Service is not running");
1627         return MMISERVICE_NOT_RUNNING;
1628     }
1629     if (!PerHelper->VerifySystemApp()) {
1630         MMI_HILOGE("Verify system APP failed");
1631         return ERROR_NOT_SYSAPI;
1632     }
1633     int32_t delay;
1634     int32_t ret = GetKeyboardRepeatDelay(delay);
1635     if (ret != RET_OK) {
1636         MMI_HILOGE("Get keyboard repeat delay failed ret:%{public}d", ret);
1637         return RET_ERR;
1638     }
1639     WRITEINT32(reply, delay, IPC_STUB_WRITE_PARCEL_ERR);
1640     return RET_OK;
1641 }
1642 
StubGetKeyboardRepeatRate(MessageParcel & data,MessageParcel & reply)1643 int32_t MultimodalInputConnectStub::StubGetKeyboardRepeatRate(MessageParcel& data, MessageParcel& reply)
1644 {
1645     CALL_DEBUG_ENTER;
1646     if (!IsRunning()) {
1647         MMI_HILOGE("Service is not running");
1648         return MMISERVICE_NOT_RUNNING;
1649     }
1650     if (!PerHelper->VerifySystemApp()) {
1651         MMI_HILOGE("Verify system APP failed");
1652         return ERROR_NOT_SYSAPI;
1653     }
1654     int32_t rate;
1655     int32_t ret = GetKeyboardRepeatRate(rate);
1656     if (ret != RET_OK) {
1657         MMI_HILOGE("Get keyboard repeat rate failed ret:%{public}d", ret);
1658         return RET_ERR;
1659     }
1660     WRITEINT32(reply, rate, IPC_STUB_WRITE_PARCEL_ERR);
1661     return RET_OK;
1662 }
1663 
StubSetTouchpadPinchSwitch(MessageParcel & data,MessageParcel & reply)1664 int32_t MultimodalInputConnectStub::StubSetTouchpadPinchSwitch(MessageParcel& data, MessageParcel& reply)
1665 {
1666     CALL_DEBUG_ENTER;
1667     int32_t ret = VerifyTouchPadSetting();
1668     if (ret != RET_OK) {
1669         MMI_HILOGE("Verify touchpad setting failed.");
1670         return ret;
1671     }
1672 
1673     bool switchFlag = true;
1674     READBOOL(data, switchFlag, IPC_PROXY_DEAD_OBJECT_ERR);
1675     ret = SetTouchpadPinchSwitch(switchFlag);
1676     if (ret != RET_OK) {
1677         MMI_HILOGE("Set touchpad pinch switch failed ret:%{public}d", ret);
1678         return ret;
1679     }
1680     return RET_OK;
1681 }
1682 
StubGetTouchpadPinchSwitch(MessageParcel & data,MessageParcel & reply)1683 int32_t MultimodalInputConnectStub::StubGetTouchpadPinchSwitch(MessageParcel& data, MessageParcel& reply)
1684 {
1685     CALL_DEBUG_ENTER;
1686     int32_t ret = VerifyTouchPadSetting();
1687     if (ret != RET_OK) {
1688         MMI_HILOGE("Verify touchpad setting failed.");
1689         return ret;
1690     }
1691 
1692     bool switchFlag = true;
1693     ret = GetTouchpadPinchSwitch(switchFlag);
1694     if (ret != RET_OK) {
1695         MMI_HILOGE("Call GetTouchpadPinchSwitch failed ret:%{public}d", ret);
1696         return ret;
1697     }
1698     WRITEBOOL(reply, switchFlag, IPC_STUB_WRITE_PARCEL_ERR);
1699     MMI_HILOGD("Touchpad pinch switch :%{public}d, ret:%{public}d", switchFlag, ret);
1700     return RET_OK;
1701 }
1702 
StubSetTouchpadSwipeSwitch(MessageParcel & data,MessageParcel & reply)1703 int32_t MultimodalInputConnectStub::StubSetTouchpadSwipeSwitch(MessageParcel& data, MessageParcel& reply)
1704 {
1705     CALL_DEBUG_ENTER;
1706     int32_t ret = VerifyTouchPadSetting();
1707     if (ret != RET_OK) {
1708         MMI_HILOGE("Verify touchpad setting failed.");
1709         return ret;
1710     }
1711 
1712     bool switchFlag = true;
1713     READBOOL(data, switchFlag, IPC_PROXY_DEAD_OBJECT_ERR);
1714     ret = SetTouchpadSwipeSwitch(switchFlag);
1715     if (ret != RET_OK) {
1716         MMI_HILOGE("Set touchpad swipe switch failed ret:%{public}d", ret);
1717         return ret;
1718     }
1719     return RET_OK;
1720 }
1721 
StubGetTouchpadSwipeSwitch(MessageParcel & data,MessageParcel & reply)1722 int32_t MultimodalInputConnectStub::StubGetTouchpadSwipeSwitch(MessageParcel& data, MessageParcel& reply)
1723 {
1724     CALL_DEBUG_ENTER;
1725     int32_t ret = VerifyTouchPadSetting();
1726     if (ret != RET_OK) {
1727         MMI_HILOGE("Verify touchpad setting failed.");
1728         return ret;
1729     }
1730 
1731     bool switchFlag = true;
1732     ret = GetTouchpadSwipeSwitch(switchFlag);
1733     if (ret != RET_OK) {
1734         MMI_HILOGE("Call GetTouchpadSwipeSwitch failed ret:%{public}d", ret);
1735         return ret;
1736     }
1737     WRITEBOOL(reply, switchFlag, IPC_STUB_WRITE_PARCEL_ERR);
1738     MMI_HILOGD("Touchpad swipe switch :%{public}d, ret:%{public}d", switchFlag, ret);
1739     return RET_OK;
1740 }
1741 
StubSetTouchpadRightClickType(MessageParcel & data,MessageParcel & reply)1742 int32_t MultimodalInputConnectStub::StubSetTouchpadRightClickType(MessageParcel& data, MessageParcel& reply)
1743 {
1744     CALL_DEBUG_ENTER;
1745     int32_t ret = VerifyTouchPadSetting();
1746     if (ret != RET_OK) {
1747         MMI_HILOGE("Verify touchpad setting failed.");
1748         return ret;
1749     }
1750 
1751     int32_t type = 1;
1752     READINT32(data, type, IPC_PROXY_DEAD_OBJECT_ERR);
1753     ret = SetTouchpadRightClickType(type);
1754     if (ret != RET_OK) {
1755         MMI_HILOGE("Set touchpad right button menu type failed ret:%{public}d", ret);
1756         return ret;
1757     }
1758     return RET_OK;
1759 }
1760 
StubGetTouchpadRightClickType(MessageParcel & data,MessageParcel & reply)1761 int32_t MultimodalInputConnectStub::StubGetTouchpadRightClickType(MessageParcel& data, MessageParcel& reply)
1762 {
1763     CALL_DEBUG_ENTER;
1764     int32_t ret = VerifyTouchPadSetting();
1765     if (ret != RET_OK) {
1766         MMI_HILOGE("Verify touchpad setting failed.");
1767         return ret;
1768     }
1769 
1770     int32_t type = 1;
1771     ret = GetTouchpadRightClickType(type);
1772     if (ret != RET_OK) {
1773         MMI_HILOGE("Call GetTouchpadRightClickType failed ret:%{public}d", ret);
1774         return ret;
1775     }
1776     WRITEINT32(reply, type, IPC_STUB_WRITE_PARCEL_ERR);
1777     MMI_HILOGD("Touchpad right button menu type :%{public}d, ret:%{public}d", type, ret);
1778     return RET_OK;
1779 }
1780 } // namespace MMI
1781 } // namespace OHOS
1782