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