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