diff --git a/BUILD.gn b/BUILD.gn index 24ec5287d5028b43f4551ec75add1749bcadff21..facec1bc370ef2fbb9ec64152597e81cd8bf8cab 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -181,7 +181,6 @@ group("mmi_tests") { "service:EventFilterHandlerTest", "service:EventHandlerTest", "service:EventNormalizeHandlerTest", - "service:InfraredEmitterTest", "service:InputDisplayBindHelperTest", "service:InputEventHandlerTest", "service:InputWindowsManagerEXTest", @@ -244,6 +243,10 @@ group("mmi_tests") { "service:TouchDrawingManagerTest", ] } + + if (drivers_interface_rtos_extra_enable) { + deps += [ "service:InfraredEmitterTest" ] + } } group("examples_group") { diff --git a/bundle.json b/bundle.json index 5701997a16cff1c426194e622a859df9bcd450df..3666eb91fc837fa99bec01b4af4b69eb12fff1db 100644 --- a/bundle.json +++ b/bundle.json @@ -102,7 +102,8 @@ "ipc", "sensor", "idl_tool", - "runtime_core" + "runtime_core", + "drivers_interface_rtos_extra" ], "third_party": [ "libuv", diff --git a/frameworks/napi/input_event_client/src/js_register_module.cpp b/frameworks/napi/input_event_client/src/js_register_module.cpp index 1ff3b5b4d58eaf00b8287838c2af835ad07888ed..0434d0341537499f7f0b04d0790520003973ebc1 100644 --- a/frameworks/napi/input_event_client/src/js_register_module.cpp +++ b/frameworks/napi/input_event_client/src/js_register_module.cpp @@ -375,6 +375,8 @@ static void HandleMousePropertyInt32(napi_env env, napi_value mouseHandle, item.SetPointerId(0); item.SetDisplayX(screenX); item.SetDisplayY(screenY); + item.SetDisplayXPos(screenX); + item.SetDisplayYPos(screenY); pointerEvent->SetPointerId(0); pointerEvent->AddPointerItem(item); } @@ -504,6 +506,8 @@ static void HandleTouchAttribute(napi_env env, std::shared_ptr poi } pointerItem.SetDisplayX(screenX); pointerItem.SetDisplayY(screenY); + pointerItem.SetDisplayXPos(screenX); + pointerItem.SetDisplayYPos(screenY); pointerItem.SetPointerId(pointerId); pointerItem.SetToolType(toolType); pointerItem.SetPressure(pressure); diff --git a/frameworks/native/input/oh_input_manager.cpp b/frameworks/native/input/oh_input_manager.cpp index a3cc8b41ebb9ad7cd341e4d71b0c3446eba0249c..8f46190d9a1364ccbb4eb1473f70653d51321598 100644 --- a/frameworks/native/input/oh_input_manager.cpp +++ b/frameworks/native/input/oh_input_manager.cpp @@ -172,6 +172,7 @@ static const std::vector g_finalKeyCodes = { OHOS::MMI::KeyEvent::KEYCODE_META_LEFT, OHOS::MMI::KeyEvent::KEYCODE_META_RIGHT }; +using OHOS::MMI::AUTHORIZE_QUERY_STATE; Input_Result OH_Input_GetKeyState(struct Input_KeyState* keyState) { @@ -505,6 +506,8 @@ static int32_t HandleMouseProperty(const struct Input_MouseEvent* mouseEvent, item.SetPointerId(0); item.SetDisplayX(screenX); item.SetDisplayY(screenY); + item.SetDisplayXPos(screenX); + item.SetDisplayYPos(screenY); g_mouseEvent->SetPointerId(0); g_mouseEvent->UpdatePointerItem(g_mouseEvent->GetPointerId(), item); return INPUT_SUCCESS; @@ -790,6 +793,8 @@ static int32_t HandleTouchProperty(const struct Input_TouchEvent* touchEvent, } item.SetDisplayX(screenX); item.SetDisplayY(screenY); + item.SetDisplayXPos(screenX); + item.SetDisplayYPos(screenY); item.SetPointerId(id); g_touchEvent->SetPointerId(id); g_touchEvent->SetSourceType(OHOS::MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN); @@ -2722,6 +2727,108 @@ Input_Result OH_Input_QueryMaxTouchPoints(int32_t *count) return INPUT_SUCCESS; } +Input_Result OH_Input_RequestInjection(Input_InjectAuthorizeCallback callback) +{ + CALL_DEBUG_ENTER; + CHKPR(callback, INPUT_PARAMETER_ERROR); + int32_t reqId = 0; + int32_t status = 0; + int32_t ret = OHOS::MMI::InputManager::GetInstance()->RequestInjection(status, reqId); + MMI_HILOGD("RequestInjection ret:%{public}d,status:%{public}d,reqId:%{public}d", ret, status, reqId); + if (ret != RET_OK) { + MMI_HILOGE("RequestInjection fail, error:%{public}d", ret); + if (ret == OHOS::MMI::ERROR_DEVICE_NOT_SUPPORTED) { + return INPUT_DEVICE_NOT_SUPPORTED; + } + if (ret == OHOS::MMI::ERROR_OPERATION_FREQUENT) { + return INPUT_INJECTION_OPERATION_FREQUENT; + } + return INPUT_SERVICE_EXCEPTION; + } + AUTHORIZE_QUERY_STATE recvStatus = static_cast(status); + if (recvStatus == AUTHORIZE_QUERY_STATE::OTHER_PID_IN_AUTHORIZATION_SELECTION || + recvStatus == AUTHORIZE_QUERY_STATE::CURRENT_PID_IN_AUTHORIZATION_SELECTION) { + return INPUT_INJECTION_AUTHORIZING; + } + if (recvStatus == AUTHORIZE_QUERY_STATE::OTHER_PID_AUTHORIZED) { + return INPUT_INJECTION_AUTHORIZED_OTHERS; + } + if (recvStatus == AUTHORIZE_QUERY_STATE::CURRENT_PID_AUTHORIZED) { + return INPUT_INJECTION_AUTHORIZED; + } + if (recvStatus == AUTHORIZE_QUERY_STATE::UNAUTHORIZED) { + MMI_HILOGD("RequestInjection ok reqId:%{public}d", reqId); + OHOS::MMI::InputManager::GetInstance()->InsertRequestInjectionCallback(reqId, + [callback, reqId](int32_t status) { + MMI_HILOGD("RequestInjection callback reqId:%{public}d,status:%{public}d", + reqId, status); + AUTHORIZE_QUERY_STATE callStatus = static_cast(status); + if (callStatus == AUTHORIZE_QUERY_STATE::CURRENT_PID_AUTHORIZED) { + callback(Input_InjectionStatus::AUTHORIZED); + } else { + callback(Input_InjectionStatus::UNAUTHORIZED); + } + }); + return INPUT_SUCCESS; + } + return INPUT_SERVICE_EXCEPTION; +} + +Input_Result OH_Input_QueryAuthorizedStatus(Input_InjectionStatus* status) +{ + CALL_DEBUG_ENTER; + CHKPR(status, INPUT_PARAMETER_ERROR); + int32_t tmpStatus = 0; + int32_t ret = OHOS::MMI::InputManager::GetInstance()->QueryAuthorizedStatus(tmpStatus); + MMI_HILOGD("QueryAuthorizedStatus ret:%{public}d,tmpStatus:%{public}d", ret, tmpStatus); + if (ret != RET_OK) { + MMI_HILOGE("QueryAuthorizedStatus fail, error:%{public}d", ret); + return INPUT_SERVICE_EXCEPTION; + } + AUTHORIZE_QUERY_STATE recvStatus = static_cast(tmpStatus); + if (recvStatus == AUTHORIZE_QUERY_STATE::OTHER_PID_IN_AUTHORIZATION_SELECTION + || recvStatus == AUTHORIZE_QUERY_STATE::OTHER_PID_AUTHORIZED + || recvStatus == AUTHORIZE_QUERY_STATE::UNAUTHORIZED) { + *status = Input_InjectionStatus::UNAUTHORIZED; + } else if (recvStatus == AUTHORIZE_QUERY_STATE::CURRENT_PID_IN_AUTHORIZATION_SELECTION) { + *status = Input_InjectionStatus::AUTHORIZING; + } else if (recvStatus == AUTHORIZE_QUERY_STATE::CURRENT_PID_AUTHORIZED) { + *status = Input_InjectionStatus::AUTHORIZED; + } else { + MMI_HILOGE("QueryAuthorizedStatus fail, status:%{public}d", recvStatus); + return INPUT_SERVICE_EXCEPTION; + } + return INPUT_SUCCESS; +} + +Input_Result OH_Input_GetPointerLocation(int32_t *displayId, double *displayX, double *displayY) +{ + CALL_DEBUG_ENTER; + CHKPR(displayId, INPUT_PARAMETER_ERROR); + CHKPR(displayX, INPUT_PARAMETER_ERROR); + CHKPR(displayY, INPUT_PARAMETER_ERROR); + int32_t tmpDisplayId = 0; + double tmpX = 0.0; + double tmpY = 0.0; + int32_t ret = OHOS::MMI::InputManager::GetInstance()->GetPointerLocation(tmpDisplayId, tmpX, tmpY); + if (ret != RET_OK) { + MMI_HILOGE("Query pointer location failed, error:%{public}d", ret); + if (ret == OHOS::MMI::ERROR_DEVICE_NO_POINTER) { + MMI_HILOGE("The device has no pointer"); + return INPUT_DEVICE_NO_POINTER; + } + if (ret == OHOS::MMI::ERROR_APP_NOT_FOCUSED) { + MMI_HILOGE("The app is not the focused app"); + return INPUT_APP_NOT_FOCUSED; + } + return INPUT_SERVICE_EXCEPTION; + } + *displayId = tmpDisplayId; + *displayX = tmpX; + *displayY = tmpY; + return INPUT_SUCCESS; +} + static void TransformTouchActionDown(std::shared_ptr pointerEvent, OHOS::MMI::PointerEvent::PointerItem &item, int64_t time) { @@ -2794,6 +2901,8 @@ static int32_t TransformTouchProperty(const struct Input_TouchEvent *touchEvent, } item.SetDisplayX(screenX); item.SetDisplayY(screenY); + item.SetDisplayXPos(screenX); + item.SetDisplayYPos(screenY); int32_t globalX = touchEvent->globalX; int32_t globalY = touchEvent->globalY; @@ -2801,6 +2910,8 @@ static int32_t TransformTouchProperty(const struct Input_TouchEvent *touchEvent, item.SetGlobalY(globalY); item.SetWindowX(windowX); item.SetWindowY(windowY); + item.SetWindowXPos(windowX); + item.SetWindowYPos(windowY); int32_t id = touchEvent->id; if (id < 0) { diff --git a/frameworks/native/input/test/oh_input_manager_test.cpp b/frameworks/native/input/test/oh_input_manager_test.cpp index da666abc21fbf39b047031bf13c32883eff5f7d5..5719525115cdb975ba464be7568b08726bdcde17 100644 --- a/frameworks/native/input/test/oh_input_manager_test.cpp +++ b/frameworks/native/input/test/oh_input_manager_test.cpp @@ -84,6 +84,7 @@ constexpr int32_t MAX_MULTI_TOUCH_POINT_NUM { 10 }; constexpr int32_t UNKNOWN_MULTI_TOUCH_POINT_NUM { -1 }; constexpr int32_t DEFAULT_GLOBAL_X { -1 }; constexpr int32_t DEFAULT_GLOBAL_Y { -1 }; +constexpr int32_t REQUEST_INJECTION_TIME_MS { 4000 }; } // namespace class OHInputManagerTest : public testing::Test { @@ -1988,5 +1989,95 @@ HWTEST_F(OHInputManagerTest, OHInputManagerTest_AxisEventGlobalCoordinates, Test ASSERT_EQ(OH_Input_GetAxisEventGlobalY(&axisEvent, &globalY), INPUT_SUCCESS); EXPECT_TRUE((globalX == DEFAULT_GLOBAL_X) && (globalY == DEFAULT_GLOBAL_Y)); } + +/** + * @tc.name: OHInputManagerTest_RequestInjection_001 + * @tc.desc: Verify the RequestInjection + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(OHInputManagerTest, OHInputManagerTest_RequestInjection_001, TestSize.Level1) +{ + auto retResult = OH_Input_RequestInjection(nullptr); + EXPECT_EQ(retResult, INPUT_PARAMETER_ERROR); + retResult = OH_Input_QueryAuthorizedStatus(nullptr); + EXPECT_EQ(retResult, INPUT_PARAMETER_ERROR); + auto fnCallBack = [](Input_InjectionStatus authorizedStatus) { + MMI_HILOGI("OH_Input_RequestInjection callbak:status:%{public}d", authorizedStatus); + }; +#ifndef OHOS_BUILD_PC_PRIORITY + retResult = OH_Input_RequestInjection(fnCallBack); + EXPECT_EQ(retResult, INPUT_DEVICE_NOT_SUPPORTED); + return; +#endif + Input_InjectionStatus status = Input_InjectionStatus::UNAUTHORIZED; + InputManager::GetInstance()->Authorize(false); + retResult = OH_Input_QueryAuthorizedStatus(&status); + EXPECT_EQ(retResult, INPUT_SUCCESS); + EXPECT_EQ(status, Input_InjectionStatus::UNAUTHORIZED); + + retResult = OH_Input_RequestInjection(fnCallBack); + EXPECT_EQ(retResult, INPUT_SUCCESS); + + retResult = OH_Input_RequestInjection(fnCallBack); + EXPECT_EQ(retResult, INPUT_INJECTION_AUTHORIZING); + + retResult = OH_Input_QueryAuthorizedStatus(&status); + EXPECT_EQ(retResult, INPUT_SUCCESS); + EXPECT_EQ(status, Input_InjectionStatus::AUTHORIZING); + + InputManager::GetInstance()->Authorize(true); + + retResult = OH_Input_RequestInjection(fnCallBack); + EXPECT_EQ(retResult, INPUT_INJECTION_AUTHORIZED); + + retResult = OH_Input_QueryAuthorizedStatus(&status); + EXPECT_EQ(retResult, INPUT_SUCCESS); + EXPECT_EQ(status, Input_InjectionStatus::AUTHORIZED); + + InputManager::GetInstance()->Authorize(false); + OH_Input_CancelInjection(); + retResult = OH_Input_QueryAuthorizedStatus(&status); + EXPECT_EQ(retResult, INPUT_SUCCESS); + EXPECT_EQ(status, Input_InjectionStatus::UNAUTHORIZED); +} + +/** + * @tc.name: OHInputManagerTest_RequestInjection_002 + * @tc.desc: Verify the RequestInjection + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(OHInputManagerTest, OHInputManagerTest_RequestInjection_002, TestSize.Level1) +{ + Input_InjectionStatus status = Input_InjectionStatus::UNAUTHORIZED; + auto retResult = OH_Input_QueryAuthorizedStatus(&status); + EXPECT_EQ(retResult, INPUT_SUCCESS); +#ifndef OHOS_BUILD_PC_PRIORITY + return; +#endif + auto fnCallBack = [](Input_InjectionStatus authorizedStatus) { + MMI_HILOGI("OH_Input_RequestInjection callbak:status:%{public}d", authorizedStatus); + }; + InputManager::GetInstance()->Authorize(false); + OH_Input_CancelInjection(); + std::this_thread::sleep_for(std::chrono::milliseconds(REQUEST_INJECTION_TIME_MS)); + retResult = OH_Input_RequestInjection(fnCallBack); + EXPECT_EQ(retResult, INPUT_SUCCESS); + InputManager::GetInstance()->Authorize(false); + retResult = OH_Input_QueryAuthorizedStatus(&status); + EXPECT_EQ(retResult, INPUT_SUCCESS); + EXPECT_EQ(status, Input_InjectionStatus::UNAUTHORIZED); + + InputManager::GetInstance()->Authorize(false); + retResult = OH_Input_RequestInjection(fnCallBack); + EXPECT_EQ(retResult, INPUT_INJECTION_OPERATION_FREQUENT); + + retResult = OH_Input_QueryAuthorizedStatus(&status); + EXPECT_EQ(retResult, INPUT_SUCCESS); + EXPECT_EQ(status, Input_InjectionStatus::UNAUTHORIZED); + InputManager::GetInstance()->Authorize(false); + OH_Input_CancelInjection(); +} } // namespace MMI } // namespace OHOS \ No newline at end of file diff --git a/frameworks/proxy/BUILD.gn b/frameworks/proxy/BUILD.gn index c6c7a26c1be8d5681c4b2648e883c9e398f4a2d8..2a552de12ce9ce8413c76388459dba8914d679de 100644 --- a/frameworks/proxy/BUILD.gn +++ b/frameworks/proxy/BUILD.gn @@ -102,7 +102,6 @@ if (is_arkui_x) { "//foundation/multimedia/image_framework/interfaces/innerkits:image_native", ] - part_name = "input" subsystem_name = "multimodalinput" } @@ -155,8 +154,8 @@ ohos_shared_library("libmmi-client") { part_name = "input" subsystem_name = "multimodalinput" external_deps = [ - "c_utils:utils", "cJSON:cjson", + "c_utils:utils", "config_policy:configpolicy_util", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -169,7 +168,7 @@ ohos_shared_library("libmmi-client") { ] if (!is_arkui_x) { - public_external_deps = ["eventhandler:libeventhandler"] + public_external_deps = [ "eventhandler:libeventhandler" ] } if (hitrace_enabled) { @@ -282,7 +281,6 @@ ohos_unittest("InputHandlerManagerTest") { ] external_deps = [ - "call_manager:tel_call_manager_api", "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", "data_share:datashare_consumer", @@ -315,6 +313,10 @@ ohos_unittest("InputHandlerManagerTest") { if (hitrace_enabled) { external_deps += [ "hitrace:hitrace_meter" ] } + + if (call_manager_service_enabled) { + external_deps += ["call_manager:tel_call_manager_api"] + } } ohos_unittest("SwitchEventInputSubscribeManagerTest") { @@ -329,10 +331,6 @@ ohos_unittest("SwitchEventInputSubscribeManagerTest") { ] sources = [ - "${mmi_path}/service/connect_manager/src/input_binder_client_server.cpp", - "${mmi_path}/service/connect_manager/src/input_binder_client_stub.cpp", - "${mmi_path}/service/connect_manager/src/multimodal_input_connect_death_recipient.cpp", - "${mmi_path}/service/connect_manager/src/multimodal_input_connect_manager.cpp", "event_handler/src/input_active_subscribe_manager.cpp", "event_handler/src/input_handler_manager.cpp", "event_handler/src/multimodal_event_handler.cpp", @@ -365,6 +363,7 @@ ohos_unittest("SwitchEventInputSubscribeManagerTest") { deps = [ "${mmi_path}/frameworks/proxy:libmmi-client", "${mmi_path}/frameworks/proxy:libmmi-common", + "${mmi_path}/service/connect_manager:mmi_connect_manager_proxy", "${mmi_path}/util:libmmi-util", ] external_deps = [ @@ -372,8 +371,8 @@ ohos_unittest("SwitchEventInputSubscribeManagerTest") { "access_token:libaccesstoken_sdk", "access_token:libnativetoken_shared", "access_token:libtokensetproc_shared", - "c_utils:utils", "cJSON:cjson", + "c_utils:utils", "config_policy:configpolicy_util", "eventhandler:libeventhandler", "googletest:gmock_main", @@ -399,10 +398,6 @@ ohos_unittest("InputMonitorManagerTest") { ] sources = [ - "${mmi_path}/service/connect_manager/src/input_binder_client_server.cpp", - "${mmi_path}/service/connect_manager/src/input_binder_client_stub.cpp", - "${mmi_path}/service/connect_manager/src/multimodal_input_connect_death_recipient.cpp", - "${mmi_path}/service/connect_manager/src/multimodal_input_connect_manager.cpp", "event_handler/src/anr_handler.cpp", "event_handler/src/bytrace_adapter.cpp", "event_handler/src/input_handler_manager.cpp", @@ -438,17 +433,18 @@ ohos_unittest("InputMonitorManagerTest") { deps = [ "${mmi_path}/common/anco/comm:mmi_anco_channel_stub", + "${mmi_path}/frameworks/proxy:libmmi-client", "${mmi_path}/frameworks/proxy:libmmi-common", "${mmi_path}/service:libmmi-server", + "${mmi_path}/service/connect_manager:mmi_connect_manager_proxy", "${mmi_path}/service/filter:mmi_event_filter_service", "${mmi_path}/util:libmmi-util", - "${mmi_path}/frameworks/proxy:libmmi-client", ] external_deps = [ "ability_runtime:abilitykit_native", - "c_utils:utils", "cJSON:cjson", + "c_utils:utils", "config_policy:configpolicy_util", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -474,10 +470,6 @@ ohos_unittest("InputManagerImplTest") { ] sources = [ - "${mmi_path}/service/connect_manager/src/input_binder_client_server.cpp", - "${mmi_path}/service/connect_manager/src/input_binder_client_stub.cpp", - "${mmi_path}/service/connect_manager/src/multimodal_input_connect_death_recipient.cpp", - "${mmi_path}/service/connect_manager/src/multimodal_input_connect_manager.cpp", "event_handler/src/anr_handler.cpp", "event_handler/src/bytrace_adapter.cpp", "event_handler/src/input_active_subscribe_manager.cpp", @@ -507,17 +499,18 @@ ohos_unittest("InputManagerImplTest") { deps = [ "${mmi_path}/common/anco/comm:mmi_anco_channel_stub", + "${mmi_path}/frameworks/proxy:libmmi-client", "${mmi_path}/frameworks/proxy:libmmi-common", "${mmi_path}/service:libmmi-server", + "${mmi_path}/service/connect_manager:mmi_connect_manager_proxy", "${mmi_path}/service/filter:mmi_event_filter_service", "${mmi_path}/util:libmmi-util", - "${mmi_path}/frameworks/proxy:libmmi-client", ] external_deps = [ "ability_runtime:abilitykit_native", - "c_utils:utils", "cJSON:cjson", + "c_utils:utils", "config_policy:configpolicy_util", "eventhandler:libeventhandler", "ffrt:libffrt", @@ -584,8 +577,8 @@ ohos_unittest("InputManagerTest") { "access_token:libaccesstoken_sdk", "access_token:libnativetoken_shared", "access_token:libtokensetproc_shared", - "c_utils:utils", "cJSON:cjson", + "c_utils:utils", "config_policy:configpolicy_util", "eventhandler:libeventhandler", "googletest:gmock_main", @@ -714,16 +707,16 @@ ohos_unittest("KeyEventInputSubscribeManagerTest") { ] deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", "${mmi_path}/service:libmmi-server", "${mmi_path}/util:libmmi-util", - "${mmi_path}/frameworks/proxy:libmmi-client", ] external_deps = [ "ability_runtime:abilitykit_native", "c_utils:utils", - "hilog:libhilog", "eventhandler:libeventhandler", + "hilog:libhilog", ] } @@ -754,8 +747,8 @@ ohos_unittest("LongPressEventSubscribeManagerTest") { external_deps = [ "ability_runtime:abilitykit_native", "c_utils:utils", - "hilog:libhilog", "eventhandler:libeventhandler", + "hilog:libhilog", ] } @@ -785,8 +778,8 @@ ohos_unittest("InputDeviceImplTest") { external_deps = [ "ability_runtime:abilitykit_native", - "hilog:libhilog", "eventhandler:libeventhandler", + "hilog:libhilog", ] } diff --git a/frameworks/proxy/event_handler/include/input_manager_impl.h b/frameworks/proxy/event_handler/include/input_manager_impl.h index b2a60cfdf60e61dbd0e79616a76f2747eca1045c..456ae1da03b414365675697951e1af656cf85156 100644 --- a/frameworks/proxy/event_handler/include/input_manager_impl.h +++ b/frameworks/proxy/event_handler/include/input_manager_impl.h @@ -208,6 +208,7 @@ public: int32_t GetFunctionKeyState(int32_t funcKey, bool &resultState); int32_t SetFunctionKeyState(int32_t funcKey, bool enable); int32_t SetPointerLocation(int32_t x, int32_t y, int32_t displayId); + int32_t GetPointerLocation(int32_t &displayId, double &displayX, double &displayY); int32_t EnableInputDevice(bool enable); // 快捷键拉起Ability int32_t SetKeyDownDuration(const std::string &businessId, int32_t delay); @@ -224,6 +225,8 @@ public: int32_t GetKeyState(std::vector &pressedKeys, std::map &specialKeysState); void Authorize(bool isAuthorize); int32_t CancelInjection(); + int32_t RequestInjection(int32_t &status, int32_t &reqId); + int32_t QueryAuthorizedStatus(int32_t &status); int32_t HasIrEmitter(bool &hasIrEmitter); int32_t GetInfraredFrequencies(std::vector& requencys); diff --git a/frameworks/proxy/event_handler/src/input_manager_impl.cpp b/frameworks/proxy/event_handler/src/input_manager_impl.cpp index d819060f11a1e105095fc58d17c4c9768ae62a24..83817aa67b43c734d399bb5ab677761847477abe 100644 --- a/frameworks/proxy/event_handler/src/input_manager_impl.cpp +++ b/frameworks/proxy/event_handler/src/input_manager_impl.cpp @@ -2023,6 +2023,21 @@ int32_t InputManagerImpl::SetPointerLocation(int32_t x, int32_t y, int32_t displ #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING } +int32_t InputManagerImpl::GetPointerLocation(int32_t &displayId, double &displayX, double &displayY) +{ + CALL_INFO_TRACE; +#if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING) + int32_t ret = MULTIMODAL_INPUT_CONNECT_MGR->GetPointerLocation(displayId, displayX, displayY); + if (ret != RET_OK) { + MMI_HILOGE("Get Pointer Location failed, ret:%{public}d", ret); + } + return ret; +#else + MMI_HILOGW("Pointer device or pointer drawing module does not support"); + return ERROR_UNSUPPORT; +#endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING +} + int32_t InputManagerImpl::EnterCaptureMode(int32_t windowId) { CALL_INFO_TRACE; @@ -2562,6 +2577,18 @@ int32_t InputManagerImpl::CancelInjection() return RET_OK; } +int32_t InputManagerImpl::RequestInjection(int32_t &status, int32_t &reqId) +{ + CALL_DEBUG_ENTER; + return MULTIMODAL_INPUT_CONNECT_MGR->RequestInjection(status, reqId); +} + +int32_t InputManagerImpl::QueryAuthorizedStatus(int32_t &status) +{ + CALL_DEBUG_ENTER; + return MULTIMODAL_INPUT_CONNECT_MGR->QueryAuthorizedStatus(status); +} + #ifdef OHOS_BUILD_ENABLE_VKEYBOARD int32_t InputManagerImpl::CreateVKeyboardDevice(sptr &vkeyboardDevice) { diff --git a/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp b/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp index 877ef354ec1e0c3fc89f80a49c6ef6c2e5e199e2..1203c420bf15a356daf469db415d5673498caca4 100644 --- a/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp +++ b/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp @@ -1096,203 +1096,5 @@ HWTEST_F(InputManagerImplTest, SubscribeInputActive_Test001, TestSize.Level1) InputMgrImpl.UnsubscribeInputActive(subscriberId); } -/** - * @tc.name: InputManagerImplTest_GetDisplayBindInfo - * @tc.desc: Test GetDisplayBindInfo - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(InputManagerImplTest, InputManagerImplTest_GetDisplayBindInfo, TestSize.Level1) -{ - CALL_TEST_DEBUG; - DisplayBindInfos infos; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.GetDisplayBindInfo(infos)); - std::map, int32_t> datas; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.GetAllMmiSubscribedEvents(datas)); - std::string msg = "test"; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetDisplayBind(0, 0, msg)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.IsGRLOrHopper()); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.PrintWindowGroupInfo()); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.EnableCombineKey(false)); -} - -/** - * @tc.name: InputManagerImplTest_AboutPoint - * @tc.desc: Test AboutPoint - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(InputManagerImplTest, InputManagerImplTest_AboutPoint, TestSize.Level1) -{ - CALL_TEST_DEBUG; - PointerStyle pointerStyle; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.GetPointerStyle(-1, pointerStyle, false)); - pointerStyle.id = 1; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetPointerStyle(-1, pointerStyle, false)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetPointerLocation(-1, -1, -1)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.ClearWindowPointerStyle(-1, -1)); -} - -/** - * @tc.name: InputManagerImplTest_AboutCaptureMode - * @tc.desc: Test AboutCaptureMode - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(InputManagerImplTest, InputManagerImplTest_AboutCaptureMode, TestSize.Level1) -{ - CALL_TEST_DEBUG; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.EnterCaptureMode(-1)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.LeaveCaptureMode(-1)); -} - -/** - * @tc.name: InputManagerImplTest_AboutTouchpadScrollSwitch - * @tc.desc: Test AboutTouchpadScrollSwitch - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(InputManagerImplTest, InputManagerImplTest_AboutTouchpadScrollSwitch, TestSize.Level1) -{ - CALL_TEST_DEBUG; - bool switchFlag = false; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.GetTouchpadScrollSwitch(switchFlag)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetTouchpadScrollSwitch(switchFlag)); -} - -/** - * @tc.name: InputManagerImplTest_AboutTouchpadScrollDirection - * @tc.desc: Test AboutTouchpadScrollDirection - * @tc.require: - */ -HWTEST_F(InputManagerImplTest, InputManagerImplTest_AboutTouchpadScrollDirection, TestSize.Level1) -{ - CALL_TEST_DEBUG; - bool switchFlag = false; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.GetTouchpadScrollDirection(switchFlag)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetTouchpadScrollDirection(switchFlag)); -} - -/** - * @tc.name: InputManagerImplTest_AboutTouchpadTapSwitch - * @tc.desc: Test AboutTouchpadTapSwitch - * @tc.require: - */ -HWTEST_F(InputManagerImplTest, InputManagerImplTest_AboutTouchpadTapSwitch, TestSize.Level1) -{ - CALL_TEST_DEBUG; - bool switchFlag = false; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.GetTouchpadTapSwitch(switchFlag)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetTouchpadTapSwitch(switchFlag)); -} - -/** - * @tc.name: InputManagerImplTest_AboutTouchpadPinchSwitch - * @tc.desc: Test AboutTouchpadPinchSwitch - * @tc.require: - */ -HWTEST_F(InputManagerImplTest, InputManagerImplTest_AboutTouchpadPinchSwitch, TestSize.Level1) -{ - CALL_TEST_DEBUG; - bool switchFlag = false; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.GetTouchpadPinchSwitch(switchFlag)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetTouchpadPinchSwitch(switchFlag)); -} - -/** - * @tc.name: InputManagerImplTest_AboutTouchpadSwipeSwitch - * @tc.desc: Test AboutTouchpadSwipeSwitch - * @tc.require: - */ -HWTEST_F(InputManagerImplTest, InputManagerImplTest_AboutTouchpadSwipeSwitch, TestSize.Level1) -{ - CALL_TEST_DEBUG; - bool switchFlag = false; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.GetTouchpadSwipeSwitch(switchFlag)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetTouchpadSwipeSwitch(switchFlag)); -} - -/** - * @tc.name: InputManagerImplTest_AboutTouchpadRotateSwitch - * @tc.desc: Test AboutTouchpadRotateSwitch - * @tc.require: - */ -HWTEST_F(InputManagerImplTest, InputManagerImplTest_AboutTouchpadRotateSwitch, TestSize.Level1) -{ - CALL_TEST_DEBUG; - bool switchFlag = false; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.GetTouchpadRotateSwitch(switchFlag)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetTouchpadRotateSwitch(switchFlag)); -} - -/** - * @tc.name: InputManagerImplTest_AboutTouchpadDoubleTapAndDragState - * @tc.desc: Test AboutTouchpadDoubleTapAndDragState - * @tc.require: - */ -HWTEST_F(InputManagerImplTest, InputManagerImplTest_AboutTouchpadDoubleTapAndDragState, TestSize.Level1) -{ - CALL_TEST_DEBUG; - bool switchFlag = false; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.GetTouchpadDoubleTapAndDragState(switchFlag)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetTouchpadDoubleTapAndDragState(switchFlag)); -} - -/** - * @tc.name: InputManagerImplTest_AboutTouchpadThreeFingersTapSwitch - * @tc.desc: Test AboutTouchpadThreeFingersTapSwitch - * @tc.require: - */ -HWTEST_F(InputManagerImplTest, InputManagerImplTest_AboutTouchpadThreeFingersTapSwitch, TestSize.Level1) -{ - CALL_TEST_DEBUG; - bool switchFlag = false; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetTouchpadThreeFingersTapSwitch(switchFlag)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetTouchpadThreeFingersTapSwitch(switchFlag)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SwitchTouchTracking(false)); -} - -/** - * @tc.name: InputManagerImplTest_AboutTouchpadPointerSpeed - * @tc.desc: Test AboutTouchpadPointerSpeed - * @tc.require: - */ -HWTEST_F(InputManagerImplTest, InputManagerImplTest_AboutTouchpadPointerSpeed, TestSize.Level1) -{ - CALL_TEST_DEBUG; - int32_t speed = -1; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.GetTouchpadPointerSpeed(speed)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetTouchpadPointerSpeed(speed)); -} - -/** - * @tc.name: InputManagerImplTest_AboutTouchpadRightClickType - * @tc.desc: Test AboutTouchpadRightClickType - * @tc.require: - */ -HWTEST_F(InputManagerImplTest, InputManagerImplTest_AboutTouchpadRightClickType, TestSize.Level1) -{ - CALL_TEST_DEBUG; - int32_t speed = -1; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.GetTouchpadRightClickType(speed)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetTouchpadRightClickType(speed)); -} - -/** - * @tc.name: InputManagerImplTest_AboutShieldStatus - * @tc.desc: Test AboutShieldStatus - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(InputManagerImplTest, InputManagerImplTest_AboutShieldStatus, TestSize.Level1) -{ - CALL_TEST_DEBUG; - bool isShield = false; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.GetShieldStatus(-1, isShield)); - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.SetShieldStatus(-1, isShield)); - std::vector pressedKeys = {-1}; - std::map specialKeysState = {{-1, -1}}; - EXPECT_NO_FATAL_FAILURE(InputMgrImpl.GetKeyState(pressedKeys, specialKeysState)); -} } // namespace MMI } // namespace OHOS diff --git a/frameworks/proxy/events/src/input_manager.cpp b/frameworks/proxy/events/src/input_manager.cpp index f35e6d3884e589348c4aaaa70df6a7edd9467196..1b27751f678e480034808a794669eee3d44a3c48 100644 --- a/frameworks/proxy/events/src/input_manager.cpp +++ b/frameworks/proxy/events/src/input_manager.cpp @@ -568,6 +568,11 @@ int32_t InputManager::SetPointerLocation(int32_t x, int32_t y, int32_t displayId return InputMgrImpl.SetPointerLocation(x, y, displayId); } +int32_t InputManager::GetPointerLocation(int32_t &displayId, double &displayX, double &displayY) +{ + return InputMgrImpl.GetPointerLocation(displayId, displayX, displayY); +} + int32_t InputManager::EnterCaptureMode(int32_t windowId) { return InputMgrImpl.EnterCaptureMode(windowId); @@ -798,6 +803,34 @@ void InputManager::Authorize(bool isAuthorize) InputMgrImpl.Authorize(isAuthorize); } +int32_t InputManager::RequestInjection(int32_t &status, int32_t &reqId) +{ + int32_t ret = InputMgrImpl.RequestInjection(status, reqId); + return ret; +} + +int32_t InputManager::QueryAuthorizedStatus(int32_t &status) +{ + int32_t ret = InputMgrImpl.QueryAuthorizedStatus(status); + return ret; +} + +void InputManager::RequestInjectionCallback(int32_t reqId, int32_t status) +{ + std::lock_guard lock(mutexMapCallBack_); + auto itFind = mapCallBack_.find(reqId); + if (itFind != mapCallBack_.end()) { + itFind->second(status); + mapCallBack_.erase(itFind); + } +} + +void InputManager::InsertRequestInjectionCallback(int32_t reqId, std::function fun) +{ + std::lock_guard lock(mutexMapCallBack_); + mapCallBack_[reqId] = fun; +} + int32_t InputManager::HasIrEmitter(bool &hasIrEmitter) { return InputMgrImpl.HasIrEmitter(hasIrEmitter); diff --git a/frameworks/proxy/events/src/pointer_event.cpp b/frameworks/proxy/events/src/pointer_event.cpp index 5c6c499b1cfc15b2ef2bedba89790e4cadeadfa0..416130147a13f23db864999784614bb9d04b29b4 100644 --- a/frameworks/proxy/events/src/pointer_event.cpp +++ b/frameworks/proxy/events/src/pointer_event.cpp @@ -788,6 +788,17 @@ bool PointerEvent::GetPointerItem(int32_t pointerId, PointerItem &pointerItem) c return false; } +bool PointerEvent::GetOriginPointerItem(int32_t pointerId, PointerItem &pointerItem) const +{ + for (const auto &item : pointers_) { + if (item.GetOriginPointerId() == pointerId) { + pointerItem = item; + return true; + } + } + return false; +} + void PointerEvent::RemovePointerItem(int32_t pointerId) { for (auto it = pointers_.begin(); it != pointers_.end(); ++it) { diff --git a/frameworks/proxy/events/test/input_event_test.cpp b/frameworks/proxy/events/test/input_event_test.cpp index dc9dacb565b8833e60de184c872d7104237f1ceb..ce452e1570970ab3e41c4b9170e4ea40743e107c 100644 --- a/frameworks/proxy/events/test/input_event_test.cpp +++ b/frameworks/proxy/events/test/input_event_test.cpp @@ -264,5 +264,33 @@ HWTEST_F(InputEventTest, InputEventTest_Unmarshalling_001, TestSize.Level1) auto ret = InputEvent->Unmarshalling(in); ASSERT_TRUE(ret == nullptr); } + +/** + * @tc.name: InputEventTest_DisplayBindInfo_ReadFromParcel_001 + * @tc.desc: Test ReadFromParcel + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputEventTest, InputEventTest_DisplayBindInfo_ReadFromParcel_001, TestSize.Level1) +{ + CALL_TEST_DEBUG; + DisplayBindInfo info; + Parcel in; + ASSERT_NO_FATAL_FAILURE(info.ReadFromParcel(in)); +} + +/** + * @tc.name: InputEventTest_DisplayBindInfo_Unmarshalling_001 + * @tc.desc: Test Unmarshalling + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputEventTest, InputEventTest_DisplayBindInfo_Unmarshalling_001, TestSize.Level1) +{ + CALL_TEST_DEBUG; + DisplayBindInfo info; + Parcel in; + ASSERT_NO_FATAL_FAILURE(info.Unmarshalling(in)); +} } // namespace MMI } // namespace OHOS \ No newline at end of file diff --git a/frameworks/proxy/events/test/input_manager_test.cpp b/frameworks/proxy/events/test/input_manager_test.cpp index ddecd97865b4e5fff2df511705ba2e937ad06df8..09822bffa59e5a428bef7aa100cfe8505ffedf27 100644 --- a/frameworks/proxy/events/test/input_manager_test.cpp +++ b/frameworks/proxy/events/test/input_manager_test.cpp @@ -2119,6 +2119,22 @@ HWTEST_F(InputManagerTest, InputManagerTest_SetPointerLocation_002, TestSize.Lev ASSERT_NO_FATAL_FAILURE(InputManager::GetInstance()->SetPointerLocation(x, y, displayId)); } +/** + * @tc.name: InputManagerTest_GetPointerLocation_001 + * @tc.desc: Get pointer location + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputManagerTest, InputManagerTest_GetPointerLocation_001, TestSize.Level1) +{ + CALL_TEST_DEBUG; + int32_t displayId = -1; + double displayX = 0.0; + double displayY = 0.0; + int32_t ret = InputManager::GetInstance()->GetPointerLocation(displayId, displayX, displayY); + EXPECT_EQ(ret, RET_OK); +} + /** * @tc.name: InputManagerTest_GetTouchpadRightClickType_001 * @tc.desc: Get touchpad right click type @@ -5962,11 +5978,11 @@ HWTEST_F(InputManagerTest, InputManagerTest_SwitchTouchTracking_001, TestSize.Le CALL_TEST_DEBUG; std::string PRODUCT_TYPE = system::GetParameter("const.product.devicetype", "unknown"); bool switchFlag = true; - int32_t ret = InputManager::GetInstance()->GetTouchpadSwipeSwitch(switchFlag); + int32_t ret = InputManager::GetInstance()->SwitchTouchTracking(switchFlag); if ((PRODUCT_TYPE != "phone") && (PRODUCT_TYPE != "tablet")) { EXPECT_EQ(ret, CAPABILITY_NOT_SUPPORTED); } else { - EXPECT_EQ(ret, RET_OK); + EXPECT_NE(ret, CAPABILITY_NOT_SUPPORTED); } } @@ -6039,5 +6055,33 @@ HWTEST_F(InputManagerTest, InputManagerTest_QueryPointerRecord_005, TestSize.Lev std::vector> pointerList; EXPECT_EQ(InputManager::GetInstance()->QueryPointerRecord(count, pointerList), RET_OK); } + +/* + * @tc.name: InputManagerTest_InsertRequestInjectionCallback_001 + * @tc.desc: InsertRequestInjectionCallback + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputManagerTest, InputManagerTest_InsertRequestInjectionCallback_001, TestSize.Level1) +{ + CALL_TEST_DEBUG; + int32_t reqId = 1; + std::function callback; + ASSERT_NO_FATAL_FAILURE(InputManager::GetInstance()->InsertRequestInjectionCallback(reqId, callback)); +} + +/* + * @tc.name: InputManagerTest_RequestInjectionCallback_001 + * @tc.desc: RequestInjectionCallback + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputManagerTest, InputManagerTest_RequestInjectionCallback_001, TestSize.Level1) +{ + CALL_TEST_DEBUG; + int32_t reqId = -1; + int32_t status = 0; + ASSERT_NO_FATAL_FAILURE(InputManager::GetInstance()->RequestInjectionCallback(reqId, status)); +} } // namespace MMI } // namespace OHOS diff --git a/frameworks/proxy/events/test/pointer_style_test.cpp b/frameworks/proxy/events/test/pointer_style_test.cpp index 3a60d58d25e368f6af4adee981d2411a02cf3fec..d9228ef23dcaaed62a238a3d049a3b3f74bdeb76 100644 --- a/frameworks/proxy/events/test/pointer_style_test.cpp +++ b/frameworks/proxy/events/test/pointer_style_test.cpp @@ -148,5 +148,33 @@ HWTEST_F(PointerStyleTest, PointerStyleTest_CustomCursorParcel_Unmarshalling_001 auto ret = cusCor.Unmarshalling(out); ASSERT_EQ(ret, nullptr); } + +/** + * @tc.name: PointerStyleTest_PointerStyle_ReadFromParcel_001 + * @tc.desc: Test ReadFromParcel + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PointerStyleTest, PointerStyleTest_PointerStyle_ReadFromParcel_001, TestSize.Level1) +{ + CALL_TEST_DEBUG; + PointerStyle pointerStyle; + Parcel parcel; + ASSERT_NO_FATAL_FAILURE(pointerStyle.ReadFromParcel(parcel)); +} + +/** + * @tc.name: PointerStyleTest_PointerStyle_Unmarshalling_001 + * @tc.desc: Test Unmarshalling + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(PointerStyleTest, PointerStyleTest_PointerStyle_Unmarshalling_001, TestSize.Level1) +{ + CALL_TEST_DEBUG; + PointerStyle pointerStyle; + Parcel parcel; + ASSERT_NO_FATAL_FAILURE(pointerStyle.Unmarshalling(parcel)); +} } // namespace MMI } // namespace OHOS \ No newline at end of file diff --git a/frameworks/proxy/module_loader/src/mmi_client.cpp b/frameworks/proxy/module_loader/src/mmi_client.cpp index 9ec6ba0782049cce00941d86a03dae465cfaab2c..8e6ff498e72fb7761469290c789702a620ff755b 100644 --- a/frameworks/proxy/module_loader/src/mmi_client.cpp +++ b/frameworks/proxy/module_loader/src/mmi_client.cpp @@ -110,7 +110,7 @@ bool MMIClient::StartEventRunner() CALL_DEBUG_ENTER; CHK_PID_AND_TID(); bool selfCreateEventHandle = false; - if (USE_ISOLATE_DISPATCH_THREAD || eventHandler_ == nullptr) { + if (USE_ISOLATE_DISPATCH_THREAD || eventHandler_ == nullptr || !USE_FILE_DESCRIPTION) { MMI_HILOGI("USE_ISOLATE_DISPATCH_THREAD:%{public}d, eventHandler_:%{public}d", USE_ISOLATE_DISPATCH_THREAD, (eventHandler_ == nullptr)); auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME); @@ -149,7 +149,7 @@ bool MMIClient::AddFdListener(int32_t fd, bool selfCreate) } CHKPF(eventHandler_); auto fdListener = std::make_shared(GetSharedPtr()); - if (!USE_ISOLATE_DISPATCH_THREAD && !selfCreate) { + if (!USE_ISOLATE_DISPATCH_THREAD && !selfCreate && USE_FILE_DESCRIPTION) { fdListener->SetDeamonWaiter(); } diff --git a/intention/cooperate/plugin/include/input_event_transmission/input_event_serialization.h b/intention/cooperate/plugin/include/input_event_transmission/input_event_serialization.h index 99d7ad33cfcfb467c3c47a67e6fdac36f480f7cc..c3c16dfa545feb964627b37949503bced2c18465 100644 --- a/intention/cooperate/plugin/include/input_event_transmission/input_event_serialization.h +++ b/intention/cooperate/plugin/include/input_event_transmission/input_event_serialization.h @@ -62,7 +62,7 @@ private: static void ReadFunctionKeys(NetPacket &pkt, std::shared_ptr key); #ifdef OHOS_BUILD_ENABLE_SECURITY_PART - static constexpr uint32_t MAX_HMAC_SIZE = 64; + static constexpr uint32_t MAX_HMAC_SIZE = 160; struct SecCompPointEvent { double touchX; double touchY; diff --git a/interfaces/kits/c/input/oh_input_manager.h b/interfaces/kits/c/input/oh_input_manager.h index dd61420e1ddffe523df6876eed168a97dd027c79..2c150efddd71c930d750f80954fef3929b63b768 100644 --- a/interfaces/kits/c/input/oh_input_manager.h +++ b/interfaces/kits/c/input/oh_input_manager.h @@ -256,9 +256,53 @@ typedef enum Input_Result { /** @error Already occupied by the other */ INPUT_OCCUPIED_BY_OTHER = 4200003, /** @error No keyboard device connected */ - INPUT_KEYBOARD_DEVICE_NOT_EXIST = 3900002 + INPUT_KEYBOARD_DEVICE_NOT_EXIST = 3900002, + /** + * @error Authorizing + * @since 20 + */ + INPUT_INJECTION_AUTHORIZING = 3900005, + /** + * @error Too many operations + * @since 20 + */ + INPUT_INJECTION_OPERATION_FREQUENT = 3900006, + /** + * @error Authorized + * @since 20 + */ + INPUT_INJECTION_AUTHORIZED = 3900007, + /** + * @error Authorized to other applications + * @since 20 + */ + INPUT_INJECTION_AUTHORIZED_OTHERS = 3900008, + /** + * @error App is not the focused app + * @since 20 + */ + INPUT_APP_NOT_FOCUSED = 3900009, + /** + * @error The device has no pointer + * @since 20 + */ + INPUT_DEVICE_NO_POINTER = 3900010, } Input_Result; +/** + * @brief Enumerates the injection authorization status. + * + * @since 20 + */ +typedef enum Input_InjectionStatus { + /** Unauthorized */ + UNAUTHORIZED = 0, + /** Authorizing */ + AUTHORIZING = 1, + /** Authorized */ + AUTHORIZED = 2, +} Input_InjectionStatus; + /** * @brief Defines the hot key structure. * @@ -314,6 +358,13 @@ typedef void (*Input_DeviceAddedCallback)(int32_t deviceId); */ typedef void (*Input_DeviceRemovedCallback)(int32_t deviceId); +/** + * @brief Defines the event injection callback. + * @param authorizedStatus Authorization status. + * @since 20 + */ +typedef void (*Input_InjectAuthorizeCallback)(Input_InjectionStatus authorizedStatus); + /** * @brief Defines the structure for the interceptor of event callbacks, * including mouseCallback, touchCallback, and axisCallback. @@ -1961,6 +2012,52 @@ Input_Result OH_Input_GetFunctionKeyState(int32_t keyCode, int32_t *state); */ Input_Result OH_Input_QueryMaxTouchPoints(int32_t *count); +/** + * @brief Requests for injection authorization. + * + * @param callback - callback used to return the result. + * @return OH_Input_RequestInjection function result code. + * {@link INPUT_SUCCESS} Success.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@INPUT_DEVICE_NOT_SUPPORTED} Capability not supported.\n + * {@link INPUT_SERVICE_EXCEPTION} Service error.\n + * {@link INPUT_INJECTION_AUTHORIZING} Authorizing.\n + * {@link INPUT_INJECTION_OPERATION_FREQUENT} Too many operations.\n + * {@link INPUT_INJECTION_AUTHORIZED} Authorized.\n + * {@link INPUT_INJECTION_AUTHORIZED_OTHERS} Authorized to other applications.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ +Input_Result OH_Input_RequestInjection(Input_InjectAuthorizeCallback callback); + +/** + * @brief Queries the injection authorization status. + * + * @param status Injection authorization status. For details, see {@Link Input_InjectionStatus}. + * @return OH_Input_QueryAuthorizedStatus function result code. + * {@link INPUT_SUCCESS} Success.\n + * {@link INPUT_PARAMETER_ERROR} The status is NULL\n + * {@link INPUT_SERVICE_EXCEPTION} Service error.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 20 + */ +Input_Result OH_Input_QueryAuthorizedStatus(Input_InjectionStatus* status); + +/** + * @brief Get pointer location. + * + * @param displayId The displayId for the pointer location. + * @param displayX The displayX for the pointer location. + * @param displayY The displayY for the pointer location. + * @return OH_Input_GetPointerLocation function api result code + * {@link INPUT_SUCCESS} if the operation is successful; + * {@link INPUT_PARAMETER_ERROR} if parameter is a null pointer; + * {@link INPUT_APP_NOT_FOCUSED} if the app is not the focused app; + * {@link INPUT_DEVICE_NO_POINTER} if the device has no pointer; + * {@link INPUT_SERVICE_EXCEPTION} if the service is exception. + * @since 20 + */ +Input_Result OH_Input_GetPointerLocation(int32_t *displayId, double *displayX, double *displayY); #ifdef __cplusplus } #endif diff --git a/interfaces/kits/c/ohinput.ndk.json b/interfaces/kits/c/ohinput.ndk.json index 5760ca5a8d0fba321befd72791659249647156f6..2ab35b9b78b0d4c2ab9f8df75142646ff9786b9a 100644 --- a/interfaces/kits/c/ohinput.ndk.json +++ b/interfaces/kits/c/ohinput.ndk.json @@ -506,5 +506,17 @@ { "first_introduced": "20", "name": "OH_Input_TouchEventToPointerEvent" + }, + { + "first_introduced": "20", + "name": "OH_Input_RequestInjection" + }, + { + "first_introduced": "20", + "name": "OH_Input_QueryAuthorizedStatus" + } + { + "first_introduced": "20", + "name": "OH_Input_GetPointerLocation" } ] \ No newline at end of file diff --git a/interfaces/native/innerkits/event/include/pointer_event.h b/interfaces/native/innerkits/event/include/pointer_event.h index 5e56d70548c0cf34a78dcbd0ca1a9479279fd40a..48ad68c9e7a016d01e9a417f2e6e15583c54749e 100644 --- a/interfaces/native/innerkits/event/include/pointer_event.h +++ b/interfaces/native/innerkits/event/include/pointer_event.h @@ -1459,6 +1459,16 @@ public: */ bool GetPointerItem(int32_t pointerId, PointerItem &pointerItem) const; + /** + * @brief Obtains the origin pointer item of a specified pointer ID. + * @param pointerId Indicates the pointer ID. + * @param pointerItem Indicates the item used to receive the data of the pointer. + * @return Returns true if the data of the origin pointer with the specified ID exists; + * returns false otherwise. + * @since 20 + */ + bool GetOriginPointerItem(int32_t pointerId, PointerItem &pointerItem) const; + /** * @brief Adds a pointer item. * @param pointerItem Indicates the pointer item to add. diff --git a/interfaces/native/innerkits/proxy/include/input_manager.h b/interfaces/native/innerkits/proxy/include/input_manager.h index a3003d78f561794bd749043cb1edb16a030b39a2..bb501bbe5fef7d4323269ce30a1960a691cca5c4 100644 --- a/interfaces/native/innerkits/proxy/include/input_manager.h +++ b/interfaces/native/innerkits/proxy/include/input_manager.h @@ -682,6 +682,16 @@ public: */ int32_t SetPointerLocation(int32_t x, int32_t y, int32_t displayId = -1); + /** + * @brief Query pointer location. + * @param displayId The displayId for the pointer location. + * @param displayX The displayX for the pointer location. + * @param displayY The displayY for the pointer location. + * @return Returns 0 if success; returns a non-0 value otherwise. + * @since 20 + */ + int32_t GetPointerLocation(int32_t &displayId, double &displayX, double &displayY); + /** * @brief 进入捕获模式 * @param windowId 窗口id. @@ -1239,6 +1249,10 @@ public: * @since 20 */ int32_t SwitchScreenCapturePermission(uint32_t permissionType, bool enable); + int32_t RequestInjection(int32_t &status, int32_t &reqId); + int32_t QueryAuthorizedStatus(int32_t &status); + void RequestInjectionCallback(int32_t reqId, int32_t status); + void InsertRequestInjectionCallback(int32_t reqId, std::function fun); /** * @brief When the collaborative application is disconnected, clear the mouse hide flag. @@ -1260,6 +1274,8 @@ private: InputManager() = default; DISALLOW_COPY_AND_MOVE(InputManager); static InputManager *instance_; + std::mutex mutexMapCallBack_; + std::map> mapCallBack_; }; } // namespace MMI } // namespace OHOS diff --git a/multimodalinput_mini.gni b/multimodalinput_mini.gni index de079493985e75153db3faf0d505338f04131b62..f0969e96796281c9c21ef13f68b7fdafbcd5a450 100644 --- a/multimodalinput_mini.gni +++ b/multimodalinput_mini.gni @@ -61,6 +61,7 @@ declare_args() { input_feature_event_recorder = true input_ext_feature_keyboard_ext_flag = false input_feature_watch_cfg_source = false + drivers_interface_rtos_extra_enable = false if (defined(global_parts_info) && defined(global_parts_info.resourceschedule_resource_schedule_service)) { @@ -72,6 +73,11 @@ declare_args() { screenlock_manager_enabled = true } + if (defined(global_parts_info) && + defined(global_parts_info.hdf_drivers_interface_rtos_extra)) { + drivers_interface_rtos_extra_enable = true + } + if (is_emulator) { input_feature_pointer_drawing = false } @@ -360,6 +366,10 @@ if (input_feature_one_hand_mode_enable) { input_default_defines += [ "OHOS_BUILD_ENABLE_ONE_HAND_MODE" ] } +if (call_manager_service_enabled) { + input_default_defines += [ "OHOS_BUILD_ENABLE_CALL_MANAGER" ] +} + if (!defined(global_parts_info) || defined(global_parts_info.security_security_component_manager)) { security_component_enable = true @@ -498,3 +508,7 @@ if (input_feature_key_pressed_handler) { if (input_feature_event_recorder) { input_default_defines += [ "OHOS_BUILD_ENABLE_EVENT_RECORDER" ] } + +if (drivers_interface_rtos_extra_enable) { + input_default_defines += [ "OHOS_BUILD_ENABLE_RTOS_EXTRA" ] +} diff --git a/service/BUILD.gn b/service/BUILD.gn index ee9e4b4295a254f4ccf1347535b1395f3593fad6..b65980baaf85c901318e3d8532d58447eae1bd22 100644 --- a/service/BUILD.gn +++ b/service/BUILD.gn @@ -384,7 +384,6 @@ ohos_shared_library("libmmi-server") { if (input_feature_product != "watch") { sources += [ - "infrared_emitter/src/infrared_emitter_controller.cpp", "window_manager/src/knuckle_divergent_point.cpp", "window_manager/src/knuckle_drawing_manager.cpp", "window_manager/src/knuckle_dynamic_drawing_manager.cpp", @@ -419,6 +418,14 @@ ohos_shared_library("libmmi-server") { "ipc:ipc_single", "safwk:system_ability_fwk", ] + + if (drivers_interface_rtos_extra_enable) { + sources += [ "infrared_emitter/src/infrared_emitter_controller.cpp" ] + external_deps += [ + "drivers_interface_rtos_extra:libconsumerir_proxy_1.0", + "hdf_core:libhdi", + ] + } } if (hitrace_enabled) { @@ -1540,11 +1547,15 @@ ohos_unittest("AccountManagerTest") { include_dirs = [ "${mmi_path}/service/account_manager/include", - "${mmi_service_path}/device_state_manager/include", + "${mmi_path}/service/device_state_manager/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/util/common/include", ] configs = [ "${mmi_path}:coverage_flags", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + "${mmi_path}/service/filter:mmi_event_filter_config", ":libmmi_server_config", ] @@ -1553,27 +1564,40 @@ ohos_unittest("AccountManagerTest") { "-Dprotected=public", ] - sources = [ "account_manager/test/account_manager_test.cpp" ] - - deps = [ - "${mmi_path}/service:libmmi-server", - "${mmi_path}/util:libmmi-util", + sources = [ + "${mmi_path}/service/account_manager/test/account_manager_test.cpp", + "${mmi_path}/service/account_manager/test/mock_setting_datashare.cpp", + ] + sources += [ + "${mmi_path}/service/account_manager/src/account_manager.cpp", + "${mmi_path}/service/display_state_manager/src/display_event_monitor.cpp", + "${mmi_path}/service/event_handler/src/touchpad_settings_handler.cpp", + "${mmi_path}/service/timer_manager/src/timer_manager.cpp", ] + deps = [ "${mmi_path}/util:libmmi-util" ] + external_deps = [ "ability_runtime:wantagent_innerkits", "cJSON:cjson", "c_utils:utils", - "call_manager:tel_call_manager_api", "common_event_service:cesfwk_innerkits", "data_share:datashare_consumer", "graphic_2d:2d_graphics", + "graphic_2d:librender_service_base", "graphic_2d:librender_service_client", "hilog:libhilog", "image_framework:image_native", "init:libbegetutil", "ipc:ipc_core", + "libinput:libinput-third-mmi", + "preferences:native_preferences", + "window_manager:libwm", ] + + if (call_manager_service_enabled) { + external_deps += [ "call_manager:tel_call_manager_api" ] + } } ohos_unittest("SubscriberTest") { @@ -2146,6 +2170,13 @@ ohos_unittest("InfraredEmitterTest") { "init:libbegetutil", "ipc:ipc_core", ] + + if (drivers_interface_rtos_extra_enable) { + external_deps += [ + "drivers_interface_rtos_extra:libconsumerir_proxy_1.0", + "hdf_core:libhdi", + ] + } } ohos_unittest("InterceptorTest") { @@ -2565,6 +2596,7 @@ ohos_unittest("ServerMsgHandlerTest") { external_deps = [ "ability_runtime:ability_connect_callback_stub", + "ability_runtime:app_manager", "ability_runtime:dataobs_manager", "cJSON:cjson", "c_utils:utils", diff --git a/service/account_manager/test/account_manager_test.cpp b/service/account_manager/test/account_manager_test.cpp index 761780d4064617bc3a51cabd036f86bacde4dfde..97a6896080a3ee377c4c73558bd5975e905a6324 100644 --- a/service/account_manager/test/account_manager_test.cpp +++ b/service/account_manager/test/account_manager_test.cpp @@ -28,7 +28,8 @@ namespace OHOS { namespace MMI { namespace { using namespace testing::ext; -constexpr int32_t MAIN_ACCOUNT_ID { 100 }; +constexpr int32_t TEST_ACCOUNT_ID_001 { 1 }; +constexpr int32_t TEST_ACCOUNT_ID_002 { 2 }; constexpr size_t DEFAULT_BUFFER_LENGTH { 512 }; const std::string SECURE_SETTING_URI_PROXY {""}; } // namespace @@ -48,9 +49,8 @@ public: HWTEST_F(AccountManagerTest, AccountManagerTest_GetInstance_01, TestSize.Level1) { CALL_TEST_DEBUG; - AccountManager accountManager; - accountManager.instance_ = nullptr; - ASSERT_NO_FATAL_FAILURE(accountManager.GetInstance()); + AccountManager::instance_ = nullptr; + ASSERT_NE(ACCOUNT_MGR, nullptr); } /** @@ -62,10 +62,9 @@ HWTEST_F(AccountManagerTest, AccountManagerTest_GetInstance_01, TestSize.Level1) HWTEST_F(AccountManagerTest, AccountManagerTest_SubscribeCommonEvent_01, TestSize.Level1) { CALL_TEST_DEBUG; - AccountManager accountManager; - accountManager.subscriber_ = nullptr; - accountManager.timerId_ = -1; - ASSERT_NO_FATAL_FAILURE(accountManager.SubscribeCommonEvent()); + ACCOUNT_MGR->subscriber_ = nullptr; + ACCOUNT_MGR->timerId_ = -1; + ASSERT_NO_FATAL_FAILURE(ACCOUNT_MGR->SubscribeCommonEvent()); } /** @@ -77,10 +76,9 @@ HWTEST_F(AccountManagerTest, AccountManagerTest_SubscribeCommonEvent_01, TestSiz HWTEST_F(AccountManagerTest, AccountManagerTest_UnsubscribeCommonEvent_01, TestSize.Level1) { CALL_TEST_DEBUG; - AccountManager accountManager; - ASSERT_NO_FATAL_FAILURE(accountManager.SubscribeCommonEvent()); - accountManager.subscriber_ = nullptr; - ASSERT_NO_FATAL_FAILURE(accountManager.UnsubscribeCommonEvent()); + ASSERT_NO_FATAL_FAILURE(ACCOUNT_MGR->SubscribeCommonEvent()); + ACCOUNT_MGR->subscriber_ = nullptr; + ASSERT_NO_FATAL_FAILURE(ACCOUNT_MGR->UnsubscribeCommonEvent()); } /** @@ -92,27 +90,9 @@ HWTEST_F(AccountManagerTest, AccountManagerTest_UnsubscribeCommonEvent_01, TestS HWTEST_F(AccountManagerTest, AccountManagerTest_SubscribeCommonEvent_02, TestSize.Level1) { CALL_TEST_DEBUG; - AccountManager accountManager; - accountManager.subscriber_ = nullptr; - accountManager.timerId_ = 1; - ASSERT_NO_FATAL_FAILURE(accountManager.SubscribeCommonEvent()); -} - -/** - * @tc.name: AccountManagerTest_SetupMainAccount_01 - * @tc.desc: Test the funcation SetupMainAccount - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(AccountManagerTest, AccountManagerTest_SetupMainAccount_01, TestSize.Level1) -{ - CALL_TEST_DEBUG; - AccountManager accountManager; - accountManager.currentAccountId_ = MAIN_ACCOUNT_ID; - auto [_, isNew] = accountManager.accounts_.emplace(MAIN_ACCOUNT_ID, - std::make_unique(MAIN_ACCOUNT_ID)); - EXPECT_TRUE(isNew); - ASSERT_NO_FATAL_FAILURE(accountManager.SetupMainAccount()); + ACCOUNT_MGR->subscriber_ = nullptr; + ACCOUNT_MGR->timerId_ = 1; + ASSERT_NO_FATAL_FAILURE(ACCOUNT_MGR->SubscribeCommonEvent()); } /** @@ -124,14 +104,10 @@ HWTEST_F(AccountManagerTest, AccountManagerTest_SetupMainAccount_01, TestSize.Le HWTEST_F(AccountManagerTest, AccountManagerTest_OnAddUser_01, TestSize.Level1) { CALL_TEST_DEBUG; - AccountManager accountManager; + int32_t accountId = TEST_ACCOUNT_ID_001; EventFwk::CommonEventData data; - int32_t accountId = data.GetCode(); - accountId = 3; - auto [_, isNew] = accountManager.accounts_.emplace(accountId, - std::make_unique(accountId)); - EXPECT_TRUE(isNew); - ASSERT_NO_FATAL_FAILURE(accountManager.OnAddUser(data)); + data.SetCode(accountId); + ASSERT_NO_FATAL_FAILURE(ACCOUNT_MGR->OnAddUser(data)); } /** @@ -143,12 +119,11 @@ HWTEST_F(AccountManagerTest, AccountManagerTest_OnAddUser_01, TestSize.Level1) HWTEST_F(AccountManagerTest, AccountManagerTest_OnRemoveUser_01, TestSize.Level1) { CALL_TEST_DEBUG; - AccountManager accountManager; + int32_t accountId = TEST_ACCOUNT_ID_002; EventFwk::CommonEventData data; - int32_t accountId = data.GetCode(); - accountId = 5; - ASSERT_NO_FATAL_FAILURE(accountManager.OnAddUser(data)); - ASSERT_NO_FATAL_FAILURE(accountManager.OnRemoveUser(data)); + data.SetCode(accountId); + ASSERT_NO_FATAL_FAILURE(ACCOUNT_MGR->OnAddUser(data)); + ASSERT_NO_FATAL_FAILURE(ACCOUNT_MGR->OnRemoveUser(data)); } /** @@ -160,43 +135,52 @@ HWTEST_F(AccountManagerTest, AccountManagerTest_OnRemoveUser_01, TestSize.Level1 HWTEST_F(AccountManagerTest, AccountManagerTest_OnCommonEvent_01, TestSize.Level1) { CALL_TEST_DEBUG; - AccountManager accountManager; EventFwk::CommonEventData data; - ASSERT_NO_FATAL_FAILURE(accountManager.OnCommonEvent(data)); + ASSERT_NO_FATAL_FAILURE(ACCOUNT_MGR->OnCommonEvent(data)); } /** * @tc.name: AccountManagerTest_OnSwitchUser_01 - * @tc.desc: Test the funcation OnSwitchUser + * @tc.desc: Test OnSwitchUser with empty account * @tc.type: FUNC * @tc.require: */ HWTEST_F(AccountManagerTest, AccountManagerTest_OnSwitchUser_01, TestSize.Level1) { CALL_TEST_DEBUG; - AccountManager accountManager; + int32_t accountId = TEST_ACCOUNT_ID_002; EventFwk::CommonEventData data; - int32_t accountId = data.GetCode(); - accountId = 1; - accountManager.currentAccountId_ = 1; - ASSERT_NO_FATAL_FAILURE(accountManager.OnSwitchUser(data)); + data.SetCode(accountId); + ASSERT_NO_FATAL_FAILURE(ACCOUNT_MGR->OnSwitchUser(data)); } /** * @tc.name: AccountManagerTest_OnSwitchUser_02 - * @tc.desc: Test the funcation OnSwitchUser + * @tc.desc: Test OnSwitchUser with used account * @tc.type: FUNC * @tc.require: */ HWTEST_F(AccountManagerTest, AccountManagerTest_OnSwitchUser_02, TestSize.Level1) { CALL_TEST_DEBUG; - AccountManager accountManager; + int32_t accountId = TEST_ACCOUNT_ID_001; EventFwk::CommonEventData data; - int32_t accountId = data.GetCode(); - accountId = 2; - accountManager.currentAccountId_ = -1; - ASSERT_NO_FATAL_FAILURE(accountManager.OnSwitchUser(data)); + data.SetCode(accountId); + ASSERT_NO_FATAL_FAILURE(ACCOUNT_MGR->OnSwitchUser(data)); +} + +/** + * @tc.name: AccountManagerTest_GetCurrentAccountSetting + * @tc.desc: Test the funcation GetCurrentAccountSetting + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(AccountManagerTest, AccountManagerTest_GetCurrentAccountSetting, TestSize.Level1) +{ + CALL_TEST_DEBUG; + auto accountSetting = ACCOUNT_MGR->GetCurrentAccountSetting(); + int32_t accountId = accountSetting.GetAccountId(); + EXPECT_EQ(accountId, TEST_ACCOUNT_ID_001); } /** @@ -274,7 +258,7 @@ HWTEST_F(AccountManagerTest, AccountManagerTest_ReadSwitchStatus_02, TestSize.Le int32_t accountId = 5; AccountManager::AccountSetting accountSetting(accountId); accountSetting.accountId_ = 2; - std::string key = "down"; + std::string key = "invaild"; bool currentSwitchStatus = false; char buf[DEFAULT_BUFFER_LENGTH] {}; @@ -443,7 +427,7 @@ HWTEST_F(AccountManagerTest, AccountManagerTest_ReadSwitchStatus_04, TestSize.Le CALL_TEST_DEBUG; int32_t accountId = 5; AccountManager::AccountSetting accountSetting(accountId); - std::string key = "down"; + std::string key = "invaild"; bool currentSwitchStatus = false; char buf[DEFAULT_BUFFER_LENGTH] {}; @@ -483,19 +467,5 @@ HWTEST_F(AccountManagerTest, AccountManagerTest_ReadLongPressTime_04, TestSize.L ASSERT_NO_FATAL_FAILURE(accountSetting.ReadLongPressTime()); } -/** - * @tc.name: AccountManagerTest_GetCurrentAccountSetting - * @tc.desc: Test the funcation GetCurrentAccountSetting - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(AccountManagerTest, AccountManagerTest_GetCurrentAccountSetting, TestSize.Level1) -{ - CALL_TEST_DEBUG; - AccountManager manager; - manager.currentAccountId_ = 123; - ASSERT_NO_FATAL_FAILURE(manager.GetCurrentAccountSetting()); -} - } // namespace MMI } // namespace OHOS \ No newline at end of file diff --git a/service/account_manager/test/mock_setting_datashare.cpp b/service/account_manager/test/mock_setting_datashare.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a19f322392a118545bc4e251ba07cda218e91c9c --- /dev/null +++ b/service/account_manager/test/mock_setting_datashare.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mmi_log.h" +#include "setting_datashare.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "mock_setting_datashare" + +namespace OHOS { +namespace MMI { +std::shared_ptr SettingDataShare::instance_ = nullptr; +std::mutex SettingDataShare::mutex_; + +SettingDataShare::~SettingDataShare() {} + +SettingDataShare& SettingDataShare::GetInstance(int32_t systemAbilityId) +{ + MMI_HILOGI("Mock SettingDataShare::GetInstance called"); + if (instance_ == nullptr) { + std::lock_guard lock(mutex_); + if (instance_ == nullptr) { + instance_ = std::make_shared(); + } + } + return *instance_; +} + +ErrCode SettingDataShare::GetBoolValue(const std::string& key, bool& value, const std::string &strUri) +{ + MMI_HILOGI("Mock SettingDataShare::GetBoolValue called"); + if (strcmp(key.c_str(), "invaild") == 0) return -1; + return ERR_OK; +} + +ErrCode SettingDataShare::GetIntValue(const std::string& key, int32_t& value, const std::string &strUri) +{ + MMI_HILOGI("Mock SettingDataShare::GetIntValue called"); + return ERR_OK; +} + +ErrCode SettingDataShare::GetStringValue(const std::string& key, std::string& value, const std::string &strUri) +{ + MMI_HILOGI("Mock SettingDataShare::GetStringValue called"); + return ERR_OK; +} + +sptr SettingDataShare::CreateObserver(const std::string& key, SettingObserver::UpdateFunc& func) +{ + MMI_HILOGI("Mock SettingDataShare::CreateObserver called"); + return nullptr; +} + +ErrCode SettingDataShare::RegisterObserver(const sptr& observer, const std::string &strUri) +{ + MMI_HILOGI("Mock SettingDataShare::RegisterObserver called"); + return ERR_OK; +} + +ErrCode SettingDataShare::UnregisterObserver(const sptr& observer, const std::string &strUri) +{ + MMI_HILOGI("Mock SettingDataShare::UnregisterObserver called"); + return ERR_OK; +} + +} // namespace MMI +} // namespace OHOS diff --git a/service/connect_manager/BUILD.gn b/service/connect_manager/BUILD.gn index 4a55006d51b8e1736dcfb212b2ca5a5a45df3fc2..d4293e962b29880efa4f2c92129c5619b3622b92 100644 --- a/service/connect_manager/BUILD.gn +++ b/service/connect_manager/BUILD.gn @@ -22,6 +22,10 @@ idl_gen_interface("multimodal_input_interface") { log_tag = "MultimodalInputConnect" } +idl_gen_interface("multimodal_input_binder_client_interface") { + sources = [ "IInputBinderClient.idl" ] +} + config("mmi_connect_manager_config") { include_dirs = [ "${mmi_path}/common/anco/comm/include", @@ -58,6 +62,9 @@ ohos_source_set("mmi_connect_manager_service") { output_values = get_target_outputs(":multimodal_input_interface") sources += filter_include(output_values, [ "*_stub.cpp" ]) + output_clinet_values = get_target_outputs(":multimodal_input_binder_client_interface") + sources += filter_include(output_clinet_values, [ "*_proxy.cpp" ]) + branch_protector_ret = "pac_ret" sanitize = { cfi = true @@ -74,6 +81,7 @@ ohos_source_set("mmi_connect_manager_service") { deps = [ ":multimodal_input_interface", + ":multimodal_input_binder_client_interface", "${mmi_path}/frameworks/proxy:libmmi-common", ] @@ -140,12 +148,15 @@ ohos_source_set("mmi_connect_manager_proxy") { sources += [ "${mmi_connect_manager_path}/src/input_binder_client_server.cpp", - "${mmi_connect_manager_path}/src/input_binder_client_stub.cpp", + "${mmi_connect_manager_path}/src/input_binder_client_server_impl.cpp", ] output_values = get_target_outputs(":multimodal_input_interface") sources += filter_include(output_values, [ "*_proxy.cpp" ]) + output_clinet_values = get_target_outputs(":multimodal_input_binder_client_interface") + sources += filter_include(output_clinet_values, [ "*_stub.cpp" ]) + configs = [ ":mmi_connect_manager_config", "${mmi_path}/common/anco/comm:mmi_anco_channel_config", @@ -154,6 +165,7 @@ ohos_source_set("mmi_connect_manager_proxy") { deps = [ ":multimodal_input_interface", + ":multimodal_input_binder_client_interface", "${mmi_path}/frameworks/proxy:libmmi-common", ] external_deps = [ diff --git a/service/connect_manager/src/input_binder_client_stub.cpp b/service/connect_manager/IInputBinderClient.idl similarity index 38% rename from service/connect_manager/src/input_binder_client_stub.cpp rename to service/connect_manager/IInputBinderClient.idl index 1fbe284bc20e7b8b70e7a933f675e719c8ab852d..0c87faeb16466d8d1976d83402ce9b6daf693484 100644 --- a/service/connect_manager/src/input_binder_client_stub.cpp +++ b/service/connect_manager/IInputBinderClient.idl @@ -1,10 +1,10 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,28 +13,6 @@ * limitations under the License. */ -#include "input_binder_client_stub.h" - -#include "message_parcel.h" -#include "mmi_log.h" - -#undef MMI_LOG_TAG -#define MMI_LOG_TAG "InputBinderClientStub" - -namespace OHOS { -namespace MMI { - -int32_t InputBinderClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - std::u16string descriptor = InputBinderClientStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - MMI_HILOGE("Client and service descriptors are inconsistent"); - return INVALID_DATA; - } - MMI_HILOGD("Begin, cmd:%{public}u", code); - return NO_ERROR; +interface OHOS.MMI.IInputBinderClient { + void NoticeRequestInjectionResult([in] int reqId, [in] int status); } -} // namespace OHOS -} // namespace MMI diff --git a/service/connect_manager/IMultimodalInputConnect.idl b/service/connect_manager/IMultimodalInputConnect.idl index fb4fa1df8b3c9c55b235fdf2eb1418984565c958..85a173173cec202200ea183a6a8fde6f61042ecd 100644 --- a/service/connect_manager/IMultimodalInputConnect.idl +++ b/service/connect_manager/IMultimodalInputConnect.idl @@ -119,6 +119,7 @@ interface OHOS.MMI.IMultimodalInputConnect { void GetFunctionKeyState([in] int funckey, [out] boolean state); void SetFunctionKeyState([in] int funcKey, [in] boolean enable); void SetPointerLocation([in] int x, [in] int y, [in] int displayId); + void GetPointerLocation([out] int displayId, [out] double displayX, [out] double displayY); void ClearWindowPointerStyle([in] int pid, [in] int windowId); void SetMouseCaptureMode([in] int windowId, [in] boolean isCaptureMode); void GetWindowPid([in] int windowId, [out] int windowPid); @@ -149,6 +150,8 @@ interface OHOS.MMI.IMultimodalInputConnect { void GetKeyState([out] int[] pressedKeys, [out] Map specialKeysState); void Authorize([in] boolean isAuthorize); void CancelInjection(); + void RequestInjection([out] int status, [out] int reqId); + void QueryAuthorizedStatus([out] int status); void HasIrEmitter([out] boolean hasIrEmitter); void GetInfraredFrequencies([out] InfraredFrequency[] requencys); void TransmitInfrared([in] long number, [in] long[] pattern); diff --git a/service/connect_manager/include/input_binder_client_server.h b/service/connect_manager/include/input_binder_client_server.h index aebd1e945c73e0824658c9c398de3dc0a74110f9..72b67b9f869d8043eb03e68968e43247a04579b2 100644 --- a/service/connect_manager/include/input_binder_client_server.h +++ b/service/connect_manager/include/input_binder_client_server.h @@ -17,8 +17,9 @@ #define INPUT_BINDER_CLIENT_SERVER_H #include "singleton.h" - +#include "iinput_binder_client.h" #include "input_binder_client_stub.h" +#include "iremote_object.h" namespace OHOS { namespace MMI { @@ -30,7 +31,7 @@ public: private: void InitClientSrv(); std::mutex clientSrvMutex_; - sptr clientSrvStub_ = nullptr; + sptr clientSrvStub_ = nullptr; }; #define INPUT_BINDER_CLIENT_SERVICE ::OHOS::DelayedSingleton::GetInstance() } // namespace MMI diff --git a/service/connect_manager/include/input_binder_client_stub.h b/service/connect_manager/include/input_binder_client_server_impl.h similarity index 54% rename from service/connect_manager/include/input_binder_client_stub.h rename to service/connect_manager/include/input_binder_client_server_impl.h index 2f8a762ec0a193f4c2444f3c3037cbfc0a11cde3..2f18d3c8b51bed799fb14d03e774954d1b58c3d7 100644 --- a/service/connect_manager/include/input_binder_client_stub.h +++ b/service/connect_manager/include/input_binder_client_server_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,22 +13,21 @@ * limitations under the License. */ -#ifndef I_INPUT_BINDER_CLIENT_STUB_H -#define I_INPUT_BINDER_CLIENT_STUB_H +#ifndef INPUT_BINDER_CLIENT_SERVER_IMPL_H +#define INPUT_BINDER_CLIENT_SERVER_IMPL_H -#include "iremote_stub.h" - -#include "i_input_binder_client.h" +#include "input_binder_client_stub.h" +#include "iremote_object.h" namespace OHOS { namespace MMI { -class InputBinderClientStub : public IRemoteStub { +class InputBinderClientServerImpl final: public InputBinderClientStub { + DISALLOW_COPY_AND_MOVE(InputBinderClientServerImpl); public: - InputBinderClientStub() = default; - virtual ~InputBinderClientStub() = default; - virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) override; + InputBinderClientServerImpl() = default; + ~InputBinderClientServerImpl() = default; + ErrCode NoticeRequestInjectionResult(int32_t reqId, int32_t status) override; }; } // namespace MMI } // namespace OHOS -#endif // I_INPUT_BINDER_CLIENT_STUB_H +#endif // INPUT_BINDER_CLIENT_SERVER_IMPL_H \ No newline at end of file diff --git a/service/connect_manager/include/multimodal_input_connect_manager.h b/service/connect_manager/include/multimodal_input_connect_manager.h index da507483e38df20adff26846f3314f9f38fe211b..42d65ebf923bf13b06b22fbfc8de765d55725a5f 100644 --- a/service/connect_manager/include/multimodal_input_connect_manager.h +++ b/service/connect_manager/include/multimodal_input_connect_manager.h @@ -115,6 +115,7 @@ public: int32_t GetFunctionKeyState(int32_t funcKey, bool &state); int32_t SetFunctionKeyState(int32_t funcKey, bool enable); int32_t SetPointerLocation(int32_t x, int32_t y, int32_t displayId); + int32_t GetPointerLocation(int32_t &displayId, double &displayX, double &displayY); int32_t SetMouseCaptureMode(int32_t windowId, bool isCaptureMode); int32_t GetWindowPid(int32_t windowId); int32_t AppendExtraData(const ExtraData& extraData); @@ -144,6 +145,8 @@ public: int32_t GetKeyState(std::vector &pressedKeys, std::map &specialKeysState); int32_t Authorize(bool isAuthorize); int32_t CancelInjection(); + int32_t RequestInjection(int32_t &status, int32_t &reqId); + int32_t QueryAuthorizedStatus(int32_t &status); int32_t HasIrEmitter(bool &hasIrEmitter); int32_t GetInfraredFrequencies(std::vector& requencys); int32_t TransmitInfrared(int64_t number, std::vector& pattern); diff --git a/service/connect_manager/src/input_binder_client_server.cpp b/service/connect_manager/src/input_binder_client_server.cpp index 60e982369ecce4335d4e8dea4e4dc47804ef3542..2dde515aced335df758d70a306c7451e8602eafb 100644 --- a/service/connect_manager/src/input_binder_client_server.cpp +++ b/service/connect_manager/src/input_binder_client_server.cpp @@ -14,8 +14,9 @@ */ #include "input_binder_client_server.h" - +#include "input_binder_client_server_impl.h" #include "mmi_log.h" +#include "input_manager.h" #undef MMI_LOG_TAG #define MMI_LOG_TAG "InputBinderClientServer" @@ -35,7 +36,7 @@ void InputBinderClientServer::InitClientSrv() CALL_DEBUG_ENTER; std::lock_guard clientLock(clientSrvMutex_); if (clientSrvStub_ == nullptr) { - clientSrvStub_ = new (std::nothrow) InputBinderClientStub(); + clientSrvStub_ = sptr::MakeSptr(); CHKPV(clientSrvStub_); } } diff --git a/service/connect_manager/include/i_input_binder_client.h b/service/connect_manager/src/input_binder_client_server_impl.cpp similarity index 62% rename from service/connect_manager/include/i_input_binder_client.h rename to service/connect_manager/src/input_binder_client_server_impl.cpp index 51fc176433c50969bdd1caf9286ed5ff90e6beb4..30aff26f997e1c196842118df6d6420d15487492 100644 --- a/service/connect_manager/include/i_input_binder_client.h +++ b/service/connect_manager/src/input_binder_client_server_impl.cpp @@ -13,17 +13,20 @@ * limitations under the License. */ -#ifndef I_INPUT_BINDER_CLIENT_H -#define I_INPUT_BINDER_CLIENT_H +#include "input_binder_client_server_impl.h" +#include "mmi_log.h" +#include "input_manager.h" -#include "iremote_broker.h" +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "InputBinderClientServerImpl" namespace OHOS { namespace MMI { -class IInputBinderClient : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"IInputBinderClient"); -}; +ErrCode InputBinderClientServerImpl::NoticeRequestInjectionResult(int32_t reqId, int32_t status) +{ + CALL_DEBUG_ENTER; + InputManager::GetInstance()->RequestInjectionCallback(reqId, status); + return RET_OK; +} } // namespace MMI -} // namespace OHOS -#endif // I_INPUT_BINDER_CLIENT_H +} // namespace OHOS \ No newline at end of file diff --git a/service/connect_manager/src/multimodal_input_connect_manager.cpp b/service/connect_manager/src/multimodal_input_connect_manager.cpp index 8db222c661594a71ba3cc4864ff074950a53fa50..934cab7a4b0d8c41efdf8f13ba508212b26767bb 100644 --- a/service/connect_manager/src/multimodal_input_connect_manager.cpp +++ b/service/connect_manager/src/multimodal_input_connect_manager.cpp @@ -607,6 +607,13 @@ int32_t MultimodalInputConnectManager::SetPointerLocation(int32_t x, int32_t y, return multimodalInputConnectService_->SetPointerLocation(x, y, displayId); } +int32_t MultimodalInputConnectManager::GetPointerLocation(int32_t &displayId, double &displayX, double &displayY) +{ + std::lock_guard guard(lock_); + CHKPR(multimodalInputConnectService_, INVALID_HANDLER_ID); + return multimodalInputConnectService_->GetPointerLocation(displayId, displayX, displayY); +} + bool MultimodalInputConnectManager::ConnectMultimodalInputService() __attribute__((no_sanitize("cfi"))) { CALL_DEBUG_ENTER; @@ -914,6 +921,20 @@ int32_t MultimodalInputConnectManager::CancelInjection() return multimodalInputConnectService_->CancelInjection(); } +int32_t MultimodalInputConnectManager::RequestInjection(int32_t &status, int32_t &reqId) +{ + std::lock_guard guard(lock_); + CHKPR(multimodalInputConnectService_, INVALID_HANDLER_ID); + return multimodalInputConnectService_->RequestInjection(status, reqId); +} + +int32_t MultimodalInputConnectManager::QueryAuthorizedStatus(int32_t &status) +{ + std::lock_guard guard(lock_); + CHKPR(multimodalInputConnectService_, INVALID_HANDLER_ID); + return multimodalInputConnectService_->QueryAuthorizedStatus(status); +} + int32_t MultimodalInputConnectManager::HasIrEmitter(bool &hasIrEmitter) { std::lock_guard guard(lock_); diff --git a/service/crown_transform_processor/src/crown_transform_processor.cpp b/service/crown_transform_processor/src/crown_transform_processor.cpp index 73952d8c5fb6e487c34f57ecd2e10b04b8d3abdb..3639911fdcae4ed836fe25f1c815e7feda4f625b 100644 --- a/service/crown_transform_processor/src/crown_transform_processor.cpp +++ b/service/crown_transform_processor/src/crown_transform_processor.cpp @@ -193,8 +193,12 @@ void CrownTransformProcessor::HandleCrownRotatePostInner(double velocity, double PointerEvent::PointerItem pointerItem; pointerItem.SetDisplayX(mouseInfo.physicalX); pointerItem.SetDisplayY(mouseInfo.physicalY); + pointerItem.SetDisplayXPos(mouseInfo.physicalX); + pointerItem.SetDisplayYPos(mouseInfo.physicalY); pointerItem.SetWindowX(0); pointerItem.SetWindowY(0); + pointerItem.SetWindowXPos(0.0); + pointerItem.SetWindowYPos(0.0); pointerItem.SetPointerId(0); pointerItem.SetPressed(false); int64_t time = GetSysClockTime(); diff --git a/service/event_dispatch/src/event_dispatch_handler.cpp b/service/event_dispatch/src/event_dispatch_handler.cpp index 059ddad55c93c2a026e0550fa7855a69706e310e..23df15a2e7b821c7b4b88869d9c22b3e4a8321f4 100644 --- a/service/event_dispatch/src/event_dispatch_handler.cpp +++ b/service/event_dispatch/src/event_dispatch_handler.cpp @@ -187,8 +187,8 @@ void EventDispatchHandler::HandleMultiWindowPointerEvent(std::shared_ptrSetTargetWindowId(windowId); pointerEvent->SetAgentWindowId(windowInfo->agentWindowId); - int32_t windowX = pointerItem.GetDisplayX() - windowInfo->area.x; - int32_t windowY = pointerItem.GetDisplayY() - windowInfo->area.y; + double windowX = pointerItem.GetDisplayX() - windowInfo->area.x; + double windowY = pointerItem.GetDisplayY() - windowInfo->area.y; auto physicalDisplayInfo = WIN_MGR->GetPhysicalDisplay(windowInfo->displayId); CHKPV(physicalDisplayInfo); if (!windowInfo->transform.empty()) { @@ -198,8 +198,10 @@ void EventDispatchHandler::HandleMultiWindowPointerEvent(std::shared_ptr(windowX)); + pointerItem.SetWindowY(static_cast(windowY)); + pointerItem.SetWindowXPos(windowX); + pointerItem.SetWindowYPos(windowY); pointerItem.SetTargetWindowId(windowId); pointerEvent->UpdatePointerItem(pointerId, pointerItem); pointerEvent->SetDispatchTimes(count++); @@ -344,6 +346,8 @@ void EventDispatchHandler::UpdateDisplayXY(const std::shared_ptr & windowInputType != WindowInputType::MIX_BUTTOM_ANTI_AXIS_MOVE) { pointerItem.SetDisplayX(pointerItem.GetFixedDisplayX()); pointerItem.SetDisplayY(pointerItem.GetFixedDisplayY()); + pointerItem.SetDisplayXPos(pointerItem.GetFixedDisplayX()); + pointerItem.SetDisplayYPos(pointerItem.GetFixedDisplayY()); point->UpdatePointerItem(pointerId, pointerItem); } else { MMI_HILOGI("targetDisplayId=%{private}d, targetWindowId=%{private}d, windowInputType=%{private}d, " diff --git a/service/event_dispatch/test/event_dispatch_test.cpp b/service/event_dispatch/test/event_dispatch_test.cpp index 5fda6c494984bafe546977cb6d6f1ab35e1ee4ba..dc1ab3d7cbed720de57f333cde7f813abf0d05ce 100644 --- a/service/event_dispatch/test/event_dispatch_test.cpp +++ b/service/event_dispatch/test/event_dispatch_test.cpp @@ -2074,6 +2074,114 @@ HWTEST_F(EventDispatchTest, EventDispatchTest_GetClientFd_006, TestSize.Level1) point->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE); EXPECT_EQ(eventdispatchhandler.GetClientFd(pid, point), INVALID_FD); } + +/** + * @tc.name: EventDispatchTest_HandleKeyEvent_001 + * @tc.desc: Test the function HandleKeyEvent + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventDispatchTest, EventDispatchTest_HandleKeyEvent_001, TestSize.Level1) +{ + EventDispatchHandler eventdispatchhandler; + std::shared_ptr keyEvent = KeyEvent::Create(); + ASSERT_NE(keyEvent, nullptr); + ASSERT_NO_FATAL_FAILURE(eventdispatchhandler.HandleKeyEvent(keyEvent)); +} + +/** + * @tc.name: EventDispatchTest_HandlePointerEvent_001 + * @tc.desc: Test the function HandlePointerEvent + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventDispatchTest, EventDispatchTest_HandlePointerEvent_001, TestSize.Level1) +{ + EventDispatchHandler eventdispatchhandler; + std::shared_ptr pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + ASSERT_NO_FATAL_FAILURE(eventdispatchhandler.HandlePointerEvent(pointerEvent)); +} + +/** + * @tc.name: EventDispatchTest_FilterInvalidPointerItem_010 + * @tc.desc: Test the function FilterInvalidPointerItem + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventDispatchTest, EventDispatchTest_FilterInvalidPointerItem_010, TestSize.Level1) +{ + EventDispatchHandler eventdispatchhandler; + int32_t fd = 1; + int32_t eventType = 3; + std::shared_ptr pointerEvent = std::make_shared(eventType); + + std::vector pointerIdList; + pointerEvent->pointerId_ = 3; + pointerIdList.push_back(pointerEvent->pointerId_); + pointerEvent->pointerId_ = 5; + pointerIdList.push_back(pointerEvent->pointerId_); + EXPECT_TRUE(pointerIdList.size() > 1); + + PointerEvent::PointerItem pointeritem; + pointeritem.SetWindowX(10); + pointeritem.SetWindowY(20); + pointeritem.SetTargetWindowId(2); + int32_t id = 1; + EXPECT_FALSE(pointerEvent->GetPointerItem(id, pointeritem)); + + pointeritem.targetWindowId_ = 3; + auto itemPid = WIN_MGR->GetWindowPid(pointeritem.targetWindowId_); + EXPECT_FALSE(itemPid >= 0); + ASSERT_NO_FATAL_FAILURE(eventdispatchhandler.FilterInvalidPointerItem(pointerEvent, fd)); +} + +/** + * @tc.name: EventDispatchTest_SearchCancelList_004 + * @tc.desc: Test SearchCancelList + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventDispatchTest, EventDispatchTest_SearchCancelList_004, TestSize.Level1) +{ + EventDispatchHandler handler; + int32_t pointerId = 1; + int32_t windowId = 1; + std::shared_ptr result = handler.SearchCancelList(pointerId, windowId); + ASSERT_EQ(result, nullptr); +} + +/** + * @tc.name: EventDispatchTest_HandleMultiWindowPointerEvent_009 + * @tc.desc: Test HandleMultiWindowPointerEvent + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventDispatchTest, EventDispatchTest_HandleMultiWindowPointerEvent_009, TestSize.Level1) +{ + EventDispatchHandler eventdispatchhandler; + int32_t eventType = 3; + std::shared_ptr point = std::make_shared(eventType); + EXPECT_NE(point, nullptr); + + std::vector windowIds; + windowIds.push_back(1); + windowIds.push_back(2); + windowIds.push_back(3); + + PointerEvent::PointerItem pointerItem; + pointerItem.SetWindowX(10); + pointerItem.SetWindowY(20); + pointerItem.SetTargetWindowId(2); + + int32_t pointerId = 1; + int32_t windowId = 1; + std::shared_ptr windowInfo1 = std::make_shared(); + windowInfo1->id = 1; + eventdispatchhandler.cancelEventList_[1].push_back(windowInfo1); + auto windowInfo = eventdispatchhandler.SearchCancelList(pointerId, windowId); + ASSERT_NO_FATAL_FAILURE(eventdispatchhandler.HandleMultiWindowPointerEvent(point, pointerItem)); +} } // namespace MMI } // namespace OHOS diff --git a/service/event_handler/src/event_normalize_handler.cpp b/service/event_handler/src/event_normalize_handler.cpp index e99069c8eb8feef44a861714ffc2b747b9dcd41e..4e7e09d3caa2b6fbc7e35b3d37078d0ef61a8170 100644 --- a/service/event_handler/src/event_normalize_handler.cpp +++ b/service/event_handler/src/event_normalize_handler.cpp @@ -1156,6 +1156,9 @@ void EventNormalizeHandler::SwipeInwardProcess(std::shared_ptr poi default: return; } + pointerItem.SetDisplayXPos(pointerItem.GetDisplayX()); + pointerItem.SetDisplayYPos(pointerItem.GetDisplayY()); + // angle and direction judge if ((std::abs(pointerItem.GetDisplayX() - lastPointerX) * SWIPE_INWARD_ANGLE_JUDGE < std::abs(pointerItem.GetDisplayY() - lastPointerY) || diff --git a/service/event_handler/test/event_normalize_handler_test.cpp b/service/event_handler/test/event_normalize_handler_test.cpp index dd27b1af0c6b9a4ca77d436bda7ba45f81c70ea2..8814f55d202ce949d0a2572d5735fda008d28b76 100644 --- a/service/event_handler/test/event_normalize_handler_test.cpp +++ b/service/event_handler/test/event_normalize_handler_test.cpp @@ -84,7 +84,9 @@ void EventNormalizeHandlerTest::SetupTouchpad() void EventNormalizeHandlerTest::CloseTouchpad() { - libinput_.RemovePath(vTouchpad_.GetDevPath()); + if (!vTouchpad_.GetDevPath().empty()) { + libinput_.RemovePath(vTouchpad_.GetDevPath()); + } vTouchpad_.Close(); } @@ -102,7 +104,9 @@ void EventNormalizeHandlerTest::SetupUwbRemoteControl() void EventNormalizeHandlerTest::CloseUwbRemoteControl() { - libinput_.RemovePath(vUwbRemoteControl_.GetDevPath()); + if (!vUwbRemoteControl_.GetDevPath().empty()) { + libinput_.RemovePath(vUwbRemoteControl_.GetDevPath()); + } vUwbRemoteControl_.Close(); } diff --git a/service/event_resample/include/event_resample.h b/service/event_resample/include/event_resample.h index 6012158f64a8613e36ee85cd56a08d24d552ece6..3fdb4183c1fcf23a9daea781979e284cfdb04e0b 100644 --- a/service/event_resample/include/event_resample.h +++ b/service/event_resample/include/event_resample.h @@ -256,8 +256,8 @@ private: void RewriteMessage(TouchState& state, MotionEvent &event); ssize_t FindSampleNoLaterThan(const Batch& batch, int64_t time); bool ShouldResampleTool(int32_t toolType); - std::pair TransformSampleWindowXY(std::shared_ptr pointerEvent, - PointerEvent::PointerItem &item, int32_t logicX, int32_t logicY); + std::pair TransformSampleWindowXY(std::shared_ptr pointerEvent, + PointerEvent::PointerItem &item, double logicX, double logicY); }; inline static float CalcCoord(float a, float b, float alpha) diff --git a/service/event_resample/src/event_resample.cpp b/service/event_resample/src/event_resample.cpp index 21975747b9f82bd8cd80f292e15973daf9e820e4..c4acf7869b21f6effd2ba15c0ec5efb3eca2dd2b 100644 --- a/service/event_resample/src/event_resample.cpp +++ b/service/event_resample/src/event_resample.cpp @@ -192,10 +192,14 @@ void EventResample::UpdatePointerEvent(MotionEvent* outEvent) auto logicY = it.second.coordY; item.SetDisplayX(logicX); item.SetDisplayY(logicY); + item.SetDisplayXPos(logicX); + item.SetDisplayYPos(logicY); auto windowXY = TransformSampleWindowXY(pointerEvent_, item, logicX, logicY); - item.SetWindowX(windowXY.first); - item.SetWindowY(windowXY.second); + item.SetWindowX(static_cast(windowXY.first)); + item.SetWindowY(static_cast(windowXY.second)); + item.SetWindowXPos(windowXY.first); + item.SetWindowYPos(windowXY.second); if (PointerEvent::POINTER_ACTION_MOVE == outEvent->pointerAction) { item.SetPressed(true); @@ -209,8 +213,8 @@ void EventResample::UpdatePointerEvent(MotionEvent* outEvent) } } -std::pair EventResample::TransformSampleWindowXY(std::shared_ptr pointerEvent, - PointerEvent::PointerItem &item, int32_t logicX, int32_t logicY) +std::pair EventResample::TransformSampleWindowXY(std::shared_ptr pointerEvent, + PointerEvent::PointerItem &item, double logicX, double logicY) { CALL_DEBUG_ENTER; if (pointerEvent == nullptr) { @@ -229,9 +233,7 @@ std::pair EventResample::TransformSampleWindowXY(std::shared_p } auto windowXY = WIN_MGR->TransformWindowXY(window, logicX + physicalDisplayInfo->x, logicY + physicalDisplayInfo->y); - auto windowX = static_cast(windowXY.first); - auto windowY = static_cast(windowXY.second); - return {windowX, windowY}; + return {windowXY.first, windowXY.second}; } } return {logicX, logicY}; diff --git a/service/event_resample/test/event_resample_test.cpp b/service/event_resample/test/event_resample_test.cpp index a73cd563b26d8231cf31c5576524344d0fafca91..84f4c4e5c3e4d23e45b7f10fe998969dab0231af 100644 --- a/service/event_resample/test/event_resample_test.cpp +++ b/service/event_resample/test/event_resample_test.cpp @@ -617,10 +617,12 @@ HWTEST_F(EventResampleTest, EventResampleTest_TransformSampleWindowXY, TestSize. CALL_TEST_DEBUG; std::shared_ptr pointerEvent = nullptr; PointerEvent::PointerItem item; - int32_t logicX = 100; - int32_t logicY = 100; - std::pair pair { logicX, logicY }; - ASSERT_EQ(EventResampleHdr->TransformSampleWindowXY(pointerEvent, item, logicX, logicY), pair); + double logicX = 100; + double logicY = 100; + std::pair pair { logicX, logicY }; + auto result = EventResampleHdr->TransformSampleWindowXY(pointerEvent, item, logicX, logicY); + EXPECT_DOUBLE_EQ(result.first, pair.first); + EXPECT_DOUBLE_EQ(result.second, pair.second); } /** diff --git a/service/infrared_emitter/include/infrared_emitter_controller.h b/service/infrared_emitter/include/infrared_emitter_controller.h index b275353ec5f4661384a251e63ff19bfedbefdf08..be03ae530d5e90d1bf97643e3c3d3854f1f197ee 100644 --- a/service/infrared_emitter/include/infrared_emitter_controller.h +++ b/service/infrared_emitter/include/infrared_emitter_controller.h @@ -17,11 +17,13 @@ #define INFRARED_EMMITTER_CONTROLLER_H #include "nocopyable.h" -#include "infrared_emitter_def.h" +#include "refbase.h" +#include "v1_0/consumer_ir.h" +#include +#include namespace OHOS { namespace MMI { -using namespace OHOS::HDI::V1_0; struct InfraredFrequencyInfo { int64_t max_ { 0 }; int64_t min_ { 0 }; @@ -35,7 +37,7 @@ public: */ static InfraredEmitterController *GetInstance(); virtual ~InfraredEmitterController(); - void InitInfraredEmitter(); + sptr InitInfraredEmitter(); bool Transmit(int64_t carrierFreq, const std::vector pattern); bool GetFrequencies(std::vector &frequencyInfo); @@ -43,8 +45,6 @@ private: InfraredEmitterController(); DISALLOW_COPY_AND_MOVE(InfraredEmitterController); static InfraredEmitterController *instance_; - ConsumerIr *irInterface_ {nullptr}; - void *soIrHandle_ {nullptr}; }; } } diff --git a/service/infrared_emitter/src/infrared_emitter_controller.cpp b/service/infrared_emitter/src/infrared_emitter_controller.cpp index 9b430f40297d764a2ab8fd518763bb816389f97b..5a577fcf11c38b3a4458cbb90a6444aa4e79f57a 100644 --- a/service/infrared_emitter/src/infrared_emitter_controller.cpp +++ b/service/infrared_emitter/src/infrared_emitter_controller.cpp @@ -16,7 +16,7 @@ #include "infrared_emitter_controller.h" #include - +#include "idevmgr_hdi.h" #include "mmi_log.h" #undef MMI_LOG_DOMAIN @@ -27,23 +27,14 @@ namespace OHOS { namespace MMI { namespace { -const char* IR_WRAPPER_PATH = "libconsumer_ir_service_1.0.z.so"; +const std::string CONSUMER_NAME = "consumerir_service"; std::mutex mutex_; } -using namespace OHOS::HDI::V1_0; + InfraredEmitterController *InfraredEmitterController::instance_ = new (std::nothrow) InfraredEmitterController(); InfraredEmitterController::InfraredEmitterController() {} -InfraredEmitterController::~InfraredEmitterController() -{ - CALL_DEBUG_ENTER; - std::lock_guard guard(mutex_); - irInterface_ = nullptr; - if (soIrHandle_ != nullptr) { - dlclose(soIrHandle_); - soIrHandle_ = nullptr; - } -} +InfraredEmitterController::~InfraredEmitterController() {} InfraredEmitterController *InfraredEmitterController::GetInstance() { @@ -51,51 +42,37 @@ InfraredEmitterController *InfraredEmitterController::GetInstance() return instance_; } -void InfraredEmitterController::InitInfraredEmitter() +sptr InfraredEmitterController::InitInfraredEmitter() { - CALL_DEBUG_ENTER; - if (irInterface_ != nullptr) { - return; - } - if (soIrHandle_ == nullptr) { - soIrHandle_ = dlopen(IR_WRAPPER_PATH, RTLD_NOW); - if (soIrHandle_ == nullptr) { - MMI_HILOGE("Loaded %{public}s failed:%{public}s", IR_WRAPPER_PATH, dlerror()); - return; - } + MMI_HILOGI("Infrared emitter call ConsumerIr:fnCreate begin"); + sptr consumerIr = + OHOS::HDI::Consumerir::V1_0::ConsumerIr::Get(CONSUMER_NAME); + if (consumerIr != nullptr) { + return consumerIr; } - typedef ConsumerIr* (*funCreate_ptr) (void); - funCreate_ptr fnCreate = nullptr; - fnCreate = (funCreate_ptr)dlsym(soIrHandle_, "ConsumerIrImplGetInstance"); - const char *dlsymError = dlerror(); - if (dlsymError != nullptr) { - MMI_HILOGE("Loaded ConsumerIrImplGetInstance failed:%{public}s", dlsymError); - dlclose(soIrHandle_); - soIrHandle_ = nullptr; - return; + auto devmgr = OHOS::HDI::DeviceManager::V1_0::IDeviceManager::Get(); + if (devmgr == nullptr) { + MMI_HILOGE("devmgr is null."); + return nullptr; } - if (fnCreate == nullptr) { - MMI_HILOGE("Loaded ConsumerIrImplGetInstance is null"); - dlclose(soIrHandle_); - soIrHandle_ = nullptr; - return; + if (devmgr->LoadDevice(CONSUMER_NAME) != 0) { + MMI_HILOGE("LoadDevice(%{public}s) failed.", CONSUMER_NAME.c_str()); + return nullptr; } - MMI_HILOGI("Infrared emitter call ConsumerIr:fnCreate begin"); - irInterface_ = (ConsumerIr *)fnCreate(); - if (irInterface_ == nullptr) { - MMI_HILOGE("Infrared emitter init fail irInterface_ is nullptr"); - dlclose(soIrHandle_); - soIrHandle_ = nullptr; - return; + consumerIr = OHOS::HDI::Consumerir::V1_0::ConsumerIr::Get(CONSUMER_NAME); + if (consumerIr == nullptr) { + MMI_HILOGE("Infrared emitter init fail consumerIr is nullptr"); + return nullptr; } + return consumerIr; } bool InfraredEmitterController::Transmit(int64_t carrierFreq, const std::vector pattern) { CALL_DEBUG_ENTER; std::lock_guard guard(mutex_); - InitInfraredEmitter(); - CHKPF(irInterface_); + sptr consumerIr = InitInfraredEmitter(); + CHKPF(consumerIr); int32_t tempCarrierFreq = carrierFreq; std::vector tempPattern; std::string context = "infraredFrequency:" + std::to_string(tempCarrierFreq) + ";"; @@ -104,11 +81,11 @@ bool InfraredEmitterController::Transmit(int64_t carrierFreq, const std::vector< context = context + "index:" + std::to_string(i) + ": pattern:" + std::to_string(per) + ";"; tempPattern.push_back(per); } - MMI_HILOGI("irInterface_->Transmit params:%{public}s", context.c_str()); + MMI_HILOGI("consumerIr->Transmit params:%{public}s", context.c_str()); bool outRet = false; - int32_t ret = irInterface_->Transmit(tempCarrierFreq, tempPattern, outRet); - MMI_HILOGI("irInterface_->Transmit ret:%{public}d", ret); + int32_t ret = consumerIr->Transmit(tempCarrierFreq, tempPattern, outRet); + MMI_HILOGI("consumerIr->Transmit ret:%{public}d", ret); if (ret < 0) { MMI_HILOGE("Infrared emitter transmit failed:%{public}d", ret); return false; @@ -124,16 +101,13 @@ bool InfraredEmitterController::GetFrequencies(std::vector guard(mutex_); - InitInfraredEmitter(); - if (!irInterface_) { - MMI_HILOGE("Infrared emitter not init"); - return false; - } + sptr consumerIr = InitInfraredEmitter(); + CHKPF(consumerIr); bool outRet = false; - std::vector outRange; - MMI_HILOGI("irInterface_->GetCarrierFreqs"); - int32_t ret = irInterface_->GetCarrierFreqs(outRet, outRange); - MMI_HILOGI("irInterface_->GetCarrierFreqs ret:%{public}d", ret); + std::vector outRange; + MMI_HILOGI("consumerIr->GetCarrierFreqs"); + int32_t ret = consumerIr->GetCarrierFreqs(outRet, outRange); + MMI_HILOGI("consumerIr->GetCarrierFreqs ret:%{public}d", ret); if (ret < 0) { MMI_HILOGE("Infrared emitter GetCarrierFreqs failed:%{public}d", ret); return false; @@ -151,6 +125,7 @@ bool InfraredEmitterController::GetFrequencies(std::vectorGetCarrierFreqs context:%{public}s", context.c_str()); return true; } } // namespace MMI diff --git a/service/infrared_emitter/test/infrared_emitter_controller_test.cpp b/service/infrared_emitter/test/infrared_emitter_controller_test.cpp index 057a7bfbca5e743b4584de8c8dc901a53dcf4d85..dcb6a783425b483102fdd0311f7c7a5e98fc1746 100644 --- a/service/infrared_emitter/test/infrared_emitter_controller_test.cpp +++ b/service/infrared_emitter/test/infrared_emitter_controller_test.cpp @@ -27,7 +27,6 @@ namespace MMI { #ifndef OHOS_BUILD_PC_UNIT_TEST namespace { using namespace testing::ext; -const std::string IR_WRAPPER_PATH = "libconsumer_ir_service_1.0.z.so"; } // namespace class InfraredEmitterControllerTest : public testing::Test { @@ -62,10 +61,6 @@ HWTEST_F(InfraredEmitterControllerTest, InfraredEmitterControllerTest_InitInfrar { CALL_TEST_DEBUG; InfraredEmitterController controller; - controller.irInterface_ = nullptr; - controller.soIrHandle_ = nullptr; - ASSERT_NO_FATAL_FAILURE(controller.InitInfraredEmitter()); - controller.soIrHandle_ = dlopen(IR_WRAPPER_PATH.c_str(), RTLD_NOW); ASSERT_NO_FATAL_FAILURE(controller.InitInfraredEmitter()); } @@ -81,8 +76,7 @@ HWTEST_F(InfraredEmitterControllerTest, InfraredEmitterControllerTest_Transmit_0 InfraredEmitterController controller; int64_t carrierFreq = 12; std::vector pattern = {10, 20, 30}; - bool ret = controller.Transmit(carrierFreq, pattern); - ASSERT_TRUE(ret); + ASSERT_NO_FATAL_FAILURE(controller.Transmit(carrierFreq, pattern)); } /** @@ -95,11 +89,9 @@ HWTEST_F(InfraredEmitterControllerTest, InfraredEmitterControllerTest_GetFrequen { CALL_TEST_DEBUG; InfraredEmitterController controller; - controller.irInterface_ = nullptr; std::vector frequencyInfo; frequencyInfo.push_back(InfraredFrequencyInfo({1, 1000})); - bool ret = controller.GetFrequencies(frequencyInfo); - ASSERT_TRUE(ret); + ASSERT_NO_FATAL_FAILURE(controller.GetFrequencies(frequencyInfo)); } #endif // OHOS_BUILD_PC_UNIT_TEST } // namespace MMI diff --git a/service/interceptor/test/event_interceptor_handler_test.cpp b/service/interceptor/test/event_interceptor_handler_test.cpp index 5a35fd75b19553ff810cf26d3f649e9a854360a9..bdf3038ba2a1b1e26ae3f3ce6ca72a3eeda6dc22 100644 --- a/service/interceptor/test/event_interceptor_handler_test.cpp +++ b/service/interceptor/test/event_interceptor_handler_test.cpp @@ -714,5 +714,339 @@ HWTEST_F(EventInterceptorHandlerTest, TouchPadKnuckleDoubleClickHandle_Test_003, bool result = handler.TouchPadKnuckleDoubleClickHandle(event); EXPECT_TRUE(result); } + +/** + * @tc.name: EventInterceptorHandler_Test_0011 + * @tc.desc: Test the function HandleKeyEvent + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventInterceptorHandlerTest, EventInterceptorHandler_Test_0011, TestSize.Level1) +{ + CALL_TEST_DEBUG; + EventInterceptorHandler handler; + std::shared_ptr event = KeyEvent::Create(); + event->SetKeyAction(KNUCKLE_2F_DOUBLE_CLICK); + ASSERT_NO_FATAL_FAILURE(handler.HandleKeyEvent(event)); +} + +/** + * @tc.name: EventInterceptorHandler_Test_0018 + * @tc.desc: Test the function TouchPadKnuckleDoubleClickHandle + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventInterceptorHandlerTest, EventInterceptorHandler_Test_0018, TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr event = KeyEvent::Create(); + int32_t keyAction = 123; + event->SetKeyAction(keyAction); // or KNUCKLE_2F_DOUBLE_CLICK + EventInterceptorHandler handler; + handler.nextHandler_ = std::make_shared(); + ASSERT_NO_FATAL_FAILURE(handler.TouchPadKnuckleDoubleClickHandle(event)); +} + +/** + * @tc.name: EventInterceptorHandler_Test_0019 + * @tc.desc: Test the function HandlePointerEvent + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventInterceptorHandlerTest, EventInterceptorHandler_Test_0019, TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr pointerEvent = PointerEvent::Create(); + auto InputEvent = InputEvent::Create(); + ASSERT_NE(InputEvent, nullptr); + InputEvent->ClearFlag(); + uint32_t flag = 1; + InputEvent->AddFlag(flag); + EventInterceptorHandler handler; + ASSERT_NO_FATAL_FAILURE(handler.HandlePointerEvent(pointerEvent)); +} + +static uint32_t TestCapabilityToTags(InputDeviceCapability capability) +{ + return static_cast((1 << capability) - (capability / INPUT_DEV_CAP_MAX)); +} + +/** + * @tc.name: EventInterceptorHandler_Test_0020 + * @tc.desc: Test the function CheckInputDeviceSource + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventInterceptorHandlerTest, EventInterceptorHandler_Test_0020, TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr pointerEvent = PointerEvent::Create(); + pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN); + uint32_t deviceTags = TestCapabilityToTags(InputDeviceCapability::INPUT_DEV_CAP_TOUCH); + bool ret = EventInterceptorHandler::CheckInputDeviceSource(pointerEvent, deviceTags); + EXPECT_EQ(ret, true); + deviceTags = TestCapabilityToTags(InputDeviceCapability::INPUT_DEV_CAP_TABLET_TOOL); + ret = EventInterceptorHandler::CheckInputDeviceSource(pointerEvent, deviceTags); + EXPECT_EQ(ret, true); + deviceTags = 0; + ret = EventInterceptorHandler::CheckInputDeviceSource(pointerEvent, deviceTags); + EXPECT_EQ(ret, false); + + pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE); + deviceTags = TestCapabilityToTags(InputDeviceCapability::INPUT_DEV_CAP_POINTER); + ret = EventInterceptorHandler::CheckInputDeviceSource(pointerEvent, deviceTags); + EXPECT_EQ(ret, true); + deviceTags = TestCapabilityToTags(InputDeviceCapability::INPUT_DEV_CAP_TOUCH); + ret = EventInterceptorHandler::CheckInputDeviceSource(pointerEvent, deviceTags); + EXPECT_EQ(ret, false); + + pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD); + deviceTags = TestCapabilityToTags(InputDeviceCapability::INPUT_DEV_CAP_POINTER); + ret = EventInterceptorHandler::CheckInputDeviceSource(pointerEvent, deviceTags); + EXPECT_EQ(ret, true); + deviceTags = TestCapabilityToTags(InputDeviceCapability::INPUT_DEV_CAP_TOUCH); + ret = EventInterceptorHandler::CheckInputDeviceSource(pointerEvent, deviceTags); + EXPECT_EQ(ret, false); + + pointerEvent->SetSourceType(0); + deviceTags = TestCapabilityToTags(InputDeviceCapability::INPUT_DEV_CAP_POINTER); + ret = EventInterceptorHandler::CheckInputDeviceSource(pointerEvent, deviceTags); + EXPECT_EQ(ret, false); + deviceTags = TestCapabilityToTags(InputDeviceCapability::INPUT_DEV_CAP_TOUCH); + ret = EventInterceptorHandler::CheckInputDeviceSource(pointerEvent, deviceTags); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: EventInterceptorHandler_Test_0021 + * @tc.desc: Test the function HandleEvent when ENABLE_KEYBOARD + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventInterceptorHandlerTest, EventInterceptorHandler_Test_0021, TestSize.Level1) +{ + CALL_TEST_DEBUG; + InputHandlerType handlerType = InputHandlerType::NONE; + HandleEventType eventType = HANDLE_EVENT_TYPE_NONE; + int32_t priority = 0; + uint32_t deviceTags = 0; + SessionPtr session = std::make_shared(PROGRAM_NAME, g_moduleType, + g_writeFd, UID_ROOT, g_pid); + EventInterceptorHandler::SessionHandler interceptor(handlerType, eventType, priority, + deviceTags, session); + EventInterceptorHandler::InterceptorCollection interceptorHandler; + interceptorHandler.interceptors_.push_back(interceptor); + std::shared_ptr keyEvent = KeyEvent::Create(); + bool ret = interceptorHandler.HandleEvent(keyEvent); + EXPECT_EQ(ret, false); + + KeyEvent::KeyItem item; + keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN); + item.SetKeyCode(KeyEvent::KEYCODE_UNKNOWN); + item.SetDownTime(200); + keyEvent->AddKeyItem(item); + ret = interceptorHandler.HandleEvent(keyEvent); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: EventInterceptorHandler_Test_0022 + * @tc.desc: Test the function HandleEvent when ENABLE_KEYBOARD + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventInterceptorHandlerTest, EventInterceptorHandler_Test_0022, TestSize.Level1) +{ + CALL_TEST_DEBUG; + InputHandlerType handlerType = InputHandlerType::NONE; + HandleEventType eventType = HANDLE_EVENT_TYPE_KEY; + int32_t priority = 0; + uint32_t deviceTags = INPUT_DEV_CAP_KEYBOARD; + EventInterceptorHandler::SessionHandler interceptor(handlerType, eventType, priority, + deviceTags, nullptr); + EventInterceptorHandler::InterceptorCollection interceptorHandler; + interceptorHandler.interceptors_.push_back(interceptor); + std::shared_ptr keyEvent = KeyEvent::Create(); + KeyEvent::KeyItem item; + keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN); + item.SetKeyCode(KeyEvent::KEYCODE_UNKNOWN); + item.SetDownTime(200); + keyEvent->AddKeyItem(item); + + bool ret = interceptorHandler.HandleEvent(keyEvent); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: EventInterceptorHandler_Test_0023 + * @tc.desc: Test the function HandleEvent when ENABLE_KEYBOARD + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventInterceptorHandlerTest, EventInterceptorHandler_Test_0023, TestSize.Level1) +{ + CALL_TEST_DEBUG; + InputHandlerType handlerType = InputHandlerType::NONE; + HandleEventType eventType = HANDLE_EVENT_TYPE_KEY; + int32_t priority = 0; + uint32_t deviceTags = INPUT_DEV_CAP_TOUCH; + EventInterceptorHandler::SessionHandler interceptor(handlerType, eventType, priority, + deviceTags, nullptr); + EventInterceptorHandler::InterceptorCollection interceptorHandler; + interceptorHandler.interceptors_.push_back(interceptor); + std::shared_ptr keyEvent = KeyEvent::Create(); + KeyEvent::KeyItem item; + keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN); + item.SetKeyCode(KeyEvent::KEYCODE_UNKNOWN); + item.SetDownTime(200); + keyEvent->AddKeyItem(item); + + bool ret = interceptorHandler.HandleEvent(keyEvent); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: EventInterceptorHandler_Test_0024 + * @tc.desc: Test the function HandleEvent when ENABLE_KEYBOARD + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventInterceptorHandlerTest, EventInterceptorHandler_Test_0024, TestSize.Level1) +{ + CALL_TEST_DEBUG; + InputHandlerType handlerType = InputHandlerType::NONE; + HandleEventType eventType = HANDLE_EVENT_TYPE_KEY; + int32_t priority = 0; + uint32_t deviceTags = INPUT_DEV_CAP_KEYBOARD; + SessionPtr session = std::make_shared(PROGRAM_NAME, g_moduleType, + g_writeFd, UID_ROOT, g_pid); + EventInterceptorHandler::SessionHandler interceptor(handlerType, eventType, priority, + deviceTags, session); + EventInterceptorHandler::InterceptorCollection interceptorHandler; + interceptorHandler.interceptors_.push_back(interceptor); + std::shared_ptr keyEvent = KeyEvent::Create(); + KeyEvent::KeyItem item; + keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN); + item.SetKeyCode(KeyEvent::KEYCODE_UNKNOWN); + item.SetDownTime(200); + keyEvent->AddKeyItem(item); + + ASSERT_NO_FATAL_FAILURE(interceptorHandler.HandleEvent(keyEvent)); +} + +/** + * @tc.name: EventInterceptorHandler_Test_0025 + * @tc.desc: Test the function HandleEvent when ENABLE_KEYBOARD + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventInterceptorHandlerTest, EventInterceptorHandler_Test_0025, TestSize.Level1) +{ + CALL_TEST_DEBUG; + InputHandlerType handlerType = InputHandlerType::NONE; + HandleEventType eventType = HANDLE_EVENT_TYPE_NONE; + int32_t priority = 0; + uint32_t deviceTags = INPUT_DEV_CAP_KEYBOARD; + SessionPtr session = std::make_shared(PROGRAM_NAME, g_moduleType, + g_writeFd, UID_ROOT, g_pid); + EventInterceptorHandler::SessionHandler interceptor(handlerType, eventType, priority, + deviceTags, session); + EventInterceptorHandler::InterceptorCollection interceptorHandler; + interceptorHandler.interceptors_.push_back(interceptor); + std::shared_ptr keyEvent = KeyEvent::Create(); + KeyEvent::KeyItem item; + keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN); + item.SetKeyCode(KeyEvent::KEYCODE_UNKNOWN); + item.SetDownTime(200); + keyEvent->AddKeyItem(item); + + bool ret = interceptorHandler.HandleEvent(keyEvent); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: EventInterceptorHandler_Test_0026 + * @tc.desc: Test the function HandleEvent when ENABLE_KEYBOARD + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventInterceptorHandlerTest, EventInterceptorHandler_Test_0026, TestSize.Level1) +{ + CALL_TEST_DEBUG; + InputHandlerType handlerType = InputHandlerType::NONE; + HandleEventType eventType = HANDLE_EVENT_TYPE_NONE; + int32_t priority = 0; + uint32_t deviceTags = 0; + SessionPtr sessionFirst = std::make_shared(PROGRAM_NAME, g_moduleType, + g_writeFd, UID_ROOT, g_pid); + EventInterceptorHandler::SessionHandler interceptorFirst(handlerType, eventType, priority, + deviceTags, sessionFirst); + EventInterceptorHandler::InterceptorCollection interceptorHandler; + interceptorHandler.interceptors_.push_back(interceptorFirst); + std::shared_ptr pointerEvent = PointerEvent::Create(); + bool ret = interceptorHandler.HandleEvent(pointerEvent); + EXPECT_EQ(ret, false); + + PointerEvent::PointerItem item; + item.SetPointerId(0); + pointerEvent->AddPointerItem(item); + ret = interceptorHandler.HandleEvent(pointerEvent); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: EventInterceptorHandler_Test_0027 + * @tc.desc: Test the function HandleEvent when ENABLE_KEYBOARD + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventInterceptorHandlerTest, EventInterceptorHandler_Test_0027, TestSize.Level1) +{ + CALL_TEST_DEBUG; + InputHandlerType handlerType = InputHandlerType::NONE; + HandleEventType eventType = HANDLE_EVENT_TYPE_NONE; + int32_t priority = 0; + uint32_t deviceTags = 0; + EventInterceptorHandler::SessionHandler interceptorFirst(handlerType, eventType, priority, + deviceTags, nullptr); + EventInterceptorHandler::InterceptorCollection interceptorHandler; + interceptorHandler.interceptors_.push_back(interceptorFirst); + std::shared_ptr pointerEvent = PointerEvent::Create(); + + PointerEvent::PointerItem item; + item.SetPointerId(0); + pointerEvent->AddPointerItem(item); + bool ret = interceptorHandler.HandleEvent(pointerEvent); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: EventInterceptorHandler_Test_0028 + * @tc.desc: Test the function HandleEvent when ENABLE_KEYBOARD + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(EventInterceptorHandlerTest, EventInterceptorHandler_Test_0028, TestSize.Level1) +{ + CALL_TEST_DEBUG; + InputHandlerType handlerType = InputHandlerType::NONE; + HandleEventType eventType = HANDLE_EVENT_TYPE_POINTER; + int32_t priority = 0; + uint32_t deviceTags = 0; + SessionPtr sessionFirst = std::make_shared(PROGRAM_NAME, g_moduleType, + g_writeFd, UID_ROOT, g_pid); + EventInterceptorHandler::SessionHandler interceptorFirst(handlerType, eventType, priority, + deviceTags, sessionFirst); + EventInterceptorHandler::InterceptorCollection interceptorHandler; + interceptorHandler.interceptors_.push_back(interceptorFirst); + std::shared_ptr pointerEvent = PointerEvent::Create(); + + PointerEvent::PointerItem item; + item.SetPointerId(0); + pointerEvent->AddPointerItem(item); + bool ret = interceptorHandler.HandleEvent(pointerEvent); + EXPECT_EQ(ret, false); +} + } // namespace MMI } // namespace OHOS \ No newline at end of file diff --git a/service/key_command/test/key_command_handler_test.cpp b/service/key_command/test/key_command_handler_test.cpp index 36be6d22f47197198ad6e7cb51efe1fc7c21cfbb..49dc03c04123d20d940bb106498d803af9494001 100644 --- a/service/key_command/test/key_command_handler_test.cpp +++ b/service/key_command/test/key_command_handler_test.cpp @@ -13,7 +13,9 @@ * limitations under the License. */ +#include #include +#include #include "cJSON.h" #include "util.h" @@ -1078,12 +1080,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_CheckTwoFingerGestureActio displayInfo.width = 150; displayInfo.height = 300; displayInfo.uniq = "default0"; - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager.displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); bool ret = handler.CheckTwoFingerGestureAction(); EXPECT_FALSE(ret); handler.twoFingerGesture_.touches[0].x = 30; @@ -1127,12 +1127,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_CheckTwoFingerGestureActio displayInfo.width = 150; displayInfo.height = 300; displayInfo.uniq = "default0"; - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager.displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); handler.twoFingerGesture_.touches[0].y = 200; handler.twoFingerGesture_.touches[1].x = 30; bool ret = handler.CheckTwoFingerGestureAction(); @@ -1301,16 +1299,14 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_ConvertVPToPX_004, TestSiz DisplayInfo displayInfo; displayInfo.dpi = -10; displayInfo.uniq = "default0"; - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager.displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); int32_t ret = handler.ConvertVPToPX(vp); ASSERT_EQ(ret, 0); displayInfo.dpi = 160; - displayGroupInfoRef.displaysInfo.push_back(displayInfo); + it->second.displaysInfo.push_back(displayInfo); ret = handler.ConvertVPToPX(vp); ASSERT_EQ(ret, 0); } @@ -4063,12 +4059,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_ConvertVPToPX_002, TestSiz displayInfo.width = 4; displayInfo.height = 5; displayInfo.dpi = -1; - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager.displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); ret = handler.ConvertVPToPX(vp); ASSERT_EQ(ret, 0); } @@ -4092,12 +4086,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_ConvertVPToPX_003, TestSiz displayInfo.width = 4; displayInfo.height = 5; displayInfo.dpi = 160; - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager.displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); int32_t ret = handler.ConvertVPToPX(vp); ASSERT_EQ(ret, 0); } @@ -4129,12 +4121,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_CheckTwoFingerGestureActio displayInfo.width = 4; displayInfo.height = 5; displayInfo.dpi = -1; - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager.displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); bool ret = handler.CheckTwoFingerGestureAction(); EXPECT_FALSE(ret); } @@ -4166,12 +4156,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_CheckTwoFingerGestureActio displayInfo.width = 40; displayInfo.height = 50; displayInfo.dpi = -1; - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager.displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); bool ret = handler.CheckTwoFingerGestureAction(); EXPECT_FALSE(ret); } @@ -4203,12 +4191,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_CheckTwoFingerGestureActio displayInfo.width = 40; displayInfo.height = 50; displayInfo.dpi = -1; - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager.displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); bool ret = handler.CheckTwoFingerGestureAction(); EXPECT_FALSE(ret); } @@ -5617,13 +5603,11 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_HandleKnuckleGestureDownEv windowInfo.id = 0; windowInfo.windowType = WINDOW_INPUT_METHOD_TYPE; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.windowsInfo.push_back(windowInfo); + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.windowsInfo.push_back(windowInfo); - displayGroupInfoRef.displaysInfo.push_back(displayInfo); IInputWindowsManager::instance_ = inputWindowsManager; ASSERT_NO_FATAL_FAILURE(handler.HandleKnuckleGestureDownEvent(touchEvent)); @@ -5658,12 +5642,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_CheckTwoFingerGestureActio displayInfo.height = 2720; displayInfo.uniq = "default0"; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); IInputWindowsManager::instance_ = inputWindowsManager; handler.twoFingerGesture_.touches[0].x = 600; handler.twoFingerGesture_.touches[0].y = 600; @@ -5724,12 +5706,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_ConvertVPToPX_006, TestSiz displayInfo.dpi = -1; displayInfo.uniq = "default0"; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); IInputWindowsManager::instance_ = inputWindowsManager; KeyCommandHandler handler; int32_t ret = handler.ConvertVPToPX(vp); @@ -5765,13 +5745,11 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_CheckKnuckleCondition_001, windowInfo.id = 0; windowInfo.windowType = WINDOW_INPUT_METHOD_TYPE; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.windowsInfo.push_back(windowInfo); + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.windowsInfo.push_back(windowInfo); - displayGroupInfoRef.displaysInfo.push_back(displayInfo); IInputWindowsManager::instance_ = inputWindowsManager; touchEvent->SetTargetDisplayId(1); @@ -5825,13 +5803,11 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_CheckKnuckleCondition_002, windowInfo.id = 0; windowInfo.windowType = WINDOW_INPUT_METHOD_TYPE; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.windowsInfo.push_back(windowInfo); + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.windowsInfo.push_back(windowInfo); - displayGroupInfoRef.displaysInfo.push_back(displayInfo); IInputWindowsManager::instance_ = inputWindowsManager; touchEvent->SetTargetDisplayId(0); @@ -5872,12 +5848,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_HandleKnuckleGestureTouchM displayInfo.id = 0; displayInfo.direction = DIRECTION0; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); IInputWindowsManager::instance_ = inputWindowsManager; KeyCommandHandler handler; @@ -5923,12 +5897,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_HandleKnuckleGestureTouchM displayInfo.id = 0; displayInfo.direction = DIRECTION0; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); IInputWindowsManager::instance_ = inputWindowsManager; KeyCommandHandler handler; @@ -5974,12 +5946,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_HandleKnuckleGestureTouchM displayInfo.id = 0; displayInfo.direction = DIRECTION0; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); IInputWindowsManager::instance_ = inputWindowsManager; KeyCommandHandler handler; @@ -6022,12 +5992,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_HandleKnuckleGestureTouchM displayInfo.id = 0; displayInfo.direction = DIRECTION0; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); IInputWindowsManager::instance_ = inputWindowsManager; KeyCommandHandler handler; @@ -6073,12 +6041,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_HandleKnuckleGestureTouchM displayInfo.id = 0; displayInfo.direction = DIRECTION0; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); IInputWindowsManager::instance_ = inputWindowsManager; KeyCommandHandler handler; @@ -6123,12 +6089,10 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_HandleKnuckleGestureTouchM displayInfo.id = 0; displayInfo.direction = DIRECTION0; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.displaysInfo.push_back(displayInfo); } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); IInputWindowsManager::instance_ = inputWindowsManager; KeyCommandHandler handler; @@ -6315,13 +6279,11 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_CheckSpecialRepeatKey_001, auto inputWindowsManager = std::make_shared(); WindowInfo windowInfo; windowInfo.id = 0; - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.windowsInfo.push_back(windowInfo); + it->second.focusWindowId = 0; } - displayGroupInfoRef.windowsInfo.push_back(windowInfo); - displayGroupInfoRef.focusWindowId = 0; UDSServer udsServer; udsServer.idxPidMap_.insert(std::make_pair(0, 1)); SessionPtr sessionPtr = std::make_shared(repeatKey.ability.bundleName, @@ -6358,13 +6320,11 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_CheckSpecialRepeatKey_002, auto inputWindowsManager = std::make_shared(); WindowInfo windowInfo; windowInfo.id = 0; - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.windowsInfo.push_back(windowInfo); + it->second.focusWindowId = 0; } - displayGroupInfoRef.windowsInfo.push_back(windowInfo); - displayGroupInfoRef.focusWindowId = 0; UDSServer udsServer; udsServer.idxPidMap_.insert(std::make_pair(0, 1)); SessionPtr sessionPtr = std::make_shared(repeatKey.ability.bundleName, @@ -6401,13 +6361,11 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_CheckSpecialRepeatKey_003, auto inputWindowsManager = std::make_shared(); WindowInfo windowInfo; windowInfo.id = 0; - DisplayGroupInfo displayGroupInfoRef; auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; + it->second.windowsInfo.push_back(windowInfo); + it->second.focusWindowId = 0; } - displayGroupInfoRef.windowsInfo.push_back(windowInfo); - displayGroupInfoRef.focusWindowId = 0; UDSServer udsServer; udsServer.idxPidMap_.insert(std::make_pair(0, 1)); SessionPtr sessionPtr = std::make_shared(repeatKey.ability.bundleName, @@ -6780,5 +6738,316 @@ HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_HasScreenCapturePermission EXPECT_EQ(handler.HasScreenCapturePermission(SHORTCUT_KEY_SCREEN_RECORDING), 1); EXPECT_EQ(handler.HasScreenCapturePermission(DEFAULT_PERMISSIONS), 1); } + +/** + * @tc.name: KeyCommandHandlerTest_RegisterProximitySensor + * @tc.desc: Test if (bundleName.find(matchName) == std::string::npos) + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_RegisterProximitySensor, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + std::shared_ptr keyEvent = KeyEvent::Create(); + ASSERT_NE(keyEvent, nullptr); + keyEvent->SetKeyCode(KeyEvent::KEYCODE_VOLUME_DOWN); + + RepeatKey repeatKey; + repeatKey.keyCode = KeyEvent::KEYCODE_VOLUME_DOWN; + repeatKey.ability.bundleName = ".camera"; + + auto inputWindowsManager = std::make_shared(); + WindowInfo windowInfo; + windowInfo.id = 0; + auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); + if (it != inputWindowsManager->displayGroupInfoMap_.end()) { + it->second.windowsInfo.push_back(windowInfo); + it->second.focusWindowId = 0; + } + UDSServer udsServer; + udsServer.idxPidMap_.insert(std::make_pair(0, 1)); + SessionPtr sessionPtr = std::make_shared(repeatKey.ability.bundleName, + MODULE_TYPE, UDS_FD, UDS_UID, UDS_PID); + udsServer.sessionsMap_[1] = sessionPtr; + inputWindowsManager->udsServer_ = &udsServer; + EXPECT_NE(inputWindowsManager->udsServer_, nullptr); + IInputWindowsManager::instance_ = inputWindowsManager; + ASSERT_NO_FATAL_FAILURE(handler.RegisterProximitySensor()); + handler.hasRegisteredSensor_ = true; + ASSERT_NO_FATAL_FAILURE(handler.RegisterProximitySensor()); +} + +/** + * @tc.name: KeyCommandHandlerTest_HandleKeyEvent_020 + * @tc.desc: Test HandleKeyEvent + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_HandleKeyEvent_020, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + std::shared_ptr keyEvent = nullptr; + ASSERT_NO_FATAL_FAILURE(handler.HandleKeyEvent(keyEvent)); +} + +/** + * @tc.name: KeyCommandHandlerTest_HandleKeyEvent_030 + * @tc.desc: Test ParseRepeatKeyMaxCount + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_HandleKeyEvent_030, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + ASSERT_NO_FATAL_FAILURE(handler.ParseRepeatKeyMaxCount()); +} + +/** + * @tc.name: KeyCommandHandlerTest_HandleKeyEvent_031 + * @tc.desc: Test UnregisterProximitySensor + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_HandleKeyEvent_031, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + handler.hasRegisteredSensor_ = true; + ASSERT_NO_FATAL_FAILURE(handler.UnregisterProximitySensor()); + handler.hasRegisteredSensor_ = false; + ASSERT_NO_FATAL_FAILURE(handler.UnregisterProximitySensor()); +} + +/** + * @tc.name: KeyCommandHandlerTest_HandleKeyEvent_032 + * @tc.desc: Test RegisterProximitySensor + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_HandleKeyEvent_032, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + handler.hasRegisteredSensor_ = true; + ASSERT_NO_FATAL_FAILURE(handler.RegisterProximitySensor()); + handler.hasRegisteredSensor_ = false; + ASSERT_NO_FATAL_FAILURE(handler.RegisterProximitySensor()); +} + +/** + * @tc.name: KeyCommandHandlerTest_HandleKeyEvent_033 + * @tc.desc: Test SendSaveEvent + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_HandleKeyEvent_033, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + std::shared_ptr keyEvent = KeyEvent::Create(); + ASSERT_NE(keyEvent, nullptr); + handler.isParseConfig_ = false; + ASSERT_NO_FATAL_FAILURE(handler.SendSaveEvent(keyEvent)); +} + +/** + * @tc.name: KeyCommandHandlerTest_HandleKeyEvent_034 + * @tc.desc: Test MenuClickProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_HandleKeyEvent_034, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + std::shared_ptr keyEvent = KeyEvent::Create(); + DisplayEventMonitor displayEventMonitor; + std::string bundleName = ""; + std::string abilityName = ""; + std::string action = ""; + displayEventMonitor.screenStatus_ = "usual.event.SCREEN_OFF"; + displayEventMonitor.isScreenLocked_ = false; + ASSERT_NO_FATAL_FAILURE(handler.MenuClickProcess(bundleName, abilityName, action)); + displayEventMonitor.screenStatus_ = "usual"; + displayEventMonitor.isScreenLocked_ = true; + ASSERT_NO_FATAL_FAILURE(handler.MenuClickProcess(bundleName, abilityName, action)); +} + +/** + * @tc.name: KeyCommandHandlerTest_RegisterProximitySensor_001 + * @tc.desc: Test MenuClickProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_RegisterProximitySensor_001, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + handler.hasRegisteredSensor_ = true; + handler.RegisterProximitySensor(); + EXPECT_EQ(handler.hasRegisteredSensor_, true); +} + +/** + * @tc.name: KeyCommandHandlerTest_RegisterProximitySensor_002 + * @tc.desc: Test MenuClickProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_RegisterProximitySensor_002, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + handler.hasRegisteredSensor_ = false; + handler.RegisterProximitySensor(); + EXPECT_EQ(handler.hasRegisteredSensor_, false); +} + +/** + * @tc.name: KeyCommandHandlerTest_RegisterProximitySensor_001 + * @tc.desc: Test MenuClickProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_UnregisterProximitySensor_001, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + handler.hasRegisteredSensor_ = true; + handler.UnregisterProximitySensor(); + EXPECT_EQ(handler.hasRegisteredSensor_, false); +} + +/** + * @tc.name: KeyCommandHandlerTest_RegisterProximitySensor_002 + * @tc.desc: Test MenuClickProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_UnregisterProximitySensor_002, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + handler.hasRegisteredSensor_ = false; + handler.UnregisterProximitySensor(); + EXPECT_EQ(handler.hasRegisteredSensor_, false); +} + +/** + * @tc.name: KeyCommandHandlerTest_MenuClickHandle_001 + * @tc.desc: Test MenuClickProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_MenuClickHandle_001, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + std::shared_ptr event = KeyEvent::Create(); + event->SetKeyCode(KeyEvent::KEYCODE_MENU); + event->SetKeyAction(KeyEvent::KEY_ACTION_DOWN); + bool ret = handler.MenuClickHandle(event); + EXPECT_EQ(ret, true); + EXPECT_EQ(handler.existMenuDown_, true); +} + +/** + * @tc.name: KeyCommandHandlerTest_MenuClickHandle_002 + * @tc.desc: Test MenuClickProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_MenuClickHandle_002, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + std::shared_ptr event = KeyEvent::Create(); + event->SetKeyCode(KeyEvent::KEYCODE_MENU); + event->SetKeyAction(KeyEvent::KEY_ACTION_DOWN); + bool ret = handler.MenuClickHandle(event); + EXPECT_EQ(ret, true); + EXPECT_EQ(handler.existMenuDown_, true); + + event->SetKeyAction(KeyEvent::KEY_ACTION_UP); + std::this_thread::sleep_for(std::chrono::seconds(1)); + ret = handler.MenuClickHandle(event); + EXPECT_EQ(handler.existMenuDown_, false); + EXPECT_EQ(handler.tmpkeyEvent_, nullptr); + EXPECT_EQ(ret, true); +} + +/** + * @tc.name: KeyCommandHandlerTest_MenuClickHandle_003 + * @tc.desc: Test MenuClickProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_MenuClickHandle_003, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + std::shared_ptr event = KeyEvent::Create(); + event->SetKeyCode(KeyEvent::KEYCODE_MENU); + event->SetKeyAction(KeyEvent::KEY_ACTION_DOWN); + bool ret = handler.MenuClickHandle(event); + EXPECT_EQ(ret, true); + EXPECT_EQ(handler.existMenuDown_, true); + + event->SetKeyAction(KeyEvent::KEY_ACTION_UP); + ret = handler.MenuClickHandle(event); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: KeyCommandHandlerTest_MenuClickHandle_004 + * @tc.desc: Test MenuClickProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_MenuClickHandle_004, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + std::shared_ptr event = KeyEvent::Create(); + event->SetKeyCode(KeyEvent::KEYCODE_MENU); + event->SetKeyAction(KeyEvent::KEY_ACTION_UP); + bool ret = handler.MenuClickHandle(event); + EXPECT_EQ(ret, false); + EXPECT_EQ(handler.existMenuDown_, false); +} + +/** + * @tc.name: KeyCommandHandlerTest_MenuClickHandle_005 + * @tc.desc: Test MenuClickProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeyCommandHandlerTest, KeyCommandHandlerTest_MenuClickHandle_005, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyCommandHandler handler; + std::shared_ptr event = KeyEvent::Create(); + event->SetKeyCode(KeyEvent::KEYCODE_MENU); + event->SetKeyAction(KeyEvent::KEY_ACTION_UP); + bool ret = handler.MenuClickHandle(event); + EXPECT_EQ(ret, false); + EXPECT_EQ(handler.existMenuDown_, false); + + ret = handler.MenuClickHandle(event); + EXPECT_EQ(ret, false); + + handler.existMenuDown_ = true; + event->SetKeyAction(KeyEvent::KEY_ACTION_DOWN); + ret = handler.MenuClickHandle(event); + EXPECT_EQ(ret, false); + + handler.existMenuDown_ = false; + event->SetKeyAction(KeyEvent::KEY_ACTION_UP); + ret = handler.MenuClickHandle(event); + EXPECT_EQ(ret, false); +} } // namespace MMI } // namespace OHOS diff --git a/service/key_command/test/long_press_subscriber_handler_test.cpp b/service/key_command/test/long_press_subscriber_handler_test.cpp index b4510329651d608167604c028b5d164026d79242..9dfc378e44b5bb0a0f32eeb9059b451fbf9e0b07 100644 --- a/service/key_command/test/long_press_subscriber_handler_test.cpp +++ b/service/key_command/test/long_press_subscriber_handler_test.cpp @@ -1044,12 +1044,10 @@ HWTEST_F(LongPressSubscribeHandlerTest, LongPressSubscribeHandlerTest_StartFinge displayInfo.height = 2720; displayInfo.uniq = "default0"; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; - auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); - if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; - } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); + auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); + if (it != inputWindowsManager->displayGroupInfoMap_.end()) { + it->second.displaysInfo.push_back(displayInfo); + } IInputWindowsManager::instance_ = inputWindowsManager; LONG_PRESS_EVENT_HANDLER->fingerGesture_.touches[0].x = 600; LONG_PRESS_EVENT_HANDLER->fingerGesture_.touches[0].y = 600; @@ -1077,18 +1075,16 @@ HWTEST_F(LongPressSubscribeHandlerTest, LongPressSubscribeHandlerTest_CheckFinge displayInfo.height = 2720; displayInfo.uniq = "default0"; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; - auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); - if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; - } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); + auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); + if (it != inputWindowsManager->displayGroupInfoMap_.end()) { + it->second.displaysInfo.push_back(displayInfo); + } IInputWindowsManager::instance_ = inputWindowsManager; LONG_PRESS_EVENT_HANDLER->fingerGesture_.touches[0].x = 600; LONG_PRESS_EVENT_HANDLER->fingerGesture_.touches[0].y = 600; int32_t fingerCount = 1; bool ret = LONG_PRESS_EVENT_HANDLER->CheckFingerGestureAction(fingerCount); - EXPECT_EQ(ret, false); + EXPECT_EQ(ret, true); LONG_PRESS_EVENT_HANDLER->fingerGesture_.touches[0].x = 20; LONG_PRESS_EVENT_HANDLER->fingerGesture_.touches[0].y = 600; @@ -1128,12 +1124,10 @@ HWTEST_F(LongPressSubscribeHandlerTest, LongPressSubscribeHandlerTest_CheckFinge displayInfo.height = 2720; displayInfo.uniq = "default0"; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; - auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); - if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; - } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); + auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); + if (it != inputWindowsManager->displayGroupInfoMap_.end()) { + it->second.displaysInfo.push_back(displayInfo); + } IInputWindowsManager::instance_ = inputWindowsManager; int32_t fingerCount = 2; LONG_PRESS_EVENT_HANDLER->fingerGesture_.touches[0].x = 600; @@ -1142,7 +1136,7 @@ HWTEST_F(LongPressSubscribeHandlerTest, LongPressSubscribeHandlerTest_CheckFinge LONG_PRESS_EVENT_HANDLER->fingerGesture_.touches[1].x = 800; LONG_PRESS_EVENT_HANDLER->fingerGesture_.touches[1].y = 600; bool ret = LONG_PRESS_EVENT_HANDLER->CheckFingerGestureAction(fingerCount); - EXPECT_EQ(ret, false); + EXPECT_EQ(ret, true); LONG_PRESS_EVENT_HANDLER->fingerGesture_.touches[1].x = 10; LONG_PRESS_EVENT_HANDLER->fingerGesture_.touches[1].y = 600; @@ -1181,12 +1175,10 @@ HWTEST_F(LongPressSubscribeHandlerTest, LongPressSubscribeHandlerTest_CheckFinge displayInfo.height = 2720; displayInfo.uniq = "default0"; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; - auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); - if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; - } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); + auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); + if (it != inputWindowsManager->displayGroupInfoMap_.end()) { + it->second.displaysInfo.push_back(displayInfo); + } IInputWindowsManager::instance_ = inputWindowsManager; int32_t fingerCount = 2; LONG_PRESS_EVENT_HANDLER->fingerGesture_.touches[0].x = 600; @@ -1263,12 +1255,10 @@ HWTEST_F(LongPressSubscribeHandlerTest, LongPressSubscribeHandlerTest_ConvertVPT displayInfo.dpi = -1; displayInfo.uniq = "default0"; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; - auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); - if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; - } - displayGroupInfoRef.displaysInfo.push_back(displayInfo); + auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); + if (it != inputWindowsManager->displayGroupInfoMap_.end()) { + it->second.displaysInfo.push_back(displayInfo); + } IInputWindowsManager::instance_ = inputWindowsManager; int32_t ret = LONG_PRESS_EVENT_HANDLER->ConvertVPToPX(vp); ASSERT_EQ(ret, 0); @@ -1383,14 +1373,11 @@ HWTEST_F(LongPressSubscribeHandlerTest, LongPressSubscribeHandlerTest_NotifySubs WindowInfo windowInfo; windowInfo.id = 10000; auto inputWindowsManager = std::make_shared(); - DisplayGroupInfo displayGroupInfoRef; - auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); - if (it != inputWindowsManager->displayGroupInfoMap_.end()) { - displayGroupInfoRef = it->second; - } - displayGroupInfoRef.windowsInfo.push_back(windowInfo); + auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID); + if (it != inputWindowsManager->displayGroupInfoMap_.end()) { + it->second.windowsInfo.push_back(windowInfo); + } IInputWindowsManager::instance_ = inputWindowsManager; - auto pointerEvent = SetupSingleFingerDownEvent(); ASSERT_TRUE(pointerEvent != nullptr); PointerEvent::PointerItem item; diff --git a/service/key_command/test/pull_throw_subscriber_handler_test.cpp b/service/key_command/test/pull_throw_subscriber_handler_test.cpp index 55897c46fc5e6a784f6873d1fa127e3bb6b2199d..5a559df1156c0d3b7f4202a0854ff224d2d228ec 100644 --- a/service/key_command/test/pull_throw_subscriber_handler_test.cpp +++ b/service/key_command/test/pull_throw_subscriber_handler_test.cpp @@ -323,5 +323,309 @@ HWTEST_F(PullThrowSubscriberHandlerTest, CheckThrowAngleValidTest_001, testing:: angle = 500; ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->CheckThrowAngleValid(angle)); } + +/** + * @tc.name: PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0011 + * @tc.desc: Test HandleFingerGesturePullMoveEvent + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(PullThrowSubscriberHandlerTest, PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0011, + testing::ext::TestSize.Level1) +{ + CALL_TEST_DEBUG; + auto touchEvent = SetupSingleFingerDownEvent(); + ASSERT_TRUE(touchEvent != nullptr); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = false; + PULL_THROW_EVENT_HANDLER->alreadyTouchDown_ = true; + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullMoveEvent(touchEvent)); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = true; + PULL_THROW_EVENT_HANDLER->alreadyTouchDown_ = false; + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullMoveEvent(touchEvent)); + touchEvent = SetupDoubleFingerDownEvent(); + ASSERT_TRUE(touchEvent != nullptr); + PULL_THROW_EVENT_HANDLER->StartFingerGesture(); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = false; + PULL_THROW_EVENT_HANDLER->alreadyTouchDown_ = true; + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullMoveEvent(touchEvent)); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = true; + PULL_THROW_EVENT_HANDLER->alreadyTouchDown_ = false; + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullMoveEvent(touchEvent)); +} + +/** + * @tc.name: PullThrowSubscriberHandlerTest_HandleFingerGesturePullUpEvent_0012 + * @tc.desc: Test HandleFingerGesturePullUpEvent + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(PullThrowSubscriberHandlerTest, PullThrowSubscriberHandlerTest_HandleFingerGesturePullUpEvent_0012, + testing::ext::TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = true; + PointerEvent::PointerItem item; + PointerEvent::PointerItem item1; + pointerEvent->pointers_.push_back(item); + pointerEvent->pointers_.push_back(item1); + pointerEvent->SetActionTime(1000); + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullUpEvent(pointerEvent)); + pointerEvent->SetActionTime(0); + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullUpEvent(pointerEvent)); +} + +/** + * @tc.name: PullThrowSubscriberHandlerTest_HandleFingerGesturePullUpEvent_0013 + * @tc.desc: Test HandleFingerGesturePullUpEvent + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(PullThrowSubscriberHandlerTest, PullThrowSubscriberHandlerTest_HandleFingerGesturePullUpEvent_0013, + testing::ext::TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = true; + PointerEvent::PointerItem item; + PointerEvent::PointerItem item1; + pointerEvent->pointers_.push_back(item); + pointerEvent->pointers_.push_back(item1); + pointerEvent->SetActionTime(1000); + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullUpEvent(pointerEvent)); + pointerEvent->SetActionTime(0); + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullUpEvent(pointerEvent)); +} + +/** + * @tc.name: PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0012 + * @tc.desc: Test HandleFingerGesturePullUpEvent + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(PullThrowSubscriberHandlerTest, PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0012, + testing::ext::TestSize.Level1) +{ + CALL_TEST_DEBUG; + auto touchEvent = SetupSingleFingerDownEvent(); + ASSERT_TRUE(touchEvent != nullptr); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = true; + PULL_THROW_EVENT_HANDLER->alreadyTouchDown_ = true; + PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullMoveEvent(touchEvent); + EXPECT_EQ(PULL_THROW_EVENT_HANDLER->alreadyTouchDown_, false); +} + +/** + * @tc.name: PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0013 + * @tc.desc: Test HandleFingerGesturePullUpEvent + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(PullThrowSubscriberHandlerTest, PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0013, + testing::ext::TestSize.Level1) +{ + CALL_TEST_DEBUG; + auto touchEvent = SetupSingleFingerDownEvent(); + ASSERT_TRUE(touchEvent != nullptr); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = true; + PULL_THROW_EVENT_HANDLER->alreadyTouchDown_ = true; + PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullMoveEvent(touchEvent); + EXPECT_EQ(PULL_THROW_EVENT_HANDLER->alreadyTouchDown_, false); + PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullMoveEvent(touchEvent); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = false; + PULL_THROW_EVENT_HANDLER->alreadyTouchDown_ = true; + PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullMoveEvent(touchEvent); + EXPECT_EQ(PULL_THROW_EVENT_HANDLER->alreadyTouchDown_, true); + PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullMoveEvent(touchEvent); +} + +/** + * @tc.name: PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0014 + * @tc.desc: Test HandleFingerGesturePullUpEvent + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(PullThrowSubscriberHandlerTest, PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0014, + testing::ext::TestSize.Level1) +{ + CALL_TEST_DEBUG; + auto touchEvent = SetupSingleFingerDownEvent(); + ASSERT_TRUE(touchEvent != nullptr); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = true; + PULL_THROW_EVENT_HANDLER->alreadyTouchDown_ = true; + PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullMoveEvent(touchEvent); + EXPECT_EQ(PULL_THROW_EVENT_HANDLER->alreadyTouchDown_, false); + + std::this_thread::sleep_for(std::chrono::seconds(1)); + PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullMoveEvent(touchEvent); +} + +/** + * @tc.name: PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0015 + * @tc.desc: Test HandleFingerGesturePullUpEvent + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(PullThrowSubscriberHandlerTest, PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0015, + testing::ext::TestSize.Level1) +{ + CALL_TEST_DEBUG; + auto touchEvent = SetupSingleFingerDownEvent(); + ASSERT_TRUE(touchEvent != nullptr); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = true; + PULL_THROW_EVENT_HANDLER->alreadyTouchDown_ = true; + PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullMoveEvent(touchEvent); + EXPECT_EQ(PULL_THROW_EVENT_HANDLER->alreadyTouchDown_, false); + + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = false; + PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullMoveEvent(touchEvent); + + std::this_thread::sleep_for(std::chrono::seconds(1)); + PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullMoveEvent(touchEvent); +} + +/** + * @tc.name: PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0016 + * @tc.desc: Test HandleFingerGesturePullUpEvent + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(PullThrowSubscriberHandlerTest, PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0016, + testing::ext::TestSize.Level1) +{ + CALL_TEST_DEBUG; + auto touchEvent = SetupSingleFingerDownEvent(); + ASSERT_TRUE(touchEvent != nullptr); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = true; + PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullUpEvent(touchEvent); +} + +/** + * @tc.name: PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0017 + * @tc.desc: Test HandleFingerGesturePullUpEvent + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(PullThrowSubscriberHandlerTest, PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0017, + testing::ext::TestSize.Level1) +{ + CALL_TEST_DEBUG; + auto touchEvent = SetupSingleFingerDownEvent(); + ASSERT_TRUE(touchEvent != nullptr); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = true; + PULL_THROW_EVENT_HANDLER->triggerTime_ = WINDOW_TIME_INTERVAL; + PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullUpEvent(touchEvent); +} + +/** + * @tc.name: PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0018 + * @tc.desc: Test HandleFingerGesturePullUpEvent + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(PullThrowSubscriberHandlerTest, PullThrowSubscriberHandlerTest_HandleFingerGesturePullMoveEvent_0018, + testing::ext::TestSize.Level1) +{ + CALL_TEST_DEBUG; + auto touchEvent = SetupSingleFingerDownEvent(); + ASSERT_TRUE(touchEvent != nullptr); + int32_t pointId = touchEvent->GetPointerId(); + PointerEvent::PointerItem item; + bool ret = touchEvent->GetPointerItem(pointId, item); + EXPECT_EQ(ret, true); + int32_t downY = PullThrowSubscriberHandler::SPIN_UP_AREA_Y + 100; + item.SetDisplayY(downY); + touchEvent->AddPointerItem(item); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = true; + PULL_THROW_EVENT_HANDLER->triggerTime_ = WINDOW_TIME_INTERVAL; + PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullUpEvent(touchEvent); + + ret = touchEvent->GetPointerItem(pointId, item); + EXPECT_EQ(ret, true); + downY = PullThrowSubscriberHandler::SPIN_DOWN_AREA_Y + 100; + item.SetDisplayY(downY); + touchEvent->AddPointerItem(item); + PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullUpEvent(touchEvent); +} + +/** + * @tc.name: PullThrowSubscriberHandlerTest_CheckThrowAngleValid_002 + * @tc.desc: Test HandleFingerGesturePullUpEvent + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(PullThrowSubscriberHandlerTest, PullThrowSubscriberHandlerTest_CheckThrowAngleValid_002, + testing::ext::TestSize.Level1) +{ + CALL_TEST_DEBUG; + double angle = 0; + bool ret = PULL_THROW_EVENT_HANDLER->CheckThrowAngleValid(angle); + EXPECT_EQ(ret, false); + + angle = PullThrowSubscriberHandler::ANGLE_DOWN_MIN; + ret = PULL_THROW_EVENT_HANDLER->CheckThrowAngleValid(angle); + EXPECT_EQ(ret, true); + + angle = PullThrowSubscriberHandler::ANGLE_DOWN_MAX + 10; + ret = PULL_THROW_EVENT_HANDLER->CheckThrowAngleValid(angle); + EXPECT_EQ(ret, false); + + angle = PullThrowSubscriberHandler::ANGLE_UP_MIN; + ret = PULL_THROW_EVENT_HANDLER->CheckThrowAngleValid(angle); + EXPECT_EQ(ret, true); + + angle = PullThrowSubscriberHandler::ANGLE_UP_MAX + 10; + ret = PULL_THROW_EVENT_HANDLER->CheckThrowAngleValid(angle); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: PullThrowSubscriberHandlerTest_HandleFingerGesturePullUpEvent_0014 + * @tc.desc: Test HandleFingerGesturePullUpEvent + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(PullThrowSubscriberHandlerTest, PullThrowSubscriberHandlerTest_HandleFingerGesturePullUpEvent_0014, + testing::ext::TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + PULL_THROW_EVENT_HANDLER->gestureInProgress_ = true; + PointerEvent::PointerItem item; + PointerEvent::PointerItem item1; + pointerEvent->pointers_.push_back(item); + pointerEvent->pointers_.push_back(item1); + pointerEvent->SetActionTime(1000); + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullUpEvent(pointerEvent)); + pointerEvent->SetActionTime(0); + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->HandleFingerGesturePullUpEvent(pointerEvent)); +} + +/** + * @tc.name: PullThrowSubscriberHandlerTest_HandleFingerGesturePullUpEvent_0015 + * @tc.desc: Test CheckThrowAngleValid + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(PullThrowSubscriberHandlerTest, PullThrowSubscriberHandlerTest_HandleFingerGesturePullUpEvent_0015, + testing::ext::TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + double angle = -300.0; + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->CheckThrowAngleValid(angle)); + angle = -200.0; + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->CheckThrowAngleValid(angle)); + angle = -50.0; + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->CheckThrowAngleValid(angle)); + angle = 0; + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->CheckThrowAngleValid(angle)); + double angle2{1e-1}; + ASSERT_NO_FATAL_FAILURE(PULL_THROW_EVENT_HANDLER->CheckThrowAngleValid(angle2)); +} } // namespace MMI } // namespace OHOS \ No newline at end of file diff --git a/service/key_command/test/setting_datashare_test.cpp b/service/key_command/test/setting_datashare_test.cpp index d7ad29d0b7da6c05419ef2d70c4dd8e5c740280e..3f54c135f9d99d478ea6fe792094a804a9af629d 100644 --- a/service/key_command/test/setting_datashare_test.cpp +++ b/service/key_command/test/setting_datashare_test.cpp @@ -278,5 +278,20 @@ HWTEST_F(SettingObserverTest, CheckIfSettingsDataReadyTest1, TestSize.Level1) settingDataShare.remoteObj_ = nullptr; ASSERT_NO_FATAL_FAILURE(settingDataShare.CheckIfSettingsDataReady()); } + +/** + * @tc.name: CheckIfSettingsUnregisterObserver20 + * @tc.desc: Test CheckIfSettingsDataReady + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(SettingObserverTest, CheckIfSettingsUnregisterObserver20, TestSize.Level1) +{ + CALL_DEBUG_ENTER; + SettingDataShare settingDataShare; + settingDataShare.isDataShareReady_ = false; + settingDataShare.remoteObj_ = nullptr; + ASSERT_NO_FATAL_FAILURE(settingDataShare.CheckIfSettingsDataReady()); +} } // namespace MMI } // namespace OHOS \ No newline at end of file diff --git a/service/libinput_adapter/include/libinput_adapter.h b/service/libinput_adapter/include/libinput_adapter.h index 46e668bd6c13d37862f8aa0fbc0c7366075e1774..fe45cbc94c5ae8ea85279862a18718d03026ca52 100644 --- a/service/libinput_adapter/include/libinput_adapter.h +++ b/service/libinput_adapter/include/libinput_adapter.h @@ -29,15 +29,14 @@ typedef std::function HandleTouchPoint; -typedef std::function GetMessage; -typedef std::function>& retMsgList)> GetAllTouchMessage; -typedef std::function ClearTouchMessage; -typedef std::function>& retMsgList)> GetAllKeyMessage; -typedef std::function ClearKeyMessage; typedef std::function HardwareKeyEventDetected; typedef std::function GetKeyboardActivationState; typedef std::function IsFloatingKeyboard; typedef std::function IsVKeyboardShown; +typedef std::function& events)> GetLibinputEventForVKeyboard; +typedef std::function& events)> GetLibinputEventForVTrackpad; #ifdef OHOS_BUILD_ENABLE_VKEYBOARD enum VTPSwipeStateType { @@ -53,6 +52,21 @@ enum VKeyboardMessageType { VStopLongPressControl = 17, VSwitchLayout = 18, }; +enum VKeyboardEventType { + NoKeyboardEvent = -1, + NormalKeyboardEvent = 0, + HideCursor = 1, + UpdateCaps = 2, + StopLongpress = 3 +}; + +enum VTrackpadEventType { + NoTrackpadEvent = -1, + NormalTrackpadEvent = 0, + PinchBegin = 1, + PinchUpdate = 2, + PinchEnd = 3 +}; enum class VTPStateMachineMessageType : int32_t { UNKNOWN = 0, POINTER_MOVE = 1, @@ -114,15 +128,12 @@ public: } void InitVKeyboard(HandleTouchPoint handleTouchPoint, - GetMessage getMessage, - GetAllTouchMessage getAllTouchMessage, - ClearTouchMessage clearTouchMessage, - GetAllKeyMessage getAllKeyMessage, - ClearKeyMessage clearKeyMessage, HardwareKeyEventDetected hardwareKeyEventDetected, GetKeyboardActivationState getKeyboardActivationState, IsFloatingKeyboard isFloatingKeyboard, - IsVKeyboardShown isVKeyboardShown + IsVKeyboardShown isVKeyboardShown, + GetLibinputEventForVKeyboard getLibinputEventForVKeyboard, + GetLibinputEventForVTrackpad getLibinputEventForVTrackpad ); private: @@ -136,94 +147,30 @@ private: #ifdef OHOS_BUILD_ENABLE_VKEYBOARD void HandleVFullKeyboardMessages( libinput_event *event, int64_t frameTime, libinput_event_type eventType, libinput_event_touch *touch); + void HandleVKeyboardMessage(VKeyboardEventType eventType, std::vector keyEvents, + int64_t frameTime); + void HandleVTrackpadMessage(VTrackpadEventType eventType, std::vector events, + int64_t frameTime, libinput_event_touch *touch); bool IsVKeyboardActivationDropEvent(libinput_event_touch* touch, libinput_event_type eventType); - void HandleVKeyTouchpadMessages(libinput_event_touch* touch); - void OnVKeyTrackPadMessage(libinput_event_touch* touch, - const std::vector>& msgList); - void CheckSwipeState(libinput_event_touch* touch, - VTPStateMachineMessageType msgType, const std::vector& msgItem); - void OnVKeyTrackPadGestureMessage(libinput_event_touch* touch, - VTPStateMachineMessageType msgType, const std::vector& msgItem); - void OnVKeyTrackPadGestureTwoMessage(libinput_event_touch* touch, - VTPStateMachineMessageType msgType, const std::vector& msgItem); - void OnVKeyTrackPadGestureThreeMessage(libinput_event_touch* touch, - VTPStateMachineMessageType msgType, const std::vector& msgItem); - bool HandleVKeyTrackPadPointerMove(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadLeftBtnDown(libinput_event_touch* touch, - const std::vector& msgItem); - void HandleVKeyTrackPadTouchPadDown(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadLeftBtnUp(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadTouchPadUp(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadRightBtnDown(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadRightBtnUp(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadTwoFingerTap(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadScrollBegin(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadScrollUpdate(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadScrollEnd(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadPinchBegin(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadPinchUpdate(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadPinchEnd(libinput_event_touch* touch, - const std::vector& msgItem); void InjectEventForTwoFingerOnTouchpad(libinput_event_touch* touch, libinput_event_type eventType, int64_t frameTime); void InjectEventForCastWindow(libinput_event_touch* touch); bool IsCursorInCastWindow(); - bool HandleVKeyTrackPadPanBegin(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadPanUpdate(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadPanEnd(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadSwipeBegin(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadSwipeUpdate(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadSwipeEnd(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadRotateBegin(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadRotateUpdate(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadSwipeFourEnd(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadRotateFourBegin(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadRotateFourUpdate(libinput_event_touch* touch, - const std::vector& msgItem); - bool HandleVKeyTrackPadRotateEnd(libinput_event_touch* touch, - const std::vector& msgItem); - void update_pointer_move(VTPStateMachineMessageType msgType); int32_t ConvertToTouchEventType(libinput_event_type eventType); - void PrintVKeyTPPointerLog(event_pointer &pEvent); - void PrintVKeyTPGestureLog(event_gesture &gEvent); void HandleHWKeyEventForVKeyboard(libinput_event* event); - void HandleVKeyTrackPadSingleTap(libinput_event_touch* touch, - const std::vector& msgItem, - libinput_event* event, bool& delayvtpDestroy); void ShowMouseCursor(); void HideMouseCursorTemporary(); double GetAccumulatedPressure(int touchId, int32_t eventType, double touchPressure); bool SkipTouchMove(int touchId, int32_t eventType); // compress touch move events in consecutive two frame void DelayInjectKeyEventCallback(); - bool CreateVKeyboardDelayTimer(libinput_event *event, int32_t delayMs, int32_t keyCode); + bool CreateVKeyboardDelayTimer(libinput_event *event, int32_t delayMs, libinput_event *keyEvent); void StartVKeyboardDelayTimer(int32_t delayMs); bool GetIsCaptureMode(); void UpdateBootFlag(); VTPSwipeStateType vtpSwipeState_ = VTPSwipeStateType::SWIPE_END; libinput_event *vkbDelayedEvent_ = nullptr; + libinput_event *vkbDelayedKeyEvent_ = nullptr; int32_t vkbDelayedKeyCode_ = 0; std::chrono::system_clock::time_point vtpSingleTapDownTime; const double vtpSingleTapThreshold = 0.18; // s @@ -236,15 +183,12 @@ private: FunInputEvent funInputEvent_; HandleTouchPoint handleTouchPoint_ { nullptr }; - GetMessage getMessage_ { nullptr }; - GetAllTouchMessage getAllTouchMessage_ { nullptr }; - ClearTouchMessage clearTouchMessage_ { nullptr }; - GetAllKeyMessage getAllKeyMessage_ { nullptr }; - ClearKeyMessage clearKeyMessage_ { nullptr }; HardwareKeyEventDetected hardwareKeyEventDetected_ { nullptr }; GetKeyboardActivationState getKeyboardActivationState_ { nullptr }; IsFloatingKeyboard isFloatingKeyboard_ { nullptr }; IsVKeyboardShown isVKeyboardShown_ { nullptr }; + GetLibinputEventForVKeyboard getLibinputEventForVKeyboard_ { nullptr }; + GetLibinputEventForVTrackpad getLibinputEventForVTrackpad_ { nullptr }; int32_t deviceId; std::unordered_map> touchPoints_; static std::unordered_map keyCodes_; diff --git a/service/libinput_adapter/src/libinput_adapter.cpp b/service/libinput_adapter/src/libinput_adapter.cpp index 190e90e50cca89ab82d1daebc9737ad33a397b1e..79298b0662fe093224d4eeb081ba58b9345108c3 100644 --- a/service/libinput_adapter/src/libinput_adapter.cpp +++ b/service/libinput_adapter/src/libinput_adapter.cpp @@ -47,24 +47,6 @@ constexpr int32_t MIN_RIGHT_BTN_AREA_PERCENT { 0 }; constexpr int32_t MAX_RIGHT_BTN_AREA_PERCENT { 100 }; constexpr int32_t INVALID_RIGHT_BTN_AREA { -1 }; #ifdef OHOS_BUILD_ENABLE_VKEYBOARD -constexpr int32_t VKEY_TP_SM_MSG_SIZE { 6 }; -constexpr int32_t VKEY_TP_SM_MSG_TYPE_IDX { 0 }; -constexpr int32_t VKEY_TP_SM_MSG_POINTER_ID_IDX { 1 }; -constexpr int32_t VKEY_TP_SM_MSG_POS_X_IDX { 2 }; -constexpr int32_t VKEY_TP_SM_MSG_POS_Y_IDX { 3 }; -constexpr int32_t VKEY_TP_SM_MSG_SCALE_IDX { 4 }; -constexpr int32_t VKEY_TP_SM_MSG_ANGLE_IDX { 5 }; -constexpr int32_t VKEY_TP_GSE_TWO_FINGERS { 2 }; -constexpr int32_t VKEY_TP_GSE_THREE_FINGERS { 3 }; -constexpr int32_t VKEY_TP_GSE_FOUR_FINGERS { 4 }; -constexpr uint32_t VKEY_TP_LB_ID { 272 }; -constexpr uint32_t VKEY_TP_RB_ID { 273 }; -constexpr uint32_t VKEY_TP_SEAT_BTN_COUNT_NONE { 0 }; -constexpr uint32_t VKEY_TP_SEAT_BTN_COUNT_ONE { 1 }; -constexpr uint32_t VKEY_TP_AXES_ZERO { 0 }; -constexpr uint32_t VKEY_TP_AXES_ONE { 1 }; -constexpr uint32_t VKEY_TP_AXES_TWO { 2 }; -constexpr double VTP_SCALE_AND_ANGLE_FACTOR { 1000.0 }; constexpr uint32_t KEY_CAPSLOCK { 58 }; constexpr uint32_t LIBINPUT_KEY_VOLUME_DOWN { 114 }; constexpr uint32_t LIBINPUT_KEY_VOLUME_UP { 115 }; @@ -290,26 +272,20 @@ void LibinputAdapter::ProcessPendingEvents() } void LibinputAdapter::InitVKeyboard(HandleTouchPoint handleTouchPoint, - GetMessage getMessage, - GetAllTouchMessage getAllTouchMessage, - ClearTouchMessage clearTouchMessage, - GetAllKeyMessage getAllKeyMessage, - ClearKeyMessage clearKeyMessage, HardwareKeyEventDetected hardwareKeyEventDetected, GetKeyboardActivationState getKeyboardActivationState, IsFloatingKeyboard isFloatingKeyboard, - IsVKeyboardShown isVKeyboardShown) + IsVKeyboardShown isVKeyboardShown, + GetLibinputEventForVKeyboard getLibinputEventForVKeyboard, + GetLibinputEventForVTrackpad getLibinputEventForVTrackpad) { handleTouchPoint_ = handleTouchPoint; - getMessage_ = getMessage; - getAllTouchMessage_ = getAllTouchMessage; - clearTouchMessage_ = clearTouchMessage; - getAllKeyMessage_ = getAllKeyMessage; - clearKeyMessage_ = clearKeyMessage; hardwareKeyEventDetected_ = hardwareKeyEventDetected; getKeyboardActivationState_ = getKeyboardActivationState; isFloatingKeyboard_ = isFloatingKeyboard; isVKeyboardShown_ = isVKeyboardShown; + getLibinputEventForVKeyboard_ = getLibinputEventForVKeyboard; + getLibinputEventForVTrackpad_ = getLibinputEventForVTrackpad; // init touch device Id. deviceId = -1; @@ -322,28 +298,25 @@ void LibinputAdapter::DelayInjectKeyEventCallback() CHKPV(vkbDelayedEvent_); libinput_event_touch *touch = libinput_event_get_touch_event(vkbDelayedEvent_); CHKPV(touch); - libinput_event_keyboard *key_event_pressed = libinput_create_keyboard_event( - touch, vkbDelayedKeyCode_, libinput_key_state::LIBINPUT_KEY_STATE_RELEASED); CHKPV(funInputEvent_); int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event *)key_event_pressed, frameTime); - free(key_event_pressed); + funInputEvent_(vkbDelayedKeyEvent_, frameTime); + free(vkbDelayedKeyEvent_); libinput_event_destroy(vkbDelayedEvent_); vkbDelayedEvent_ = nullptr; } // return true if timer has started successfully. -bool LibinputAdapter::CreateVKeyboardDelayTimer(libinput_event *event, int32_t delayMs, int32_t keyCode) +bool LibinputAdapter::CreateVKeyboardDelayTimer(libinput_event *event, int32_t delayMs, libinput_event *keyEvent) { if (vkbDelayedEvent_ != nullptr) { - MMI_HILOGI("A delayed event is pending, skip delay msg for KC=%{private}d, Delay=%{public}d", - keyCode, delayMs); + MMI_HILOGI("A delayed event is pending, skip delay msg, Delay=%{public}d", delayMs); return false; } vkbDelayedEvent_ = event; - vkbDelayedKeyCode_ = keyCode; - MMI_HILOGI("Create the delayed event for KC=%{private}d, Delay=%{public}d", keyCode, delayMs); + vkbDelayedKeyEvent_ = keyEvent; + MMI_HILOGD("Create the delayed event Delay=%{public}d", delayMs); return true; } @@ -370,32 +343,6 @@ bool LibinputAdapter::GetIsCaptureMode() } #endif // OHOS_BUILD_ENABLE_VKEYBOARD -void LibinputAdapter::InjectKeyEvent(libinput_event_touch* touch, int32_t keyCode, - libinput_key_state state, int64_t frameTime) -{ -#ifdef OHOS_BUILD_ENABLE_VKEYBOARD - // Note: during caps lock down, the vkeyboardData.capsLock inside libinput is toggled. - libinput_event_keyboard* key_event_pressed = - libinput_create_keyboard_event(touch, keyCode, state); - - if (keyCode == KEY_CAPSLOCK && state == libinput_key_state::LIBINPUT_KEY_STATE_PRESSED) { - std::shared_ptr keyEvent = KeyEventHdr->GetKeyEvent(); - if (keyEvent != nullptr) { - bool isCapsLockOn = keyEvent->GetFunctionKey(MMI::KeyEvent::CAPS_LOCK_FUNCTION_KEY); - keyEvent->SetFunctionKey(MMI::KeyEvent::CAPS_LOCK_FUNCTION_KEY, !isCapsLockOn); - - struct libinput_device* device = INPUT_DEV_MGR->GetKeyboardDevice(); - if (device != nullptr) { - DeviceLedUpdate(device, KeyEvent::CAPS_LOCK_FUNCTION_KEY, !isCapsLockOn); - } - } - } - - funInputEvent_((libinput_event*)key_event_pressed, frameTime); - free(key_event_pressed); -#endif // OHOS_BUILD_ENABLE_VKEYBOARD -} - #ifdef OHOS_BUILD_ENABLE_VKEYBOARD void LibinputAdapter::HandleVFullKeyboardMessages( libinput_event *event, int64_t frameTime, libinput_event_type eventType, libinput_event_touch *touch) @@ -403,55 +350,43 @@ void LibinputAdapter::HandleVFullKeyboardMessages( // delay the event destroy. bool delayDestroy = false; int32_t confirmedDelayMs(0); + + if (getLibinputEventForVKeyboard_ == nullptr || getLibinputEventForVTrackpad_ == nullptr) { + return; + } - // handle keyboard and trackpad messages. + // handle keyboard messages. while (true) { int32_t delayMs(0); - int32_t toggleCodeSecond(0); - int32_t keyCode(0); - VKeyboardMessageType type = (VKeyboardMessageType)getMessage_(delayMs, toggleCodeSecond, keyCode); - MMI_HILOGD("Get message type:%{private}d", static_cast(type)); - if (type == VNoMessage) { + std::vector keyEvents; + VKeyboardEventType eventType = (VKeyboardEventType)getLibinputEventForVKeyboard_(touch, delayMs, keyEvents); + if (eventType == VKeyboardEventType::NoKeyboardEvent || keyEvents.size() == 0) { break; } - // if need to delay, not injecting but store them. Limit to up event. - if (delayMs > 0 && type == VKeyboardMessageType::VStopLongPressControl && !delayDestroy) { + // if need to delay, not injecting but store them. Limit to up event. + if (delayMs > 0 && eventType == VKeyboardEventType::StopLongpress && !delayDestroy) { // start delaying. - delayDestroy = CreateVKeyboardDelayTimer(event, delayMs, keyCode); + delayDestroy = CreateVKeyboardDelayTimer(event, delayMs, *keyEvents.begin()); if (delayDestroy) { // create and delay this event. confirmedDelayMs = delayMs; continue; } } - // otherwise, do regular processing in real-time. - switch (type) { - case VKeyboardMessageType::VKeyPressed: { - MMI_HILOGD("press key:%{private}d", keyCode); - InjectKeyEvent(touch, keyCode, libinput_key_state::LIBINPUT_KEY_STATE_PRESSED, frameTime); - InjectKeyEvent(touch, keyCode, libinput_key_state::LIBINPUT_KEY_STATE_RELEASED, frameTime); - break; - } - case VKeyboardMessageType::VStartLongPressControl: { - MMI_HILOGD("long press start:%{private}d", keyCode); - InjectKeyEvent(touch, keyCode, libinput_key_state::LIBINPUT_KEY_STATE_PRESSED, frameTime); - break; - } - case VKeyboardMessageType::VStopLongPressControl: { - MMI_HILOGD("long press stop:%{private}d", keyCode); - InjectKeyEvent(touch, keyCode, libinput_key_state::LIBINPUT_KEY_STATE_RELEASED, frameTime); - break; - } - case VKeyboardMessageType::VSwitchLayout: { - HideMouseCursorTemporary(); - break; - } - default: - break; + HandleVKeyboardMessage(eventType, keyEvents, frameTime); + } + + // handle trackpad messages. + while (true) { + std::vector events; + VTrackpadEventType eventType = (VTrackpadEventType)getLibinputEventForVTrackpad_(touch, events); + if (eventType == VTrackpadEventType::NoTrackpadEvent) { + break; } + + HandleVTrackpadMessage(eventType, events, frameTime, touch); } - HandleVKeyTouchpadMessages(touch); if (eventType == LIBINPUT_EVENT_TOUCH_FRAME) { // still let frame info go through. @@ -464,879 +399,69 @@ void LibinputAdapter::HandleVFullKeyboardMessages( } } -void LibinputAdapter::HandleVKeyTouchpadMessages(libinput_event_touch* touch) -{ - // Handle all track pad key messages - std::vector> keyMsgList; - if (getAllKeyMessage_ != nullptr) { - getAllKeyMessage_(keyMsgList); - } - if (clearKeyMessage_ != nullptr) { - clearKeyMessage_(); - } - if (!keyMsgList.empty()) { - ShowMouseCursor(); - } - OnVKeyTrackPadMessage(touch, keyMsgList); - // Handle all track pad touch messages - std::vector> touchMsgList; - if (getAllTouchMessage_ != nullptr) { - getAllTouchMessage_(touchMsgList); - } - if (clearTouchMessage_ != nullptr) { - clearTouchMessage_(); - } - if (!touchMsgList.empty()) { - ShowMouseCursor(); - } - OnVKeyTrackPadMessage(touch, touchMsgList); -} - -void LibinputAdapter::HandleVKeyTrackPadTouchPadDown(libinput_event_touch *touch, const std::vector &msgItem) -{ - MMI_HILOGD("Virtual TrackPad state machine message: LEFT_TOUCH_DOWN"); - vtpSingleTapDownTime = std::chrono::system_clock::now(); - if (vtpTimerId_ != EXPIRED_TIMER_ID && vtpState_ == VKeyboardStatusType::SINGLE_TAP) { - MMI_HILOGI("Virtual TrackPad state %{public}d, Cancel the previous release", vtpState_); - // Cancel the previous release - TimerMgr->RemoveTimer(vtpTimerId_); - SafeDestroyVTrackPadDelayedEvent(); - vtpState_ = VKeyboardStatusType::DOUBLE_TAP; - } else if (vtpTimerId_ != EXPIRED_TIMER_ID && vtpState_ == VKeyboardStatusType::DOUBLE_TAP) { - MMI_HILOGI("Virtual TrackPad state %{public}d, Cancel the double tap release", vtpState_); - // Cancel the previous release - TimerMgr->RemoveTimer(vtpTimerId_); - SafeDestroyVTrackPadDelayedEvent(); - } -} - -void LibinputAdapter::update_pointer_move(auto msgType) -{ - if (msgType != VTPStateMachineMessageType::POINTER_MOVE) { - pointer_move_count = 0; - } -} - -void LibinputAdapter::CheckSwipeState(libinput_event_touch* touch, - VTPStateMachineMessageType msgType, const std::vector& msgItem) -{ - if (vtpSwipeState_ == VTPSwipeStateType::SWIPE_BEGIN && - msgType != VTPStateMachineMessageType::SWIPE_UPDATE && - msgType != VTPStateMachineMessageType::SWIPE_END) { - HandleVKeyTrackPadSwipeEnd(touch, msgItem); - } - update_pointer_move(msgType); -} - -void LibinputAdapter::OnVKeyTrackPadMessage(libinput_event_touch* touch, - const std::vector>& msgList) -{ - for (auto msgItem : msgList) { - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - continue; - } - auto msgType = static_cast(msgItem[VKEY_TP_SM_MSG_TYPE_IDX]); - CheckSwipeState(touch, msgType, msgItem); - switch (msgType) { - case VTPStateMachineMessageType::POINTER_MOVE: - if (!HandleVKeyTrackPadPointerMove(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad pointer move event cannot be handled"); - } - break; - case VTPStateMachineMessageType::LEFT_CLICK_DOWN: - if (!HandleVKeyTrackPadLeftBtnDown(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad left button down event cannot be handled"); - } - break; - case VTPStateMachineMessageType::LEFT_TOUCH_DOWN: - if (!HandleVKeyTrackPadTouchPadDown(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad Touchpad down event cannot be handled"); - } - break; - case VTPStateMachineMessageType::LEFT_CLICK_UP: - if (!HandleVKeyTrackPadLeftBtnUp(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad left button up event cannot be handled"); - } - break; - case VTPStateMachineMessageType::LEFT_TOUCH_UP: - if (!HandleVKeyTrackPadTouchPadUp(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad Touchpad up event cannot be handled"); - } - break; - case VTPStateMachineMessageType::RIGHT_CLICK_DOWN: - if (!HandleVKeyTrackPadRightBtnDown(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad right button down event cannot be handled"); - } - break; - case VTPStateMachineMessageType::RIGHT_CLICK_UP: - if (!HandleVKeyTrackPadRightBtnUp(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad right button up event cannot be handled"); - } - break; - case VTPStateMachineMessageType::TWO_FINGER_TAP: - if (!HandleVKeyTrackPadTwoFingerTap(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad two finger tap event cannot be handled"); - } - break; - default: - OnVKeyTrackPadGestureMessage(touch, msgType, msgItem); - break; - } - } -} - -void LibinputAdapter::OnVKeyTrackPadGestureMessage(libinput_event_touch* touch, - VTPStateMachineMessageType msgType, const std::vector& msgItem) +void LibinputAdapter::HandleVKeyboardMessage(VKeyboardEventType eventType, + std::vector keyEvents, int64_t frameTime) { - switch (msgType) { - case VTPStateMachineMessageType::SCROLL_BEGIN: - if (!HandleVKeyTrackPadScrollBegin(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad scroll begin event cannot be handled"); - } - break; - case VTPStateMachineMessageType::SCROLL_UPDATE: - if (!HandleVKeyTrackPadScrollUpdate(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad scroll update event cannot be handled"); - } - break; - case VTPStateMachineMessageType::SCROLL_END: - if (!HandleVKeyTrackPadScrollEnd(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad scroll end event cannot be handled"); - } - break; - case VTPStateMachineMessageType::PINCH_BEGIN: - if (!HandleVKeyTrackPadPinchBegin(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad pinch begin event cannot be handled"); - } - break; - case VTPStateMachineMessageType::PINCH_UPDATE: - if (!HandleVKeyTrackPadPinchUpdate(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad pinch update event cannot be handled"); + switch (eventType) { + case VKeyboardEventType::NormalKeyboardEvent: { + for (auto event : keyEvents) { + funInputEvent_(event, frameTime); + free(event); } break; - case VTPStateMachineMessageType::PINCH_END: - if (!HandleVKeyTrackPadPinchEnd(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad pinch end event cannot be handled"); + } + case VKeyboardEventType::UpdateCaps: { + for (auto event : keyEvents) { + funInputEvent_(event, frameTime); + free(event); } - break; - default: - OnVKeyTrackPadGestureTwoMessage(touch, msgType, msgItem); - break; - } -} + struct libinput_device* device = INPUT_DEV_MGR->GetKeyboardDevice(); + if (device != nullptr) { + std::shared_ptr keyEvent = KeyEventHdr->GetKeyEvent(); + if (keyEvent != nullptr) { + bool isCapsLockOn = keyEvent->GetFunctionKey(MMI::KeyEvent::CAPS_LOCK_FUNCTION_KEY); -void LibinputAdapter::OnVKeyTrackPadGestureTwoMessage(libinput_event_touch* touch, - VTPStateMachineMessageType msgType, const std::vector& msgItem) -{ - switch (msgType) { - case VTPStateMachineMessageType::PAN_BEGIN: - if (!HandleVKeyTrackPadPanBegin(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad pan begin event cannot be handled"); - } - break; - case VTPStateMachineMessageType::PAN_UPDATE: - if (!HandleVKeyTrackPadPanUpdate(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad pan update event cannot be handled"); - } - break; - case VTPStateMachineMessageType::PAN_END: - if (!HandleVKeyTrackPadPanEnd(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad pan end event cannot be handled"); - } - break; - case VTPStateMachineMessageType::ROT_BEGIN: - if (!HandleVKeyTrackPadRotateBegin(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad rotate begin event cannot be handled"); - } - break; - case VTPStateMachineMessageType::ROT_UPDATE: - if (!HandleVKeyTrackPadRotateUpdate(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad rotate update event cannot be handled"); + DeviceLedUpdate(device, KeyEvent::CAPS_LOCK_FUNCTION_KEY, !isCapsLockOn); + keyEvent->SetFunctionKey(MMI::KeyEvent::CAPS_LOCK_FUNCTION_KEY, !isCapsLockOn); + } } break; - case VTPStateMachineMessageType::ROT_END: - if (!HandleVKeyTrackPadRotateEnd(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad rotate end event cannot be handled"); - } + } + case VKeyboardEventType::HideCursor: { + HideMouseCursorTemporary(); break; + } default: - OnVKeyTrackPadGestureThreeMessage(touch, msgType, msgItem); - break; - } -} - -void LibinputAdapter::OnVKeyTrackPadGestureThreeMessage(libinput_event_touch* touch, - VTPStateMachineMessageType msgType, const std::vector& msgItem) -{ - switch (msgType) { - case VTPStateMachineMessageType::SWIPE_BEGIN: - if (!HandleVKeyTrackPadSwipeBegin(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad swipe begin event cannot be handled"); - } - break; - case VTPStateMachineMessageType::SWIPE_UPDATE: - if (!HandleVKeyTrackPadSwipeUpdate(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad swipe update event cannot be handled"); - } - break; - case VTPStateMachineMessageType::SWIPE_END: - if (!HandleVKeyTrackPadSwipeEnd(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad swipe end event cannot be handled"); - } - break; - case VTPStateMachineMessageType::SWIPE_FOUR_BEGIN: - if (!HandleVKeyTrackPadSwipeFourBegin(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad swipe four begin event cannot be handled"); - } - break; - case VTPStateMachineMessageType::SWIPE_FOUR_UPDATE: - if (!HandleVKeyTrackPadSwipeFourUpdate(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad swipe four update event cannot be handled"); - } break; - case VTPStateMachineMessageType::SWIPE_FOUR_END: - if (!HandleVKeyTrackPadSwipeFourEnd(touch, msgItem)) { - MMI_HILOGE("Virtual TrackPad swipe four end event cannot be handled"); - } - break; - } -} - -bool LibinputAdapter::HandleVKeyTrackPadSwipeBegin(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (vtpSwipeState_ != VTPSwipeStateType::SWIPE_END) { - HandleVKeyTrackPadSwipeEnd(touch, msgItem); - return false; - } - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - event_gesture gEvent; - gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN; - gEvent.finger_count = VKEY_TP_GSE_THREE_FINGERS; - sloted_coords_info slotInfo = {}; - slotInfo.active_count = VKEY_TP_GSE_THREE_FINGERS; - slotInfo.coords[0].is_active = true; - slotInfo.coords[0].x = static_cast(msgPPosX); - slotInfo.coords[0].y = static_cast(msgPPosY); - slotInfo.coords[0].is_active = true; - slotInfo.coords[1].x = static_cast(msgPPosX); - slotInfo.coords[1].y = static_cast(msgPPosY); - slotInfo.coords[1].is_active = true; - gEvent.solt_touches = slotInfo; - libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); - funInputEvent_((libinput_event*)lgEvent, frameTime); - free(lgEvent); - vtpSwipeState_ = VTPSwipeStateType::SWIPE_BEGIN; - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadSwipeUpdate(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (vtpSwipeState_ == VTPSwipeStateType::SWIPE_END) { - return false; - } - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - int32_t msgPSwipe = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - event_gesture gEvent; - gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE; - gEvent.finger_count = VKEY_TP_GSE_THREE_FINGERS; - gEvent.delta_x = 0; - gEvent.delta_y = msgPSwipe; - gEvent.delta_unaccel_x = 0; - gEvent.delta_unaccel_y = msgPSwipe; - sloted_coords_info slotInfo = {}; - slotInfo.active_count = VKEY_TP_GSE_THREE_FINGERS; - slotInfo.coords[0].is_active = true; - slotInfo.coords[0].x = static_cast(msgPPosX); - slotInfo.coords[0].y = static_cast(msgPPosY); - slotInfo.coords[0].is_active = true; - slotInfo.coords[1].x = static_cast(msgPPosX); - slotInfo.coords[1].y = static_cast(msgPPosY); - slotInfo.coords[1].is_active = true; - gEvent.solt_touches = slotInfo; - libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); - funInputEvent_((libinput_event*)lgEvent, frameTime); - free(lgEvent); - vtpSwipeState_ = VTPSwipeStateType::SWIPE_UPDATE; - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadSwipeEnd(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (vtpSwipeState_ == VTPSwipeStateType::SWIPE_END) { - return false; - } - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - int32_t msgPSwipe = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - event_gesture gEvent; - gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_SWIPE_END; - gEvent.finger_count = VKEY_TP_GSE_THREE_FINGERS; - sloted_coords_info slotInfo = {}; - slotInfo.active_count = VKEY_TP_GSE_THREE_FINGERS; - slotInfo.coords[0].is_active = true; - slotInfo.coords[0].x = static_cast(msgPPosX); - slotInfo.coords[0].y = static_cast(msgPPosY); - slotInfo.coords[0].is_active = true; - slotInfo.coords[1].x = static_cast(msgPPosX); - slotInfo.coords[1].y = static_cast(msgPPosY); - slotInfo.coords[1].is_active = true; - gEvent.solt_touches = slotInfo; - libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); - funInputEvent_((libinput_event*)lgEvent, frameTime); - free(lgEvent); - vtpSwipeState_ = VTPSwipeStateType::SWIPE_END; - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadSwipeFourBegin(libinput_event_touch* touch, - const std::vector& msgItem) -{ - CHKPF(funInputEvent_); - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - event_gesture gEvent; - gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN; - gEvent.finger_count = VKEY_TP_GSE_FOUR_FINGERS; - PrintVKeyTPGestureLog(gEvent); - libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); - CHKPF(lgEvent); - funInputEvent_((libinput_event*)lgEvent, frameTime); - free(lgEvent); - vtpSwipeState_ = VTPSwipeStateType::SWIPE_BEGIN; - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadSwipeFourUpdate(libinput_event_touch* touch, - const std::vector& msgItem) -{ - CHKPF(funInputEvent_); - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - event_gesture gEvent; - gEvent.device_coords_x[0] = msgPPosX; - gEvent.device_coords_y[0] = msgPPosY; - gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE; - gEvent.finger_count = VKEY_TP_GSE_FOUR_FINGERS; - libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); - CHKPF(lgEvent); - funInputEvent_((libinput_event*)lgEvent, frameTime); - free(lgEvent); - vtpSwipeState_ = VTPSwipeStateType::SWIPE_UPDATE; - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadSwipeFourEnd(libinput_event_touch* touch, - const std::vector& msgItem) -{ - CHKPF(funInputEvent_); - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - event_gesture gEvent; - gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_SWIPE_END; - gEvent.finger_count = VKEY_TP_GSE_FOUR_FINGERS; - libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); - CHKPF(lgEvent); - funInputEvent_((libinput_event*)lgEvent, frameTime); - free(lgEvent); - vtpSwipeState_ = VTPSwipeStateType::SWIPE_END; - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadPointerMove(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - event_pointer pEvent; - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD; - pEvent.delta_raw_x = msgPPosX; - pEvent.delta_raw_y = msgPPosY; - libinput_event_pointer* lpEvent = libinput_create_pointer_event(touch, pEvent); - PrintVKeyTPPointerLog(pEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - return true; } -bool LibinputAdapter::HandleVKeyTrackPadLeftBtnDown(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - event_pointer pEvent; - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD; - pEvent.button = VKEY_TP_LB_ID; - pEvent.seat_button_count = VKEY_TP_SEAT_BTN_COUNT_ONE; - pEvent.state = libinput_button_state::LIBINPUT_BUTTON_STATE_PRESSED; - pEvent.delta_x = VTP_LEFT_BUTTON_DELTA_X; - pEvent.delta_y = VTP_LEFT_BUTTON_DELTA_Y; - pEvent.delta_raw_x = VTP_LEFT_BUTTON_DELTA_X; - pEvent.delta_raw_y = VTP_LEFT_BUTTON_DELTA_Y; - libinput_event_pointer* lpEvent = libinput_create_pointer_event(touch, pEvent); - PrintVKeyTPPointerLog(pEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - return true; -} -// Scenario: Single tap Mode; Action: Send Press immediately + Plan a release in 180ms -void LibinputAdapter::HandleVKeyTrackPadSingleTap(libinput_event_touch* touch, - const std::vector& msgItem, - libinput_event* event, bool& delayvtpDestroy) +void LibinputAdapter::HandleVTrackpadMessage(VTrackpadEventType eventType, std::vector events, + int64_t frameTime, libinput_event_touch *touch) { - CHKPV(funInputEvent_); - MMI_HILOGI("Scenario: Single tap Mode"); - std::chrono::duration delta = std::chrono::system_clock::now() - vtpSingleTapDownTime; - if (delta.count() > vtpSingleTapThreshold) { - MMI_HILOGI("Single tap not sent. Time exceeded the limit."); + if (eventType != VTrackpadEventType::NormalTrackpadEvent) { return; } - event_pointer pEvent; - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_TAP; - pEvent.button = VKEY_TP_LB_ID; - pEvent.seat_button_count = VKEY_TP_SEAT_BTN_COUNT_ONE; - pEvent.state = libinput_button_state::LIBINPUT_BUTTON_STATE_PRESSED; - pEvent.delta_x = VTP_LEFT_BUTTON_DELTA_X; - pEvent.delta_y = VTP_LEFT_BUTTON_DELTA_Y; - pEvent.delta_raw_x = VTP_LEFT_BUTTON_DELTA_X; - pEvent.delta_raw_y = VTP_LEFT_BUTTON_DELTA_Y; - libinput_event_pointer* lpEvent = libinput_create_pointer_event(touch, pEvent); - CHKPV(lpEvent); - MMI_HILOGD("Virtual TrackPad send: LIBINPUT_EVENT_POINTER_TAP PRESS"); - PrintVKeyTPPointerLog(pEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - bool touchUpDelay = false; - touchUpDelay = CreateVTrackPadDelayTimer(event); - if (touchUpDelay) { - delayvtpDestroy = true; - StartVTrackPadDelayTimer(); - MMI_HILOGD("Start the delay %{private}d", WAIT_TIME_MS_DTAP); - } -} - -bool LibinputAdapter::HandleVKeyTrackPadLeftBtnUp(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - event_pointer pEvent; - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD; - pEvent.button = VKEY_TP_LB_ID; - pEvent.seat_button_count = VKEY_TP_SEAT_BTN_COUNT_NONE; - pEvent.state = libinput_button_state::LIBINPUT_BUTTON_STATE_RELEASED; - pEvent.delta_x = VTP_LEFT_BUTTON_DELTA_X; - pEvent.delta_y = VTP_LEFT_BUTTON_DELTA_Y; - pEvent.delta_raw_x = VTP_LEFT_BUTTON_DELTA_X; - pEvent.delta_raw_y = VTP_LEFT_BUTTON_DELTA_Y; - libinput_event_pointer* lpEvent = libinput_create_pointer_event(touch, pEvent); - PrintVKeyTPPointerLog(pEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadTouchPadUp(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - event_pointer pEvent; - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_TAP; - pEvent.button = VKEY_TP_LB_ID; - pEvent.seat_button_count = VKEY_TP_SEAT_BTN_COUNT_NONE; - pEvent.state = libinput_button_state::LIBINPUT_BUTTON_STATE_RELEASED; - pEvent.delta_x = VTP_LEFT_BUTTON_DELTA_X; - pEvent.delta_y = VTP_LEFT_BUTTON_DELTA_Y; - pEvent.delta_raw_x = VTP_LEFT_BUTTON_DELTA_X; - pEvent.delta_raw_y = VTP_LEFT_BUTTON_DELTA_Y; - libinput_event_pointer* lpEvent = libinput_create_pointer_event(touch, pEvent); - PrintVKeyTPPointerLog(pEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadRightBtnDown(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - event_pointer pEvent; - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_BUTTON; - pEvent.button = VKEY_TP_RB_ID; - pEvent.seat_button_count = VKEY_TP_SEAT_BTN_COUNT_ONE; - pEvent.state = libinput_button_state::LIBINPUT_BUTTON_STATE_PRESSED; - libinput_event_pointer* lpEvent = libinput_create_pointer_event(touch, pEvent); - PrintVKeyTPPointerLog(pEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadRightBtnUp(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - event_pointer pEvent; - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_BUTTON; - pEvent.button = VKEY_TP_RB_ID; - pEvent.seat_button_count = VKEY_TP_SEAT_BTN_COUNT_NONE; - pEvent.state = libinput_button_state::LIBINPUT_BUTTON_STATE_RELEASED; - libinput_event_pointer* lpEvent = libinput_create_pointer_event(touch, pEvent); - PrintVKeyTPPointerLog(pEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadTwoFingerTap(libinput_event_touch* touch, const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int64_t frameTime = GetSysClockTime(); - // tap down - event_pointer pDownEvent; - pDownEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_TAP; - pDownEvent.button = VKEY_TP_RB_ID; - pDownEvent.seat_button_count = VKEY_TP_SEAT_BTN_COUNT_NONE; - pDownEvent.state = libinput_button_state::LIBINPUT_BUTTON_STATE_PRESSED; - libinput_event_pointer* lpDownEvent = libinput_create_pointer_event(touch, pDownEvent); - CHKPF(lpDownEvent); - PrintVKeyTPPointerLog(pDownEvent); - funInputEvent_((libinput_event*)lpDownEvent, frameTime); - free(lpDownEvent); - - // tap up - event_pointer pUpEvent; - pUpEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_TAP; - pUpEvent.button = VKEY_TP_RB_ID; - pUpEvent.seat_button_count = VKEY_TP_SEAT_BTN_COUNT_NONE; - pUpEvent.state = libinput_button_state::LIBINPUT_BUTTON_STATE_RELEASED; - libinput_event_pointer* lpUpEvent = libinput_create_pointer_event(touch, pUpEvent); - CHKPF(lpUpEvent); - PrintVKeyTPPointerLog(pUpEvent); - funInputEvent_((libinput_event*)lpUpEvent, frameTime); - free(lpUpEvent); - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadScrollBegin(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - MMI_HILOGI("VKey TrackPad Scroll Begin"); - event_pointer pEvent; - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_SCROLL_FINGER_BEGIN; - pEvent.delta_x = msgPPosX; - pEvent.delta_y = msgPPosY; - pEvent.delta_raw_x = msgPPosX; - pEvent.delta_raw_y = msgPPosY; - pEvent.axes = VKEY_TP_AXES_ZERO; - libinput_event_pointer* lpEvent = libinput_create_pointer_event(touch, pEvent); - PrintVKeyTPPointerLog(pEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadScrollUpdate(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - MMI_HILOGI("VKey TrackPad Scroll Update"); - event_pointer pEvent; - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_AXIS; - pEvent.delta_x = msgPPosX; - pEvent.delta_y = msgPPosY; - pEvent.delta_raw_x = msgPPosX; - pEvent.delta_raw_y = msgPPosY; - pEvent.source = libinput_pointer_axis_source::LIBINPUT_POINTER_AXIS_SOURCE_FINGER; - pEvent.axes = VKEY_TP_AXES_ZERO; - // Moving in the x direction - if (msgPPosX != 0) { - pEvent.axes |= VKEY_TP_AXES_TWO; - } - // Moving in the y direction - if (msgPPosY != 0) { - pEvent.axes |= VKEY_TP_AXES_ONE; - } - libinput_event_pointer* lpEvent = libinput_create_pointer_event(touch, pEvent); - PrintVKeyTPPointerLog(pEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_SCROLL_FINGER; - lpEvent = libinput_create_pointer_event(touch, pEvent); - PrintVKeyTPPointerLog(pEvent); - frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadScrollEnd(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - MMI_HILOGI("VKey TrackPad Scroll End"); - event_pointer pEvent; - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_SCROLL_FINGER_END; - pEvent.delta_x = msgPPosX; - pEvent.delta_y = msgPPosY; - pEvent.delta_raw_x = msgPPosX; - pEvent.delta_raw_y = msgPPosY; - pEvent.axes = VKEY_TP_AXES_ZERO; - libinput_event_pointer* lpEvent = libinput_create_pointer_event(touch, pEvent); - PrintVKeyTPPointerLog(pEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - return true; -} -bool LibinputAdapter::HandleVKeyTrackPadPinchBegin(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - int32_t msgPScale = msgItem[VKEY_TP_SM_MSG_SCALE_IDX]; - double scaleToDouble = static_cast(msgPScale) / VTP_SCALE_AND_ANGLE_FACTOR; - int32_t msgPAngle = msgItem[VKEY_TP_SM_MSG_ANGLE_IDX]; - double angleToDouble = static_cast(msgPAngle) / VTP_SCALE_AND_ANGLE_FACTOR; - MMI_HILOGI("VKey TrackPad Pinch Begin"); - event_gesture gEvent; - gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_PINCH_BEGIN; - gEvent.finger_count = VKEY_TP_GSE_TWO_FINGERS; - gEvent.cancelled = 0; - gEvent.delta_x = msgPPosX; - gEvent.delta_y = msgPPosY; - gEvent.delta_unaccel_x = msgPPosX; - gEvent.delta_unaccel_y = msgPPosY; - sloted_coords_info slotInfo; - gEvent.solt_touches = slotInfo; - gEvent.scale = scaleToDouble; - gEvent.angle = angleToDouble; - libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); - PrintVKeyTPGestureLog(gEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lgEvent, frameTime); - free(lgEvent); - - InjectEventForTwoFingerOnTouchpad(touch, libinput_event_type::LIBINPUT_EVENT_TOUCHPAD_DOWN, frameTime); - - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadPinchUpdate(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - int32_t msgPScale = msgItem[VKEY_TP_SM_MSG_SCALE_IDX]; - double scaleToDouble = static_cast(msgPScale) / VTP_SCALE_AND_ANGLE_FACTOR; - int32_t msgPAngle = msgItem[VKEY_TP_SM_MSG_ANGLE_IDX]; - double angleToDouble = static_cast(msgPAngle) / VTP_SCALE_AND_ANGLE_FACTOR; - MMI_HILOGI("VKey TrackPad Pinch Update"); - event_gesture gEvent; - gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_PINCH_UPDATE; - gEvent.finger_count = VKEY_TP_GSE_TWO_FINGERS; - gEvent.cancelled = 0; - gEvent.delta_x = msgPPosX; - gEvent.delta_y = msgPPosY; - gEvent.delta_unaccel_x = msgPPosX; - gEvent.delta_unaccel_y = msgPPosY; - sloted_coords_info slotInfo; - gEvent.solt_touches = slotInfo; - gEvent.scale = scaleToDouble; - gEvent.angle = angleToDouble; - libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); - PrintVKeyTPGestureLog(gEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lgEvent, frameTime); - free(lgEvent); - - InjectEventForTwoFingerOnTouchpad(touch, libinput_event_type::LIBINPUT_EVENT_TOUCHPAD_MOTION, frameTime); - - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadPinchEnd(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - int32_t msgPScale = msgItem[VKEY_TP_SM_MSG_SCALE_IDX]; - double scaleToDouble = static_cast(msgPScale) / VTP_SCALE_AND_ANGLE_FACTOR; - int32_t msgPAngle = msgItem[VKEY_TP_SM_MSG_ANGLE_IDX]; - double angleToDouble = static_cast(msgPAngle) / VTP_SCALE_AND_ANGLE_FACTOR; - MMI_HILOGI("VKey TrackPad Pinch End"); - event_gesture gEvent; - gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_PINCH_END; - gEvent.finger_count = VKEY_TP_GSE_TWO_FINGERS; - gEvent.cancelled = 0; - gEvent.delta_x = msgPPosX; - gEvent.delta_y = msgPPosY; - gEvent.delta_unaccel_x = msgPPosX; - gEvent.delta_unaccel_y = msgPPosY; - sloted_coords_info slotInfo; - gEvent.solt_touches = slotInfo; - gEvent.scale = scaleToDouble; - gEvent.angle = angleToDouble; - libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); - PrintVKeyTPGestureLog(gEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lgEvent, frameTime); - free(lgEvent); - - if (IsCursorInCastWindow()) { - InjectEventForCastWindow(touch); - } else { - InjectEventForTwoFingerOnTouchpad(touch, libinput_event_type::LIBINPUT_EVENT_TOUCHPAD_UP, frameTime); - } - - return true; -} - -void LibinputAdapter::InjectEventForTwoFingerOnTouchpad(libinput_event_touch* touch, - libinput_event_type eventType, int64_t frameTime) -{ - event_touch tEvent; - tEvent.event_type = eventType; - tEvent.seat_slot = VKEY_PINCH_FIRST_FINGER_ID; - libinput_event_touch* ltEvent = libinput_create_touch_event(touch, tEvent); - if (ltEvent != nullptr) { - funInputEvent_((libinput_event*)ltEvent, frameTime); - free(ltEvent); - } - - tEvent.seat_slot = VKEY_PINCH_SECOND_FINGER_ID; - ltEvent = libinput_create_touch_event(touch, tEvent); - if (ltEvent != nullptr) { - funInputEvent_((libinput_event*)ltEvent, frameTime); - free(ltEvent); + for (auto event : events) { + libinput_event_type injectEventType = libinput_event_get_type(event); + funInputEvent_(event, frameTime); + free(event); + + if (injectEventType == libinput_event_type::LIBINPUT_EVENT_GESTURE_PINCH_BEGIN) { + InjectEventForTwoFingerOnTouchpad(touch, libinput_event_type::LIBINPUT_EVENT_TOUCHPAD_DOWN, + frameTime); + } else if (injectEventType == libinput_event_type::LIBINPUT_EVENT_GESTURE_PINCH_UPDATE) { + InjectEventForTwoFingerOnTouchpad(touch, libinput_event_type::LIBINPUT_EVENT_TOUCHPAD_MOTION, + frameTime); + } else if (injectEventType == libinput_event_type::LIBINPUT_EVENT_GESTURE_PINCH_END) { + if (IsCursorInCastWindow()) { + InjectEventForCastWindow(touch); + } else { + InjectEventForTwoFingerOnTouchpad(touch, libinput_event_type::LIBINPUT_EVENT_TOUCHPAD_UP, + frameTime); + } + } } } @@ -1381,202 +506,6 @@ bool LibinputAdapter::IsCursorInCastWindow() return inputWindowsManager->IsMouseInCastWindow(); } -bool LibinputAdapter::HandleVKeyTrackPadPanBegin(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - MMI_HILOGI("VKey TrackPad Pan Begin"); - event_pointer pEvent; - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_SCROLL_FINGER_BEGIN; - pEvent.delta_x = msgPPosX; - pEvent.delta_y = msgPPosY; - pEvent.delta_raw_x = msgPPosX; - pEvent.delta_raw_y = msgPPosY; - pEvent.axes = VKEY_TP_AXES_ZERO; - libinput_event_pointer* lpEvent = libinput_create_pointer_event(touch, pEvent); - PrintVKeyTPPointerLog(pEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadPanUpdate(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - MMI_HILOGI("VKey TrackPad Pan Update"); - event_pointer pEvent; - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_AXIS; - pEvent.delta_x = msgPPosX; - pEvent.delta_y = msgPPosY; - pEvent.delta_raw_x = msgPPosX; - pEvent.delta_raw_y = msgPPosY; - pEvent.source = libinput_pointer_axis_source::LIBINPUT_POINTER_AXIS_SOURCE_FINGER; - pEvent.axes = VKEY_TP_AXES_TWO; - libinput_event_pointer* lpEvent = libinput_create_pointer_event(touch, pEvent); - PrintVKeyTPPointerLog(pEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_SCROLL_FINGER; - lpEvent = libinput_create_pointer_event(touch, pEvent); - PrintVKeyTPPointerLog(pEvent); - frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadPanEnd(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - MMI_HILOGI("VKey TrackPad Pan End"); - event_pointer pEvent; - pEvent.event_type = libinput_event_type::LIBINPUT_EVENT_POINTER_SCROLL_FINGER_END; - pEvent.delta_x = msgPPosX; - pEvent.delta_y = msgPPosY; - pEvent.delta_raw_x = msgPPosX; - pEvent.delta_raw_y = msgPPosY; - pEvent.axes = VKEY_TP_AXES_ZERO; - libinput_event_pointer* lpEvent = libinput_create_pointer_event(touch, pEvent); - PrintVKeyTPPointerLog(pEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lpEvent, frameTime); - free(lpEvent); - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadRotateBegin(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - int32_t msgPScale = msgItem[VKEY_TP_SM_MSG_SCALE_IDX]; - double scaleToDouble = static_cast(msgPScale) / VTP_SCALE_AND_ANGLE_FACTOR; - int32_t msgPAngle = msgItem[VKEY_TP_SM_MSG_ANGLE_IDX]; - double angleToDouble = static_cast(msgPAngle) / VTP_SCALE_AND_ANGLE_FACTOR; - MMI_HILOGI("VKey TrackPad Rotate Begin"); - event_gesture gEvent; - gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_PINCH_BEGIN; - gEvent.finger_count = VKEY_TP_GSE_TWO_FINGERS; - gEvent.cancelled = 0; - gEvent.delta_x = msgPPosX; - gEvent.delta_y = msgPPosY; - gEvent.delta_unaccel_x = msgPPosX; - gEvent.delta_unaccel_y = msgPPosY; - sloted_coords_info slotInfo; - gEvent.solt_touches = slotInfo; - gEvent.scale = scaleToDouble; - gEvent.angle = angleToDouble; - libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); - PrintVKeyTPGestureLog(gEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lgEvent, frameTime); - free(lgEvent); - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadRotateUpdate(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - int32_t msgPScale = msgItem[VKEY_TP_SM_MSG_SCALE_IDX]; - double scaleToDouble = static_cast(msgPScale) / VTP_SCALE_AND_ANGLE_FACTOR; - int32_t msgPAngle = msgItem[VKEY_TP_SM_MSG_ANGLE_IDX]; - double angleToDouble = static_cast(msgPAngle) / VTP_SCALE_AND_ANGLE_FACTOR; - MMI_HILOGI("VKey TrackPad Rotate Update"); - event_gesture gEvent; - gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_PINCH_UPDATE; - gEvent.finger_count = VKEY_TP_GSE_TWO_FINGERS; - gEvent.cancelled = 0; - gEvent.delta_x = msgPPosX; - gEvent.delta_y = msgPPosY; - gEvent.delta_unaccel_x = msgPPosX; - gEvent.delta_unaccel_y = msgPPosY; - sloted_coords_info slotInfo; - gEvent.solt_touches = slotInfo; - gEvent.scale = scaleToDouble; - gEvent.angle = angleToDouble; - libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); - PrintVKeyTPGestureLog(gEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lgEvent, frameTime); - free(lgEvent); - return true; -} - -bool LibinputAdapter::HandleVKeyTrackPadRotateEnd(libinput_event_touch* touch, - const std::vector& msgItem) -{ - if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { - MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", - static_cast(msgItem.size())); - return false; - } - int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; - int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; - int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; - int32_t msgPScale = msgItem[VKEY_TP_SM_MSG_SCALE_IDX]; - double scaleToDouble = static_cast(msgPScale) / VTP_SCALE_AND_ANGLE_FACTOR; - int32_t msgPAngle = msgItem[VKEY_TP_SM_MSG_ANGLE_IDX]; - double angleToDouble = static_cast(msgPAngle) / VTP_SCALE_AND_ANGLE_FACTOR; - MMI_HILOGI("VKey TrackPad Rotate End"); - event_gesture gEvent; - gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_PINCH_END; - gEvent.finger_count = VKEY_TP_GSE_TWO_FINGERS; - gEvent.cancelled = 0; - gEvent.delta_x = msgPPosX; - gEvent.delta_y = msgPPosY; - gEvent.delta_unaccel_x = msgPPosX; - gEvent.delta_unaccel_y = msgPPosY; - sloted_coords_info slotInfo; - gEvent.solt_touches = slotInfo; - gEvent.scale = scaleToDouble; - gEvent.angle = angleToDouble; - libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); - PrintVKeyTPGestureLog(gEvent); - int64_t frameTime = GetSysClockTime(); - funInputEvent_((libinput_event*)lgEvent, frameTime); - free(lgEvent); - return true; -} - int32_t LibinputAdapter::ConvertToTouchEventType( libinput_event_type eventType) { @@ -1591,43 +520,6 @@ int32_t LibinputAdapter::ConvertToTouchEventType( } } -void LibinputAdapter::PrintVKeyTPPointerLog(event_pointer &pEvent) -{ - MMI_HILOGD("######## pointerEvent"); - MMI_HILOGD("######## event type:%{public}d, delta.x:%{public}d, delta.y:%{public}d", - static_cast(pEvent.event_type), static_cast(pEvent.delta_x), - static_cast(pEvent.delta_y)); - MMI_HILOGD("######## delta_raw.x:%{public}d, delta_raw.y:%{public}d", - static_cast(pEvent.delta_raw_x), static_cast(pEvent.delta_raw_y)); - MMI_HILOGD("######## absolute.x:%{public}d, absolute.y:%{public}d, source:%{public}d", - static_cast(pEvent.absolute_x), static_cast(pEvent.absolute_y), - static_cast(pEvent.source)); - MMI_HILOGD("######## axes:%{public}d, button:%{public}d, seat button count:%{public}d", - static_cast(pEvent.axes), static_cast(pEvent.button), - static_cast(pEvent.seat_button_count)); - MMI_HILOGD("######## state:%{public}d, discrete.x:%{public}d, discrete.y:%{public}d", - static_cast(pEvent.state), static_cast(pEvent.discrete_x), - static_cast(pEvent.discrete_y)); - MMI_HILOGD("######## v120.x:%{public}d, v120.y:%{public}d", - static_cast(pEvent.v120_x), static_cast(pEvent.v120_y)); -} - -void LibinputAdapter::PrintVKeyTPGestureLog(event_gesture &gEvent) -{ - MMI_HILOGD("######## gestureEvent"); - MMI_HILOGD("######## event_type:%{public}d, finger_count:%{public}d, cancelled:%{public}d", - static_cast(gEvent.event_type), static_cast(gEvent.finger_count), - static_cast(gEvent.cancelled)); - MMI_HILOGD("######## delta_x:%{public}f, delta_y:%{public}f", - static_cast(gEvent.delta_x), static_cast(gEvent.delta_y)); - MMI_HILOGD("######## delta_unaccel_x:%{public}f, delta_unaccel_y:%{public}f", - static_cast(gEvent.delta_unaccel_x), static_cast(gEvent.delta_unaccel_y)); - MMI_HILOGD("######## solt_touches active_count:%{public}d", - static_cast(gEvent.solt_touches.active_count)); - MMI_HILOGD("######## scale:%{public}f, angle:%{public}f", - static_cast(gEvent.scale), static_cast(gEvent.angle)); -} - void LibinputAdapter::HandleHWKeyEventForVKeyboard(libinput_event* event) { MMI_HILOGD("Hardware keyboard key event detected"); diff --git a/service/message_handle/include/authorize_helper.h b/service/message_handle/include/authorize_helper.h index 0f80566e5cd318a0201ff2c5697330fa56e1278c..34c93af20b7d686454cbe8636a668a039a8a953b 100644 --- a/service/message_handle/include/authorize_helper.h +++ b/service/message_handle/include/authorize_helper.h @@ -33,10 +33,10 @@ public: AuthorizeHelper(); ~AuthorizeHelper(); DISALLOW_COPY_AND_MOVE(AuthorizeHelper); - void Init(ClientDeathHandler& clientDeathHandler); + void Init(ClientDeathHandler* clientDeathHandler); void CancelAuthorize(int32_t pid); int32_t GetAuthorizePid(); - int32_t AddAuthorizeProcess(int32_t pid, AuthorizeExitCallback exitCallback); + int32_t AddAuthorizeProcess(int32_t pid, AuthorizeExitCallback exitCallback, const int32_t reqId = -1); inline AuthorizeState GetAuthorizeState() { std::lock_guard lock(mutex_); @@ -47,14 +47,18 @@ public: protected: void OnClientDeath(int32_t pid); void AuthorizeProcessExit(); - private: + void NotifyRequestInjectionResult(); + void NoticeRequestInjectionResult(const int32_t reqId, const int32_t callingPid); + void ClearRequestInjectionCallback(int32_t callingPid); int32_t pid_; AuthorizeState state_ { AuthorizeState::STATE_UNAUTHORIZE }; std::atomic_bool isInit_ { false }; AuthorizeExitCallback exitCallback_ { nullptr }; static std::mutex mutex_; static std::shared_ptr instance_; + ClientDeathHandler* clientDeathHandler_; + std::map mapQueryAuthorizeInfo_; }; #define AUTHORIZE_HELPER ::OHOS::MMI::AuthorizeHelper::GetInstance() diff --git a/service/message_handle/include/client_death_handler.h b/service/message_handle/include/client_death_handler.h index d8da1c040074db77ae7cdcb237af49c026431ada..a72057131052cf2542069f2eaf6961e6f8ae67e3 100644 --- a/service/message_handle/include/client_death_handler.h +++ b/service/message_handle/include/client_death_handler.h @@ -35,6 +35,7 @@ public: bool AddClientDeathCallback(CallBackType type, ClientDeathCallback callback); bool UnregisterClientDeathRecipient(const wptr &remoteObj); void RemoveClientDeathCallback(CallBackType type); + sptr GetClientProxy(int32_t pid); protected: bool RegisterClientDeathRecipient(const sptr &binderClientSrv); diff --git a/service/message_handle/include/server_msg_handler.h b/service/message_handle/include/server_msg_handler.h index 397836e1dadf7ee13b233b9b80d2da2ab3e3a216..38809573ed042ec6d8c81ee1ddf58a092c6e6777 100644 --- a/service/message_handle/include/server_msg_handler.h +++ b/service/message_handle/include/server_msg_handler.h @@ -29,7 +29,6 @@ #include "sec_comp_enhance_kit.h" #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT - namespace OHOS { namespace MMI { enum class AuthorizationStatus : int32_t { @@ -119,6 +118,12 @@ public: #endif // OHOS_BUILD_ENABLE_KEYBOARD int32_t OnAuthorize(bool isAuthorize); int32_t OnCancelInjection(int32_t callPidId = 0); + int32_t RequestInjection(const int32_t callingPid, int32_t &status, int32_t &reqId); + int32_t QueryAuthorizedStatus(const int32_t callingPid, int32_t &status); + bool IsPC() const; + int32_t GetRequestInjectionCallbackReqId(); + bool CheckForRequestInjectionFrequentAccess(int32_t callingPid, int64_t interval); + int32_t SetPixelMapData(int32_t infoId, void* pixelMap); bool InitInjectNoticeSource(); bool AddInjectNotice(const InjectNoticeInfo& noticeInfo); @@ -172,6 +177,8 @@ private: std::map> transparentWins_; std::shared_ptr injectNotice_ { nullptr }; ClientDeathHandler clientDeathHandler_; + std::mutex mutexMapQueryAuthorizeLastTimestamp_; + std::map mapQueryAuthorizeLastTimestamp_; }; } // namespace MMI } // namespace OHOS diff --git a/service/message_handle/src/authorize_helper.cpp b/service/message_handle/src/authorize_helper.cpp index 363fe1a9f73d699cf0a9893be62808325a1299e6..ea9cb13d5f6de6444d27b4bf60e04413f38ab171 100644 --- a/service/message_handle/src/authorize_helper.cpp +++ b/service/message_handle/src/authorize_helper.cpp @@ -15,6 +15,9 @@ #include "authorize_helper.h" +#include "error_multimodal.h" +#include "iinput_binder_client.h" +#include "input_binder_client_proxy.h" #include "mmi_log.h" #undef MMI_LOG_DOMAIN @@ -57,7 +60,7 @@ int32_t AuthorizeHelper::GetAuthorizePid() return pid; } -void AuthorizeHelper::Init(ClientDeathHandler &clientDeathHandler) +void AuthorizeHelper::Init(ClientDeathHandler* clientDeathHandler) { CALL_DEBUG_ENTER; if (isInit_) { @@ -65,14 +68,24 @@ void AuthorizeHelper::Init(ClientDeathHandler &clientDeathHandler) return; } - clientDeathHandler.AddClientDeathCallback(CallBackType::CALLBACK_TYPE_AUTHORIZE_HELPER, + if (clientDeathHandler == nullptr) { + MMI_HILOGE("clientDeathHandler is nullptr"); + return; + } + + clientDeathHandler->AddClientDeathCallback(CallBackType::CALLBACK_TYPE_AUTHORIZE_HELPER, [&](int32_t pid) -> void { OnClientDeath(pid); }); + clientDeathHandler_ = clientDeathHandler; isInit_ = true; } void AuthorizeHelper::OnClientDeath(int32_t pid) { CALL_DEBUG_ENTER; + { + std::lock_guard lock(mutex_); + ClearRequestInjectionCallback(pid); + } if (pid != pid_) { MMI_HILOGD("Cancel process is inconsistent with authorize, cancel pid:%{public}d, authorize pid:%{public}d", pid, pid_); @@ -93,7 +106,7 @@ void AuthorizeHelper::AuthorizeProcessExit() pid_ = INVALID_AUTHORIZE_PID; } -int32_t AuthorizeHelper::AddAuthorizeProcess(int32_t pid, AuthorizeExitCallback exitCallback) +int32_t AuthorizeHelper::AddAuthorizeProcess(int32_t pid, AuthorizeExitCallback exitCallback, const int32_t reqId) { CALL_DEBUG_ENTER; if (!isInit_) { @@ -116,6 +129,9 @@ int32_t AuthorizeHelper::AddAuthorizeProcess(int32_t pid, AuthorizeExitCallback pid_ = pid; state_ = AuthorizeState::STATE_SELECTION_AUTHORIZE; exitCallback_ = exitCallback; + if (reqId > 0) { + mapQueryAuthorizeInfo_.insert(std::make_pair(reqId, pid_)); + } MMI_HILOGD("A process enters the authorization select state %{public}d", state_); return RET_OK; } @@ -126,6 +142,7 @@ int32_t AuthorizeHelper::AddAuthorizeProcess(int32_t pid, AuthorizeExitCallback } if (state_ == AuthorizeState::STATE_SELECTION_AUTHORIZE) { state_ = AuthorizeState::STATE_AUTHORIZE; + NotifyRequestInjectionResult(); } exitCallback_ = exitCallback; MMI_HILOGD("A process will be authorized, authorize pid:%{public}d", pid_); @@ -146,7 +163,52 @@ void AuthorizeHelper::CancelAuthorize(int32_t pid) } state_ = AuthorizeState::STATE_UNAUTHORIZE; pid_ = INVALID_AUTHORIZE_PID; + NotifyRequestInjectionResult(); exitCallback_ = nullptr; } + +void AuthorizeHelper::NotifyRequestInjectionResult() +{ + CALL_DEBUG_ENTER; + if (clientDeathHandler_ == nullptr) { + MMI_HILOGE("clientDeathHandler is nullptr"); + return; + } + for (auto it = mapQueryAuthorizeInfo_.begin(); it != mapQueryAuthorizeInfo_.end();) { + NoticeRequestInjectionResult(it->first, it->second); + mapQueryAuthorizeInfo_.erase(it++); + } +} + +void AuthorizeHelper::NoticeRequestInjectionResult(const int32_t reqId, const int32_t callingPid) +{ + auto object = clientDeathHandler_->GetClientProxy(callingPid); + sptr pClientProxy = iface_cast(object); + if (!pClientProxy) { + MMI_HILOGE("pClientProxy is nullptr"); + return; + } + auto sendStatus = AUTHORIZE_QUERY_STATE::UNAUTHORIZED; + if (state_ == AuthorizeState::STATE_AUTHORIZE) { + if (pid_ == callingPid) { + sendStatus = AUTHORIZE_QUERY_STATE::CURRENT_PID_AUTHORIZED; + } + } + MMI_HILOGD("result callback! pid_:%{public}d,sendStatus:%{public}d,state_:%{public}d,mapId:%{public}d", + pid_, sendStatus, state_, callingPid); + pClientProxy->NoticeRequestInjectionResult(reqId, static_cast(sendStatus)); +} + +void AuthorizeHelper::ClearRequestInjectionCallback(int32_t callingPid) +{ + CALL_DEBUG_ENTER; + for (auto it = mapQueryAuthorizeInfo_.begin(); it != mapQueryAuthorizeInfo_.end();) { + if (it->second == callingPid) { + mapQueryAuthorizeInfo_.erase(it++); + } else { + it++; + } + } +} } // namespace MMI } // namespace OHOS diff --git a/service/message_handle/src/client_death_handler.cpp b/service/message_handle/src/client_death_handler.cpp index e5ddb8f143c166f2e843ea1ba854d094dfec4a37..6845007d559946ca866c662ee4b5d48311bccdd8 100644 --- a/service/message_handle/src/client_death_handler.cpp +++ b/service/message_handle/src/client_death_handler.cpp @@ -160,5 +160,17 @@ void ClientDeathHandler::NotifyDeath(int32_t pid) (it->second)(pid); } } + +sptr ClientDeathHandler::GetClientProxy(int32_t pid) +{ + CALL_DEBUG_ENTER; + std::lock_guard lockPidMap(mutexPidMap_); + auto it = clientPidMap_.find(pid); + if (it == clientPidMap_.end()) { + MMI_HILOGI("Not found Death recipient proxy! pid:%{public}d", pid); + return nullptr; + } + return it->second; +} } // namespace MMI } // namespace OHOS diff --git a/service/message_handle/src/server_msg_handler.cpp b/service/message_handle/src/server_msg_handler.cpp index 3ee102fac7b6f9e82ad0feb906c2bf00af879ebb..cd214089667fe0fe7c8ff1b08f8a66407229110c 100644 --- a/service/message_handle/src/server_msg_handler.cpp +++ b/service/message_handle/src/server_msg_handler.cpp @@ -40,6 +40,7 @@ #ifdef OHOS_BUILD_ENABLE_TOUCH_DRAWING #include "touch_drawing_manager.h" #endif // #ifdef OHOS_BUILD_ENABLE_TOUCH_DRAWING +#include "util.h" #undef MMI_LOG_DOMAIN #define MMI_LOG_DOMAIN MMI_LOG_SERVER @@ -78,6 +79,7 @@ constexpr float FACTOR_18 { 1.0f }; constexpr float FACTOR_27 { 1.2f }; constexpr float FACTOR_55 { 1.6f }; constexpr float FACTOR_MAX { 2.4f }; +constexpr int64_t QUERY_AUTHORIZE_MAX_INTERVAL_TIME { 3000 }; } // namespace void ServerMsgHandler::Init(UDSServer &udsServer) @@ -102,7 +104,7 @@ void ServerMsgHandler::Init(UDSServer &udsServer) continue; } } - AUTHORIZE_HELPER->Init(clientDeathHandler_); + AUTHORIZE_HELPER->Init(&clientDeathHandler_); } void ServerMsgHandler::OnMsgHandler(SessionPtr sess, NetPacket& pkt) @@ -594,6 +596,8 @@ void ServerMsgHandler::UpdatePointerEvent(std::shared_ptr pointerE auto mouseInfo = WIN_MGR->GetMouseInfo(); pointerItem.SetDisplayX(mouseInfo.physicalX); pointerItem.SetDisplayY(mouseInfo.physicalY); + pointerItem.SetDisplayXPos(mouseInfo.physicalX); + pointerItem.SetDisplayYPos(mouseInfo.physicalY); pointerEvent->UpdatePointerItem(pointerEvent->GetPointerId(), pointerItem); pointerEvent->SetTargetDisplayId(mouseInfo.displayId); } @@ -1259,6 +1263,97 @@ int32_t ServerMsgHandler::OnCancelInjection(int32_t callPid) return ERR_OK; } +int32_t ServerMsgHandler::RequestInjection(const int32_t callingPid, int32_t &status, int32_t &reqId) +{ + CALL_DEBUG_ENTER; + if (!IsPC()) { + return ERROR_DEVICE_NOT_SUPPORTED; + } + auto ret = QueryAuthorizedStatus(callingPid, status); + MMI_HILOGD("QueryAuthorizedStatus,ret:%{public}d, callingPid:%{public}d, status:%{public}d", + ret, callingPid, status); + if (ret != ERR_OK) { + MMI_HILOGE("QueryAuthorizedStatus,ret:%{public}d, callingPid:%{public}d", ret, callingPid); + return ret; + } + if (static_cast(status) != AUTHORIZE_QUERY_STATE::UNAUTHORIZED) { + return ERR_OK; + } + if (CheckForRequestInjectionFrequentAccess(callingPid, QUERY_AUTHORIZE_MAX_INTERVAL_TIME)) { + return ERROR_OPERATION_FREQUENT; + } + LaunchAbility(); + AuthorizeExitCallback fnCallback = [&] (int32_t pid) { + MMI_HILOGI("User not authorized to inject pid:%{public}d", pid); + AUTH_DIALOG.CloseDialog(); + }; + reqId = GetRequestInjectionCallbackReqId(); + return AUTHORIZE_HELPER->AddAuthorizeProcess(callingPid, fnCallback, reqId); +} + +int32_t ServerMsgHandler::QueryAuthorizedStatus(const int32_t callingPid, int32_t &status) +{ + CALL_DEBUG_ENTER; + auto state = AUTHORIZE_HELPER->GetAuthorizeState(); + if (state == AuthorizeState::STATE_UNAUTHORIZE) { + status = static_cast(AUTHORIZE_QUERY_STATE::UNAUTHORIZED); + return ERR_OK; + } + int32_t curAuthPid = AUTHORIZE_HELPER->GetAuthorizePid(); + if (curAuthPid == callingPid) { + if (state == AuthorizeState::STATE_SELECTION_AUTHORIZE) { + status = static_cast(AUTHORIZE_QUERY_STATE::CURRENT_PID_IN_AUTHORIZATION_SELECTION); + } else { + status = static_cast(AUTHORIZE_QUERY_STATE::CURRENT_PID_AUTHORIZED); + } + return ERR_OK; + } + if (state == AuthorizeState::STATE_SELECTION_AUTHORIZE) { + status = static_cast(AUTHORIZE_QUERY_STATE::OTHER_PID_IN_AUTHORIZATION_SELECTION); + } else { + status = static_cast(AUTHORIZE_QUERY_STATE::OTHER_PID_AUTHORIZED); + } + return ERR_OK; +} + +bool ServerMsgHandler::IsPC() const +{ + return PRODUCT_TYPE == PRODUCT_TYPE_PC; +} + +int32_t ServerMsgHandler::GetRequestInjectionCallbackReqId() +{ + static std::atomic reqId(1); + if (reqId >= INT32_MAX - 1) { + reqId = 1; + return reqId; + } + return reqId.fetch_add(1); +} + +bool ServerMsgHandler::CheckForRequestInjectionFrequentAccess(int32_t callingPid, int64_t interval) +{ + CALL_DEBUG_ENTER; + int64_t curTimestamp = GetMillisTime(); + std::lock_guard lock(mutexMapQueryAuthorizeLastTimestamp_); + for (auto it = mapQueryAuthorizeLastTimestamp_.begin(); it != mapQueryAuthorizeLastTimestamp_.end();) { + if (curTimestamp - it->second >= interval) { + MMI_HILOGD("requestInjection cur:%{public}" PRId64",it:%{public}" PRId64",sub:%{public}" PRId64"", + curTimestamp, it->second, curTimestamp - it->second); + mapQueryAuthorizeLastTimestamp_.erase(it++); + } else { + it++; + } + } + auto itFind = mapQueryAuthorizeLastTimestamp_.find(callingPid); + if (itFind == mapQueryAuthorizeLastTimestamp_.end()) { + MMI_HILOGD("requestInjection instert: %{public}d", callingPid); + mapQueryAuthorizeLastTimestamp_.insert(std::make_pair(callingPid, curTimestamp)); + return false; + } + return true; +} + void ServerMsgHandler::SetWindowInfo(int32_t infoId, WindowInfo &info) { CALL_DEBUG_ENTER; diff --git a/service/message_handle/test/server_msg_handler_test.cpp b/service/message_handle/test/server_msg_handler_test.cpp index 440643b602c83eb99b4dfbcceb6cdefdddac2d8d..df2bb1c85e1b8d0f4272a2dfda1e5d3123e63266 100644 --- a/service/message_handle/test/server_msg_handler_test.cpp +++ b/service/message_handle/test/server_msg_handler_test.cpp @@ -31,6 +31,7 @@ #include "input_device_manager.h" #include "mmi_log.h" #include "pointer_event.h" +#include "running_process_info.h" #include "server_msg_handler.h" #include "stream_buffer.h" @@ -54,6 +55,7 @@ constexpr int32_t MOUSE_ICON_SIZE = 64; constexpr int32_t COMMON_PERMISSION_CHECK_ERROR { 201 }; constexpr int32_t ERR_DEVICE_NOT_EXIST { 3900002 }; constexpr int32_t ERR_NON_INPUT_APPLICATION { 3900003 }; +constexpr int32_t CAST_INPUT_DEVICEID { 0xAAAAAAFF }; constexpr float FACTOR_0 { 1.0f }; constexpr float FACTOR_8 { 0.7f }; constexpr float FACTOR_18 { 1.0f }; @@ -1983,6 +1985,37 @@ HWTEST_F(ServerMsgHandlerTest, ServerMsgHandlerTest_OnAuthorize_002, TestSize.Le EXPECT_EQ(result, ERR_OK); } +/** + * @tc.name: ServerMsgHandlerTest_RequestInjection_001 + * @tc.desc: Test the function RequestInjection + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(ServerMsgHandlerTest, ServerMsgHandlerTest_RequestInjection_001, TestSize.Level1) +{ + CALL_TEST_DEBUG; + ServerMsgHandler handler; + int32_t callingPid = 100000; + int32_t status = 0; + int32_t reqId = 0; + auto isPC = handler.IsPC(); + int32_t result = ERR_OK; + if (!isPC) { + result = handler.RequestInjection(callingPid, status, reqId); + EXPECT_EQ(result, ERROR_DEVICE_NOT_SUPPORTED); + return; + } + handler.OnCancelInjection(callingPid); + result = handler.OnAuthorize(false); + EXPECT_EQ(result, ERR_OK); + result = handler.RequestInjection(callingPid, status, reqId); + EXPECT_EQ(result, RET_ERR); + result = handler.OnAuthorize(true); + EXPECT_EQ(result, ERR_OK); + result = handler.OnAuthorize(false); + EXPECT_EQ(result, ERR_OK); +} + /** * @tc.name: ServerMsgHandlerTest_OnMoveMouse_002 * @tc.desc: Test the function OnMoveMouse @@ -2885,5 +2918,143 @@ HWTEST_F(ServerMsgHandlerTest, ServerMsgHandlerTest_UnsubscribeKeyMonitor002, Te int32_t ret = handler.UnsubscribeKeyMonitor(session, keyOption); EXPECT_EQ(ret, RET_OK); } + +/** + * @tc.name: ServerMsgHandlerTest_DealGesturePointers002 + * @tc.desc: Test the function DealGesturePointers + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(ServerMsgHandlerTest, ServerMsgHandlerTest_DealGesturePointers002, TestSize.Level1) +{ + CALL_TEST_DEBUG; + ServerMsgHandler handler; + auto pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + pointerEvent->SetId(1); + pointerEvent->SetPointerId(10001); + pointerEvent->bitwise_ = InputEvent::EVENT_FLAG_ACCESSIBILITY; + ASSERT_NO_FATAL_FAILURE(handler.DealGesturePointers(pointerEvent)); + auto touchEvent = PointerEvent::Create(); + ASSERT_NE(touchEvent, nullptr); + PointerEvent::PointerItem item; + item.SetPointerId(10002); + item.SetOriginPointerId(10002); + item.SetPressed(true); + touchEvent->AddPointerItem(item); + ASSERT_NO_FATAL_FAILURE(handler.DealGesturePointers(pointerEvent)); +} + +/** + * @tc.name: ServerMsgHandlerTest_OnSetFunctionKeyState003 + * @tc.desc: Test the function OnSetFunctionKeyState + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(ServerMsgHandlerTest, ServerMsgHandlerTest_OnSetFunctionKeyState003, TestSize.Level1) +{ + CALL_TEST_DEBUG; + ServerMsgHandler handler; + AppExecFwk::RunningProcessInfo processInfo; + processInfo.extensionType_ = AppExecFwk::ExtensionAbilityType::INPUTMETHOD; + int32_t funcKey = 1; + int32_t pid = 15; + bool enable = true; + INPUT_DEV_MGR->IsKeyboardDevice(nullptr); + ASSERT_NO_FATAL_FAILURE(handler.OnSetFunctionKeyState(pid, funcKey, enable)); + enable = false; + ASSERT_NO_FATAL_FAILURE(handler.OnSetFunctionKeyState(pid, funcKey, enable)); +} + +/** + * @tc.name: ServerMsgHandlerTest_OnInjectPointerEventExt002 + * @tc.desc: Test OnInjectPointerEventExt + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(ServerMsgHandlerTest, ServerMsgHandlerTest_OnInjectPointerEventExt002, TestSize.Level1) +{ + CALL_TEST_DEBUG; + ServerMsgHandler msgHandler; + std::shared_ptr pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + InputHandler->eventNormalizeHandler_ = std::make_shared(); + pointerEvent->SetId(1); + pointerEvent->eventType_ = 1; + pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN); + pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN); + msgHandler.nativeTargetWindowIds_.insert(std::make_pair(pointerEvent->GetPointerId(), 10)); + ASSERT_NO_FATAL_FAILURE(msgHandler.OnInjectPointerEventExt(pointerEvent, true)); + + pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE); + pointerEvent->SetPointerId(1); + pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE); + pointerEvent->bitwise_ = InputEvent::EVENT_FLAG_RAW_POINTER_MOVEMENT; + ASSERT_NO_FATAL_FAILURE(msgHandler.OnInjectPointerEventExt(pointerEvent, true)); + + pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_JOYSTICK); + pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE); + pointerEvent->AddFlag(InputEvent::EVENT_FLAG_NONE); + ASSERT_NO_FATAL_FAILURE(msgHandler.OnInjectPointerEventExt(pointerEvent, true)); + + pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD); + pointerEvent->bitwise_ = InputEvent::EVENT_FLAG_HIDE_POINTER; + ASSERT_NO_FATAL_FAILURE(msgHandler.OnInjectPointerEventExt(pointerEvent, true)); +} + +/** +@tc.name: ServerMsgHandlerTest_FixTargetWindowId_008 +@tc.desc: Test FixTargetWindowId +@tc.type: FUNC +@tc.require: +*/ +HWTEST_F(ServerMsgHandlerTest, ServerMsgHandlerTest_FixTargetWindowId_008, TestSize.Level1) +{ + CALL_TEST_DEBUG; + ServerMsgHandler handler; + handler.shellTargetWindowIds_.clear(); + handler.castTargetWindowIds_.clear(); + handler.accessTargetWindowIds_.clear(); + handler.nativeTargetWindowIds_.clear(); + auto pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + pointerEvent->SetDeviceId(CAST_INPUT_DEVICEID); + int32_t action = PointerEvent::POINTER_ACTION_DOWN; + int32_t pointerId = -1; + PointerEvent::PointerItem item; + item.SetPointerId(pointerId); + pointerEvent->AddPointerItem(item); + pointerEvent->SetPointerId(-1); + handler.shellTargetWindowIds_[0] = -1; + pointerEvent->SetZOrder(1); + ASSERT_NO_FATAL_FAILURE(handler.FixTargetWindowId(pointerEvent, action, true)); + handler.castTargetWindowIds_[0] = -1; + ASSERT_NO_FATAL_FAILURE(handler.FixTargetWindowId(pointerEvent, action, true)); + pointerEvent->SetZOrder(-1); + ASSERT_NO_FATAL_FAILURE(handler.FixTargetWindowId(pointerEvent, action, true)); + pointerEvent->AddFlag(InputEvent::EVENT_FLAG_ACCESSIBILITY); + ASSERT_NO_FATAL_FAILURE(handler.FixTargetWindowId(pointerEvent, action, true)); + handler.accessTargetWindowIds_[0] = -1; + pointerEvent->AddFlag(InputEvent::EVENT_FLAG_NO_INTERCEPT); + ASSERT_NO_FATAL_FAILURE(handler.FixTargetWindowId(pointerEvent, action, true)); + handler.nativeTargetWindowIds_[0] = -1; + ASSERT_NO_FATAL_FAILURE(handler.FixTargetWindowId(pointerEvent, action, true)); +} + +/** +@tc.name: ServerMsgHandlerTest_SwitchTouchTracking +@tc.desc: Test SwitchTouchTracking +@tc.type: FUNC +@tc.require: +*/ +HWTEST_F(ServerMsgHandlerTest, ServerMsgHandlerTest_SwitchTouchTracking, TestSize.Level1) +{ + CALL_TEST_DEBUG; + ServerMsgHandler handler; + bool touchTracking = true; + ASSERT_NO_FATAL_FAILURE(handler.SwitchTouchTracking(touchTracking)); + touchTracking = false; + ASSERT_NO_FATAL_FAILURE(handler.SwitchTouchTracking(touchTracking)); +} } // namespace MMI } // namespace OHOS diff --git a/service/module_loader/include/mmi_service.h b/service/module_loader/include/mmi_service.h index 7b0cb8768ffa62cb0e706691ff9cea69bc02489b..05c355fcec2609a4e62cf7c05d62366c8ba19399 100644 --- a/service/module_loader/include/mmi_service.h +++ b/service/module_loader/include/mmi_service.h @@ -152,6 +152,7 @@ public: ErrCode GetFunctionKeyState(int32_t funcKey, bool &state) override; ErrCode SetFunctionKeyState(int32_t funcKey, bool enable) override; ErrCode SetPointerLocation(int32_t x, int32_t y, int32_t displayId) override; + ErrCode GetPointerLocation(int32_t &displayId, double &displayX, double &displayY) override; ErrCode SetMouseCaptureMode(int32_t windowId, bool isCaptureMode) override; ErrCode GetWindowPid(int32_t windowId, int32_t &windowPid) override; ErrCode AppendExtraData(const ExtraData &extraData) override; @@ -182,6 +183,8 @@ public: std::unordered_map& specialKeysState) override; ErrCode Authorize(bool isAuthorize) override; ErrCode CancelInjection() override; + ErrCode RequestInjection(int32_t &status, int32_t &reqId) override; + ErrCode QueryAuthorizedStatus(int32_t &status) override; ErrCode SetMoveEventFilters(bool flag) override; #ifdef OHOS_RSS_CLIENT void OnAddResSchedSystemAbility(int32_t systemAbilityId, const std::string &deviceId); diff --git a/service/module_loader/src/mmi_service.cpp b/service/module_loader/src/mmi_service.cpp index 5bb3e91e71cef32ba049b5214a92a7ecda89ba4c..e096351576dc456776f27d2bfe2842cbd0265835 100644 --- a/service/module_loader/src/mmi_service.cpp +++ b/service/module_loader/src/mmi_service.cpp @@ -45,9 +45,9 @@ #ifdef OHOS_BUILD_ENABLE_GESTURESENSE_WRAPPER #include "gesturesense_wrapper.h" #endif // OHOS_BUILD_ENABLE_GESTURESENSE_WRAPPER -#ifndef OHOS_BUILD_ENABLE_WATCH +#ifdef OHOS_BUILD_ENABLE_RTOS_EXTRA #include "infrared_emitter_controller.h" -#endif // OHOS_BUILD_ENABLE_WATCH +#endif // OHOS_BUILD_ENABLE_RTOS_EXTRA #include "ipc_skeleton.h" #include "i_pointer_drawing_manager.h" #include "i_preference_manager.h" @@ -186,7 +186,12 @@ typedef bool (*GAUSSIANKEYBOARD_ISFLOATINGKEYBOARD_TYPE)(); GAUSSIANKEYBOARD_ISFLOATINGKEYBOARD_TYPE gaussiankeyboard_isFloatingKeyboard_ = nullptr; typedef bool (*VKEYBOARD_ISSHOWN)(); VKEYBOARD_ISSHOWN vkeyboard_isShown_ = nullptr; - +typedef int32_t (*GET_LIBINPUT_EVENT_FOR_VKEYBOARD_TYPE)( + libinput_event_touch *touch, int32_t& delayMs, std::vector& events); +GET_LIBINPUT_EVENT_FOR_VKEYBOARD_TYPE getLibinputEventForVKeyboard_ = nullptr; +typedef int32_t (*GET_LIBINPUT_EVENT_FOR_VTRACKPAD_TYPE)( + libinput_event_touch *touch, std::vector& events); +GET_LIBINPUT_EVENT_FOR_VTRACKPAD_TYPE getLibinputEventForVTrackpad_ = nullptr; #endif // OHOS_BUILD_ENABLE_VKEYBOARD #ifdef OHOS_BUILD_PC_PRIORITY constexpr int32_t PC_PRIORITY { 2 }; @@ -2914,6 +2919,38 @@ ErrCode MMIService::SetPointerLocation(int32_t x, int32_t y, int32_t displayId) return RET_OK; } +ErrCode MMIService::GetPointerLocation(int32_t &displayId, double &displayX, double &displayY) +{ + CALL_INFO_TRACE; +#if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING) + auto tokenId = IPCSkeleton::GetCallingTokenID(); + auto tokenType = OHOS::Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(tokenId); + if (tokenType != OHOS::Security::AccessToken::TOKEN_HAP) { + return ERROR_APP_NOT_FOCUSED; + } + bool hasPointerDevice = INPUT_DEV_MGR->HasPointerDevice(); + if (!hasPointerDevice) { + MMI_HILOGE("There hasn't any pointer device"); + return ERROR_DEVICE_NO_POINTER; + } + int32_t clientPid = GetCallingPid(); + bool focusPid = WIN_MGR->CheckAppFocused(clientPid); + if (!focusPid) { + return ERROR_APP_NOT_FOCUSED; + } + int32_t ret = delegateTasks_.PostSyncTask( + [&displayId, &displayX, &displayY] { + return ::OHOS::DelayedSingleton::GetInstance()->GetPointerLocation(displayId, + displayX, displayY); + }); + if (ret != RET_OK) { + MMI_HILOGE("Get pointer location failed, ret:%{public}d", ret); + return ret; + } +#endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING + return RET_OK; +} + void MMIService::OnDelegateTask(epoll_event &ev) { if ((ev.events & EPOLLIN) == 0) { @@ -4019,6 +4056,36 @@ ErrCode MMIService::HasIrEmitter(bool &hasIrEmitter) return RET_OK; } +ErrCode MMIService::RequestInjection(int32_t &status, int32_t &reqId) +{ + int32_t pid = GetCallingPid(); + int32_t ret = delegateTasks_.PostSyncTask( + [this, pid, &status, &reqId] { + return sMsgHandler_.RequestInjection(pid, status, reqId); + } + ); + if (ret != RET_OK) { + MMI_HILOGE("OnHasIrEmitter failed, ret:%{public}d", ret); + return ret; + } + return RET_OK; +} + +ErrCode MMIService::QueryAuthorizedStatus(int32_t &status) +{ + int32_t pid = GetCallingPid(); + int32_t ret = delegateTasks_.PostSyncTask( + [this, pid, &status] { + return sMsgHandler_.QueryAuthorizedStatus(pid, status); + } + ); + if (ret != RET_OK) { + MMI_HILOGE("QueryAuthorizedStatus failed, ret:%{public}d", ret); + return ret; + } + return RET_OK; +} + ErrCode MMIService::GetInfraredFrequencies(std::vector& frequencies) { CALL_DEBUG_ENTER; @@ -4026,7 +4093,7 @@ ErrCode MMIService::GetInfraredFrequencies(std::vector& frequ MMI_HILOGE("Infrared permission check failed"); return ERROR_NO_PERMISSION; } -#ifndef OHOS_BUILD_ENABLE_WATCH +#ifdef OHOS_BUILD_ENABLE_RTOS_EXTRA MMI_HILOGI("Start get infrared frequency"); std::vector infos; if (!InfraredEmitterController::GetInstance()->GetFrequencies(infos)) { @@ -4046,7 +4113,7 @@ ErrCode MMIService::GetInfraredFrequencies(std::vector& frequ ",min=" + std::to_string(frequencies[i].min_) + ";"; } MMI_HILOGD("Data from hdf context:%{public}s", context.c_str()); -#endif // OHOS_BUILD_ENABLE_WATCH +#endif // OHOS_BUILD_ENABLE_RTOS_EXTRA return RET_OK; } @@ -4057,7 +4124,7 @@ ErrCode MMIService::TransmitInfrared(int64_t number, const std::vector& MMI_HILOGE("StubTransmitInfrared permission check failed. returnCode:%{public}d", ERROR_NO_PERMISSION); return ERROR_NO_PERMISSION; } -#ifndef OHOS_BUILD_ENABLE_WATCH +#ifdef OHOS_BUILD_ENABLE_RTOS_EXTRA std::string context = "infraredFrequency:" + std::to_string(number) + ";"; int32_t size = static_cast(pattern.size()); for (int32_t i = 0; i < size; i++) { @@ -4068,7 +4135,7 @@ ErrCode MMIService::TransmitInfrared(int64_t number, const std::vector& MMI_HILOGE("Failed to transmit"); return RET_ERR; } -#endif // OHOS_BUILD_ENABLE_WATCH +#endif // OHOS_BUILD_ENABLE_RTOS_EXTRA return RET_OK; } @@ -4145,16 +4212,6 @@ void MMIService::InitVKeyboardFuncHandler() g_VKeyboardHandle = dlopen(VKEYBOARD_PATH.c_str(), RTLD_NOW); if (g_VKeyboardHandle != nullptr) { handleTouchPoint_ = (HANDLE_TOUCHPOINT_TYPE)dlsym(g_VKeyboardHandle, "HandleTouchPoint"); - statemachineMessageQueue_getLibinputMessage_ = (STATEMACINEMESSAGQUEUE_GETLIBINPUTMESSAGE_TYPE)dlsym( - g_VKeyboardHandle, "StateMachineMessageQueueGetLibinputMessage"); - trackPadEngine_getAllTouchMessage_ = (TRACKPADENGINE_GETALLTOUCHMESSAGE_TYPE)dlsym( - g_VKeyboardHandle, "TrackPadEngineGetAllTouchMessage"); - trackPadEngine_clearTouchMessage_ = (TRACKPADENGINE_CLEARTOUCHMESSAGE_TYPE)dlsym( - g_VKeyboardHandle, "TrackPadEngineClearTouchMessage"); - trackPadEngine_getAllKeyMessage_ = (TRACKPADENGINE_GETALLKEYMESSAGE_TYPE)dlsym( - g_VKeyboardHandle, "TrackPadEngineGetAllKeyMessage"); - trackPadEngine_clearKeyMessage_ = (TRACKPADENGINE_CLEARKEYMESSAGE_TYPE)dlsym( - g_VKeyboardHandle, "TrackPadEngineClearKeyMessage"); vkeyboard_hardwareKeyEventDetected_ = (VKEYBOARD_HARDWAREKEYEVENTDETECTED_TYPE)dlsym( g_VKeyboardHandle, "HardwareKeyEventDetected"); vkeyboard_getKeyboardActivationState_ = (VKEYBOARD_GETKEYBOARDACTIVATIONSTATE_TYPE)dlsym( @@ -4162,17 +4219,17 @@ void MMIService::InitVKeyboardFuncHandler() gaussiankeyboard_isFloatingKeyboard_ = (GAUSSIANKEYBOARD_ISFLOATINGKEYBOARD_TYPE)dlsym( g_VKeyboardHandle, "IsFloatingKeyboard"); vkeyboard_isShown_ = (VKEYBOARD_ISSHOWN)dlsym(g_VKeyboardHandle, "IsVKeyboardShown"); - + getLibinputEventForVKeyboard_ = (GET_LIBINPUT_EVENT_FOR_VKEYBOARD_TYPE)dlsym( + g_VKeyboardHandle, "GetLibinputEventForVKeyboard"); + getLibinputEventForVTrackpad_ = (GET_LIBINPUT_EVENT_FOR_VTRACKPAD_TYPE)dlsym( + g_VKeyboardHandle, "GetLibinputEventForVTrackpad"); libinputAdapter_.InitVKeyboard(handleTouchPoint_, - statemachineMessageQueue_getLibinputMessage_, - trackPadEngine_getAllTouchMessage_, - trackPadEngine_clearTouchMessage_, - trackPadEngine_getAllKeyMessage_, - trackPadEngine_clearKeyMessage_, vkeyboard_hardwareKeyEventDetected_, vkeyboard_getKeyboardActivationState_, gaussiankeyboard_isFloatingKeyboard_, - vkeyboard_isShown_); + vkeyboard_isShown_, + getLibinputEventForVKeyboard_, + getLibinputEventForVTrackpad_); } } } diff --git a/service/module_loader/test/mmi_service_test.cpp b/service/module_loader/test/mmi_service_test.cpp index 9fa79b0917d4f04bca831accd1c8f165996bff09..623723a080a5f54872d2b67e23917e8bed1fb71b 100644 --- a/service/module_loader/test/mmi_service_test.cpp +++ b/service/module_loader/test/mmi_service_test.cpp @@ -1100,5 +1100,22 @@ HWTEST_F(MMIServerTest, MMIServerTest_OnAppDebugStoped_01, TestSize.Level1) listener.appDebugPid_ = 4; ASSERT_NO_FATAL_FAILURE(listener.OnAppDebugStoped(debugInfos)); } + +/** + * @tc.name: MMIServerTest_GetPointerLocation_001 + * @tc.desc: Test the function GetPointerLocation + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(MMIServerTest, MMIServerTest_GetPointerLocation_001, TestSize.Level1) +{ + CALL_TEST_DEBUG; + MMIService mmiService; + int32_t displayId = 0; + double displayX = 0.0; + double displayY = 0.0; + int32_t ret = mmiService.GetPointerLocation(displayId, displayX, displayY); + EXPECT_EQ(ret, ERROR_APP_NOT_FOCUSED); +} } // namespace MMI } // namespace OHOS \ No newline at end of file diff --git a/service/mouse_event_normalize/include/mouse_event_normalize.h b/service/mouse_event_normalize/include/mouse_event_normalize.h index 7dbbea2f106a9cac71b56ddced4e9c4789cc2f34..d4879cac3605564aa630a9dacc514bb7ae103251 100644 --- a/service/mouse_event_normalize/include/mouse_event_normalize.h +++ b/service/mouse_event_normalize/include/mouse_event_normalize.h @@ -45,6 +45,7 @@ public: void OnDisplayLost(int32_t displayId); int32_t GetDisplayId() const; int32_t SetPointerLocation(int32_t x, int32_t y, int32_t dispiayId); + int32_t GetPointerLocation(int32_t &displayId, double &displayX, double &displayY); int32_t SetTouchpadScrollSwitch(int32_t pid, bool switchFlag) const; void GetTouchpadScrollSwitch(bool &switchFlag) const; int32_t SetTouchpadScrollDirection(bool state) const; diff --git a/service/mouse_event_normalize/include/mouse_transform_processor.h b/service/mouse_event_normalize/include/mouse_transform_processor.h index ff155b14709a6ba3760a894552ee2615617a326f..2412f87ea598296249876963b8e8ee6ef0086c3f 100644 --- a/service/mouse_event_normalize/include/mouse_transform_processor.h +++ b/service/mouse_event_normalize/include/mouse_transform_processor.h @@ -42,6 +42,7 @@ extern "C" { DEVICE_M_PC = 6, DEVICE_FOLD_PC_VIRT = 7, DEVICE_M_TABLET = 8, + DEVICE_Q_TABLET = 9, }; int32_t HandleMotionAccelerateMouse(const Offset* offset, bool mode, double* abs_x, double* abs_y, int32_t speed, int32_t deviceType); @@ -170,6 +171,7 @@ public: static int32_t SetPointerSpeed(int32_t speed); static int32_t GetPointerSpeed(); static int32_t SetPointerLocation(int32_t x, int32_t y, int32_t displayId); + static int32_t GetPointerLocation(int32_t &displayId, double &displayX, double &displayY); static int32_t SetTouchpadScrollSwitch(int32_t pid, bool switchFlag); static void GetTouchpadScrollSwitch(bool &switchFlag); static int32_t SetTouchpadScrollDirection(bool state); diff --git a/service/mouse_event_normalize/src/mouse_event_normalize.cpp b/service/mouse_event_normalize/src/mouse_event_normalize.cpp index b0e9dffd6116c3224967dda495385581793da8a8..c176a1ff695e261111013a7605b5fa7bfd11511b 100644 --- a/service/mouse_event_normalize/src/mouse_event_normalize.cpp +++ b/service/mouse_event_normalize/src/mouse_event_normalize.cpp @@ -202,6 +202,11 @@ int32_t MouseEventNormalize::SetPointerLocation(int32_t x, int32_t y, int32_t di return MouseTransformProcessor::SetPointerLocation(x, y, displayId); } +int32_t MouseEventNormalize::GetPointerLocation(int32_t &displayId, double &displayX, double &displayY) +{ + return MouseTransformProcessor::GetPointerLocation(displayId, displayX, displayY); +} + int32_t MouseEventNormalize::SetTouchpadScrollSwitch(int32_t pid, bool switchFlag) const { return MouseTransformProcessor::SetTouchpadScrollSwitch(pid, switchFlag); diff --git a/service/mouse_event_normalize/src/mouse_transform_processor.cpp b/service/mouse_event_normalize/src/mouse_transform_processor.cpp index 6e0c8756801ecb79c40b0c206f0b8fb9d4fa24bc..7e88e8b6749e55c3714e1a121bb615033fe7b4bd 100644 --- a/service/mouse_event_normalize/src/mouse_transform_processor.cpp +++ b/service/mouse_event_normalize/src/mouse_transform_processor.cpp @@ -62,6 +62,7 @@ const char* DEVICE_TYPE_M_PC { "M_PC" }; const char* DEVICE_TYPE_M_TABLET1 { "MRDI" }; const char* DEVICE_TYPE_M_TABLET2 { "MRO" }; const char* DEVICE_TYPE_M_TABLET3 { "MRDIL" }; +const char* DEVICE_TYPE_Q_TABLET { "QXS" }; const std::string PRODUCT_TYPE = OHOS::system::GetParameter("const.build.product", "HYM"); const std::string MOUSE_FILE_NAME { "mouse_settings.xml" }; const std::string TOUCHPAD_FILE_NAME { "touchpad_settings.xml" }; @@ -415,12 +416,20 @@ bool MouseTransformProcessor::IsWindowRotation(const DisplayInfo* displayInfo) { MMI_HILOGD("ROTATE_POLICY: %{public}d, FOLDABLE_DEVICE_POLICY:%{public}s", ROTATE_POLICY, FOLDABLE_DEVICE_POLICY.c_str()); + + bool foldableDevicePolicyMain = false; + bool foldableDevicePolicyFull = false; + if (!FOLDABLE_DEVICE_POLICY.empty()) { + foldableDevicePolicyMain = FOLDABLE_DEVICE_POLICY[0] == ROTATE_WINDOW_ROTATE; + } + if (FOLDABLE_DEVICE_POLICY.size() > FOLDABLE_DEVICE) { + foldableDevicePolicyFull = FOLDABLE_DEVICE_POLICY[FOLDABLE_DEVICE] == ROTATE_WINDOW_ROTATE; + } + return (ROTATE_POLICY == WINDOW_ROTATE || (ROTATE_POLICY == FOLDABLE_DEVICE && - ((displayInfo->displayMode == DisplayMode::MAIN && - FOLDABLE_DEVICE_POLICY[0] == ROTATE_WINDOW_ROTATE) || - (displayInfo->displayMode == DisplayMode::FULL && - FOLDABLE_DEVICE_POLICY[FOLDABLE_DEVICE] == ROTATE_WINDOW_ROTATE)))); + ((displayInfo->displayMode == DisplayMode::MAIN && foldableDevicePolicyMain) || + (displayInfo->displayMode == DisplayMode::FULL && foldableDevicePolicyFull)))); } Direction MouseTransformProcessor::GetDisplayDirection(const DisplayInfo *displayInfo) @@ -441,7 +450,7 @@ Direction MouseTransformProcessor::GetDisplayDirection(const DisplayInfo *displa return displayDirection; } -void MouseTransformProcessor::CalculateOffset(const DisplayInfo* displayInfo, Offset &offset) +void MouseTransformProcessor::CalculateOffset(const DisplayInfo *displayInfo, Offset &offset) { #ifndef OHOS_BUILD_EMULATOR if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { @@ -797,6 +806,9 @@ double MouseTransformProcessor::HandleAxisAccelateTouchPad(double axisValue) PRODUCT_TYPE == DEVICE_TYPE_M_TABLET3) { deviceType = DeviceType::DEVICE_M_TABLET; } + if (PRODUCT_TYPE == DEVICE_TYPE_Q_TABLET) { + deviceType = DeviceType::DEVICE_Q_TABLET; + } #ifdef OHOS_BUILD_ENABLE_VKEYBOARD if (isVirtualDeviceEvent_) { deviceType = DeviceType::DEVICE_FOLD_PC_VIRT; @@ -882,8 +894,12 @@ void MouseTransformProcessor::HandleAxisPostInner(PointerEvent::PointerItem &poi MouseState->SetMouseCoords(mouseInfo.physicalX, mouseInfo.physicalY); pointerItem.SetDisplayX(mouseInfo.physicalX); pointerItem.SetDisplayY(mouseInfo.physicalY); + pointerItem.SetDisplayXPos(mouseInfo.physicalX); + pointerItem.SetDisplayYPos(mouseInfo.physicalY); pointerItem.SetWindowX(0); pointerItem.SetWindowY(0); + pointerItem.SetWindowXPos(0.0); + pointerItem.SetWindowYPos(0.0); pointerItem.SetPointerId(0); pointerItem.SetPressed(isPressed_); int64_t time = GetSysClockTime(); @@ -917,8 +933,12 @@ bool MouseTransformProcessor::HandlePostInner(struct libinput_event_pointer* dat MouseState->SetMouseCoords(mouseInfo.physicalX, mouseInfo.physicalY); pointerItem.SetDisplayX(mouseInfo.physicalX); pointerItem.SetDisplayY(mouseInfo.physicalY); + pointerItem.SetDisplayXPos(mouseInfo.physicalX); + pointerItem.SetDisplayYPos(mouseInfo.physicalY); pointerItem.SetWindowX(0); pointerItem.SetWindowY(0); + pointerItem.SetWindowXPos(0.0); + pointerItem.SetWindowYPos(0.0); pointerItem.SetPointerId(0); pointerItem.SetPressed(isPressed_); @@ -1087,8 +1107,12 @@ void MouseTransformProcessor::HandlePostMoveMouse(PointerEvent::PointerItem& poi MouseState->SetMouseCoords(mouseInfo.physicalX, mouseInfo.physicalY); pointerItem.SetDisplayX(mouseInfo.physicalX); pointerItem.SetDisplayY(mouseInfo.physicalY); + pointerItem.SetDisplayXPos(mouseInfo.physicalX); + pointerItem.SetDisplayYPos(mouseInfo.physicalY); pointerItem.SetWindowX(0); pointerItem.SetWindowY(0); + pointerItem.SetWindowXPos(0.0); + pointerItem.SetWindowYPos(0.0); pointerItem.SetPointerId(0); pointerItem.SetPressed(isPressed_); @@ -1255,6 +1279,17 @@ int32_t MouseTransformProcessor::SetPointerLocation(int32_t x, int32_t y, int32_ return RET_OK; } +int32_t MouseTransformProcessor::GetPointerLocation(int32_t &displayId, double &displayX, double &displayY) +{ + auto mouseInfo = WIN_MGR->GetMouseInfo(); + displayId = mouseInfo.displayId; + displayX = mouseInfo.physicalX; + displayY = mouseInfo.physicalY; + MMI_HILOGD("Cursor pointer location displayId:%{public}d, displayX:%{private}f, displayY:%{private}f", + displayId, displayX, displayY); + return RET_OK; +} + #ifndef OHOS_BUILD_ENABLE_WATCH void MouseTransformProcessor::HandleTouchpadRightButton(struct libinput_event_pointer *data, const int32_t evenType, uint32_t &button) diff --git a/service/mouse_event_normalize/test/src/mouse_transform_processor_test.cpp b/service/mouse_event_normalize/test/src/mouse_transform_processor_test.cpp index 918c2c5a5f5313b494a5f7e4ed25c15ba67f6e09..a3b9583e9c227ca63147a7c731800b9976b20956 100644 --- a/service/mouse_event_normalize/test/src/mouse_transform_processor_test.cpp +++ b/service/mouse_event_normalize/test/src/mouse_transform_processor_test.cpp @@ -283,6 +283,23 @@ HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_SetPointerLoca ASSERT_EQ(processor.SetPointerLocation(x, y, displayId), idNames); } +/** + * @tc.name: MouseTransformProcessorTest_GetPointerLocation_001 + * @tc.desc: Test GetPointerLocation + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(MouseTransformProcessorTest, MouseTransformProcessorTest_GetPointerLocation_001, TestSize.Level1) +{ + int32_t deviceId = 1; + MouseTransformProcessor processor(deviceId); + int32_t displayId = -1; + double displayX = 0.0; + double displayY = 0.0; + int32_t ret = processor.GetPointerLocation(displayId, displayX, displayY); + EXPECT_EQ(ret, RET_OK); +} + /** * @tc.name: MouseTransformProcessorTest_SetPointerSpeed_009 * @tc.desc: Test GetPointerSpeed diff --git a/service/rust/src/lib.rs b/service/rust/src/lib.rs index a1bf83427722f926b91f517c499a29473b2dcdbf..12a0f743dc813f240fb84b221d3b338e3afade75 100644 --- a/service/rust/src/lib.rs +++ b/service/rust/src/lib.rs @@ -585,6 +585,11 @@ impl AxisAccelerateCurvesTouchpad { slopes: vec![3.0, 2.07, 1.72, 1.47, 1.31, 1.19, 0.55, 1.48], diff_nums: vec![0.0, 0.46, 0.82, 1.19, 1.52, 1.82, 3.74, 0.0] }, + CurveItem { + speeds: vec![0.5, 1.0, 1.38, 1.66, 2.0, 2.3, 3.4, 34.0], + slopes: vec![4.81, 3.31, 2.47, 1.78, 1.89, 1.75, 0.98, 2.28], + diff_nums: vec![0.0, 0.75, 1.59, 2.54, 2.35, 2.64, 4.42, 0.0] + }, ], }); }); @@ -1027,6 +1032,7 @@ fn get_axis_gain_touchpad(gain: *mut f64, axis_speed: f64, device_type: i32) -> 6 => 6, 7 => 5, 8 => 7, + 9 => 8, _ => 1, }; let item = AxisAccelerateCurvesTouchpad::get_instance().get_axis_curve_by_speed_touchpad(valid_device_type as usize); diff --git a/service/subscriber/include/key_subscriber_handler.h b/service/subscriber/include/key_subscriber_handler.h index 51dc2157f0c83c8f15f4280adba684fb52fdcf81..f57edf50eaa9cd4ce0fe337a08b99d7a1918c471 100644 --- a/service/subscriber/include/key_subscriber_handler.h +++ b/service/subscriber/include/key_subscriber_handler.h @@ -72,7 +72,9 @@ private: bool HandleKeyDown(const std::shared_ptr &keyEvent); bool HandleKeyUp(const std::shared_ptr &keyEvent); bool HandleKeyCancel(const std::shared_ptr &keyEvent); +#ifdef OHOS_BUILD_ENABLE_CALL_MANAGER bool HandleRingMute(std::shared_ptr keyEvent); +#endif // OHOS_BUILD_ENABLE_CALL_MANAGER bool IsPreKeysMatch(const std::set &preKeys, const std::vector &pressedKeys) const; void NotifySubscriber(std::shared_ptr keyEvent, const std::shared_ptr &subscriber); @@ -122,9 +124,11 @@ private: void GetForegroundPids(std::set &pidList); void PublishKeyPressCommonEvent(std::shared_ptr keyEvent); void RemoveSubscriberTimer(std::shared_ptr keyEvent); +#ifdef OHOS_BUILD_ENABLE_CALL_MANAGER bool HandleCallEnded(std::shared_ptr keyEvent); void HangUpCallProcess(); void RejectCallProcess(); +#endif // OHOS_BUILD_ENABLE_CALL_MANAGER private: SubscriberCollection subscriberMap_; diff --git a/service/subscriber/src/key_subscriber_handler.cpp b/service/subscriber/src/key_subscriber_handler.cpp index f0088cdcae596f2eeb361c6716e68e3ca51d2ef0..61c6f7c5d56bc99d897b39ca54d571a343640bbf 100644 --- a/service/subscriber/src/key_subscriber_handler.cpp +++ b/service/subscriber/src/key_subscriber_handler.cpp @@ -17,7 +17,9 @@ #include "app_state_observer.h" #include "bytrace_adapter.h" +#ifdef OHOS_BUILD_ENABLE_CALL_MANAGER #include "call_manager_client.h" +#endif // OHOS_BUILD_ENABLE_CALL_MANAGER #include "display_event_monitor.h" #include "device_event_monitor.h" #include "dfx_hisysevent.h" @@ -49,7 +51,9 @@ constexpr uint32_t MAX_PRE_KEY_COUNT { 4 }; constexpr int32_t REMOVE_OBSERVER { -2 }; constexpr int32_t UNOBSERVED { -1 }; constexpr int32_t ACTIVE_EVENT { 2 }; +#ifdef OHOS_BUILD_ENABLE_CALL_MANAGER std::shared_ptr callManagerClientPtr = nullptr; +#endif // OHOS_BUILD_ENABLE_CALL_MANAGER const std::string CALL_BEHAVIOR_KEY { "incall_power_button_behavior" }; const std::string SETTINGS_DATA_SYSTEM_URI { "datashare:///com.ohos.settingsdata/entry/settingsdata/USER_SETTINGSDATA_100?Proxy=true" }; @@ -579,6 +583,7 @@ void KeySubscriberHandler::PublishKeyPressCommonEvent(std::shared_ptr EventFwk::CommonEventManager::PublishCommonEvent(commonData, publishInfo); } +#ifdef OHOS_BUILD_ENABLE_CALL_MANAGER bool KeySubscriberHandler::HandleRingMute(std::shared_ptr keyEvent) { CALL_DEBUG_ENTER; @@ -637,6 +642,7 @@ bool KeySubscriberHandler::HandleRingMute(std::shared_ptr keyEvent) } return false; } +#endif // OHOS_BUILD_ENABLE_CALL_MANAGER bool KeySubscriberHandler::OnSubscribeKeyEvent(std::shared_ptr keyEvent) { @@ -647,6 +653,7 @@ bool KeySubscriberHandler::OnSubscribeKeyEvent(std::shared_ptr keyEven } }; CHKPF(keyEvent); +#ifdef OHOS_BUILD_ENABLE_CALL_MANAGER if (HandleRingMute(keyEvent)) { MMI_HILOGI("Mute Ring in subscribe keyEvent"); RemoveSubscriberTimer(keyEvent); @@ -656,6 +663,7 @@ bool KeySubscriberHandler::OnSubscribeKeyEvent(std::shared_ptr keyEven MMI_HILOGI("Call Ended in subscribe keyEvent"); return true; } +#endif // OHOS_BUILD_ENABLE_CALL_MANAGER if (!IsEnableCombineKey(keyEvent)) { MMI_HILOGI("Combine key is taken over in subscribe keyEvent"); return false; @@ -1452,6 +1460,7 @@ void KeySubscriberHandler::RemoveSubscriberTimer(std::shared_ptr keyEv } } +#ifdef OHOS_BUILD_ENABLE_CALL_MANAGER bool KeySubscriberHandler::HandleCallEnded(std::shared_ptr keyEvent) { CALL_DEBUG_ENTER; @@ -1548,6 +1557,7 @@ void KeySubscriberHandler::RejectCallProcess() } MMI_HILOGI("RejectCall success"); } +#endif // OHOS_BUILD_ENABLE_CALL_MANAGER void KeySubscriberHandler::InitDataShareListener() { diff --git a/service/subscriber/test/BUILD.gn b/service/subscriber/test/BUILD.gn index dbab700fdc0a33363440b322fc035115f421069d..f01ec54035c3d7bbe0cf3ccec09bfc80f2c6c5f9 100644 --- a/service/subscriber/test/BUILD.gn +++ b/service/subscriber/test/BUILD.gn @@ -78,10 +78,79 @@ ohos_unittest("InputActiveSubscriberHandlerTest") { ] } +ohos_unittest("KeyGestureManagerTest") { + module_out_path = module_output_path + + configs = [ + "${mmi_path}:coverage_flags", + "${mmi_path}/service:libmmi_server_config", + "${mmi_path}/service/filter:mmi_event_filter_config", + "${mmi_path}/common/anco/comm:mmi_anco_channel_config", + ] + + include_dirs = [ + "${mmi_path}/libudev/include", + "${mmi_path}/service/account_manager/include", + "${mmi_path}/service/app_state_manager/include", + "${mmi_path}/service/display_state_manager/include", + "${mmi_path}/service/fingersense_wrapper/include", + "${mmi_path}/service/key_command/include", + "${mmi_path}/service/key_event_normalize/include", + "${mmi_path}/service/subscriber/include", + "${mmi_path}/service/timer_manager/include", + "${mmi_path}/service/window_manager/include", + "${mmi_path}/service/connect_manager/include", + "${mmi_path}/service/module_loader/include", + "${mmi_path}/test/facility/libinput_interface/include", + ] + + sources = [ + "${mmi_path}/service/app_state_manager/src/app_state_observer.cpp", + "${mmi_path}/service/subscriber/src/key_gesture_manager.cpp", + "${mmi_path}/service/subscriber/test/key_gesture_manager_test.cpp", + "${mmi_path}/service/timer_manager/src/timer_manager.cpp", + ] + + cflags = [ + "-Dprivate=public", + "-Dprotected=public", + ] + + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/service:libmmi-server", + "${mmi_path}/test/facility/libinput_wrapper:libinput_wrapper_sources", + "${mmi_path}/test/facility/virtual_device:virtual_device_sources", + "${mmi_path}/util:libmmi-util", + ] + + external_deps = [ + "ability_runtime:app_manager", + "ability_runtime:dataobs_manager", + "cJSON:cjson", + "common_event_service:cesfwk_innerkits", + "hilog:libhilog", + "init:libbegetutil", + "ipc:ipc_core", + "libinput:libinput-third-mmi", + "samgr:samgr_proxy", + ] + + if (input_feature_switch) { + external_deps += [ + "graphic_2d:2d_graphics", + "graphic_2d:librender_service_client", + ] + } +} + group("mmi_subscriber_tests") { testonly = true - deps = [ ":InputActiveSubscriberHandlerTest" ] + deps = [ + ":InputActiveSubscriberHandlerTest", + ":KeyGestureManagerTest", + ] if (input_shortcut_key_rules_enabled) { deps += [ ":key_shortcut_rules_test" ] } diff --git a/service/subscriber/test/input_active_subscriber_handler_test.cpp b/service/subscriber/test/input_active_subscriber_handler_test.cpp index 2e5602d31e7243f990082363160e895680bccabb..18be39479a56c660984430000bf15969850eb6a3 100644 --- a/service/subscriber/test/input_active_subscriber_handler_test.cpp +++ b/service/subscriber/test/input_active_subscriber_handler_test.cpp @@ -15,6 +15,7 @@ #include #include "input_active_subscriber_handler.h" +#include "key_gesture_manager.h" #undef MMI_LOG_TAG #define MMI_LOG_TAG "InputActiveSubscriberHandlerTest" @@ -338,5 +339,59 @@ HWTEST_F(InputActiveSubscriberHandlerTest, InputActiveSubscriberHandlerTest_OnSe auto ret = handler.InitSessionDeleteCallback(); EXPECT_TRUE(ret); } + +/** + * @tc.name: InputActiveSubscriberHandlerTest + * @tc.desc: Test the funcation ResetTimer + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputActiveSubscriberHandlerTest, KeyGestureManagerTest_ResetTimer, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyGestureManager::Handler handler(1, 2, 3000, nullptr); + handler.timerId_ = -1; + ASSERT_NO_FATAL_FAILURE(handler.ResetTimer()); + handler.timerId_ = 0; + ASSERT_NO_FATAL_FAILURE(handler.ResetTimer()); +} + +/** + * @tc.name: KeyGestureManagerTest_Trigger + * @tc.desc: Test the funcation Trigger + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputActiveSubscriberHandlerTest, KeyGestureManagerTest_Trigger, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyGestureManager::Handler handler(1, 2, 3000, nullptr); + handler.timerId_ = -1; + std::shared_ptr keyEvent = KeyEvent::Create(); + ASSERT_NO_FATAL_FAILURE(handler.Trigger(keyEvent)); + handler.timerId_ = 0; + ASSERT_NO_FATAL_FAILURE(handler.Trigger(keyEvent)); +} + +/** + * @tc.name: KeyGestureManagerTest_Run + * @tc.desc: Test the funcation Run + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputActiveSubscriberHandlerTest, KeyGestureManagerTest_Run, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeyGestureManager::Handler handler(1, 2, 3000, nullptr); + handler.keyEvent_ = nullptr; + std::shared_ptr keyEvent = KeyEvent::Create(); + ASSERT_NO_FATAL_FAILURE(handler.Run(keyEvent)); + ASSERT_NO_FATAL_FAILURE(handler.RunPending()); + std::function)> myCallback; + handler.callback_ = myCallback; + handler.keyEvent_ = keyEvent; + ASSERT_NO_FATAL_FAILURE(handler.Run(keyEvent)); + ASSERT_NO_FATAL_FAILURE(handler.RunPending()); +} } // namespace MMI } // namespace OHOS \ No newline at end of file diff --git a/service/subscriber/test/key_gesture_manager_test.cpp b/service/subscriber/test/key_gesture_manager_test.cpp index 24a0ec2a77674925bd2adade524a458b2410153c..77fe0e5ce1f427ea810377f2cb630d5973902418 100644 --- a/service/subscriber/test/key_gesture_manager_test.cpp +++ b/service/subscriber/test/key_gesture_manager_test.cpp @@ -17,7 +17,6 @@ #include #include -#include "ability_manager_client.h" #include "display_event_monitor.h" #include "event_log_helper.h" #include "key_option.h" @@ -374,58 +373,11 @@ HWTEST_F(KeyGestureManagerTest, KeyGestureManagerTest_IsWorking_01, TestSize.Lev { CALL_TEST_DEBUG; KeyGestureManager::PullUpAccessibility pullUpAccessibility; - DISPLAY_MONITOR->screenStatus_ = EventFwk::CommonEventSupportTest::COMMON_EVENT_SCREEN_OFF; + DISPLAY_MONITOR->screenStatus_ = EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_OFF; bool ret = pullUpAccessibility.IsWorking(); EXPECT_FALSE(ret); } -/** - * @tc.name: KeyGestureManagerTest_IsWorking_02 - * @tc.desc: Test the funcation ShouldIntercept - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(KeyGestureManagerTest, KeyGestureManagerTest_IsWorking_02, TestSize.Level1) -{ - CALL_TEST_DEBUG; - KeyGestureManager::PullUpAccessibility pullUpAccessibility; - DISPLAY_MONITOR->screenStatus_ = EventFwk::CommonEventSupportTest::COMMON_EVENT_SCREEN_ON; - DISPLAY_MONITOR->isScreenLocked_ = true; - bool ret = pullUpAccessibility.IsWorking(); - EXPECT_FALSE(ret); -} - -/** - * @tc.name: KeyGestureManagerTest_IsWorking_03 - * @tc.desc: Test the funcation ShouldIntercept - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(KeyGestureManagerTest, KeyGestureManagerTest_IsWorking_03, TestSize.Level1) -{ - CALL_TEST_DEBUG; - KeyGestureManager::PullUpAccessibility pullUpAccessibility; - DISPLAY_MONITOR->screenStatus_ = EventFwk::CommonEventSupportTest::COMMON_EVENT_SCREEN_ON; - DISPLAY_MONITOR->isScreenLocked_ = false; - bool ret = pullUpAccessibility.IsWorking(); - EXPECT_FALSE(ret); -} - -/** - * @tc.name: KeyGestureManagerTest_OnTriggerAll_01 - * @tc.desc: Test the funcation OnTriggerAll - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(KeyGestureManagerTest, KeyGestureManagerTest_OnTriggerAll_01, TestSize.Level1) -{ - CALL_TEST_DEBUG; - KeyGestureManager::PullUpAccessibility pullUpAccessibility; - std::shared_ptr keyEvent = KeyEvent::Create(); - ASSERT_NE(keyEvent, nullptr); - ASSERT_NO_FATAL_FAILURE(pullUpAccessibility.OnTriggerAll(keyEvent)); -} - /** * @tc.name: KeyGestureManagerTest_RecognizeGesture_01 * @tc.desc: Test the funcation RecognizeGesture diff --git a/service/subscriber/test/key_subscriber_handler_test.cpp b/service/subscriber/test/key_subscriber_handler_test.cpp index 9346f8a212233dce3f485dab512b6d1932c47610..4bdbd7d36c10af988e61f6102873516dc67a5605 100644 --- a/service/subscriber/test/key_subscriber_handler_test.cpp +++ b/service/subscriber/test/key_subscriber_handler_test.cpp @@ -21,7 +21,9 @@ #include "key_option.h" #include "key_subscriber_handler.h" #include "key_shortcut_manager.h" +#ifdef OHOS_BUILD_ENABLE_CALL_MANAGER #include "call_manager_client.h" +#endif // OHOS_BUILD_ENABLE_CALL_MANAGER #include "common_event_data.h" #include "common_event_manager.h" #include "common_event_support.h" @@ -32,6 +34,7 @@ #include "mmi_log.h" #include "nap_process.h" #include "switch_subscriber_handler.h" +#include "tablet_subscriber_handler.h" #include "uds_server.h" #include "want.h" #include "event_log_helper.h" @@ -762,6 +765,7 @@ HWTEST_F(KeySubscriberHandlerTest, KeySubscriberHandlerTest_PrintKeyOption_001, ASSERT_NO_FATAL_FAILURE(handler.PrintKeyOption(keyOption)); } +#ifdef OHOS_BUILD_ENABLE_CALL_MANAGER /** * @tc.name: KeySubscriberHandlerTest_HandleKeyUpWithDelay_002 * @tc.desc: Test HandleKeyUpWithDelay @@ -983,6 +987,7 @@ HWTEST_F(KeySubscriberHandlerTest, KeySubscriberHandlerTest_HandleRingMute_009, keyEvent->SetKeyCode(KeyEvent::KEYCODE_VOLUME_UP); ASSERT_FALSE(keySubscriberHandler.HandleRingMute(keyEvent)); } +#endif // OHOS_BUILD_ENABLE_CALL_MANAGER /** * @tc.name: KeySubscriberHandlerTest_SubscribeKeyEvent_002 @@ -1507,6 +1512,7 @@ HWTEST_F(KeySubscriberHandlerTest, KeySubscriberHandlerTest_IsRepeatedKeyEvent, ASSERT_FALSE(handler.IsRepeatedKeyEvent(keyEvent)); } +#ifdef OHOS_BUILD_ENABLE_CALL_MANAGER /** * @tc.name: KeySubscriberHandlerTest_HandleRingMute_010 * @tc.desc: Test the funcation HandleRingMute @@ -1542,6 +1548,7 @@ HWTEST_F(KeySubscriberHandlerTest, KeySubscriberHandlerTest_HandleRingMute_010, ret = handler.HandleRingMute(keyEvent); ASSERT_FALSE(ret); } +#endif // OHOS_BUILD_ENABLE_CALL_MANAGER /** * @tc.name: KeySubscriberHandlerTest_OnSubscribeKeyEvent_002 @@ -1817,6 +1824,8 @@ HWTEST_F(KeySubscriberHandlerTest, KeySubscriberHandlerTest_HandleKeyUp_004, Tes bool ret = handler.HandleKeyUp(keyEvent); ASSERT_FALSE(ret); } + +#ifdef OHOS_BUILD_ENABLE_CALL_MANAGER /** * @tc.name: KeySubscriberHandlerTest_HandleRingMute_01 * @tc.desc: Test the funcation HandleRingMute @@ -2070,6 +2079,7 @@ HWTEST_F(KeySubscriberHandlerTest, KeySubscriberHandlerTest_HandleRingMute_11, T keyEvent->keyCode_ = KeyEvent::KEYCODE_POWER; ASSERT_FALSE(keySubscriberHandler.HandleRingMute(keyEvent)); } +#endif // OHOS_BUILD_ENABLE_CALL_MANAGER /** * @tc.name: KeySubscriberHandlerTest_AddKeyGestureSubscriber_01 @@ -2681,6 +2691,7 @@ HWTEST_F(KeySubscriberHandlerTest, KeySubscriberHandlerTest_InitDataShareListene EXPECT_NO_FATAL_FAILURE(handler.InitDataShareListener()); } +#ifdef OHOS_BUILD_ENABLE_CALL_MANAGER /** * @tc.name: KeySubscriberHandlerTest_RejectCallProcess * @tc.desc: Test RejectCallProcess @@ -2767,6 +2778,7 @@ HWTEST_F(KeySubscriberHandlerTest, KeySubscriberHandlerTest_RemoveSubscriberTime } EXPECT_NO_FATAL_FAILURE(handler.RemoveSubscriberTimer(keyEvent)); } +#endif // OHOS_BUILD_ENABLE_CALL_MANAGER /** * @tc.name: KeySubscriberHandlerTest_RemoveSubscriberKeyUpTimer @@ -2926,6 +2938,7 @@ HWTEST_F(KeySubscriberHandlerTest, KeySubscriberHandlerTest_UnsubscribeHotkey, T ASSERT_NE(handler.UnsubscribeHotkey(session, subscribeId), RET_ERR); } +#ifdef OHOS_BUILD_ENABLE_CALL_MANAGER /** * @tc.name: KeySubscriberHandlerTest_HandleCallEnded * @tc.desc: Test HandleCallEnded @@ -2998,6 +3011,7 @@ HWTEST_F(KeySubscriberHandlerTest, KeySubscriberHandlerTest_HandleCallEnded002, ret = handler.HandleCallEnded(keyEvent); ASSERT_FALSE(ret); } +#endif // OHOS_BUILD_ENABLE_CALL_MANAGER /** * @tc.name: KeySubscriberHandlerTest_RemoveSubscriberKeyUpTimer @@ -3156,6 +3170,7 @@ HWTEST_F(KeySubscriberHandlerTest, KeySubscriberHandlerTest_InterceptByVm_002, T ASSERT_NO_FATAL_FAILURE(handler.InterceptByVm(keyEvent)); } +#ifdef OHOS_BUILD_ENABLE_CALL_MANAGER /** * @tc.name: KeySubscriberHandlerTest_HandleRingMute_011 * @tc.desc: Test ring mute @@ -3205,6 +3220,7 @@ HWTEST_F(KeySubscriberHandlerTest, KeySubscriberHandlerTest_HandleRingMute_012, result = keySubscriberHandler.HandleRingMute(keyEvent); ASSERT_FALSE(DEVICE_MONITOR->GetHasHandleRingMute()); } +#endif // OHOS_BUILD_ENABLE_CALL_MANAGER /** @@ -3383,5 +3399,85 @@ HWTEST_F(KeySubscriberHandlerTest, KeySubscriberHandlerTest_AddTimer_005, TestSi ASSERT_FALSE(ret); ASSERT_FALSE(handler.CloneKeyEvent(keyEvent)); } + +/** + * @tc.name: KeySubscriberHandlerTest_ClearTimer + * @tc.desc: Test the funcation ClearTimer + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeySubscriberHandlerTest, KeySubscriberHandlerTest_ClearTimer, TestSize.Level1) +{ + CALL_TEST_DEBUG; + KeySubscriberHandler handler; + int32_t id = 1; + SessionPtr session = std::make_shared(PROGRAM_NAME, MODULE_TYPE, UDS_FD, UDS_UID, UDS_PID); + std::shared_ptr keyOption = std::make_shared(); + auto subscriber = std::make_shared(id, session, keyOption); + subscriber->timerId_ = 0; + std::shared_ptr keyEvent = KeyEvent::Create(); + subscriber->keyEvent_ = keyEvent; + handler.AddTimer(subscriber, keyEvent); + ASSERT_NO_FATAL_FAILURE(handler.ClearTimer(subscriber)); +} + +/** + * @tc.name: TabletSubscriberHandlerTest_SubscribeTabletProximity + * @tc.desc: Test the funcation AboutSubscribeTabletProximity + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeySubscriberHandlerTest, TabletSubscriberHandlerTest_SubscribeTabletProximity, TestSize.Level1) +{ + CALL_TEST_DEBUG; + auto tabletSubscriberHandler = TABLET_SCRIBER_HANDLER; + SessionPtr sess; + ASSERT_NO_FATAL_FAILURE(tabletSubscriberHandler->SubscribeTabletProximity(sess, 0)); + ASSERT_NO_FATAL_FAILURE(tabletSubscriberHandler->SubscribeTabletProximity(sess, -1)); + ASSERT_NO_FATAL_FAILURE(tabletSubscriberHandler->SubscribeTabletProximity(sess, 1)); + ASSERT_NO_FATAL_FAILURE(tabletSubscriberHandler->SubscribeTabletProximity(sess, 0)); + ASSERT_NO_FATAL_FAILURE(tabletSubscriberHandler->SubscribeTabletProximity(nullptr, 0)); + ASSERT_NO_FATAL_FAILURE(tabletSubscriberHandler->UnsubscribetabletProximity(nullptr, 0)); + ASSERT_NO_FATAL_FAILURE(tabletSubscriberHandler->UnsubscribetabletProximity(nullptr, -1)); + ASSERT_NO_FATAL_FAILURE(tabletSubscriberHandler->UnsubscribetabletProximity(sess, 0)); +} + +/** + * @tc.name: TabletSubscriberHandlerTest_OnSubscribeTabletProximity + * @tc.desc: Test the funcation OnSubscribeTabletProximity + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeySubscriberHandlerTest, TabletSubscriberHandlerTest_OnSubscribeTabletProximity, TestSize.Level1) +{ + CALL_TEST_DEBUG; + auto tabletSubscriberHandler = TABLET_SCRIBER_HANDLER; + SessionPtr sess; + tabletSubscriberHandler->SubscribeTabletProximity(sess, 0); + auto pointerEvent = std::make_shared(0); + ASSERT_NO_FATAL_FAILURE(tabletSubscriberHandler->OnSubscribeTabletProximity(pointerEvent)); + auto pointerEvent2 = std::make_shared(PointerEvent::POINTER_ACTION_PROXIMITY_OUT); + ASSERT_NO_FATAL_FAILURE(tabletSubscriberHandler->OnSubscribeTabletProximity(pointerEvent2)); + auto pointerEvent3 = std::make_shared(PointerEvent::POINTER_ACTION_PROXIMITY_IN); + ASSERT_NO_FATAL_FAILURE(tabletSubscriberHandler->OnSubscribeTabletProximity(pointerEvent3)); +} + +/** + * @tc.name: TabletSubscriberHandlerTest_OnSessionDelete + * @tc.desc: Test the funcation OnSessionDelete + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(KeySubscriberHandlerTest, TabletSubscriberHandlerTest_OnSessionDelete, TestSize.Level1) +{ + CALL_TEST_DEBUG; + auto tabletSubscriberHandler = TABLET_SCRIBER_HANDLER; + SessionPtr sess; + SessionPtr sess2; + tabletSubscriberHandler->SubscribeTabletProximity(sess, 0); + tabletSubscriberHandler->SubscribeTabletProximity(sess2, 0); + ASSERT_NO_FATAL_FAILURE(tabletSubscriberHandler->OnSessionDelete(sess)); + ASSERT_NO_FATAL_FAILURE(tabletSubscriberHandler->OnSessionDelete(sess)); +} } // namespace MMI } // namespace OHOS diff --git a/service/touch_event_normalize/src/gesture_transform_processor.cpp b/service/touch_event_normalize/src/gesture_transform_processor.cpp index e78d5a8d8af17cf94e1177662f693092dd36df48..09ee222ca2d5bd4899bac75d839e1945662c63cf 100644 --- a/service/touch_event_normalize/src/gesture_transform_processor.cpp +++ b/service/touch_event_normalize/src/gesture_transform_processor.cpp @@ -41,6 +41,8 @@ void GestureTransformProcessor::OnEventTouchPadPinchBegin(libinput_event_gesture pointerItem.SetDownTime(time); pointerItem.SetDisplayX(MouseState->GetMouseCoordsX()); pointerItem.SetDisplayY(MouseState->GetMouseCoordsY()); + pointerItem.SetDisplayXPos(MouseState->GetMouseCoordsX()); + pointerItem.SetDisplayYPos(MouseState->GetMouseCoordsY()); pointerItem.SetDeviceId(deviceId_); pointerItem.SetPointerId(defaultPointerId); pointerItem.SetWidth(0); @@ -74,6 +76,8 @@ void GestureTransformProcessor::OnEventTouchPadPinchUpdate(libinput_event_gestur pointerEvent_->GetPointerItem(defaultPointerId, pointerItem); pointerItem.SetDisplayX(MouseState->GetMouseCoordsX()); pointerItem.SetDisplayY(MouseState->GetMouseCoordsY()); + pointerItem.SetDisplayXPos(MouseState->GetMouseCoordsX()); + pointerItem.SetDisplayYPos(MouseState->GetMouseCoordsY()); pointerItem.SetPressed(MouseState->IsLeftBtnPressed()); pointerEvent_->UpdatePointerItem(defaultPointerId, pointerItem); @@ -99,6 +103,8 @@ void GestureTransformProcessor::OnEventTouchPadPinchEnd(libinput_event_gesture * pointerEvent_->GetPointerItem(defaultPointerId, pointerItem); pointerItem.SetDisplayX(MouseState->GetMouseCoordsX()); pointerItem.SetDisplayY(MouseState->GetMouseCoordsY()); + pointerItem.SetDisplayXPos(MouseState->GetMouseCoordsX()); + pointerItem.SetDisplayYPos(MouseState->GetMouseCoordsY()); pointerItem.SetPressed(MouseState->IsLeftBtnPressed()); pointerEvent_->UpdatePointerItem(defaultPointerId, pointerItem); diff --git a/service/touch_event_normalize/src/remote_control_transform_processor.cpp b/service/touch_event_normalize/src/remote_control_transform_processor.cpp index f2771b0a345e0c618ba7c8b5387427076035bc52..18e6af7187bde7d162c2adfc57d14639932793ff 100644 --- a/service/touch_event_normalize/src/remote_control_transform_processor.cpp +++ b/service/touch_event_normalize/src/remote_control_transform_processor.cpp @@ -131,8 +131,12 @@ bool Remote_ControlTransformProcessor::HandlePostInner(struct libinput_event* ev PointerEvent::PointerItem pointerItem; pointerItem.SetDisplayX(mouseInfo.physicalX); pointerItem.SetDisplayY(mouseInfo.physicalY); + pointerItem.SetDisplayXPos(mouseInfo.physicalX); + pointerItem.SetDisplayYPos(mouseInfo.physicalY); pointerItem.SetWindowX(0); pointerItem.SetWindowY(0); + pointerItem.SetWindowXPos(0.0); + pointerItem.SetWindowYPos(0.0); pointerItem.SetPointerId(0); pointerItem.SetPressed(isPressed_); diff --git a/service/touch_event_normalize/src/touchpad_transform_processor.cpp b/service/touch_event_normalize/src/touchpad_transform_processor.cpp index 5a5d7c691613d1c172d86d6d01835ecdc6057f92..510b05e33c8ff61c4b4f498ced173c40fb923aca 100644 --- a/service/touch_event_normalize/src/touchpad_transform_processor.cpp +++ b/service/touch_event_normalize/src/touchpad_transform_processor.cpp @@ -94,6 +94,8 @@ int32_t TouchPadTransformProcessor::OnEventTouchPadDown(struct libinput_event *e item.SetPressed(true); item.SetDisplayX(static_cast(logicalX)); item.SetDisplayY(static_cast(logicalY)); + item.SetDisplayXPos(logicalX); + item.SetDisplayYPos(logicalY); item.SetToolDisplayX(static_cast(toolPhysicalX)); item.SetToolDisplayY(static_cast(toolPhysicalY)); item.SetToolWidth(static_cast(toolWidth)); @@ -145,6 +147,8 @@ int32_t TouchPadTransformProcessor::OnEventTouchPadMotion(struct libinput_event item.SetPressure(pressure); item.SetDisplayX(static_cast(logicalX)); item.SetDisplayY(static_cast(logicalY)); + item.SetDisplayXPos(logicalX); + item.SetDisplayYPos(logicalY); item.SetToolDisplayX(static_cast(toolPhysicalX)); item.SetToolDisplayY(static_cast(toolPhysicalY)); item.SetToolWidth(static_cast(toolWidth)); @@ -364,6 +368,8 @@ int32_t TouchPadTransformProcessor::AddItemForEventWhileSetSwipeData(int64_t tim pointerItem.SetDownTime(time); pointerItem.SetDisplayX(avgCoord.x); pointerItem.SetDisplayY(avgCoord.y); + pointerItem.SetDisplayXPos(avgCoord.x); + pointerItem.SetDisplayYPos(avgCoord.y); pointerItem.SetDeviceId(deviceId_); pointerItem.SetPointerId(DEFAULT_POINTER_ID); pointerEvent_->SetPointerId(DEFAULT_POINTER_ID); @@ -459,9 +465,13 @@ void TouchPadTransformProcessor::SetPinchPointerItem(int64_t time) pointerItem.SetPointerId(DEFAULT_POINTER_ID); pointerItem.SetWindowX(0); pointerItem.SetWindowY(0); + pointerItem.SetWindowXPos(0.0); + pointerItem.SetWindowYPos(0.0); auto mouseInfo = WIN_MGR->GetMouseInfo(); pointerItem.SetDisplayX(mouseInfo.physicalX); pointerItem.SetDisplayY(mouseInfo.physicalY); + pointerItem.SetDisplayXPos(mouseInfo.physicalX); + pointerItem.SetDisplayYPos(mouseInfo.physicalY); pointerItem.SetToolType(PointerEvent::TOOL_TYPE_TOUCHPAD); RemoveSurplusPointerItem(); pointerEvent_->UpdatePointerItem(DEFAULT_POINTER_ID, pointerItem); diff --git a/service/touch_event_normalize/test/BUILD.gn b/service/touch_event_normalize/test/BUILD.gn index 62894d40a5ce76ec0d59749a0f9a67b3fd12052b..faf3aad43a414f9a429dc4089db678c99d462409 100644 --- a/service/touch_event_normalize/test/BUILD.gn +++ b/service/touch_event_normalize/test/BUILD.gn @@ -183,7 +183,6 @@ ohos_unittest("GestureTransformTest") { "ability_runtime:dataobs_manager", "cJSON:cjson", "c_utils:utils", - "call_manager:tel_call_manager_api", "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", "data_share:datashare_consumer", @@ -208,6 +207,10 @@ ohos_unittest("GestureTransformTest") { "window_manager:libwsutils", ] + if (call_manager_service_enabled) { + external_deps += ["call_manager:tel_call_manager_api"] + } + if (hitrace_enabled) { external_deps += [ "hitrace:hitrace_meter" ] } @@ -345,7 +348,6 @@ ohos_unittest("TabletToolTranformTest") { "ability_runtime:dataobs_manager", "cJSON:cjson", "c_utils:utils", - "call_manager:tel_call_manager_api", "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", "data_share:datashare_consumer", @@ -374,6 +376,10 @@ ohos_unittest("TabletToolTranformTest") { external_deps += [ "hitrace:hitrace_meter" ] } + if (call_manager_service_enabled) { + external_deps += ["call_manager:tel_call_manager_api"] + } + if (input_ext_feature_magiccursor) { external_deps += [ "eventhandler:libeventhandler", @@ -540,7 +546,6 @@ ohos_unittest("TouchTransformProcessorTestWithMock") { "ability_runtime:dataobs_manager", "cJSON:cjson", "c_utils:utils", - "call_manager:tel_call_manager_api", "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", "data_share:datashare_consumer", @@ -580,6 +585,10 @@ ohos_unittest("TouchTransformProcessorTestWithMock") { ] } + if (call_manager_service_enabled) { + external_deps += ["call_manager:tel_call_manager_api"] + } + if (input_feature_combination_key) { external_deps += [ "sensor:sensor_interface_native" ] } @@ -696,7 +705,6 @@ ohos_unittest("TouchpadGestureTest") { "ability_runtime:dataobs_manager", "cJSON:cjson", "c_utils:utils", - "call_manager:tel_call_manager_api", "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", "data_share:datashare_consumer", @@ -725,6 +733,10 @@ ohos_unittest("TouchpadGestureTest") { external_deps += [ "hitrace:hitrace_meter" ] } + if (call_manager_service_enabled) { + external_deps += ["call_manager:tel_call_manager_api"] + } + if (input_ext_feature_magiccursor) { external_deps += [ "eventhandler:libeventhandler", @@ -849,7 +861,6 @@ ohos_unittest("TouchPadTransformProcessorMockTest") { "ability_runtime:dataobs_manager", "cJSON:cjson", "c_utils:utils", - "call_manager:tel_call_manager_api", "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", "data_share:datashare_consumer", @@ -877,6 +888,10 @@ ohos_unittest("TouchPadTransformProcessorMockTest") { "window_manager:libwsutils", ] + if (call_manager_service_enabled) { + external_deps += ["call_manager:tel_call_manager_api"] + } + if (hitrace_enabled) { external_deps += [ "hitrace:hitrace_meter" ] } diff --git a/service/window_manager/include/input_windows_manager.h b/service/window_manager/include/input_windows_manager.h index 100f49386c18f7d7052318b32ee12fb2d01ef8fc..f73a192407d61634622a14607ae2a78f6eaa7c9c 100644 --- a/service/window_manager/include/input_windows_manager.h +++ b/service/window_manager/include/input_windows_manager.h @@ -231,6 +231,7 @@ public: bool IsMouseInCastWindow(); bool IsCaptureMode(); #endif // OHOS_BUILD_ENABLE_VKEYBOARD + int32_t GetFocusPid(); private: bool NeedTouchTracking(PointerEvent &event) const; @@ -276,9 +277,9 @@ private: bool ParseConfig(); bool ParseJson(const std::string &configFile); #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) - void SendUIExtentionPointerEvent(int32_t logicalX, int32_t logicalY, + void SendUIExtentionPointerEvent(double logicalX, double logicalY, const WindowInfo& windowInfo, std::shared_ptr pointerEvent); - void DispatchUIExtentionPointerEvent(int32_t logicalX, int32_t logicalY, + void DispatchUIExtentionPointerEvent(double logicalX, double logicalY, std::shared_ptr pointerEvent); #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #ifdef OHOS_BUILD_ENABLE_POINTER @@ -426,6 +427,7 @@ void HandleOneHandMode(const DisplayInfo &displayInfo, std::shared_ptr GetWindowInfoById(int32_t windowId) const; int32_t ShiftAppMousePointerEvent(const ShiftWindowInfo &shiftWindowInfo, bool autoGenDown); int32_t ShiftAppTouchPointerEvent(const ShiftWindowInfo &shiftWindowInfo); + int32_t ShiftAppSimulateTouchPointerEvent(const ShiftWindowInfo &shiftWindowInfo); CursorPosition GetCursorPos(const DisplayGroupInfo &displayGroupInfo); CursorPosition ResetCursorPos(const DisplayGroupInfo &displayGroupInfo); #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH @@ -484,6 +486,7 @@ private: PointerStyle lastPointerStyle_; PointerStyle dragPointerStyle_; MouseLocation mouseLocation_ = { -1, 0, 0 }; + WindowInfo lockWindowInfo_; std::map mouseLocationMap_; CursorPosition cursorPos_ {}; diff --git a/service/window_manager/src/input_windows_manager.cpp b/service/window_manager/src/input_windows_manager.cpp index 0a0a80ac3b086e2f6b515b86b9fa268aecc49231..d13b3b3901f51bc3bbab0f54e6580c605950acdd 100644 --- a/service/window_manager/src/input_windows_manager.cpp +++ b/service/window_manager/src/input_windows_manager.cpp @@ -99,9 +99,7 @@ constexpr uint32_t GUIDE_WINDOW_TYPE { 2500 }; #define SCREEN_RECORD_WINDOW_WIDTH 400 #define SCREEN_RECORD_WINDOW_HEIGHT 200 #endif // OHOS_BUILD_ENABLE_VKEYBOARD -#ifdef OHOS_BUILD_ENABLE_HARDWARE_CURSOR constexpr uint32_t CURSOR_POSITION_EXPECTED_SIZE { 2 }; -#endif // OHOS_BUILD_ENABLE_HARDWARE_CURSOR } // namespace enum PointerHotArea : int32_t { @@ -786,14 +784,14 @@ std::vector> InputWindowsManager::GetPidAndUpdate int32_t groupId = FindDisplayGroupId(keyEvent->GetTargetDisplayId()); const int32_t focusWindowId = GetFocusWindowId(groupId); if (GetHardCursorEnabled()) { - UpdateKeyEventDisplayId(keyEvent, focusWindowId_); + UpdateKeyEventDisplayId(keyEvent, focusWindowId); } WindowInfo* windowInfo = nullptr; std::vector windowsInfo = GetWindowGroupInfoByDisplayId(keyEvent->GetTargetDisplayId()); bool isUIExtention = false; auto iter = windowsInfo.begin(); for (; iter != windowsInfo.end(); ++iter) { - if (iter->id == focusWindowId_) { + if (iter->id == focusWindowId) { windowInfo = &(*iter); if (!iter->uiExtentionWindowInfo.empty() && !IsOnTheWhitelist(keyEvent)) { isUIExtention = true; @@ -1226,6 +1224,8 @@ void InputWindowsManager::SendBackCenterPointerEevent(const CursorPosition &curs pointerBackCenterEvent->GetPointerItem(pointerId, item); item.SetDisplayX(cursorPos.cursorPos.x); item.SetDisplayY(cursorPos.cursorPos.y); + item.SetDisplayXPos(cursorPos.cursorPos.x); + item.SetDisplayYPos(cursorPos.cursorPos.y); item.SetCanceled(true); pointerBackCenterEvent->UpdatePointerItem(pointerId, item); pointerBackCenterEvent->SetTargetWindowId(touchWindow->id); @@ -1838,7 +1838,7 @@ void InputWindowsManager::UpdateDisplayInfo(DisplayGroupInfo &displayGroupInfo) bFlag = (iter != pointerDrawFlagMap_.end()) ? true : false; if (!displayGroupInfo.displaysInfo.empty() && bFlag) { AdjustDisplayRotation(groupId); - if (GetHardCursorEnabled()) { + if (GetHardCursorEnabled()) { PointerDrawingManagerOnDisplayInfo(displayGroupInfo, isDisplayChanged); } else { PointerDrawingManagerOnDisplayInfo(displayGroupInfo); @@ -1933,6 +1933,8 @@ void InputWindowsManager::AdjustDragPosition(int32_t groupId) pointerEvent->GetPointerItem(pointerId, item); item.SetDisplayX(physicalX); item.SetDisplayY(physicalY); + item.SetDisplayXPos(physicalX); + item.SetDisplayYPos(physicalY); pointerEvent->UpdatePointerItem(pointerId, item); pointerEvent->SetTargetWindowId(touchWindow->id); pointerEvent->SetAgentWindowId(touchWindow->id); @@ -2264,8 +2266,12 @@ void InputWindowsManager::SetPointerEvent(int32_t pointerAction, std::shared_ptr PointerEvent::PointerItem currentPointerItem; currentPointerItem.SetWindowX(lastLogicX_- lastWindowInfo_.area.x); currentPointerItem.SetWindowY(lastLogicY_- lastWindowInfo_.area.y); + currentPointerItem.SetWindowXPos(lastLogicX_- lastWindowInfo_.area.x); + currentPointerItem.SetWindowYPos(lastLogicY_- lastWindowInfo_.area.y); currentPointerItem.SetDisplayX(lastPointerItem.GetDisplayX()); currentPointerItem.SetDisplayY(lastPointerItem.GetDisplayY()); + currentPointerItem.SetDisplayXPos(lastPointerItem.GetDisplayXPos()); + currentPointerItem.SetDisplayYPos(lastPointerItem.GetDisplayYPos()); currentPointerItem.SetPointerId(0); pointerEvent->SetTargetDisplayId(lastPointerEventCopy->GetTargetDisplayId()); SetPrivacyModeFlag(lastWindowInfo_.privacyMode, pointerEvent); @@ -2317,8 +2323,12 @@ void InputWindowsManager::SendPointerEvent(int32_t pointerAction) PointerEvent::PointerItem pointerItem; pointerItem.SetWindowX(lastLogicX_ - lastWindowInfo_.area.x); pointerItem.SetWindowY(lastLogicY_ - lastWindowInfo_.area.y); + pointerItem.SetWindowXPos(lastLogicX_ - lastWindowInfo_.area.x); + pointerItem.SetWindowYPos(lastLogicY_ - lastWindowInfo_.area.y); pointerItem.SetDisplayX(mouseLocation.physicalX); pointerItem.SetDisplayY(mouseLocation.physicalY); + pointerItem.SetDisplayXPos(mouseLocation.physicalX); + pointerItem.SetDisplayYPos(mouseLocation.physicalY); pointerItem.SetPointerId(0); pointerEvent->SetTargetDisplayId(-1); @@ -2400,6 +2410,8 @@ void InputWindowsManager::DispatchPointer(int32_t pointerAction, int32_t windowI PointerEvent::PointerItem currentPointerItem; currentPointerItem.SetWindowX(lastLogicX_ - lastWindowInfo_.area.x); currentPointerItem.SetWindowY(lastLogicY_ - lastWindowInfo_.area.y); + currentPointerItem.SetWindowXPos(lastLogicX_ - lastWindowInfo_.area.x); + currentPointerItem.SetWindowYPos(lastLogicY_ - lastWindowInfo_.area.y); if (pointerAction == PointerEvent::POINTER_ACTION_ENTER_WINDOW && windowId > 0) { auto displayGroupInfo = GetMainDisplayGroupInfo(); int32_t displayId = 0; @@ -2414,21 +2426,31 @@ void InputWindowsManager::DispatchPointer(int32_t pointerAction, int32_t windowI } currentPointerItem.SetDisplayX(cursorPosx); currentPointerItem.SetDisplayY(cursorPosy); + currentPointerItem.SetDisplayXPos(cursorPosx); + currentPointerItem.SetDisplayYPos(cursorPosy); pointerEvent->SetTargetDisplayId(displayId); if (IsMouseSimulate()) { currentPointerItem.SetWindowX(lastPointerItem.GetWindowX()); currentPointerItem.SetWindowY(lastPointerItem.GetWindowY()); + currentPointerItem.SetWindowXPos(lastPointerItem.GetWindowXPos()); + currentPointerItem.SetWindowYPos(lastPointerItem.GetWindowYPos()); currentPointerItem.SetDisplayX(lastPointerItem.GetDisplayX()); currentPointerItem.SetDisplayY(lastPointerItem.GetDisplayY()); + currentPointerItem.SetDisplayXPos(lastPointerItem.GetDisplayXPos()); + currentPointerItem.SetDisplayYPos(lastPointerItem.GetDisplayYPos()); pointerEvent->SetTargetDisplayId(lastPointerEventCopy->GetTargetDisplayId()); } } else { if (IsMouseSimulate()) { currentPointerItem.SetWindowX(lastPointerItem.GetWindowX()); currentPointerItem.SetWindowY(lastPointerItem.GetWindowY()); + currentPointerItem.SetWindowXPos(lastPointerItem.GetWindowXPos()); + currentPointerItem.SetWindowYPos(lastPointerItem.GetWindowYPos()); } currentPointerItem.SetDisplayX(lastPointerItem.GetDisplayX()); currentPointerItem.SetDisplayY(lastPointerItem.GetDisplayY()); + currentPointerItem.SetDisplayXPos(lastPointerItem.GetDisplayXPos()); + currentPointerItem.SetDisplayYPos(lastPointerItem.GetDisplayYPos()); pointerEvent->SetTargetDisplayId(lastPointerEventCopy->GetTargetDisplayId()); } currentPointerItem.SetPointerId(0); @@ -4186,13 +4208,15 @@ int32_t InputWindowsManager::UpdateMouseTarget(std::shared_ptr poi } if (GetHardCursorEnabled()) { std::vector cursorPos = HandleHardwareCursor(physicalDisplayInfo, physicalX, physicalY); - if (cursorPos.empty()) { - MMI_HILOGW("cursorPos is empty"); + if (cursorPos.size() < CURSOR_POSITION_EXPECTED_SIZE) { + MMI_HILOGW("cursorPos is invalid"); return RET_ERR; } - IPointerDrawingManager::GetInstance()->DrawMovePointer(displayId, cursorPos[0], cursorPos[1]); + IPointerDrawingManager::GetInstance()->DrawMovePointer(physicalDisplayInfo->uniqueId, + cursorPos[0], cursorPos[1]); } else { - IPointerDrawingManager::GetInstance()->DrawMovePointer(displayId, physicalX, physicalY); + IPointerDrawingManager::GetInstance()->DrawMovePointer(physicalDisplayInfo->uniqueId, + physicalX, physicalY); } MMI_HILOGI("UpdateMouseTarget id:%{public}d, logicalX:%{public}d, logicalY:%{public}d," "displayX:%{public}d, displayY:%{public}d", physicalDisplayInfo->uniqueId, logicalX, logicalY, @@ -4351,15 +4375,15 @@ int32_t InputWindowsManager::UpdateMouseTarget(std::shared_ptr poi pointerEvent->SetTargetWindowId(touchWindow->id); pointerEvent->SetAgentWindowId(touchWindow->agentWindowId); DispatchUIExtentionPointerEvent(logicalX, logicalY, pointerEvent); - auto windowX = logicalX - touchWindow->area.x; - auto windowY = logicalY - touchWindow->area.y; + double windowX = logicalX - touchWindow->area.x; + double windowY = logicalY - touchWindow->area.y; if (!(touchWindow->transform.empty())) { auto windowXY = TransformWindowXY(*touchWindow, logicalX, logicalY); } - windowX = static_cast(windowX); - windowY = static_cast(windowY); - pointerItem.SetWindowX(windowX); - pointerItem.SetWindowY(windowY); + pointerItem.SetWindowX(static_cast(windowX)); + pointerItem.SetWindowY(static_cast(windowY)); + pointerItem.SetWindowXPos(windowX); + pointerItem.SetWindowYPos(windowY); pointerEvent->UpdatePointerItem(pointerId, pointerItem); if ((extraData_.appended && (extraData_.sourceType == PointerEvent::SOURCE_TYPE_MOUSE)) || (pointerEvent->GetPointerAction() == PointerEvent::POINTER_ACTION_PULL_UP)) { @@ -4413,14 +4437,14 @@ int32_t InputWindowsManager::UpdateMouseTarget(std::shared_ptr poi "logicalX:%{public}d, logicalY:%{public}d," "displayX:%{public}d, displayY:%{public}d, windowX:%{public}d, windowY:%{public}d", isUiExtension_ ? uiExtensionPid_ : touchWindow->pid, isUiExtension_ ? uiExtensionWindowId_ : - touchWindow->id, touchWindow->agentWindowId, - logicalX, logicalY, pointerItem.GetDisplayX(), pointerItem.GetDisplayY(), windowX, windowY); + touchWindow->id, touchWindow->agentWindowId, logicalX, logicalY, + pointerItem.GetDisplayX(), pointerItem.GetDisplayY(), pointerItem.GetWindowX(), pointerItem.GetWindowY()); } else { MMI_HILOGD("pid:%{public}d, id:%{public}d, agentWindowId:%{public}d," "logicalX:%d, logicalY:%d,displayX:%d, displayY:%d, windowX:%d, windowY:%d", isUiExtension_ ? uiExtensionPid_ : touchWindow->pid, isUiExtension_ ? uiExtensionWindowId_ : - touchWindow->id, touchWindow->agentWindowId, - logicalX, logicalY, pointerItem.GetDisplayX(), pointerItem.GetDisplayY(), windowX, windowY); + touchWindow->id, touchWindow->agentWindowId, logicalX, logicalY, + pointerItem.GetDisplayX(), pointerItem.GetDisplayY(), pointerItem.GetWindowX(), pointerItem.GetWindowY()); } if (pointerEvent->GetPointerAction() == PointerEvent::POINTER_ACTION_PULL_UP) { MMI_HILOGD("Clear extra data"); @@ -4752,7 +4776,7 @@ void InputWindowsManager::UpdateTransformDisplayXY(std::shared_ptr #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) -void InputWindowsManager::SendUIExtentionPointerEvent(int32_t logicalX, int32_t logicalY, +void InputWindowsManager::SendUIExtentionPointerEvent(double logicalX, double logicalY, const WindowInfo& windowInfo, std::shared_ptr pointerEvent) { MMI_HILOG_DISPATCHI("Dispatch uiExtention pointer Event,pid:%{public}d", windowInfo.pid); @@ -4763,8 +4787,8 @@ void InputWindowsManager::SendUIExtentionPointerEvent(int32_t logicalX, int32_t MMI_HILOG_DISPATCHE("Can't find pointer item, pointer:%{public}d", pointerId); return; } - auto windowX = logicalX - windowInfo.area.x; - auto windowY = logicalY - windowInfo.area.y; + double windowX = logicalX - windowInfo.area.x; + double windowY = logicalY - windowInfo.area.y; if (!(windowInfo.transform.empty())) { auto windowXY = TransformWindowXY(windowInfo, logicalX, logicalY); windowX = windowXY.first; @@ -4776,8 +4800,12 @@ void InputWindowsManager::SendUIExtentionPointerEvent(int32_t logicalX, int32_t double physicalY = logicalY - DisplayInfoY; pointerItem.SetDisplayX(static_cast(physicalX)); pointerItem.SetDisplayY(static_cast(physicalY)); + pointerItem.SetDisplayXPos(physicalX); + pointerItem.SetDisplayYPos(physicalY); pointerItem.SetWindowX(static_cast(windowX)); pointerItem.SetWindowY(static_cast(windowY)); + pointerItem.SetWindowXPos(windowX); + pointerItem.SetWindowYPos(windowY); pointerItem.SetTargetWindowId(windowInfo.id); pointerEvent->UpdatePointerItem(pointerId, pointerItem); auto fd = udsServer_->GetClientFd(windowInfo.pid); @@ -4791,7 +4819,7 @@ void InputWindowsManager::SendUIExtentionPointerEvent(int32_t logicalX, int32_t } } -void InputWindowsManager::DispatchUIExtentionPointerEvent(int32_t logicalX, int32_t logicalY, +void InputWindowsManager::DispatchUIExtentionPointerEvent(double logicalX, double logicalY, std::shared_ptr pointerEvent) { auto displayId = pointerEvent->GetTargetDisplayId(); @@ -4950,7 +4978,7 @@ int32_t InputWindowsManager::UpdateTouchScreenTarget(std::shared_ptrGetAllPointerItems().size() == 1 && !checkToolType && pointerEvent->GetFixedMode() == PointerEvent::FixedMode::AUTO) || (pointerEvent->GetPointerAction() == PointerEvent::POINTER_ACTION_PULL_UP); - if (isSlidTouch) { + if (isSlidTouch && lockWindowInfo_.windowInputType == WindowInputType::SLID_TOUCH_WINDOW) { if (IsInHotArea(static_cast(logicalX), static_cast(logicalY), item.defaultHotAreas, item)) { UpdateTargetTouchWinIds(item, pointerItem, pointerEvent, pointerId, displayId); @@ -5064,6 +5092,10 @@ int32_t InputWindowsManager::UpdateTouchScreenTarget(std::shared_ptrGetPointerAction() == PointerEvent::POINTER_ACTION_DOWN) { + lockWindowInfo_ = *touchWindow; + MMI_HILOG_DISPATCHD("lockWid:%{public}d, lockPid:%{public}d", lockWindowInfo_.id, lockWindowInfo_.pid); + } pointerEvent->SetTargetWindowId(touchWindow->id); pointerItem.SetTargetWindowId(touchWindow->id); #ifdef OHOS_BUILD_ENABLE_ANCO @@ -5145,8 +5177,8 @@ int32_t InputWindowsManager::UpdateTouchScreenTarget(std::shared_ptr(*pointerEvent); } } - auto windowX = logicalX - touchWindow->area.x; - auto windowY = logicalY - touchWindow->area.y; + double windowX = logicalX - touchWindow->area.x; + double windowY = logicalY - touchWindow->area.y; if (!(touchWindow->transform.empty())) { auto windowXY = TransformWindowXY(*touchWindow, logicalX, logicalY); windowX = windowXY.first; @@ -5422,28 +5454,30 @@ void InputWindowsManager::DispatchTouch(int32_t pointerAction, int32_t groupId) } PointerEvent::PointerItem currentPointerItem; bool isOneHand = lastTouchEvent_->GetFixedMode() == PointerEvent::FixedMode::AUTO; - int32_t windowX = isOneHand ? lastWinX_ : (lastTouchLogicX_ - lastTouchWindowInfo_.area.x); - int32_t windowY = isOneHand ? lastWinY_ : (lastTouchLogicY_ - lastTouchWindowInfo_.area.y); + double windowX = isOneHand ? lastWinX_ : (lastTouchLogicX_ - lastTouchWindowInfo_.area.x); + double windowY = isOneHand ? lastWinY_ : (lastTouchLogicY_ - lastTouchWindowInfo_.area.y); if (isOneHand) { WindowInputType windowInputType = lastTouchWindowInfo_.windowInputType; if (windowInputType != WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE && windowInputType != WindowInputType::MIX_BUTTOM_ANTI_AXIS_MOVE) { if (!(lastTouchWindowInfo_.transform.empty())) { auto windowXY = TransformWindowXY(lastTouchWindowInfo_, lastTouchLogicX_, lastTouchLogicY_); - windowX = static_cast(windowXY.first); - windowY = static_cast(windowXY.second); + windowX = windowXY.first; + windowY = windowXY.second; } currentPointerItem.SetFixedDisplayX(lastPointerItem.GetFixedDisplayX()); currentPointerItem.SetFixedDisplayY(lastPointerItem.GetFixedDisplayY()); pointerEvent->SetFixedMode(PointerEvent::FixedMode::AUTO); } } - currentPointerItem.SetWindowX(windowX); - currentPointerItem.SetWindowY(windowY); - currentPointerItem.SetWindowXPos(static_cast(windowX)); - currentPointerItem.SetWindowYPos(static_cast(windowY)); + currentPointerItem.SetWindowX(static_cast(windowX)); + currentPointerItem.SetWindowY(static_cast(windowY)); + currentPointerItem.SetWindowXPos(windowX); + currentPointerItem.SetWindowYPos(windowY); currentPointerItem.SetDisplayX(lastPointerItem.GetDisplayX()); currentPointerItem.SetDisplayY(lastPointerItem.GetDisplayY()); + currentPointerItem.SetDisplayXPos(lastPointerItem.GetDisplayXPos()); + currentPointerItem.SetDisplayYPos(lastPointerItem.GetDisplayYPos()); currentPointerItem.SetPressed(lastPointerItem.IsPressed()); currentPointerItem.SetPointerId(lastPointerId); @@ -6947,6 +6981,8 @@ int32_t InputWindowsManager::ShiftAppMousePointerEvent(const ShiftWindowInfo &sh pointerEvent->GetPointerItem(pointerId, item); item.SetWindowX(lastLogicX_ - sourceWindowInfo.area.x); item.SetWindowY(lastLogicY_ - sourceWindowInfo.area.y); + item.SetWindowXPos(lastLogicX_ - sourceWindowInfo.area.x); + item.SetWindowYPos(lastLogicY_ - sourceWindowInfo.area.y); item.SetPressed(false); pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE); pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP); @@ -6960,9 +6996,13 @@ int32_t InputWindowsManager::ShiftAppMousePointerEvent(const ShiftWindowInfo &sh if (autoGenDown) { item.SetWindowX(shiftWindowInfo.x); item.SetWindowY(shiftWindowInfo.y); + item.SetWindowXPos(shiftWindowInfo.x); + item.SetWindowYPos(shiftWindowInfo.y); if (shiftWindowInfo.x == -1 && shiftWindowInfo.y == -1) { item.SetWindowX(lastLogicX_ - targetWindowInfo.area.x); item.SetWindowY(lastLogicY_ - targetWindowInfo.area.y); + item.SetWindowXPos(lastLogicX_ - targetWindowInfo.area.x); + item.SetWindowYPos(lastLogicY_ - targetWindowInfo.area.y); } item.SetPressed(true); pointerEvent->ClearButtonPressed(); @@ -6982,17 +7022,14 @@ int32_t InputWindowsManager::ShiftAppMousePointerEvent(const ShiftWindowInfo &sh return RET_OK; } -int32_t InputWindowsManager::ShiftAppTouchPointerEvent(const ShiftWindowInfo &shiftWindowInfo) +int32_t InputWindowsManager::ShiftAppSimulateTouchPointerEvent(const ShiftWindowInfo &shiftWindowInfo) { CHKPR(lastTouchEvent_, RET_ERR); - if (shiftWindowInfo.fingerId == -1) { - MMI_HILOGE("Failed shift pointerEvent, fingerId is invalid"); - return RET_ERR; - } const WindowInfo &sourceWindowInfo = shiftWindowInfo.sourceWindowInfo; const WindowInfo &targetWindowInfo = shiftWindowInfo.targetWindowInfo; PointerEvent::PointerItem item; - if (!lastTouchEvent_->GetPointerItem(shiftWindowInfo.fingerId, item)) { + if (!lastTouchEvent_->GetPointerItem(shiftWindowInfo.fingerId, item) && + !lastTouchEvent_->GetOriginPointerItem(shiftWindowInfo.fingerId, item)) { MMI_HILOGE("Get pointer item failed"); return RET_ERR; } @@ -7002,6 +7039,8 @@ int32_t InputWindowsManager::ShiftAppTouchPointerEvent(const ShiftWindowInfo &sh } item.SetWindowX(lastTouchLogicX_ - sourceWindowInfo.area.x); item.SetWindowY(lastTouchLogicY_ - sourceWindowInfo.area.y); + item.SetWindowXPos(lastTouchLogicX_ - sourceWindowInfo.area.x); + item.SetWindowYPos(lastTouchLogicY_ - sourceWindowInfo.area.y); item.SetPressed(false); item.SetTargetWindowId(sourceWindowInfo.id); item.SetPointerId(shiftWindowInfo.fingerId); @@ -7011,36 +7050,49 @@ int32_t InputWindowsManager::ShiftAppTouchPointerEvent(const ShiftWindowInfo &sh lastTouchEvent_->SetTargetDisplayId(sourceWindowInfo.displayId); lastTouchEvent_->SetTargetWindowId(sourceWindowInfo.id); lastTouchEvent_->SetAgentWindowId(sourceWindowInfo.agentWindowId); - int64_t time = GetSysClockTime(); - lastTouchEvent_->SetActionTime(time); - lastTouchEvent_->SetActionStartTime(time); - LogTracer lt(lastTouchEvent_->GetId(), lastTouchEvent_->GetEventType(), lastTouchEvent_->GetPointerAction()); lastTouchEvent_->UpdateId(); ClearTargetWindowId(shiftWindowInfo.fingerId); lastTouchEvent_->UpdatePointerItem(shiftWindowInfo.fingerId, item); InputHandler->GetFilterHandler()->HandlePointerEvent(lastTouchEvent_); item.SetWindowX(shiftWindowInfo.x); item.SetWindowY(shiftWindowInfo.y); + item.SetWindowXPos(shiftWindowInfo.x); + item.SetWindowYPos(shiftWindowInfo.y); if (shiftWindowInfo.x == -1 && shiftWindowInfo.y == -1) { item.SetWindowX(lastTouchLogicX_ - targetWindowInfo.area.x); item.SetWindowY(lastTouchLogicY_ - targetWindowInfo.area.y); + item.SetWindowXPos(lastTouchLogicX_ - targetWindowInfo.area.x); + item.SetWindowYPos(lastTouchLogicY_ - targetWindowInfo.area.y); } item.SetPressed(true); item.SetTargetWindowId(targetWindowInfo.id); item.SetPointerId(shiftWindowInfo.fingerId); lastTouchEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN); lastTouchEvent_->SetTargetDisplayId(targetWindowInfo.displayId); - lastTouchEvent_->SetPointerId(shiftWindowInfo.fingerId);//??? + lastTouchEvent_->SetPointerId(shiftWindowInfo.fingerId); lastTouchEvent_->SetTargetWindowId(targetWindowInfo.id); lastTouchEvent_->SetAgentWindowId(targetWindowInfo.agentWindowId); lastTouchEvent_->UpdatePointerItem(shiftWindowInfo.fingerId, item); HITRACE_METER_NAME(HITRACE_TAG_MULTIMODALINPUT, "shift touch event dispatch down event"); - + InputHandler->GetFilterHandler()->HandlePointerEvent(lastTouchEvent_); + return RET_OK; +} + +int32_t InputWindowsManager::ShiftAppTouchPointerEvent(const ShiftWindowInfo &shiftWindowInfo) +{ + if (shiftWindowInfo.fingerId == -1) { + MMI_HILOGE("Failed shift touchpointerEvent, fingerId is invalid"); + return RET_ERR; + } + if (ShiftAppSimulateTouchPointerEvent(shiftWindowInfo) != RET_OK) { + MMI_HILOGE("Failed shift touchPointerEvent"); + return RET_ERR; + } WindowInfoEX windowInfoEX; - windowInfoEX.window = targetWindowInfo; + windowInfoEX.window = shiftWindowInfo.targetWindowInfo; windowInfoEX.flag = true; touchItemDownInfos_[shiftWindowInfo.fingerId] = windowInfoEX; - InputHandler->GetFilterHandler()->HandlePointerEvent(lastTouchEvent_); + MMI_HILOGI("Shift pointer event success for touch"); return RET_OK; } @@ -7206,6 +7258,7 @@ void InputWindowsManager::TouchEnterLeaveEvent(int32_t logicalX, int32_t logical lastTouchLogicY_ = logicalY; lastTouchEvent_ = pointerEvent; lastTouchWindowInfo_ = *touchWindow; + lockWindowInfo_ = *touchWindow; DispatchTouch(PointerEvent::POINTER_ACTION_DOWN); return; } diff --git a/service/window_manager/src/pointer_drawing_manager.cpp b/service/window_manager/src/pointer_drawing_manager.cpp index 6e39facb94b542299a52a3c2ee951bd542c87a48..4b3804e8645781e12e61ff8b8c5b17334aabb1d7 100644 --- a/service/window_manager/src/pointer_drawing_manager.cpp +++ b/service/window_manager/src/pointer_drawing_manager.cpp @@ -15,6 +15,7 @@ #include "pointer_drawing_manager.h" +#include #include #include #include @@ -53,7 +54,6 @@ #include "common_event_manager.h" #include "common_event_support.h" -#include #include "param/sys_param.h" #undef MMI_LOG_DOMAIN @@ -1490,12 +1490,20 @@ bool PointerDrawingManager::IsWindowRotation(const DisplayInfo *displayInfo) { MMI_HILOGD("ROTATE_POLICY: %{public}d, FOLDABLE_DEVICE_POLICY:%{public}s", ROTATE_POLICY, FOLDABLE_DEVICE_POLICY.c_str()); + + bool foldableDevicePolicyMain = false; + bool foldableDevicePolicyFull = false; + if (!FOLDABLE_DEVICE_POLICY.empty()) { + foldableDevicePolicyMain = FOLDABLE_DEVICE_POLICY[0] == ROTATE_WINDOW_ROTATE; + } + if (FOLDABLE_DEVICE_POLICY.size() > FOLDABLE_DEVICE) { + foldableDevicePolicyFull = FOLDABLE_DEVICE_POLICY[FOLDABLE_DEVICE] == ROTATE_WINDOW_ROTATE; + } + return (ROTATE_POLICY == WINDOW_ROTATE || (ROTATE_POLICY == FOLDABLE_DEVICE && - ((displayInfo->displayMode == DisplayMode::MAIN && - FOLDABLE_DEVICE_POLICY[0] == ROTATE_WINDOW_ROTATE) || - (displayInfo->displayMode == DisplayMode::FULL && - FOLDABLE_DEVICE_POLICY[FOLDABLE_DEVICE] == ROTATE_WINDOW_ROTATE)))); + ((displayInfo->displayMode == DisplayMode::MAIN && foldableDevicePolicyMain) || + (displayInfo->displayMode == DisplayMode::FULL && foldableDevicePolicyFull)))); } Direction PointerDrawingManager::GetDisplayDirection(const DisplayInfo *displayInfo) @@ -3793,9 +3801,9 @@ bool PointerDrawingManager::GetHardCursorEnabled() if (!hardwareCursorPointerManager_->IsSupported()) { isHardCursorEnabled = false; } - static CachedHandle g_Handle = CachedParameterCreate("rosen.hardCursor.enabled", "1"); + static CachedHandle g_handle = CachedParameterCreate("rosen.hardCursor.enabled", "1"); int changed = 0; - const char *enable = CachedParameterGetChanged(g_Handle, &changed); + const char *enable = CachedParameterGetChanged(g_handle, &changed); if (ConvertToInt(enable, 1) == 0) { isHardCursorEnabled = false; } diff --git a/service/window_manager/test/input_windows_manager_one_test.cpp b/service/window_manager/test/input_windows_manager_one_test.cpp index 64397864666b1c9af3082835535ef8e9d416f83e..6fb1d222599551185c4306cf7f83e69c0670d67e 100644 --- a/service/window_manager/test/input_windows_manager_one_test.cpp +++ b/service/window_manager/test/input_windows_manager_one_test.cpp @@ -1665,5 +1665,402 @@ HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_FindTargetDispla displayId = 1; EXPECT_NO_FATAL_FAILURE(inputWindowsManager->FindTargetDisplayGroupInfo(displayId)); } + +/* * + * @tc.name: InputWindowsManagerOneTest_IsPointerOnCenter_001 + * @tc.desc: Test the funcation IsPointerOnCenter + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_IsPointerOnCenter_001, TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr inputWindowsManager = std::make_shared(); + DisplayInfo displayInfo; + displayInfo.id = 1; + displayInfo.validWidth = 1; + displayInfo.validHeight = 1; + CursorPosition currentPos; + currentPos.cursorPos.x = 0.5; + currentPos.cursorPos.y = 0.5; + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->IsPointerOnCenter(currentPos, displayInfo)); + currentPos.cursorPos.x = 1; + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->IsPointerOnCenter(currentPos, displayInfo)); + currentPos.cursorPos.x = 0.5; + currentPos.cursorPos.y = 1; + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->IsPointerOnCenter(currentPos, displayInfo)); +} + +/* * + * @tc.name: InputWindowsManagerOneTest_ShiftAppMousePointerEvent_002 + * @tc.desc: Test the funcation ShiftAppMousePointerEvent + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_ShiftAppMousePointerEvent_002, TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr inputWindowsManager = std::make_shared(); + ShiftWindowInfo shiftWindowInfo; + bool autoGenDown = false; + std::shared_ptr pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + pointerEvent->pressedButtons_.insert(1); + inputWindowsManager->lastPointerEvent_ = pointerEvent; + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ShiftAppMousePointerEvent(shiftWindowInfo, autoGenDown)); + autoGenDown = true; + shiftWindowInfo.x = -1; + shiftWindowInfo.y = -1; + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ShiftAppMousePointerEvent(shiftWindowInfo, autoGenDown)); + shiftWindowInfo.x = 1; + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ShiftAppMousePointerEvent(shiftWindowInfo, autoGenDown)); + shiftWindowInfo.x = -1; + shiftWindowInfo.y = 1; + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ShiftAppMousePointerEvent(shiftWindowInfo, autoGenDown)); +} + +/* * + * @tc.name: InputWindowsManagerOneTest_ShiftAppTouchPointerEvent002 + * @tc.desc: Test the funcation ShiftAppTouchPointerEvent + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_ShiftAppTouchPointerEvent002, TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr inputWindowsManager = std::make_shared(); + std::shared_ptr pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + inputWindowsManager->lastTouchEvent_ = pointerEvent; + ShiftWindowInfo shiftWindowInfo; + shiftWindowInfo.fingerId = -1; + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ShiftAppTouchPointerEvent(shiftWindowInfo)); + shiftWindowInfo.fingerId = 1; + pointerEvent->pointers_.clear(); + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ShiftAppTouchPointerEvent(shiftWindowInfo)); + PointerEvent::PointerItem item; + int32_t pointerId = 0; + item.SetPointerId(pointerId); + pointerEvent->pointers_.push_back(item); + item.pressed_ = true; + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ShiftAppTouchPointerEvent(shiftWindowInfo)); +} + +#ifdef OHOS_BUILD_ENABLE_KEYBOARD +/** + * @tc.name: InputWindowsManagerOneTest_ReissueEvent_005 + * @tc.desc: Verify ReissueEvent + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_ReissueEvent_005, TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr keyEvent = KeyEvent::Create(); + ASSERT_NE(keyEvent, nullptr); + std::shared_ptr inputWindowsManager = std::make_shared(); + keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UNKNOWN); + int32_t focusWindowId = -1; + inputWindowsManager->focusWindowId_ = 0; + keyEvent->SetRepeatKey(true); + + std::shared_ptr handler = std::make_shared(); + NiceMock mockInputWindowsManager; + UDSServer udServer; + EXPECT_CALL(mockInputWindowsManager, GetEventDispatchHandler).WillRepeatedly(Return(handler)); + EXPECT_CALL(mockInputWindowsManager, GetUDSServer).WillRepeatedly(Return(&udServer)); + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ReissueEvent(keyEvent, focusWindowId)); +} + +/** + * @tc.name: InputWindowsManagerOneTest_ReissueEvent_006 + * @tc.desc: Verify ReissueEvent + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_ReissueEvent_006, TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr keyEvent = KeyEvent::Create(); + ASSERT_NE(keyEvent, nullptr); + std::shared_ptr inputWindowsManager = std::make_shared(); + keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UNKNOWN); + int32_t focusWindowId = -1; + inputWindowsManager->focusWindowId_ = 0; + keyEvent->SetRepeatKey(true); + + std::shared_ptr handler = std::make_shared(); + NiceMock mockInputWindowsManager; + EXPECT_CALL(mockInputWindowsManager, GetEventDispatchHandler).WillRepeatedly(Return(handler)); + EXPECT_CALL(mockInputWindowsManager, GetUDSServer).WillRepeatedly(Return(nullptr)); + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ReissueEvent(keyEvent, focusWindowId)); +} + +/** + * @tc.name: InputWindowsManagerOneTest_ReissueEvent_007 + * @tc.desc: Verify ReissueEvent + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_ReissueEvent_007, TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr keyEvent = KeyEvent::Create(); + ASSERT_NE(keyEvent, nullptr); + std::shared_ptr inputWindowsManager = std::make_shared(); + keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UNKNOWN); + int32_t focusWindowId = -1; + inputWindowsManager->focusWindowId_ = 0; + keyEvent->SetRepeatKey(true); + + NiceMock mockInputWindowsManager; + EXPECT_CALL(mockInputWindowsManager, GetEventDispatchHandler).WillRepeatedly(Return(nullptr)); + EXPECT_CALL(mockInputWindowsManager, GetUDSServer).WillRepeatedly(Return(nullptr)); + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ReissueEvent(keyEvent, focusWindowId)); +} +#endif // OHOS_BUILD_ENABLE_KEYBOARD + +/** + * @tc.name: InputWindowsManagerOneTest_UpdateDisplayInfoExtIfNeed01 + * @tc.desc: Test UpdateDisplayInfoExtIfNeed + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_UpdateDisplayInfoExtIfNeed01, TestSize.Level0) +{ + CALL_TEST_DEBUG; + InputWindowsManager inputWindowsMgr; + DisplayGroupInfo displayGroupInfo; + DisplayInfo displayInfo; + displayGroupInfo.displaysInfo.push_back(displayInfo); + displayGroupInfo.groupId = -1; + bool needUpdateDisplayExt = true; + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateDisplayInfoExtIfNeed(displayGroupInfo, needUpdateDisplayExt)); +} + +/** + * @tc.name: InputWindowsManagerOneTest_GetMainScreenDisplayInfo + * @tc.desc: Test GetMainScreenDisplayInfo + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_GetMainScreenDisplayInfo, TestSize.Level0) +{ + CALL_TEST_DEBUG; + InputWindowsManager inputWindowsMgr; + std::vector displaysInfo; + DisplayInfo mainScreenDisplayInfo; + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetMainScreenDisplayInfo(displaysInfo, mainScreenDisplayInfo)); + mainScreenDisplayInfo.screenCombination = OHOS::MMI::ScreenCombination::SCREEN_ALONE; + displaysInfo.push_back(mainScreenDisplayInfo); + mainScreenDisplayInfo.screenCombination = OHOS::MMI::ScreenCombination::SCREEN_MAIN; + displaysInfo.push_back(mainScreenDisplayInfo); + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetMainScreenDisplayInfo(displaysInfo, mainScreenDisplayInfo)); +} + +/** + * @tc.name: InputWindowsManagerOneTest_ResetPointerPosition + * @tc.desc: Test ResetPointerPosition + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_ResetPointerPosition, TestSize.Level0) +{ + CALL_TEST_DEBUG; + InputWindowsManager inputWindowsMgr; + DisplayGroupInfo displayGroupInfo; + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.ResetPointerPosition(displayGroupInfo)); + DisplayInfo currentDisplay; + currentDisplay.screenCombination = OHOS::MMI::ScreenCombination::SCREEN_ALONE; + displayGroupInfo.displaysInfo.push_back(currentDisplay); + currentDisplay.screenCombination = OHOS::MMI::ScreenCombination::SCREEN_MAIN; + displayGroupInfo.displaysInfo.push_back(currentDisplay); + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.ResetPointerPosition(displayGroupInfo)); +} + +/** + * @tc.name: InputWindowsManagerOneTest_IsPointerOnCenter + * @tc.desc: Test IsPointerOnCenter + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_IsPointerOnCenter, TestSize.Level0) +{ + CALL_TEST_DEBUG; + InputWindowsManager inputWindowsMgr; + DisplayInfo currentDisplay; + currentDisplay.validHeight = 2; + currentDisplay.validWidth = 2; + CursorPosition currentPos; + currentPos.cursorPos.x = 1; + currentPos.cursorPos.y = 1; + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.IsPointerOnCenter(currentPos, currentDisplay)); + currentPos.cursorPos.y = 0; + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.IsPointerOnCenter(currentPos, currentDisplay)); + currentPos.cursorPos.x = 0; + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.IsPointerOnCenter(currentPos, currentDisplay)); +} + +/** + * @tc.name: InputWindowsManagerOneTest_ResetCursorPos + * @tc.desc: Test ResetCursorPos + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_ResetCursorPos, TestSize.Level0) +{ + CALL_TEST_DEBUG; + InputWindowsManager inputWindowsMgr; + DisplayGroupInfo displayGroupInfo; + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.ResetCursorPos(displayGroupInfo)); + DisplayInfo displayInfo; + displayGroupInfo.displaysInfo.push_back(displayInfo); + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.ResetCursorPos(displayGroupInfo)); +} + +/** + * @tc.name: InputWindowsManagerOneTest_IsPositionOutValidDisplay + * @tc.desc: Test IsPositionOutValidDisplay + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_IsPositionOutValidDisplay, TestSize.Level0) +{ + CALL_TEST_DEBUG; + InputWindowsManager inputWindowsMgr; + DisplayInfo currentDisplay; + currentDisplay.validHeight = 2; + currentDisplay.validWidth = 2; + currentDisplay.height = 2; + currentDisplay.width = 2; + currentDisplay.offsetX = 0; + currentDisplay.offsetY = 0; + Coordinate2D position; + position.x = 1; + position.y = 1; + currentDisplay.fixedDirection = DIRECTION90; + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.IsPositionOutValidDisplay(position, currentDisplay, true)); + currentDisplay.fixedDirection = DIRECTION180; + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.IsPositionOutValidDisplay(position, currentDisplay, true)); + currentDisplay.fixedDirection = DIRECTION270; + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.IsPositionOutValidDisplay(position, currentDisplay, true)); + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.IsPositionOutValidDisplay(position, currentDisplay, false)); +} + +/* * + * @tc.name: InputWindowsManagerOneTest_ProcessTouchTracking + * @tc.desc: Test the funcation ProcessTouchTracking + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_ProcessTouchTracking, TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr inputWindowsManager = std::make_shared(); + std::shared_ptr pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + PointerEvent::PointerItem pointerItem; + pointerItem.SetDisplayXPos(0.0); + pointerItem.SetDisplayYPos(0.0); + WindowInfo targetWindow; + targetWindow.id = 1; + pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE); + inputWindowsManager->touchTracking_ = true; + pointerEvent->targetWindowId_ = 1; + pointerEvent->pointers_.clear(); + pointerItem.SetPointerId(1); + pointerEvent->pointers_.push_back(pointerItem); + EXPECT_EQ(pointerEvent->GetPointerCount(), 1); + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ProcessTouchTracking(pointerEvent, targetWindow)); + + pointerEvent->SetTargetWindowId(targetWindow.id); + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ProcessTouchTracking(pointerEvent, targetWindow)); + + targetWindow.id = -1; + pointerEvent->pointers_.clear(); + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ProcessTouchTracking(pointerEvent, targetWindow)); +} + +/* * + * @tc.name: InputWindowsManagerOneTest_ClearMouseHideFlag + * @tc.desc: Test the funcation ClearMouseHideFlag + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_ClearMouseHideFlag, TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr inputWindowsManager = std::make_shared(); + std::shared_ptr pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + auto eventId = -1; + pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE); + pointerEvent->SetPointerId(eventId); + inputWindowsManager->lastPointerEvent_ = pointerEvent; + EXPECT_EQ(pointerEvent->GetId(), eventId); + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ClearMouseHideFlag(eventId)); + eventId = 1; + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ClearMouseHideFlag(eventId)); +} + +/* * + * @tc.name: InputWindowsManagerOneTest_IsAccessibilityEventWithZorderInjected + * @tc.desc: Test the funcation IsAccessibilityEventWithZorderInjected + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerOneTest_IsAccessibilityEventWithZorderInjected, TestSize.Level1) +{ + CALL_TEST_DEBUG; + std::shared_ptr inputWindowsManager = std::make_shared(); + std::shared_ptr pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_HOVER_ENTER); + pointerEvent->bitwise_ = InputEvent::EVENT_FLAG_SIMULATE; + pointerEvent->SetZOrder(1.0f); + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->IsAccessibilityEventWithZorderInjected(pointerEvent)); + pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE); + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->IsAccessibilityEventWithZorderInjected(pointerEvent)); + pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_HOVER_ENTER); + pointerEvent->bitwise_ = InputEvent::EVENT_FLAG_ACCESSIBILITY; + pointerEvent->SetZOrder(0.0f); + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->IsAccessibilityEventWithZorderInjected(pointerEvent)); + pointerEvent->bitwise_ = InputEvent::EVENT_FLAG_SIMULATE; + EXPECT_NO_FATAL_FAILURE(inputWindowsManager->IsAccessibilityEventWithZorderInjected(pointerEvent)); +} + +/** + * @tc.name: InputWindowsManagerTest_SendCancelEventWhenLock + * @tc.desc: Test the funcation SendCancelEventWhenLock + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputWindowsManagerOneTest, InputWindowsManagerTest_SendCancelEventWhenLock, TestSize.Level1) +{ + CALL_TEST_DEBUG; + InputWindowsManager inputWindowsMgr; + inputWindowsMgr.lastTouchEventOnBackGesture_ = PointerEvent::Create(); + ASSERT_NE(inputWindowsMgr.lastTouchEventOnBackGesture_, nullptr); + InputHandler->eventNormalizeHandler_ = std::make_shared(); + EXPECT_NE(InputHandler->eventNormalizeHandler_, nullptr); + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock()); + inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_UP); + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock()); + inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE); + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock()); + inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN); + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock()); + std::shared_ptr pointerEvent = PointerEvent::Create(); + ASSERT_NE(pointerEvent, nullptr); + WindowInfoEX windowInfoEX; + windowInfoEX.flag = true; + pointerEvent->SetPointerId(1); + + inputWindowsMgr.touchItemDownInfos_.insert(std::make_pair(pointerEvent->GetPointerId(), windowInfoEX)); + inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerId(2); + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock()); + inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerId(1); + EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock()); +} } // namespace MMI } // namespace OHOS diff --git a/service/window_manager/test/input_windows_manager_test.cpp b/service/window_manager/test/input_windows_manager_test.cpp index 3eda2f2d1d742aeb605c0306ddce75f7fc38b042..2f4f835c4ed8371b85b78c22718ce5ebc81eda39 100644 --- a/service/window_manager/test/input_windows_manager_test.cpp +++ b/service/window_manager/test/input_windows_manager_test.cpp @@ -49,6 +49,7 @@ constexpr int32_t INT32_BYTE { 4 }; constexpr uint32_t WINDOW_NAME_TYPE_SCHREENSHOT { 1 }; constexpr float SCREEN_CAPTURE_WINDOW_ZORDER { 8000.0 }; constexpr uint32_t CAST_WINDOW_TYPE { 2106 }; +constexpr uint32_t GUIDE_WINDOW_TYPE { 2500 }; constexpr uint32_t TEST_WINDOW_START { -100 }; constexpr uint32_t TEST_WINDOW_END { 100000 }; #define SCREEN_RECORD_WINDOW_WIDTH 400 @@ -6654,11 +6655,11 @@ HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateKeyEventDisplayI keyEvent = KeyEvent::Create(); ASSERT_NE(keyEvent, nullptr); inputWindowsManager.UpdateKeyEventDisplayId(keyEvent, focusWindowId); - EXPECT_EQ(keyEvent->GetTargetDisplayId(), 1); + EXPECT_EQ(keyEvent->GetTargetDisplayId(), -1); focusWindowId = 2; inputWindowsManager.UpdateKeyEventDisplayId(keyEvent, focusWindowId); - EXPECT_EQ(keyEvent->GetTargetDisplayId(), 1); + EXPECT_EQ(keyEvent->GetTargetDisplayId(), -1); DisplayInfo info1 = {.id = 0, .x = 0, .y = 0, .width = 100, .height = 200}; auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID); @@ -9930,7 +9931,7 @@ HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsMouseInCastWindow_00 /** * @tc.name: InputWindowsManagerTest_IsCaptureMode_001 - * @tc.desc: est case for IsCaptureMode when screenshot window exists + * @tc.desc: Test case for IsCaptureMode when screenshot window exists * @tc.require: */ HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsCaptureMode_001, TestSize.Level1) @@ -9982,7 +9983,7 @@ HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsCaptureMode_003, Tes /** * @tc.name: InputWindowsManagerTest_IsCaptureMode_004 - * @tc.desc: TTest case for IsCaptureMode when no special windows exist + * @tc.desc: Test case for IsCaptureMode when no special windows exist * @tc.require: */ HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsCaptureMode_004, TestSize.Level1) diff --git a/service/window_manager/test/pointer_renderer_test.cpp b/service/window_manager/test/pointer_renderer_test.cpp index 93b7c54536fe8c246da0499e59920d15b7d53708..93fb2abae59605407901ae52ec513ab6fc14e420 100644 --- a/service/window_manager/test/pointer_renderer_test.cpp +++ b/service/window_manager/test/pointer_renderer_test.cpp @@ -336,5 +336,38 @@ HWTEST_F(PointerRendererTest, PointerRendererTest_DrawImage_001, TestSize.Level1 ret = renderer.DrawImage(canvas, config); EXPECT_EQ(ret, RET_OK); } + +/** + * @tc.name: PointerRendererTest_LoadCursorSvgWithColor_001 + * @tc.desc: Test LoadCursorSvgWithColor + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(PointerRendererTest, PointerRendererTest_LoadCursorSvgWithColor_001, TestSize.Level1) +{ + CALL_TEST_DEBUG; + RenderConfig config; + PointerRenderer renderer; + pixelmap_ptr_t ret = renderer.LoadCursorSvgWithColor(config); + EXPECT_EQ(ret, nullptr); + config.color = 0xFFFFFF; + ret = renderer.LoadCursorSvgWithColor(config); + EXPECT_EQ(ret, nullptr); + config.style_ = CURSOR_COPY; + config.color = 0x000123; + ret = renderer.LoadCursorSvgWithColor(config); + EXPECT_EQ(ret, nullptr); + config.color = 0xFFFFFF; + ret = renderer.LoadCursorSvgWithColor(config); + EXPECT_EQ(ret, nullptr); + config.style_ = HAND_GRABBING; + config.color = 0xFFFFFF; + ret = renderer.LoadCursorSvgWithColor(config); + EXPECT_EQ(ret, nullptr); + config.style_ = HAND_GRABBING; + config.color = 0x000123; + ret = renderer.LoadCursorSvgWithColor(config); + EXPECT_EQ(ret, nullptr); +} } // namespace MMI } // namespace OHOS \ No newline at end of file diff --git a/service/window_manager/test/screen_pointer_test.cpp b/service/window_manager/test/screen_pointer_test.cpp index 7c703cf827b0fae37dd95dbd37d4f9eb2c15a59f..776863380619c86e3408f57950bdb320948ab6cb 100644 --- a/service/window_manager/test/screen_pointer_test.cpp +++ b/service/window_manager/test/screen_pointer_test.cpp @@ -80,7 +80,7 @@ HWTEST_F(ScreenPointerTest, ScreenPointerTest_SetInvisible_001, TestSize.Level1) PointerRenderer renderer; ASSERT_TRUE(screenpointer->Init(renderer)); bool ret = screenpointer->SetInvisible(); - EXPECT_TRUE(ret); + EXPECT_EQ(ret, hwcmgr->IsSupported()); } /** @@ -174,23 +174,23 @@ HWTEST_F(ScreenPointerTest, ScreenPointerTest_Move_001, TestSize.Level1) int32_t x = 0; int32_t y = 0; bool ret = screenpointer->Move(x, y, align); - EXPECT_TRUE(ret); + EXPECT_EQ(ret, hwcmgr->IsSupported()); screenpointer->mode_ = mode_t::SCREEN_MAIN; screenpointer->isCurrentOffScreenRendering_ = true; ret = screenpointer->Move(x, y, align); - EXPECT_TRUE(ret); + EXPECT_EQ(ret, hwcmgr->IsSupported()); screenpointer->mode_ = mode_t::SCREEN_MAIN; screenpointer->isWindowRotation_ = true; ret = screenpointer->Move(x, y, align); - EXPECT_TRUE(ret); + EXPECT_EQ(ret, hwcmgr->IsSupported()); screenpointer->mode_ = mode_t::SCREEN_EXTEND; screenpointer->isCurrentOffScreenRendering_ = false; ret = screenpointer->Move(x, y, align); - EXPECT_TRUE(ret); + EXPECT_EQ(ret, hwcmgr->IsSupported()); screenpointer->mode_ = mode_t::SCREEN_MIRROR; screenpointer->isCurrentOffScreenRendering_ = false; ret = screenpointer->Move(x, y, align); - EXPECT_TRUE(ret); + EXPECT_EQ(ret, hwcmgr->IsSupported()); } /** diff --git a/service/window_manager/test/touch_drawing_manager_test.cpp b/service/window_manager/test/touch_drawing_manager_test.cpp index 9f8d772689eeb87c9f55141a10f6355a9c749727..d94a345cdb2e53fbc5da1f3f6845c2417dba0c5d 100644 --- a/service/window_manager/test/touch_drawing_manager_test.cpp +++ b/service/window_manager/test/touch_drawing_manager_test.cpp @@ -1345,5 +1345,108 @@ HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_UpdateDisplayInfo001, touchDrawingMgr.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType); EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.UpdateDisplayInfo(displayInfo)); } + +/** + * @tc.name: TouchDrawingManagerTest_UpdateDisplayInfo002 + * @tc.desc: Test UpdateDisplayInfo + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_UpdateDisplayInfo002, TestSize.Level1) +{ + CALL_TEST_DEBUG; + TouchDrawingManager touchDrawingMgr; + DisplayInfo displayInfo; + displayInfo.direction = Direction::DIRECTION0; + touchDrawingMgr.displayInfo_.direction = Direction::DIRECTION0; + displayInfo.width = 700; + displayInfo.height = 500; + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.UpdateDisplayInfo(displayInfo)); + displayInfo.direction = Direction::DIRECTION180; + touchDrawingMgr.displayInfo_.direction = Direction::DIRECTION180; + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.UpdateDisplayInfo(displayInfo)); + displayInfo.direction = Direction::DIRECTION270; + touchDrawingMgr.displayInfo_.direction = Direction::DIRECTION270; + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.UpdateDisplayInfo(displayInfo)); + displayInfo.screenCombination = ScreenCombination::SCREEN_MAIN; + touchDrawingMgr.displayInfo_.screenCombination = ScreenCombination::SCREEN_MAIN; + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.UpdateDisplayInfo(displayInfo)); + displayInfo.uniqueId = 1; + touchDrawingMgr.displayInfo_.uniqueId = 2; + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.UpdateDisplayInfo(displayInfo)); + Rosen::RSSurfaceNodeConfig surfaceNodeConfig; + surfaceNodeConfig.SurfaceNodeName = "touch window"; + Rosen::RSSurfaceNodeType surfaceNodeType = Rosen::RSSurfaceNodeType::SELF_DRAWING_WINDOW_NODE; + touchDrawingMgr.surfaceNode_ = Rosen::RSSurfaceNode::Create(surfaceNodeConfig, surfaceNodeType); + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.UpdateDisplayInfo(displayInfo)); + touchDrawingMgr.isChangedMode_ = true; + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.UpdateDisplayInfo(displayInfo)); + touchDrawingMgr.trackerCanvasNode_ = Rosen::RSCanvasDrawingNode::Create(); + touchDrawingMgr.bubbleCanvasNode_ = Rosen::RSCanvasNode::Create(); + touchDrawingMgr.crosshairCanvasNode_ = Rosen::RSCanvasNode::Create(); + touchDrawingMgr.labelsCanvasNode_ = Rosen::RSCanvasDrawingNode::Create(); + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.UpdateDisplayInfo(displayInfo)); +} + +/** + * @tc.name: TouchDrawingManagerTest_RotationScreen_009 + * @tc.desc: Test RotationScreen + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_RotationScreen_009, TestSize.Level1) +{ + CALL_TEST_DEBUG; + TouchDrawingManager touchDrawingMgr; + touchDrawingMgr.isChangedRotation_ = true; + touchDrawingMgr.isChangedMode_ = false; + touchDrawingMgr.pointerMode_.isShow = true; + touchDrawingMgr.bubbleMode_.isShow = true; + touchDrawingMgr.stopRecord_ = true; + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.RotationScreen()); + touchDrawingMgr.stopRecord_ = false; + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.RotationScreen()); + PointerEvent::PointerItem item; + item.SetPointerId(1); + item.SetPressed(true); + touchDrawingMgr.lastPointerItem_.emplace_back(item); + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.RotationScreen()); + touchDrawingMgr.stopRecord_ = true; + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.RotationScreen()); + touchDrawingMgr.stopRecord_ = false; + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.RotationScreen()); +} + +/** + * @tc.name: TouchDrawingManagerTest_SetupSettingObserver_0010 + * @tc.desc: Test SetupSettingObserver + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_SetupSettingObserver_0010, TestSize.Level1) +{ + CALL_TEST_DEBUG; + TouchDrawingManager touchDrawingMgr; + touchDrawingMgr.scaleW_ = 1; + touchDrawingMgr.hasBubbleObserver_ = true; + touchDrawingMgr.hasPointerObserver_ = false; + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.SetupSettingObserver(1)); + touchDrawingMgr.hasBubbleObserver_ = false; + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.SetupSettingObserver(1)); +} + +/** + * @tc.name: TouchDrawingManagerTest_UpdateLabels_0010 + * @tc.desc: Test UpdateLabels + * @tc.type: Function + * @tc.require: + */ +HWTEST_F(TouchDrawingManagerTest, TouchDrawingManagerTest_UpdateLabels_0010, TestSize.Level1) +{ + CALL_TEST_DEBUG; + TouchDrawingManager touchDrawingMgr; + touchDrawingMgr.pointerMode_.isShow = false; + EXPECT_NO_FATAL_FAILURE(touchDrawingMgr.UpdateLabels()); +} } // namespace MMI } // namespace OHOS diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 0c09451d78b87fd7add0ac407e6c10603975a024..dd59d9402fbb1c57d82af72c268344327dccf8f6 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -24,6 +24,7 @@ group("test") { "addmonitor_fuzzer:fuzztest", "appendextradata_fuzzer:fuzztest", "cleanwindowstyle_fuzzer:fuzztest", + "clearmousehideflag_fuzzer:fuzztest", "enablecombinekey_fuzzer:fuzztest", "enableinputdevice_fuzzer:fuzztest", "functionkeystate_fuzzer:fuzztest", @@ -39,6 +40,7 @@ group("test") { "getkeyboardtype_fuzzer:fuzztest", "getmouseprimarybutton_fuzzer:fuzztest", "getpointercolor_fuzzer:fuzztest", + "getpointerlocation_fuzzer:fuzztest", "getpointersize_fuzzer:fuzztest", "getshieldstatus_fuzzer:fuzztest", "gettprightclicktype_fuzzer:fuzztest", @@ -135,6 +137,5 @@ group("test") { "supportkeys_fuzzer:fuzztest", "unregisterdevListener_fuzzer:fuzztest", "updatedisplayinfo_fuzzer:fuzztest", - "clearmousehideflag_fuzzer:fuzztest", ] } diff --git a/test/fuzztest/getpointerlocation_fuzzer/BUILD.gn b/test/fuzztest/getpointerlocation_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..64cb38936d5bbd20ce456fd4f15ce5b04fb0a846 --- /dev/null +++ b/test/fuzztest/getpointerlocation_fuzzer/BUILD.gn @@ -0,0 +1,53 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/test.gni") +import("../../../multimodalinput_mini.gni") +module_output_path = "input/input" + +##############################fuzztest########################################## +ohos_fuzztest("GetPointerLocationFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "${mmi_path}/test/fuzztest/getpointerlocation_fuzzer" + include_dirs = [ "${mmi_path}/interfaces/util/common/include" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "getpointerlocation_fuzzer.cpp" ] + deps = [ + "${mmi_path}/frameworks/proxy:libmmi-client", + "${mmi_path}/util:libmmi-util", + ] + external_deps = [ + "c_utils:utils", + "eventhandler:libeventhandler", + "hilog:libhilog", + "ipc:ipc_core", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":GetPointerLocationFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/getpointerlocation_fuzzer/corpus/init b/test/fuzztest/getpointerlocation_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..e4ceac1bcd4e3b3427eb63cea0c28304064333cc --- /dev/null +++ b/test/fuzztest/getpointerlocation_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/service/infrared_emitter/include/infrared_emitter_def.h b/test/fuzztest/getpointerlocation_fuzzer/getpointerlocation_fuzzer.cpp similarity index 31% rename from service/infrared_emitter/include/infrared_emitter_def.h rename to test/fuzztest/getpointerlocation_fuzzer/getpointerlocation_fuzzer.cpp index 4811ac26c5811117ecc3541da86871113fc41490..887024f4726d0265bcda94c6cac0cd6bf0495ae1 100644 --- a/service/infrared_emitter/include/infrared_emitter_def.h +++ b/test/fuzztest/getpointerlocation_fuzzer/getpointerlocation_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,33 +13,51 @@ * limitations under the License. */ -#ifndef INFRARED_EMMITTER_DEF_H -#define INFRARED_EMMITTER_DEF_H +#include "getpointerlocation_fuzzer.h" -#include "hdi_base.h" +#include "securec.h" + +#include "input_manager.h" +#include "mmi_log.h" + +#undef MMI_LOG_TAG +#define MMI_LOG_TAG "GetPointerLocationFuzzTest" namespace OHOS { -namespace HDI { -namespace V1_0 { -using namespace OHOS::HDI; -struct ConsumerIrFreqRange { - int32_t min { 0 }; - int32_t max { 0 }; -}; -class ConsumerIr : public HdiBase { -public: - DECLARE_HDI_DESCRIPTOR(u"ohos.hdi.v1_0.ConsumerIr"); - virtual ~ConsumerIr() = default; - static sptr Get(bool isStub = false); - static sptr Get(const std::string &serviceName, bool isStub = false); - virtual int32_t Transmit(int32_t carrierFreq, const std::vector &pattern, bool &status) = 0; - virtual int32_t GetCarrierFreqs(bool &status, - std::vector &range) = 0; - virtual int32_t GetVersion(uint32_t &majorVer, uint32_t &minorVer) = 0; - virtual bool IsProxy(); - virtual const std::u16string GetDesc(); -}; -} // namespace V1_0 -} // namespace HDI -} // namespace OHOS -#endif // INFRARED_EMMITTER_DEF_H \ No newline at end of file +namespace MMI { +template +size_t GetObject(T &object, const uint8_t *data, size_t size) +{ + size_t objectSize = sizeof(object); + if (objectSize > size) { + return 0; + } + errno_t ret = memcpy_s(&object, objectSize, data, objectSize); + if (ret != EOK) { + return 0; + } + return objectSize; +} + +void GetPointerLocationFuzzTest(const uint8_t* data, size_t size) +{ + size_t startPos = 0; + int32_t displayId = 0; + double displayX = 0.0; + startPos += GetObject(displayX, data + startPos, size - startPos); + double displayY = 0.0; + startPos += GetObject(displayY, data + startPos, size - startPos); + MMI_HILOGD("Call InputManager::GetPointerLocation"); + InputManager::GetInstance()->GetPointerLocation(displayId, displayX, displayY); +} +} // MMI +} // OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + OHOS::MMI::GetPointerLocationFuzzTest(data, size); + return 0; +} + diff --git a/service/connect_manager/include/input_binder_client_proxy.h b/test/fuzztest/getpointerlocation_fuzzer/getpointerlocation_fuzzer.h similarity index 40% rename from service/connect_manager/include/input_binder_client_proxy.h rename to test/fuzztest/getpointerlocation_fuzzer/getpointerlocation_fuzzer.h index acf773c266a952a3f0c9665e95c53867aa81abbd..8ec4f6933646835bc69409353c58f6f7cd5f9c1d 100644 --- a/service/connect_manager/include/input_binder_client_proxy.h +++ b/test/fuzztest/getpointerlocation_fuzzer/getpointerlocation_fuzzer.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,25 +13,9 @@ * limitations under the License. */ -#ifndef INPUT_BINDER_CLIENT_PROXY_H -#define INPUT_BINDER_CLIENT_PROXY_H +#ifndef GETPOINTERLOCATION_FUZZER_H +#define GETPOINTERLOCATION_FUZZER_H -#include "iremote_proxy.h" -#include "nocopyable.h" +#define FUZZ_PROJECT_NAME "getpointerlocation_fuzzer" -#include "i_input_binder_client.h" - -namespace OHOS { -namespace MMI { -class InputBinderClientProxy : public IRemoteProxy { -public: - DISALLOW_COPY_AND_MOVE(InputBinderClientProxy); - explicit InputBinderClientProxy(const sptr &impl) : IRemoteProxy(impl) {} - virtual ~InputBinderClientProxy() = default; - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace MMI -} // namespace OHOS -#endif // INPUT_BINDER_CLIENT_PROXY_H \ No newline at end of file +#endif // GETPOINTERLOCATION_FUZZER_H diff --git a/test/fuzztest/getpointerlocation_fuzzer/project.xml b/test/fuzztest/getpointerlocation_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fdbc407f205680885fa42663163b5c987f123a6 --- /dev/null +++ b/test/fuzztest/getpointerlocation_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/tools/inject_event/src/input_manager_command.cpp b/tools/inject_event/src/input_manager_command.cpp index 6f099566ca6102da9e48ff7f6bea484625ed6f32..06dfcefc5e1df09c9e108accccff34e79fec7ce8 100644 --- a/tools/inject_event/src/input_manager_command.cpp +++ b/tools/inject_event/src/input_manager_command.cpp @@ -2313,8 +2313,12 @@ void InputManagerCommand::FillPointerItem( { item.SetDisplayX(pointX); item.SetDisplayY(pointY); + item.SetDisplayXPos(pointX); + item.SetDisplayYPos(pointY); item.SetWindowX(pointX); item.SetWindowY(pointY); + item.SetWindowXPos(pointX); + item.SetWindowYPos(pointY); item.SetPointerId(id); item.SetPressed(press); } diff --git a/util/common/include/error_multimodal.h b/util/common/include/error_multimodal.h index c5633adaf4213aab3a09dd73dffdec5be3b625dd..d07ac7735bb00a0e05fd0c253e99201a34a57481 100644 --- a/util/common/include/error_multimodal.h +++ b/util/common/include/error_multimodal.h @@ -27,6 +27,18 @@ inline constexpr int32_t ERROR_NO_PERMISSION { -201 }; inline constexpr int32_t ERROR_KEYBOARD_NO_PERMISSION { 201 }; inline constexpr int32_t ERROR_NOT_SYSAPI { 202 }; inline constexpr int32_t ERROR_DEVICE_NOT_EXIST { 3900001 }; +inline constexpr int32_t ERROR_OPERATION_FREQUENT { -1001 }; +inline constexpr int32_t ERROR_DEVICE_NOT_SUPPORTED { -1002 }; +inline constexpr int32_t ERROR_APP_NOT_FOCUSED { 3900009 }; +inline constexpr int32_t ERROR_DEVICE_NO_POINTER { 3900010 }; + +enum class AUTHORIZE_QUERY_STATE : int32_t { + OTHER_PID_IN_AUTHORIZATION_SELECTION = 0, + OTHER_PID_AUTHORIZED = 1, + UNAUTHORIZED = 2, + CURRENT_PID_IN_AUTHORIZATION_SELECTION = 3, + CURRENT_PID_AUTHORIZED = 4 +}; enum { MODULE_CLIENT = 0x00, diff --git a/util/common/include/input_event_data_transformation.h b/util/common/include/input_event_data_transformation.h index 5c2276fb75e6b1db39e5d8bd80c4e9a3f61de2bc..c60fbeb7cd156008913b7fac2623eda24b7d3a31 100644 --- a/util/common/include/input_event_data_transformation.h +++ b/util/common/include/input_event_data_transformation.h @@ -58,7 +58,7 @@ private: static bool DeserializeSettings(NetPacket &pkt, std::shared_ptr event); #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT - static constexpr uint32_t MAX_HMAC_SIZE = 64; + static constexpr uint32_t MAX_HMAC_SIZE = 160; struct SecCompPointEvent { double touchX; double touchY; diff --git a/util/common/include/msg_handler.h b/util/common/include/msg_handler.h index c71ef6ff039f5cc54e0c3ee800ddd2ac44d50d37..97803f15fa7719c79807d4be02e876317d0a2678 100644 --- a/util/common/include/msg_handler.h +++ b/util/common/include/msg_handler.h @@ -36,7 +36,7 @@ public: return (GetMsgCallback(id) != nullptr); } - const std::string& GetDebugInfo() const + std::string GetDebugInfo() const { std::string str; for (auto &it : callbacks_) { @@ -46,7 +46,7 @@ public: if (str.size() > 0) { str.resize(str.size() - 1); } - return std::move(str); + return str; } protected: