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