From a575c3803bbe8a5a633082a3472003c651c8d769 Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Fri, 23 Aug 2024 08:57:51 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=9B=9E=E5=90=885.0-Release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- common/include/constants_dinput.h | 3 ++- common/include/input_hub.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/common/include/constants_dinput.h b/common/include/constants_dinput.h index 6979e83..d33bffe 100644 --- a/common/include/constants_dinput.h +++ b/common/include/constants_dinput.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -48,6 +48,7 @@ namespace DistributedInput { const uint32_t SCREEN_MSG_MAX = 40 * 1024 * 1024; const uint32_t AUTH_SESSION_SIDE_SERVER = 0; const uint32_t IPC_VECTOR_MAX_SIZE = 32; + const uint32_t EVENT_BUFFER_MAX = 512; /* * Device Type definitions diff --git a/common/include/input_hub.cpp b/common/include/input_hub.cpp index 77ee319..55704f9 100644 --- a/common/include/input_hub.cpp +++ b/common/include/input_hub.cpp @@ -1071,7 +1071,7 @@ int32_t InputHub::UnregisterFdFromEpoll(int fd) const int32_t InputHub::ReadNotifyLocked() { size_t res; - char eventBuf[512]; + char eventBuf[EVENT_BUFFER_MAX] = {0}; struct inotify_event *event; DHLOGI("readNotify nfd: %{public}d\n", iNotifyFd_); @@ -1087,7 +1087,7 @@ int32_t InputHub::ReadNotifyLocked() { size_t eventSize = 0; size_t eventPos = 0; - while (res >= sizeof(*event)) { + while (res >= sizeof(*event) && eventPos < static_cast(EVENT_BUFFER_MAX)) { event = reinterpret_cast(eventBuf + eventPos); JudgeDeviceOpenOrClose(*event); eventSize = sizeof(*event) + event->len; -- Gitee From 552cc33096932323ee3b029407aad294c824ec56 Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Sat, 31 Aug 2024 15:11:15 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9C=8B=E6=9D=BF?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E5=9B=9E=E5=90=885.0-Release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- common/include/input_hub.cpp | 7 +- .../src/distributed_input_sink_transport.cpp | 4 ++ .../src/distributed_input_node_manager.cpp | 4 ++ .../dinput_source_manager_event_handler.cpp | 72 +++++++++++++++++++ 4 files changed, 86 insertions(+), 1 deletion(-) diff --git a/common/include/input_hub.cpp b/common/include/input_hub.cpp index 55704f9..6288aa7 100644 --- a/common/include/input_hub.cpp +++ b/common/include/input_hub.cpp @@ -189,7 +189,12 @@ size_t InputHub::GetEvents(RawEvent *buffer, size_t bufferSize) } struct input_event readBuffer[bufferSize]; int32_t readSize = read(eventItem.data.fd, readBuffer, sizeof(struct input_event) * capacity); - size_t count = ReadInputEvent(readSize, *GetDeviceByFdLocked(eventItem.data.fd)); + Device* deviceByFd = GetDeviceByFdLocked(eventItem.data.fd); + if (!deviceByFd) { + DHLOGE("Find device by fd: %{public}d failed", eventItem.data.fd); + continue; + } + size_t count = ReadInputEvent(readSize, *deviceByFd); Device* device = GetSupportDeviceByFd(eventItem.data.fd); if (!device) { DHLOGE("Can not find device by fd: %{public}d", eventItem.data.fd); diff --git a/services/sink/transport/src/distributed_input_sink_transport.cpp b/services/sink/transport/src/distributed_input_sink_transport.cpp index 5b53749..df1842d 100644 --- a/services/sink/transport/src/distributed_input_sink_transport.cpp +++ b/services/sink/transport/src/distributed_input_sink_transport.cpp @@ -79,6 +79,10 @@ void DistributedInputSinkTransport::DInputSinkEventHandler::ProcessEvent(const A switch (eventId) { case EHandlerMsgType::DINPUT_SINK_EVENT_HANDLER_MSG: { std::shared_ptr innerMsg = event->GetSharedObject(); + if (innerMsg == nullptr) { + DHLOGE("innerMsg is null."); + break; + } nlohmann::json jsonStr; jsonStr[DINPUT_SOFTBUS_KEY_CMD_TYPE] = TRANS_SINK_MSG_BODY_DATA; jsonStr[DINPUT_SOFTBUS_KEY_INPUT_DATA] = innerMsg->dump(); diff --git a/services/source/inputinject/src/distributed_input_node_manager.cpp b/services/source/inputinject/src/distributed_input_node_manager.cpp index af1f751..7828cd1 100644 --- a/services/source/inputinject/src/distributed_input_node_manager.cpp +++ b/services/source/inputinject/src/distributed_input_node_manager.cpp @@ -203,6 +203,10 @@ void DistributedInputNodeManager::DInputNodeManagerEventHandler::ScanAllNode( { DHLOGI("ScanAllNode enter."); std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *(it); std::string devId = innerMsg[INPUT_NODE_DEVID]; diff --git a/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp b/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp index 0039c90..4ed70d8 100644 --- a/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp +++ b/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp @@ -48,6 +48,10 @@ DInputSourceManagerEventHandler::~DInputSourceManagerEventHandler() void DInputSourceManagerEventHandler::NotifyRegisterCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -80,6 +84,10 @@ void DInputSourceManagerEventHandler::NotifyRegisterCallback(const AppExecFwk::I void DInputSourceManagerEventHandler::NotifyUnregisterCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -101,6 +109,10 @@ void DInputSourceManagerEventHandler::NotifyUnregisterCallback(const AppExecFwk: void DInputSourceManagerEventHandler::NotifyPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -120,6 +132,10 @@ void DInputSourceManagerEventHandler::NotifyPrepareCallback(const AppExecFwk::In void DInputSourceManagerEventHandler::NotifyUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -139,6 +155,10 @@ void DInputSourceManagerEventHandler::NotifyUnprepareCallback(const AppExecFwk:: void DInputSourceManagerEventHandler::NotifyStartCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -165,6 +185,10 @@ void DInputSourceManagerEventHandler::NotifyStartCallback(const AppExecFwk::Inne void DInputSourceManagerEventHandler::NotifyStopCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -202,6 +226,10 @@ void DInputSourceManagerEventHandler::NotifyStopCallback(const AppExecFwk::Inner void DInputSourceManagerEventHandler::NotifyStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -221,6 +249,10 @@ void DInputSourceManagerEventHandler::NotifyStartDhidCallback(const AppExecFwk:: void DInputSourceManagerEventHandler::NotifyStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -240,6 +272,10 @@ void DInputSourceManagerEventHandler::NotifyStopDhidCallback(const AppExecFwk::I void DInputSourceManagerEventHandler::NotifyKeyStateCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -262,6 +298,10 @@ void DInputSourceManagerEventHandler::NotifyKeyStateCallback(const AppExecFwk::I void DInputSourceManagerEventHandler::NotifyStartServerCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_RESULT)) { @@ -277,6 +317,10 @@ void DInputSourceManagerEventHandler::NotifyStartServerCallback(const AppExecFwk void DInputSourceManagerEventHandler::NotifyRelayPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -295,6 +339,10 @@ void DInputSourceManagerEventHandler::NotifyRelayPrepareCallback(const AppExecFw void DInputSourceManagerEventHandler::NotifyRelayUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -313,6 +361,10 @@ void DInputSourceManagerEventHandler::NotifyRelayUnprepareCallback(const AppExec void DInputSourceManagerEventHandler::NotifyRelayPrepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -345,6 +397,10 @@ void DInputSourceManagerEventHandler::NotifyRelayPrepareRemoteInput(const AppExe void DInputSourceManagerEventHandler::NotifyRelayUnprepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -373,6 +429,10 @@ void DInputSourceManagerEventHandler::NotifyRelayUnprepareRemoteInput(const AppE void DInputSourceManagerEventHandler::NotifyRelayStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -393,6 +453,10 @@ void DInputSourceManagerEventHandler::NotifyRelayStartDhidCallback(const AppExec void DInputSourceManagerEventHandler::NotifyRelayStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -413,6 +477,10 @@ void DInputSourceManagerEventHandler::NotifyRelayStopDhidCallback(const AppExecF void DInputSourceManagerEventHandler::NotifyRelayStartTypeCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -433,6 +501,10 @@ void DInputSourceManagerEventHandler::NotifyRelayStartTypeCallback(const AppExec void DInputSourceManagerEventHandler::NotifyRelayStopTypeCallback(const AppExecFwk::InnerEvent::Pointer &event) { std::shared_ptr dataMsg = event->GetSharedObject(); + if (dataMsg == nullptr) { + DHLOGE("dataMsg is null."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || -- Gitee From 55a8d8a5e8ac87fc3ff285472a75df3b2cab3ecf Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Sun, 13 Oct 2024 10:43:54 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E9=83=A8=E4=BB=B6=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E6=95=B4=E6=94=B9=E3=80=81=E5=90=AF=E5=8A=A8=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E9=80=89=E9=A1=B9FS=E9=80=89=E9=A1=B9=E5=9B=9E=E5=90=885.0.1-r?= =?UTF-8?q?elease?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- dfx_utils/BUILD.gn | 13 ++++++++++++- inputdevicehandler/BUILD.gn | 13 ++++++++++++- interfaces/inner_kits/BUILD.gn | 13 ++++++++++++- .../test/addwhitelistinfoscallbackunittest/BUILD.gn | 2 -- .../test/delwhitelistinfoscallbackunittest/BUILD.gn | 2 -- .../ipc/test/dinputsourcecallbackunittest/BUILD.gn | 2 -- .../fuzztest/distributedinputstub_fuzzer/BUILD.gn | 4 +--- .../test/unpreparedinputcallbackunittest/BUILD.gn | 2 -- .../test/unregisterdinputcallbackunittest/BUILD.gn | 2 -- services/sink/inputcollector/BUILD.gn | 13 ++++++++++++- services/sink/sinkmanager/BUILD.gn | 13 ++++++++++++- services/sink/transport/BUILD.gn | 13 ++++++++++++- services/source/inputinject/BUILD.gn | 13 ++++++++++++- .../inputinject/test/sourceinjectunittest/BUILD.gn | 5 ++--- services/source/sourcemanager/BUILD.gn | 13 ++++++++++++- .../test/sourcemanagerunittest/BUILD.gn | 4 +--- services/source/transport/BUILD.gn | 13 ++++++++++++- .../transport/test/sourcetransunittest/BUILD.gn | 4 +--- services/state/BUILD.gn | 13 ++++++++++++- services/transportbase/BUILD.gn | 13 ++++++++++++- .../transportbase/test/transbaseunittest/BUILD.gn | 3 +-- sinkhandler/BUILD.gn | 13 ++++++++++++- sinkhandler/test/unittest/BUILD.gn | 3 +-- sourcehandler/BUILD.gn | 13 ++++++++++++- sourcehandler/test/unittest/BUILD.gn | 3 +-- test/fuzztest/dinputconfigdh_fuzzer/BUILD.gn | 6 ++---- test/fuzztest/dinputinitsink_fuzzer/BUILD.gn | 4 +--- test/fuzztest/dinputinitsource_fuzzer/BUILD.gn | 6 ++---- test/fuzztest/dinputonsessionclosed_fuzzer/BUILD.gn | 3 +-- test/fuzztest/dinputonsessionopend_fuzzer/BUILD.gn | 3 +-- test/fuzztest/dinputreleasesink_fuzzer/BUILD.gn | 4 +--- test/fuzztest/dinputreleasesource_fuzzer/BUILD.gn | 6 ++---- .../fuzztest/dinputsubscribelocaldh_fuzzer/BUILD.gn | 4 +--- .../fuzztest/distributedinputclient_fuzzer/BUILD.gn | 6 ++---- test/fuzztest/distributedinputkit_fuzzer/BUILD.gn | 4 +--- .../distributedinputsinktransport_fuzzer/BUILD.gn | 3 +-- .../distributedinputsourcetransport_fuzzer/BUILD.gn | 3 +-- .../distributedinputtransportbase_fuzzer/BUILD.gn | 3 +-- utils/BUILD.gn | 7 +++++++ utils/test/unittest/BUILD.gn | 4 +--- 40 files changed, 189 insertions(+), 82 deletions(-) diff --git a/dfx_utils/BUILD.gn b/dfx_utils/BUILD.gn index 9a03a9d..5ed35ce 100755 --- a/dfx_utils/BUILD.gn +++ b/dfx_utils/BUILD.gn @@ -45,6 +45,12 @@ ohos_shared_library("libdinput_dfx_utils") { "LOG_DOMAIN=0xD004120", ] + cflags = [ + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] + deps = [ "${utils_path}:libdinput_utils" ] external_deps = [ @@ -58,7 +64,12 @@ ohos_shared_library("libdinput_dfx_utils") { "samgr:samgr_proxy", ] - cflags_cc = [ "-DHILOG_ENABLE" ] + cflags_cc = [ + "-DHILOG_ENABLE", + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] subsystem_name = "distributedhardware" diff --git a/inputdevicehandler/BUILD.gn b/inputdevicehandler/BUILD.gn index 18db9b3..5c36f6a 100755 --- a/inputdevicehandler/BUILD.gn +++ b/inputdevicehandler/BUILD.gn @@ -45,6 +45,12 @@ ohos_shared_library("libdinput_handler") { "LOG_DOMAIN=0xD004120", ] + cflags = [ + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] + deps = [ "${services_state_path}:libdinput_sink_state", "${utils_path}:libdinput_utils", @@ -66,7 +72,12 @@ ohos_shared_library("libdinput_handler") { "samgr:samgr_proxy", ] - cflags_cc = [ "-DHILOG_ENABLE" ] + cflags_cc = [ + "-DHILOG_ENABLE", + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] subsystem_name = "distributedhardware" diff --git a/interfaces/inner_kits/BUILD.gn b/interfaces/inner_kits/BUILD.gn index 6240ed4..bcbcb96 100644 --- a/interfaces/inner_kits/BUILD.gn +++ b/interfaces/inner_kits/BUILD.gn @@ -95,6 +95,12 @@ ohos_shared_library("libdinput_sdk") { "LOG_DOMAIN=0xD004120", ] + cflags = [ + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] + external_deps = [ "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", @@ -109,7 +115,12 @@ ohos_shared_library("libdinput_sdk") { "samgr:samgr_proxy", ] - cflags_cc = [ "-DHILOG_ENABLE" ] + cflags_cc = [ + "-DHILOG_ENABLE", + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] subsystem_name = "distributedhardware" diff --git a/interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn b/interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn index a4e88ea..df605cf 100644 --- a/interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn +++ b/interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn @@ -30,8 +30,6 @@ ohos_unittest("add_white_list_infos_callbackl_test") { include_dirs = [ "${common_path}/include", "${frameworks_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${innerkits_path}/include", "${innerkits_path}/src", "${ipc_path}/include", diff --git a/interfaces/ipc/test/delwhitelistinfoscallbackunittest/BUILD.gn b/interfaces/ipc/test/delwhitelistinfoscallbackunittest/BUILD.gn index eebbae1..80d3d10 100644 --- a/interfaces/ipc/test/delwhitelistinfoscallbackunittest/BUILD.gn +++ b/interfaces/ipc/test/delwhitelistinfoscallbackunittest/BUILD.gn @@ -30,8 +30,6 @@ ohos_unittest("del_white_list_infos_callbackl_test") { include_dirs = [ "${common_path}/include", "${frameworks_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${innerkits_path}/include", "${innerkits_path}/src", "${ipc_path}/include", diff --git a/interfaces/ipc/test/dinputsourcecallbackunittest/BUILD.gn b/interfaces/ipc/test/dinputsourcecallbackunittest/BUILD.gn index 1d134a5..9a2b0af 100644 --- a/interfaces/ipc/test/dinputsourcecallbackunittest/BUILD.gn +++ b/interfaces/ipc/test/dinputsourcecallbackunittest/BUILD.gn @@ -30,8 +30,6 @@ ohos_unittest("dinput_source_callback_test") { include_dirs = [ "${common_path}/include", "${frameworks_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${innerkits_path}/include", "${innerkits_path}/src", "${ipc_path}/include", diff --git a/interfaces/ipc/test/fuzztest/distributedinputstub_fuzzer/BUILD.gn b/interfaces/ipc/test/fuzztest/distributedinputstub_fuzzer/BUILD.gn index 4aeb961..32ece36 100644 --- a/interfaces/ipc/test/fuzztest/distributedinputstub_fuzzer/BUILD.gn +++ b/interfaces/ipc/test/fuzztest/distributedinputstub_fuzzer/BUILD.gn @@ -23,7 +23,6 @@ ohos_fuzztest("DistributedInputStubFuzzTest") { fuzz_config_file = "${ipc_path}/test/fuzztest/distributedinputstub_fuzzer" include_dirs = [ - "${av_transport_path}/common/include", "${innerkits_path}/include", "${innerkits_path}/ipc/include", "${innerkits_path}/src", @@ -39,8 +38,6 @@ ohos_fuzztest("DistributedInputStubFuzzTest") { "${services_source_path}/transport/include", "${dfx_utils_path}/include", "${utils_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${common_path}/test/mock", "${distributedinput_path}/services/transportbase/include", "${distributedinput_path}/utils/include", @@ -110,6 +107,7 @@ ohos_fuzztest("DistributedInputStubFuzzTest") { "access_token:libtoken_setproc", "access_token:libtokenid_sdk", "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", "eventhandler:libeventhandler", diff --git a/interfaces/ipc/test/unpreparedinputcallbackunittest/BUILD.gn b/interfaces/ipc/test/unpreparedinputcallbackunittest/BUILD.gn index 7091aae..d18c30d 100644 --- a/interfaces/ipc/test/unpreparedinputcallbackunittest/BUILD.gn +++ b/interfaces/ipc/test/unpreparedinputcallbackunittest/BUILD.gn @@ -30,8 +30,6 @@ ohos_unittest("unprepare_d_input_call_back_test") { include_dirs = [ "${common_path}/include", "${frameworks_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${innerkits_path}/include", "${innerkits_path}/src", "${ipc_path}/include", diff --git a/interfaces/ipc/test/unregisterdinputcallbackunittest/BUILD.gn b/interfaces/ipc/test/unregisterdinputcallbackunittest/BUILD.gn index 9f28278..1acd7b1 100644 --- a/interfaces/ipc/test/unregisterdinputcallbackunittest/BUILD.gn +++ b/interfaces/ipc/test/unregisterdinputcallbackunittest/BUILD.gn @@ -30,8 +30,6 @@ ohos_unittest("unregister_d_input_call_back_test") { include_dirs = [ "${common_path}/include", "${frameworks_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${innerkits_path}/include", "${innerkits_path}/src", "${ipc_path}/include", diff --git a/services/sink/inputcollector/BUILD.gn b/services/sink/inputcollector/BUILD.gn index 3711531..57cb891 100755 --- a/services/sink/inputcollector/BUILD.gn +++ b/services/sink/inputcollector/BUILD.gn @@ -44,6 +44,12 @@ ohos_shared_library("libdinput_collector") { "LOG_DOMAIN=0xD004120", ] + cflags = [ + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] + deps = [ "${services_state_path}:libdinput_sink_state", "${utils_path}:libdinput_utils", @@ -65,7 +71,12 @@ ohos_shared_library("libdinput_collector") { "samgr:samgr_proxy", ] - cflags_cc = [ "-DHILOG_ENABLE" ] + cflags_cc = [ + "-DHILOG_ENABLE", + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] subsystem_name = "distributedhardware" diff --git a/services/sink/sinkmanager/BUILD.gn b/services/sink/sinkmanager/BUILD.gn index 806b1bd..0c65940 100644 --- a/services/sink/sinkmanager/BUILD.gn +++ b/services/sink/sinkmanager/BUILD.gn @@ -55,6 +55,12 @@ ohos_shared_library("libdinput_sink") { "LOG_DOMAIN=0xD004120", ] + cflags = [ + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] + deps = [ "${dfx_utils_path}:libdinput_dfx_utils", "${distributedinput_path}/services/state:libdinput_sink_state", @@ -88,7 +94,12 @@ ohos_shared_library("libdinput_sink") { "window_manager:libdm", ] - cflags_cc = [ "-DHILOG_ENABLE" ] + cflags_cc = [ + "-DHILOG_ENABLE", + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] subsystem_name = "distributedhardware" diff --git a/services/sink/transport/BUILD.gn b/services/sink/transport/BUILD.gn index 05d4afa..d82ddc2 100644 --- a/services/sink/transport/BUILD.gn +++ b/services/sink/transport/BUILD.gn @@ -46,6 +46,12 @@ ohos_shared_library("libdinput_sink_trans") { "LOG_DOMAIN=0xD004120", ] + cflags = [ + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] + deps = [ "${dfx_utils_path}:libdinput_dfx_utils", "${distributedinput_path}/services/transportbase:libdinput_trans_base", @@ -70,7 +76,12 @@ ohos_shared_library("libdinput_sink_trans") { "samgr:samgr_proxy", ] - cflags_cc = [ "-DHILOG_ENABLE" ] + cflags_cc = [ + "-DHILOG_ENABLE", + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] subsystem_name = "distributedhardware" diff --git a/services/source/inputinject/BUILD.gn b/services/source/inputinject/BUILD.gn index 91829be..0c84f71 100644 --- a/services/source/inputinject/BUILD.gn +++ b/services/source/inputinject/BUILD.gn @@ -49,6 +49,12 @@ ohos_shared_library("libdinput_inject") { "LOG_DOMAIN=0xD004120", ] + cflags = [ + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] + deps = [ "${dfx_utils_path}:libdinput_dfx_utils", "${services_state_path}:libdinput_sink_state", @@ -72,7 +78,12 @@ ohos_shared_library("libdinput_inject") { "samgr:samgr_proxy", ] - cflags_cc = [ "-DHILOG_ENABLE" ] + cflags_cc = [ + "-DHILOG_ENABLE", + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] subsystem_name = "distributedhardware" diff --git a/services/source/inputinject/test/sourceinjectunittest/BUILD.gn b/services/source/inputinject/test/sourceinjectunittest/BUILD.gn index 29a542b..8bcdd98 100755 --- a/services/source/inputinject/test/sourceinjectunittest/BUILD.gn +++ b/services/source/inputinject/test/sourceinjectunittest/BUILD.gn @@ -28,7 +28,6 @@ ohos_unittest("distributed_input_inner_sourceinject_test") { module_out_path = module_out_path include_dirs = [ - "${av_transport_path}/common/include", "${innerkits_path}/include", "${ipc_path}/include", "${services_source_path}/inputinject/include", @@ -39,8 +38,6 @@ ohos_unittest("distributed_input_inner_sourceinject_test") { "${service_common}/include", "${dfx_utils_path}/include", "${utils_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${distributedinput_path}/inputdevicehandler/include", "${common_path}/test/mock", ] @@ -78,7 +75,9 @@ ohos_unittest("distributed_input_inner_sourceinject_test") { external_deps = [ "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", + "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/source/sourcemanager/BUILD.gn b/services/source/sourcemanager/BUILD.gn index 11f8a32..aa02846 100644 --- a/services/source/sourcemanager/BUILD.gn +++ b/services/source/sourcemanager/BUILD.gn @@ -92,6 +92,12 @@ ohos_shared_library("libdinput_source") { "LOG_DOMAIN=0xD004120", ] + cflags = [ + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] + deps = [ "${dfx_utils_path}:libdinput_dfx_utils", "${distributedinput_path}/services/transportbase:libdinput_trans_base", @@ -123,7 +129,12 @@ ohos_shared_library("libdinput_source") { "samgr:samgr_proxy", ] - cflags_cc = [ "-DHILOG_ENABLE" ] + cflags_cc = [ + "-DHILOG_ENABLE", + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] subsystem_name = "distributedhardware" diff --git a/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn b/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn index eb21b67..9049c4d 100755 --- a/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn +++ b/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn @@ -27,7 +27,6 @@ ohos_unittest("distributed_input_sourcemanager_test") { module_out_path = module_out_path include_dirs = [ - "${av_transport_path}/common/include", "${innerkits_path}/include", "${innerkits_path}/ipc/include", "${innerkits_path}/src", @@ -43,8 +42,6 @@ ohos_unittest("distributed_input_sourcemanager_test") { "${services_source_path}/transport/include", "${dfx_utils_path}/include", "${utils_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${common_path}/test/mock", "${distributedinput_path}/services/transportbase/include", "${distributedinput_path}/utils/include", @@ -120,6 +117,7 @@ ohos_unittest("distributed_input_sourcemanager_test") { "access_token:libtoken_setproc", "access_token:libtokenid_sdk", "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", "eventhandler:libeventhandler", diff --git a/services/source/transport/BUILD.gn b/services/source/transport/BUILD.gn index 874649d..f5431b6 100755 --- a/services/source/transport/BUILD.gn +++ b/services/source/transport/BUILD.gn @@ -45,6 +45,12 @@ ohos_shared_library("libdinput_source_trans") { "LOG_DOMAIN=0xD004120", ] + cflags = [ + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] + deps = [ "${dfx_utils_path}:libdinput_dfx_utils", "${distributedinput_path}/services/transportbase:libdinput_trans_base", @@ -68,7 +74,12 @@ ohos_shared_library("libdinput_source_trans") { "samgr:samgr_proxy", ] - cflags_cc = [ "-DHILOG_ENABLE" ] + cflags_cc = [ + "-DHILOG_ENABLE", + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] subsystem_name = "distributedhardware" diff --git a/services/source/transport/test/sourcetransunittest/BUILD.gn b/services/source/transport/test/sourcetransunittest/BUILD.gn index 9decfe3..10d33f3 100755 --- a/services/source/transport/test/sourcetransunittest/BUILD.gn +++ b/services/source/transport/test/sourcetransunittest/BUILD.gn @@ -28,13 +28,10 @@ ohos_unittest("distributed_input_sourcetrans_test") { module_out_path = module_out_path include_dirs = [ - "${av_transport_path}/common/include", "${services_source_path}/transport/include", "${distributedinput_path}/services/transportbase/include", "${common_path}/include", "${frameworks_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${service_common}/include", "${services_source_path}/inputinject/include", "${services_source_path}/transport/include", @@ -80,6 +77,7 @@ ohos_unittest("distributed_input_sourcetrans_test") { external_deps = [ "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", "eventhandler:libeventhandler", diff --git a/services/state/BUILD.gn b/services/state/BUILD.gn index 8b01a01..20e77df 100644 --- a/services/state/BUILD.gn +++ b/services/state/BUILD.gn @@ -49,6 +49,12 @@ ohos_shared_library("libdinput_sink_state") { "LOG_DOMAIN=0xD004120", ] + cflags = [ + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] + deps = [ "${dfx_utils_path}:libdinput_dfx_utils", "${services_sink_path}/transport:libdinput_sink_trans", @@ -70,7 +76,12 @@ ohos_shared_library("libdinput_sink_state") { "samgr:samgr_proxy", ] - cflags_cc = [ "-DHILOG_ENABLE" ] + cflags_cc = [ + "-DHILOG_ENABLE", + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] subsystem_name = "distributedhardware" diff --git a/services/transportbase/BUILD.gn b/services/transportbase/BUILD.gn index 439a74d..622f14e 100644 --- a/services/transportbase/BUILD.gn +++ b/services/transportbase/BUILD.gn @@ -44,6 +44,12 @@ ohos_shared_library("libdinput_trans_base") { "LOG_DOMAIN=0xD004120", ] + cflags = [ + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] + deps = [ "${dfx_utils_path}:libdinput_dfx_utils", "${utils_path}:libdinput_utils", @@ -66,7 +72,12 @@ ohos_shared_library("libdinput_trans_base") { "samgr:samgr_proxy", ] - cflags_cc = [ "-DHILOG_ENABLE" ] + cflags_cc = [ + "-DHILOG_ENABLE", + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] subsystem_name = "distributedhardware" diff --git a/services/transportbase/test/transbaseunittest/BUILD.gn b/services/transportbase/test/transbaseunittest/BUILD.gn index c95459e..14c9a6d 100644 --- a/services/transportbase/test/transbaseunittest/BUILD.gn +++ b/services/transportbase/test/transbaseunittest/BUILD.gn @@ -28,12 +28,10 @@ ohos_unittest("distributed_input_transbase_test") { module_out_path = module_out_path include_dirs = [ - "${av_transport_path}/common/include", "${distributedinput_path}/services/source/transport/include", "${distributedinput_path}/services/sink/transport/include", "${distributedinput_path}/services/transportbase/include", "${common_path}/include", - "${fwk_interfaces_path}/include", "${service_common}/include", "${services_source_path}/inputinject/include", "${dfx_utils_path}/include", @@ -78,6 +76,7 @@ ohos_unittest("distributed_input_transbase_test") { external_deps = [ "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", "eventhandler:libeventhandler", diff --git a/sinkhandler/BUILD.gn b/sinkhandler/BUILD.gn index a49104d..b9a2c76 100644 --- a/sinkhandler/BUILD.gn +++ b/sinkhandler/BUILD.gn @@ -50,6 +50,12 @@ ohos_shared_library("libdinput_sink_handler") { "LOG_DOMAIN=0xD004120", ] + cflags = [ + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] + deps = [ "${dfx_utils_path}:libdinput_dfx_utils", "${innerkits_path}:libdinput_sdk", @@ -68,7 +74,12 @@ ohos_shared_library("libdinput_sink_handler") { "samgr:samgr_proxy", ] - cflags_cc = [ "-DHILOG_ENABLE" ] + cflags_cc = [ + "-DHILOG_ENABLE", + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] subsystem_name = "distributedhardware" diff --git a/sinkhandler/test/unittest/BUILD.gn b/sinkhandler/test/unittest/BUILD.gn index 51356ca..60c928e 100755 --- a/sinkhandler/test/unittest/BUILD.gn +++ b/sinkhandler/test/unittest/BUILD.gn @@ -38,8 +38,6 @@ ohos_unittest("distributed_input_sink_handler_test") { "${service_common}/include", "${common_path}/include", "${dfx_utils_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${services_source_path}/inputinject/include", "${utils_path}/include", ] @@ -74,6 +72,7 @@ ohos_unittest("distributed_input_sink_handler_test") { external_deps = [ "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "distributed_hardware_fwk:libdhfwk_sdk", "eventhandler:libeventhandler", "hilog:libhilog", "hisysevent:libhisysevent", diff --git a/sourcehandler/BUILD.gn b/sourcehandler/BUILD.gn index d054e1d..1ba3d88 100644 --- a/sourcehandler/BUILD.gn +++ b/sourcehandler/BUILD.gn @@ -52,6 +52,12 @@ ohos_shared_library("libdinput_source_handler") { "LOG_DOMAIN=0xD004120", ] + cflags = [ + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] + deps = [ "${dfx_utils_path}:libdinput_dfx_utils", "${innerkits_path}:libdinput_sdk", @@ -71,7 +77,12 @@ ohos_shared_library("libdinput_source_handler") { "samgr:samgr_proxy", ] - cflags_cc = [ "-DHILOG_ENABLE" ] + cflags_cc = [ + "-DHILOG_ENABLE", + "-fstack-protector-strong", + "-D_FORTIFY_SOURCE=2", + "-O2", + ] subsystem_name = "distributedhardware" diff --git a/sourcehandler/test/unittest/BUILD.gn b/sourcehandler/test/unittest/BUILD.gn index 4a97320..1552a55 100755 --- a/sourcehandler/test/unittest/BUILD.gn +++ b/sourcehandler/test/unittest/BUILD.gn @@ -38,8 +38,6 @@ ohos_unittest("distributed_input_source_handler_test") { "${service_common}/include", "${common_path}/include", "${dfx_utils_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${services_source_path}/inputinject/include", "${distributedinput_path}/services/state/include", "${utils_path}/include", @@ -75,6 +73,7 @@ ohos_unittest("distributed_input_source_handler_test") { external_deps = [ "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "distributed_hardware_fwk:libdhfwk_sdk", "eventhandler:libeventhandler", "hilog:libhilog", "hisysevent:libhisysevent", diff --git a/test/fuzztest/dinputconfigdh_fuzzer/BUILD.gn b/test/fuzztest/dinputconfigdh_fuzzer/BUILD.gn index 618ff36..9e19f17 100644 --- a/test/fuzztest/dinputconfigdh_fuzzer/BUILD.gn +++ b/test/fuzztest/dinputconfigdh_fuzzer/BUILD.gn @@ -24,8 +24,6 @@ ohos_fuzztest("DinputConfigDhFuzzTest") { "${distributedinput_path}/test/fuzztest/dinputconfigdh_fuzzer" include_dirs = [ - "${av_transport_path}/common/include", - "include", "${distributedinput_path}/interfaces/inner_kits/include", "${distributedinput_path}/interfaces/ipc/include", "${distributedinput_path}/services/source/sourcemanager/include", @@ -36,8 +34,6 @@ ohos_fuzztest("DinputConfigDhFuzzTest") { "${distributedinput_path}/services/state/include", "${service_common}/include", "${common_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${services_source_path}/inputinject/include", "${utils_path}/include", ] @@ -55,7 +51,9 @@ ohos_fuzztest("DinputConfigDhFuzzTest") { external_deps = [ "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", + "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/test/fuzztest/dinputinitsink_fuzzer/BUILD.gn b/test/fuzztest/dinputinitsink_fuzzer/BUILD.gn index a32520f..59a5609 100644 --- a/test/fuzztest/dinputinitsink_fuzzer/BUILD.gn +++ b/test/fuzztest/dinputinitsink_fuzzer/BUILD.gn @@ -24,7 +24,6 @@ ohos_fuzztest("DinputInitSinkFuzzTest") { "${distributedinput_path}/test/fuzztest/dinputinitsink_fuzzer" include_dirs = [ - "include", "${distributedinput_path}/interfaces/inner_kits/include", "${distributedinput_path}/interfaces/ipc/include", "${distributedinput_path}/services/source/sourcemanager/include", @@ -34,8 +33,6 @@ ohos_fuzztest("DinputInitSinkFuzzTest") { "${distributedinput_path}/inputdevicehandler/include", "${service_common}/include", "${common_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${services_source_path}/inputinject/include", "${utils_path}/include", ] @@ -54,6 +51,7 @@ ohos_fuzztest("DinputInitSinkFuzzTest") { external_deps = [ "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/test/fuzztest/dinputinitsource_fuzzer/BUILD.gn b/test/fuzztest/dinputinitsource_fuzzer/BUILD.gn index 47708c9..5851cfc 100644 --- a/test/fuzztest/dinputinitsource_fuzzer/BUILD.gn +++ b/test/fuzztest/dinputinitsource_fuzzer/BUILD.gn @@ -24,8 +24,6 @@ ohos_fuzztest("DinputInitSourceFuzzTest") { "${distributedinput_path}/test/fuzztest/dinputinitsource_fuzzer" include_dirs = [ - "${av_transport_path}/common/include", - "include", "${distributedinput_path}/interfaces/inner_kits/include", "${distributedinput_path}/interfaces/ipc/include", "${distributedinput_path}/services/source/sourcemanager/include", @@ -36,8 +34,6 @@ ohos_fuzztest("DinputInitSourceFuzzTest") { "${distributedinput_path}/inputdevicehandler/include", "${service_common}/include", "${common_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${services_source_path}/inputinject/include", "${utils_path}/include", ] @@ -55,7 +51,9 @@ ohos_fuzztest("DinputInitSourceFuzzTest") { external_deps = [ "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", + "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/test/fuzztest/dinputonsessionclosed_fuzzer/BUILD.gn b/test/fuzztest/dinputonsessionclosed_fuzzer/BUILD.gn index 712c739..e01d84a 100644 --- a/test/fuzztest/dinputonsessionclosed_fuzzer/BUILD.gn +++ b/test/fuzztest/dinputonsessionclosed_fuzzer/BUILD.gn @@ -24,11 +24,9 @@ ohos_fuzztest("DinputOnSessionClosedFuzzTest") { "${distributedinput_path}/test/fuzztest/dinputonsessionclosed_fuzzer" include_dirs = [ - "${av_transport_path}/common/include", "${services_source_path}/transport/include", "${distributedinput_path}/services/transportbase/include", "${common_path}/include", - "${fwk_interfaces_path}/include", "${service_common}/include", "${services_source_path}/inputinject/include", "${services_source_path}/transport/include", @@ -56,6 +54,7 @@ ohos_fuzztest("DinputOnSessionClosedFuzzTest") { external_deps = [ "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", diff --git a/test/fuzztest/dinputonsessionopend_fuzzer/BUILD.gn b/test/fuzztest/dinputonsessionopend_fuzzer/BUILD.gn index 6118282..dbc16d7 100644 --- a/test/fuzztest/dinputonsessionopend_fuzzer/BUILD.gn +++ b/test/fuzztest/dinputonsessionopend_fuzzer/BUILD.gn @@ -24,11 +24,9 @@ ohos_fuzztest("DinputOnSessionOpendFuzzTest") { "${distributedinput_path}/test/fuzztest/dinputonsessionopend_fuzzer" include_dirs = [ - "${av_transport_path}/common/include", "${services_source_path}/transport/include", "${distributedinput_path}/services/transportbase/include", "${common_path}/include", - "${fwk_interfaces_path}/include", "${service_common}/include", "${services_source_path}/inputinject/include", "${services_source_path}/transport/include", @@ -56,6 +54,7 @@ ohos_fuzztest("DinputOnSessionOpendFuzzTest") { external_deps = [ "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", diff --git a/test/fuzztest/dinputreleasesink_fuzzer/BUILD.gn b/test/fuzztest/dinputreleasesink_fuzzer/BUILD.gn index dee65b3..da48302 100644 --- a/test/fuzztest/dinputreleasesink_fuzzer/BUILD.gn +++ b/test/fuzztest/dinputreleasesink_fuzzer/BUILD.gn @@ -24,7 +24,6 @@ ohos_fuzztest("DinputReleaseSinkFuzzTest") { "${distributedinput_path}/test/fuzztest/dinputreleasesink_fuzzer" include_dirs = [ - "include", "${distributedinput_path}/interfaces/inner_kits/include", "${distributedinput_path}/interfaces/ipc/include", "${distributedinput_path}/services/source/sourcemanager/include", @@ -34,8 +33,6 @@ ohos_fuzztest("DinputReleaseSinkFuzzTest") { "${distributedinput_path}/inputdevicehandler/include", "${service_common}/include", "${common_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${services_source_path}/inputinject/include", "${utils_path}/include", ] @@ -54,6 +51,7 @@ ohos_fuzztest("DinputReleaseSinkFuzzTest") { external_deps = [ "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/test/fuzztest/dinputreleasesource_fuzzer/BUILD.gn b/test/fuzztest/dinputreleasesource_fuzzer/BUILD.gn index b336826..feed3f0 100644 --- a/test/fuzztest/dinputreleasesource_fuzzer/BUILD.gn +++ b/test/fuzztest/dinputreleasesource_fuzzer/BUILD.gn @@ -24,8 +24,6 @@ ohos_fuzztest("DinputReleaseSourceFuzzTest") { "${distributedinput_path}/test/fuzztest/dinputreleasesource_fuzzer" include_dirs = [ - "${av_transport_path}/common/include", - "include", "${distributedinput_path}/interfaces/inner_kits/include", "${distributedinput_path}/interfaces/ipc/include", "${distributedinput_path}/services/source/sourcemanager/include", @@ -36,8 +34,6 @@ ohos_fuzztest("DinputReleaseSourceFuzzTest") { "${distributedinput_path}/services/state/include", "${service_common}/include", "${common_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${services_source_path}/inputinject/include", "${utils_path}/include", ] @@ -55,7 +51,9 @@ ohos_fuzztest("DinputReleaseSourceFuzzTest") { external_deps = [ "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", + "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/test/fuzztest/dinputsubscribelocaldh_fuzzer/BUILD.gn b/test/fuzztest/dinputsubscribelocaldh_fuzzer/BUILD.gn index 244ac95..6f6dbdf 100644 --- a/test/fuzztest/dinputsubscribelocaldh_fuzzer/BUILD.gn +++ b/test/fuzztest/dinputsubscribelocaldh_fuzzer/BUILD.gn @@ -24,7 +24,6 @@ ohos_fuzztest("DinputSubscribeLocalDhFuzzTest") { "${distributedinput_path}/test/fuzztest/dinputsubscribelocaldh_fuzzer" include_dirs = [ - "include", "${distributedinput_path}/interfaces/inner_kits/include", "${distributedinput_path}/interfaces/ipc/include", "${distributedinput_path}/services/source/sourcemanager/include", @@ -34,8 +33,6 @@ ohos_fuzztest("DinputSubscribeLocalDhFuzzTest") { "${distributedinput_path}/inputdevicehandler/include", "${service_common}/include", "${common_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${services_source_path}/inputinject/include", "${utils_path}/include", ] @@ -54,6 +51,7 @@ ohos_fuzztest("DinputSubscribeLocalDhFuzzTest") { external_deps = [ "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/test/fuzztest/distributedinputclient_fuzzer/BUILD.gn b/test/fuzztest/distributedinputclient_fuzzer/BUILD.gn index e0385bb..ed010c2 100755 --- a/test/fuzztest/distributedinputclient_fuzzer/BUILD.gn +++ b/test/fuzztest/distributedinputclient_fuzzer/BUILD.gn @@ -25,8 +25,6 @@ ohos_fuzztest("DistributedInputClientFuzzTest") { "${distributedinput_path}/test/fuzztest/distributedinputclient_fuzzer" include_dirs = [ - "${av_transport_path}/common/include", - "include", "${distributedinput_path}/interfaces/inner_kits/include", "${distributedinput_path}/interfaces/ipc/include", "${distributedinput_path}/services/source/sourcemanager/include", @@ -38,8 +36,6 @@ ohos_fuzztest("DistributedInputClientFuzzTest") { "${distributedinput_path}/services/state/include", "${service_common}/include", "${common_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${services_source_path}/inputinject/include", "${utils_path}/include", ] @@ -57,7 +53,9 @@ ohos_fuzztest("DistributedInputClientFuzzTest") { external_deps = [ "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", + "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/test/fuzztest/distributedinputkit_fuzzer/BUILD.gn b/test/fuzztest/distributedinputkit_fuzzer/BUILD.gn index 5446cee..903bd09 100755 --- a/test/fuzztest/distributedinputkit_fuzzer/BUILD.gn +++ b/test/fuzztest/distributedinputkit_fuzzer/BUILD.gn @@ -25,7 +25,6 @@ ohos_fuzztest("DistributedInputKitFuzzTest") { "${distributedinput_path}/test/fuzztest/distributedinputkit_fuzzer" include_dirs = [ - "include", "${distributedinput_path}/interfaces/inner_kits/include", "${distributedinput_path}/interfaces/ipc/include", "${distributedinput_path}/services/source/sourcemanager/include", @@ -37,8 +36,6 @@ ohos_fuzztest("DistributedInputKitFuzzTest") { "${service_common}/include", "${common_path}/include", "${utils_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${services_source_path}/inputinject/include", "${distributedinput_path}/services/state/include", ] @@ -57,6 +54,7 @@ ohos_fuzztest("DistributedInputKitFuzzTest") { external_deps = [ "c_utils:utils", "distributed_hardware_fwk:distributedhardwareutils", + "distributed_hardware_fwk:libdhfwk_sdk", "eventhandler:libeventhandler", "hilog:libhilog", "ipc:ipc_core", diff --git a/test/fuzztest/distributedinputsinktransport_fuzzer/BUILD.gn b/test/fuzztest/distributedinputsinktransport_fuzzer/BUILD.gn index cda17bf..bdc0ac2 100755 --- a/test/fuzztest/distributedinputsinktransport_fuzzer/BUILD.gn +++ b/test/fuzztest/distributedinputsinktransport_fuzzer/BUILD.gn @@ -24,12 +24,10 @@ ohos_fuzztest("DistributedInputSinkTransportFuzzTest") { fuzz_config_file = "${distributedinput_path}/test/fuzztest/distributedinputsinktransport_fuzzer" include_dirs = [ - "${av_transport_path}/common/include", "${services_sink_path}/transport/include", "${distributedinput_path}/services/transportbase/include", "${common_path}/include", "${frameworks_path}/include", - "${fwk_interfaces_path}/include", "${service_common}/include", "${dfx_utils_path}/include", "${utils_path}/include", @@ -55,6 +53,7 @@ ohos_fuzztest("DistributedInputSinkTransportFuzzTest") { external_deps = [ "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", diff --git a/test/fuzztest/distributedinputsourcetransport_fuzzer/BUILD.gn b/test/fuzztest/distributedinputsourcetransport_fuzzer/BUILD.gn index c49970b..d64cc59 100755 --- a/test/fuzztest/distributedinputsourcetransport_fuzzer/BUILD.gn +++ b/test/fuzztest/distributedinputsourcetransport_fuzzer/BUILD.gn @@ -24,11 +24,9 @@ ohos_fuzztest("DistributedInputSourceTransportFuzzTest") { fuzz_config_file = "${distributedinput_path}/test/fuzztest/distributedinputsourcetransport_fuzzer" include_dirs = [ - "${av_transport_path}/common/include", "${services_source_path}/transport/include", "${distributedinput_path}/services/transportbase/include", "${common_path}/include", - "${fwk_interfaces_path}/include", "${service_common}/include", "${services_source_path}/inputinject/include", "${services_source_path}/transport/include", @@ -60,6 +58,7 @@ ohos_fuzztest("DistributedInputSourceTransportFuzzTest") { external_deps = [ "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", diff --git a/test/fuzztest/distributedinputtransportbase_fuzzer/BUILD.gn b/test/fuzztest/distributedinputtransportbase_fuzzer/BUILD.gn index ef8e18b..455674a 100644 --- a/test/fuzztest/distributedinputtransportbase_fuzzer/BUILD.gn +++ b/test/fuzztest/distributedinputtransportbase_fuzzer/BUILD.gn @@ -24,11 +24,9 @@ ohos_fuzztest("DistributedInputTransportBaseFuzzTest") { fuzz_config_file = "${distributedinput_path}/test/fuzztest/distributedinputtransportbase_fuzzer" include_dirs = [ - "${av_transport_path}/common/include", "${services_source_path}/transport/include", "${distributedinput_path}/services/transportbase/include", "${common_path}/include", - "${fwk_interfaces_path}/include", "${service_common}/include", "${services_source_path}/inputinject/include", "${services_source_path}/transport/include", @@ -59,6 +57,7 @@ ohos_fuzztest("DistributedInputTransportBaseFuzzTest") { external_deps = [ "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", "dsoftbus:softbus_client", diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 085b405..af7c746 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -44,6 +44,13 @@ ohos_shared_library("libdinput_utils") { "LOG_DOMAIN=0xD004120", ] + cflags = [ + "-O2", + "-D_FORTIFY_SOURCE=2", + ] + + cflags_cc = cflags + external_deps = [ "c_utils:utils", "distributed_hardware_fwk:distributed_av_receiver", diff --git a/utils/test/unittest/BUILD.gn b/utils/test/unittest/BUILD.gn index 8e73687..8907d48 100644 --- a/utils/test/unittest/BUILD.gn +++ b/utils/test/unittest/BUILD.gn @@ -28,12 +28,9 @@ ohos_unittest("distributed_input_utils_test") { module_out_path = module_out_path include_dirs = [ - "${av_transport_path}/common/include", "${utils_path}/include", "${utils_path}/test/unittest", "${common_path}/include", - "${fwk_interfaces_path}/include", - "${fwk_interfaces_path}/include/ipc", "${frameworks_path}/include", "${common_path}/test/mock", "${service_common}/include", @@ -65,6 +62,7 @@ ohos_unittest("distributed_input_utils_test") { external_deps = [ "c_utils:utils", + "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", "hilog:libhilog", -- Gitee From f4330eefe3919eb9b728f6b2282e61e908d40e2d Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Sun, 13 Oct 2024 11:04:36 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=9B=9E=E5=90=885.0.1-release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- common/include/dinput_errcode.h | 1 + .../include/distributed_input_handler.h | 8 +- .../src/distributed_input_handler.cpp | 18 ++-- .../distributed_input_handler_test.cpp | 14 ++-- .../mock/mock_distributed_input_client.cpp | 12 +-- interfaces/ipc/include/dinput_sa_manager.h | 10 +-- .../ipc/include/distributed_input_client.h | 20 ++--- interfaces/ipc/src/dinput_sa_manager.cpp | 32 +++---- .../ipc/src/distributed_input_client.cpp | 83 ++++++++++--------- .../distributedinputstub_fuzzer/BUILD.gn | 2 - .../src/distributed_input_sink_manager.cpp | 14 ++-- .../src/distributed_input_node_manager.cpp | 4 + .../dinput_source_manager_event_handler.cpp | 72 ++++++++++++++++ .../mock/mock_distributed_input_client.cpp | 12 +-- .../mock/mock_distributed_input_client.cpp | 12 +-- ...tributed_input_source_transport_fuzzer.cpp | 2 +- ...istributed_input_transport_base_fuzzer.cpp | 2 +- 17 files changed, 199 insertions(+), 119 deletions(-) diff --git a/common/include/dinput_errcode.h b/common/include/dinput_errcode.h index a950bf0..ce0f8d7 100644 --- a/common/include/dinput_errcode.h +++ b/common/include/dinput_errcode.h @@ -68,6 +68,7 @@ namespace DistributedInput { constexpr int32_t ERR_DH_INPUT_SERVER_SINK_MANAGER_START_MSG_IS_BAD = -64015; constexpr int32_t ERR_DH_INPUT_SERVER_SINK_MANAGER_STOP_MSG_IS_BAD = -64016; constexpr int32_t ERR_DH_INPUT_SERVER_SINK_MANAGER_RELEASE_FAIL = -64017; + constexpr int32_t ERR_DH_INPUT_SERVER_SINK_MANAGER_IS_NULL = -64018; // service source error code constexpr int32_t ERR_DH_INPUT_SERVER_SOURCE_INJECT_REGISTER_FAIL = -65000; constexpr int32_t ERR_DH_INPUT_SERVER_SOURCE_INJECT_UNREGISTER_FAIL = -65001; diff --git a/inputdevicehandler/include/distributed_input_handler.h b/inputdevicehandler/include/distributed_input_handler.h index 3ec7e17..04cf0a0 100644 --- a/inputdevicehandler/include/distributed_input_handler.h +++ b/inputdevicehandler/include/distributed_input_handler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -60,14 +60,14 @@ private: pthread_t collectThreadID_; bool isCollectingEvents_; - bool isStartCollectEventThread; + bool isStartCollectEventThread_; static void *CollectEventsThread(void *param); void StartInputMonitorDeviceThread(); void StopInputMonitorDeviceThread(); // The event queue. - static const int inputDeviceBufferSize = 32; - InputDeviceEvent mEventBuffer[inputDeviceBufferSize] = {}; + static const int inputDeviceBufferSize_ = 32; + InputDeviceEvent mEventBuffer_[inputDeviceBufferSize_] = {}; std::mutex operationMutex_; std::unique_ptr inputHub_; }; diff --git a/inputdevicehandler/src/distributed_input_handler.cpp b/inputdevicehandler/src/distributed_input_handler.cpp index 7582ebc..2a5f7bd 100644 --- a/inputdevicehandler/src/distributed_input_handler.cpp +++ b/inputdevicehandler/src/distributed_input_handler.cpp @@ -42,7 +42,7 @@ namespace DistributedHardware { namespace DistributedInput { IMPLEMENT_SINGLE_INSTANCE(DistributedInputHandler); DistributedInputHandler::DistributedInputHandler() - : collectThreadID_(-1), isCollectingEvents_(false), isStartCollectEventThread(false) + : collectThreadID_(-1), isCollectingEvents_(false), isStartCollectEventThread_(false) { inputHub_ = std::make_unique(true); this->m_listener = nullptr; @@ -88,9 +88,9 @@ void DistributedInputHandler::StructTransJson(const InputDevice &pBuf, std::stri int32_t DistributedInputHandler::Initialize() { - if (!isStartCollectEventThread) { + if (!isStartCollectEventThread_) { InitCollectEventsThread(); - isStartCollectEventThread = true; + isStartCollectEventThread_ = true; } return DH_SUCCESS; } @@ -196,7 +196,7 @@ void DistributedInputHandler::StartInputMonitorDeviceThread() return; } while (isCollectingEvents_) { - size_t count = inputHub_->StartCollectInputHandler(mEventBuffer, inputDeviceBufferSize); + size_t count = inputHub_->StartCollectInputHandler(mEventBuffer_, inputDeviceBufferSize_); if (count > 0) { DHLOGI("Count: %{public}zu", count); for (size_t iCnt = 0; iCnt < count; iCnt++) { @@ -212,18 +212,18 @@ void DistributedInputHandler::StartInputMonitorDeviceThread() void DistributedInputHandler::NotifyHardWare(int iCnt) { - switch (mEventBuffer[iCnt].type) { + switch (mEventBuffer_[iCnt].type) { case DeviceType::DEVICE_ADDED: if (this->m_listener != nullptr) { std::string hdInfo; - StructTransJson(mEventBuffer[iCnt].deviceInfo, hdInfo); + StructTransJson(mEventBuffer_[iCnt].deviceInfo, hdInfo); std::string subtype = "input"; - this->m_listener->PluginHardware(mEventBuffer[iCnt].deviceInfo.descriptor, hdInfo, subtype); + this->m_listener->PluginHardware(mEventBuffer_[iCnt].deviceInfo.descriptor, hdInfo, subtype); } break; case DeviceType::DEVICE_REMOVED: if (this->m_listener != nullptr) { - this->m_listener->UnPluginHardware(mEventBuffer[iCnt].deviceInfo.descriptor); + this->m_listener->UnPluginHardware(mEventBuffer_[iCnt].deviceInfo.descriptor); } break; default: @@ -238,7 +238,7 @@ void DistributedInputHandler::StopInputMonitorDeviceThread() return; } isCollectingEvents_ = false; - isStartCollectEventThread = false; + isStartCollectEventThread_ = false; inputHub_->StopCollectInputHandler(); if (collectThreadID_ != (pthread_t)(-1)) { DHLOGI("DistributedInputHandler::Wait collect thread exit"); diff --git a/inputdevicehandler/test/inputhandlertest/distributed_input_handler_test.cpp b/inputdevicehandler/test/inputhandlertest/distributed_input_handler_test.cpp index 47765dc..7228a77 100644 --- a/inputdevicehandler/test/inputhandlertest/distributed_input_handler_test.cpp +++ b/inputdevicehandler/test/inputhandlertest/distributed_input_handler_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -64,14 +64,14 @@ HWTEST_F(DInputHandlerTest, FindDevicesInfoByType_001, testing::ext::TestSize.Le dInputHandler.StartInputMonitorDeviceThread(); InputDevice inputDevice; - dInputHandler.mEventBuffer[0].type = DeviceType::DEVICE_ADDED; - dInputHandler.mEventBuffer[0].deviceInfo = inputDevice; + dInputHandler.mEventBuffer_[0].type = DeviceType::DEVICE_ADDED; + dInputHandler.mEventBuffer_[0].deviceInfo = inputDevice; dInputHandler.NotifyHardWare(0); - dInputHandler.mEventBuffer[1].type = DeviceType::DEVICE_REMOVED; - dInputHandler.mEventBuffer[1].deviceInfo = inputDevice; + dInputHandler.mEventBuffer_[1].type = DeviceType::DEVICE_REMOVED; + dInputHandler.mEventBuffer_[1].deviceInfo = inputDevice; dInputHandler.NotifyHardWare(1); - dInputHandler.mEventBuffer[2].type = DeviceType::FINISHED_DEVICE_SCAN; - dInputHandler.mEventBuffer[2].deviceInfo = inputDevice; + dInputHandler.mEventBuffer_[2].type = DeviceType::FINISHED_DEVICE_SCAN; + dInputHandler.mEventBuffer_[2].deviceInfo = inputDevice; dInputHandler.NotifyHardWare(2); std::map ret = dInputHandler.QueryExtraInfo(); EXPECT_EQ(0, ret.size()); diff --git a/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp b/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp index a466428..6f08b93 100644 --- a/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp +++ b/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp @@ -38,11 +38,11 @@ DistributedInputClient &DistributedInputClient::GetInstance() void DistributedInputClient::RegisterDInputCb::OnResult( const std::string &devId, const std::string &dhId, const int32_t &status) { - auto iter = DistributedInputClient::GetInstance().dHardWareFwkRstInfos.begin(); - for (; iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos.end(); ++iter) { + auto iter = DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.begin(); + for (; iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { iter->callback->OnRegisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.erase(iter); return; } } @@ -51,11 +51,11 @@ void DistributedInputClient::RegisterDInputCb::OnResult( void DistributedInputClient::UnregisterDInputCb::OnResult( const std::string &devId, const std::string &dhId, const int32_t &status) { - auto iter = DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.begin(); - for (; iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.end(); ++iter) { + auto iter = DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.begin(); + for (; iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { iter->callback->OnUnregisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.erase(iter); return; } } diff --git a/interfaces/ipc/include/dinput_sa_manager.h b/interfaces/ipc/include/dinput_sa_manager.h index 6792393..2abc95f 100644 --- a/interfaces/ipc/include/dinput_sa_manager.h +++ b/interfaces/ipc/include/dinput_sa_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -71,10 +71,10 @@ private: ~DInputSAManager() = default; public: - std::atomic dInputSourceSAOnline = false; - std::atomic dInputSinkSAOnline = false; - std::atomic isSubscribeSrcSAChangeListener = false; - std::atomic isSubscribeSinkSAChangeListener = false; + std::atomic dInputSourceSAOnline_ = false; + std::atomic dInputSinkSAOnline_ = false; + std::atomic isSubscribeSrcSAChangeListener_ = false; + std::atomic isSubscribeSinkSAChangeListener_ = false; std::mutex sinkMutex_; std::mutex sourceMutex_; std::mutex handlerMutex_; diff --git a/interfaces/ipc/include/distributed_input_client.h b/interfaces/ipc/include/distributed_input_client.h index 6fe7865..0e2ad78 100644 --- a/interfaces/ipc/include/distributed_input_client.h +++ b/interfaces/ipc/include/distributed_input_client.h @@ -179,7 +179,7 @@ private: private: static std::shared_ptr instance; - DInputServerType serverType = DInputServerType::NULL_SERVER_TYPE; + DInputServerType serverType_ = DInputServerType::NULL_SERVER_TYPE; DInputDeviceType inputTypes_ = DInputDeviceType::NONE; std::set> addWhiteListCallbacks_; @@ -193,12 +193,12 @@ private: std::shared_ptr eventHandler_; - std::atomic isAddWhiteListCbReg; - std::atomic isDelWhiteListCbReg; - std::atomic isNodeMonitorCbReg; - std::atomic isSimulationEventCbReg; - std::atomic isSharingDhIdsReg; - std::atomic isGetSinkScreenInfosCbReg; + std::atomic isAddWhiteListCbReg_; + std::atomic isDelWhiteListCbReg_; + std::atomic isNodeMonitorCbReg_; + std::atomic isSimulationEventCbReg_; + std::atomic isSharingDhIdsReg_; + std::atomic isGetSinkScreenInfosCbReg_; struct DHardWareFwkRegistInfo { std::string devId; @@ -212,9 +212,9 @@ private: std::shared_ptr callback = nullptr; }; - std::vector dHardWareFwkRstInfos; - std::vector dHardWareFwkUnRstInfos; - std::vector screenTransInfos; + std::vector dHardWareFwkRstInfos_; + std::vector dHardWareFwkUnRstInfos_; + std::vector screenTransInfos_; std::mutex operationMutex_; std::mutex sharingDhIdsMtx_; diff --git a/interfaces/ipc/src/dinput_sa_manager.cpp b/interfaces/ipc/src/dinput_sa_manager.cpp index 9f03e48..bb72e37 100644 --- a/interfaces/ipc/src/dinput_sa_manager.cpp +++ b/interfaces/ipc/src/dinput_sa_manager.cpp @@ -30,7 +30,7 @@ const uint32_t DINPUT_CLIENT_HANDLER_MSG_DELAY_TIME = 100; // million seconds void DInputSAManager::SystemAbilityListener::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) { if (systemAbilityId == DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID) { - DInputSAManager::GetInstance().dInputSourceSAOnline.store(false); + DInputSAManager::GetInstance().dInputSourceSAOnline_.store(false); { std::lock_guard lock(DInputSAManager::GetInstance().sourceMutex_); DInputSAManager::GetInstance().dInputSourceProxy_ = nullptr; @@ -48,7 +48,7 @@ void DInputSAManager::SystemAbilityListener::OnRemoveSystemAbility(int32_t syste } if (systemAbilityId == DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID) { - DInputSAManager::GetInstance().dInputSinkSAOnline.store(false); + DInputSAManager::GetInstance().dInputSinkSAOnline_.store(false); { std::lock_guard lock(DInputSAManager::GetInstance().sinkMutex_); DInputSAManager::GetInstance().dInputSinkProxy_ = nullptr; @@ -70,7 +70,7 @@ void DInputSAManager::SystemAbilityListener::OnRemoveSystemAbility(int32_t syste void DInputSAManager::SystemAbilityListener::OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) { if (systemAbilityId == DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID) { - DInputSAManager::GetInstance().dInputSourceSAOnline.store(true); + DInputSAManager::GetInstance().dInputSourceSAOnline_.store(true); std::lock_guard lock(DInputSAManager::GetInstance().handlerMutex_); if (DInputSAManager::GetInstance().eventHandler_ != nullptr) { DHLOGI("SendEvent DINPUT_CLIENT_CHECK_SOURCE_CALLBACK_REGISTER_MSG"); @@ -82,7 +82,7 @@ void DInputSAManager::SystemAbilityListener::OnAddSystemAbility(int32_t systemAb } if (systemAbilityId == DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID) { - DInputSAManager::GetInstance().dInputSinkSAOnline.store(true); + DInputSAManager::GetInstance().dInputSinkSAOnline_.store(true); std::lock_guard lock(DInputSAManager::GetInstance().handlerMutex_); if (DInputSAManager::GetInstance().eventHandler_ != nullptr) { DHLOGI("SendEvent DINPUT_CLIENT_CHECK_SINK_CALLBACK_REGISTER_MSG"); @@ -106,7 +106,7 @@ void DInputSAManager::Init() return; } - if (!isSubscribeSrcSAChangeListener.load()) { + if (!isSubscribeSrcSAChangeListener_.load()) { DHLOGI("try subscribe source sa change listener, saId:%{public}d", DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID); int32_t ret = systemAbilityManager->SubscribeSystemAbility(DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID, saListenerCallback); @@ -114,10 +114,10 @@ void DInputSAManager::Init() DHLOGE("subscribe source sa change failed: %{public}d", ret); return; } - isSubscribeSrcSAChangeListener.store(true); + isSubscribeSrcSAChangeListener_.store(true); } - if (!isSubscribeSinkSAChangeListener.load()) { + if (!isSubscribeSinkSAChangeListener_.load()) { DHLOGI("try subscribe sink sa change listener, saId:%{public}d", DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID); int32_t ret = systemAbilityManager->SubscribeSystemAbility(DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID, saListenerCallback); @@ -125,7 +125,7 @@ void DInputSAManager::Init() DHLOGE("subscribe sink sa change failed: %{public}d", ret); return; } - isSubscribeSinkSAChangeListener.store(true); + isSubscribeSinkSAChangeListener_.store(true); } } @@ -137,9 +137,9 @@ void DInputSAManager::RegisterEventHandler(std::shared_ptr lock(DInputSAManager::GetInstance().sourceMutex_); - if (!isSubscribeSrcSAChangeListener.load()) { + if (!isSubscribeSrcSAChangeListener_.load()) { sptr systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (!systemAbilityManager) { @@ -154,11 +154,11 @@ bool DInputSAManager::GetDInputSourceProxy() DHLOGE("subscribe source sa change failed: %{public}d", ret); return false; } - isSubscribeSrcSAChangeListener.store(true); + isSubscribeSrcSAChangeListener_.store(true); } } - if (dInputSourceSAOnline.load() && !dInputSourceProxy_) { + if (dInputSourceSAOnline_.load() && !dInputSourceProxy_) { std::lock_guard lock(DInputSAManager::GetInstance().sourceMutex_); if (dInputSourceProxy_ != nullptr) { DHLOGI("dinput source proxy has already got."); @@ -208,9 +208,9 @@ bool DInputSAManager::SetDInputSourceProxy(const sptr &remoteObje bool DInputSAManager::GetDInputSinkProxy() { - if (!isSubscribeSinkSAChangeListener.load()) { + if (!isSubscribeSinkSAChangeListener_.load()) { std::lock_guard lock(DInputSAManager::GetInstance().sinkMutex_); - if (!isSubscribeSinkSAChangeListener.load()) { + if (!isSubscribeSinkSAChangeListener_.load()) { sptr systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (!systemAbilityManager) { @@ -225,11 +225,11 @@ bool DInputSAManager::GetDInputSinkProxy() DHLOGE("subscribe sink sa change failed: %{public}d", ret); return false; } - isSubscribeSinkSAChangeListener.store(true); + isSubscribeSinkSAChangeListener_.store(true); } } - if (dInputSinkSAOnline.load() && !dInputSinkProxy_) { + if (dInputSinkSAOnline_.load() && !dInputSinkProxy_) { std::lock_guard lock(DInputSAManager::GetInstance().sinkMutex_); if (dInputSinkProxy_ != nullptr) { DHLOGI("dinput sink proxy has already got."); diff --git a/interfaces/ipc/src/distributed_input_client.cpp b/interfaces/ipc/src/distributed_input_client.cpp index a1faa31..233635b 100644 --- a/interfaces/ipc/src/distributed_input_client.cpp +++ b/interfaces/ipc/src/distributed_input_client.cpp @@ -34,8 +34,9 @@ namespace OHOS { namespace DistributedHardware { namespace DistributedInput { std::shared_ptr DistributedInputClient::instance = std::make_shared(); -DistributedInputClient::DistributedInputClient() : isAddWhiteListCbReg(false), isDelWhiteListCbReg(false), - isNodeMonitorCbReg(false), isSimulationEventCbReg(false), isSharingDhIdsReg(false), isGetSinkScreenInfosCbReg(false) +DistributedInputClient::DistributedInputClient() : isAddWhiteListCbReg_(false), isDelWhiteListCbReg_(false), + isNodeMonitorCbReg_(false), isSimulationEventCbReg_(false), isSharingDhIdsReg_(false), + isGetSinkScreenInfosCbReg_(false) { DHLOGI("DistributedInputClient init start"); std::shared_ptr runner = AppExecFwk::EventRunner::Create(true); @@ -55,12 +56,12 @@ void DistributedInputClient::RegisterDInputCb::OnResult( { std::lock_guard lock(DistributedInputClient::GetInstance().operationMutex_); for (std::vector::iterator iter = - DistributedInputClient::GetInstance().dHardWareFwkRstInfos.begin(); - iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos.end(); + DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.begin(); + iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId && (iter->callback != nullptr)) { iter->callback->OnRegisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.erase(iter); return; } } @@ -71,12 +72,12 @@ void DistributedInputClient::UnregisterDInputCb::OnResult( { std::lock_guard lock(DistributedInputClient::GetInstance().operationMutex_); for (std::vector::iterator iter = - DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.begin(); - iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.end(); + DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.begin(); + iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId && (iter->callback != nullptr)) { iter->callback->OnUnregisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.erase(iter); return; } } @@ -147,26 +148,26 @@ void DistributedInputClient::DInputClientEventHandler::ProcessEvent(const AppExe if (eventId == DINPUT_CLIENT_CLEAR_SOURCE_CALLBACK_REGISTER_MSG) { DHLOGI("Source SA exit, clear callback flag"); - DistributedInputClient::GetInstance().isAddWhiteListCbReg = false; - DistributedInputClient::GetInstance().isDelWhiteListCbReg = false; - DistributedInputClient::GetInstance().isNodeMonitorCbReg = false; - DistributedInputClient::GetInstance().isSimulationEventCbReg = false; + DistributedInputClient::GetInstance().isAddWhiteListCbReg_.store(false); + DistributedInputClient::GetInstance().isDelWhiteListCbReg_.store(false); + DistributedInputClient::GetInstance().isNodeMonitorCbReg_.store(false); + DistributedInputClient::GetInstance().isSimulationEventCbReg_.store(false); return; } if (eventId == DINPUT_CLIENT_CLEAR_SINK_CALLBACK_REGISTER_MSG) { DHLOGI("Sink SA exit, clear callback flag"); - DistributedInputClient::GetInstance().isSharingDhIdsReg = false; + DistributedInputClient::GetInstance().isSharingDhIdsReg_.store(false); return; } } void DistributedInputClient::CheckSourceRegisterCallback() { - DHLOGI("CheckSourceRegisterCallback called, isAddWhiteListCbReg[%{public}d], isDelWhiteListCbReg[%{public}d], " - "isNodeMonitorCbReg[%{public}d], isSimulationEventCbReg[%{public}d]", - isAddWhiteListCbReg.load(), isDelWhiteListCbReg.load(), isNodeMonitorCbReg.load(), - isSimulationEventCbReg.load()); + DHLOGI("CheckSourceRegisterCallback called, isAddWhiteListCbReg_[%{public}d], isDelWhiteListCbReg_[%{public}d], " + "isNodeMonitorCbReg_[%{public}d], isSimulationEventCbReg_[%{public}d]", + isAddWhiteListCbReg_.load(), isDelWhiteListCbReg_.load(), isNodeMonitorCbReg_.load(), + isSimulationEventCbReg_.load()); CheckWhiteListCallback(); CheckKeyStateCallback(); @@ -174,7 +175,7 @@ void DistributedInputClient::CheckSourceRegisterCallback() void DistributedInputClient::CheckSinkRegisterCallback() { - DHLOGI("CheckSinkRegisterCallback called, isSharingDhIdsReg[%{public}d]", isSharingDhIdsReg.load()); + DHLOGI("CheckSinkRegisterCallback called, isSharingDhIdsReg_[%{public}d]", isSharingDhIdsReg_.load()); CheckSharingDhIdsCallback(); CheckSinkScreenInfoCallback(); } @@ -186,12 +187,12 @@ void DistributedInputClient::CheckSharingDhIdsCallback() return; } std::lock_guard lock(DInputSAManager::GetInstance().sinkMutex_); - if (!isSharingDhIdsReg) { + if (!isSharingDhIdsReg_.load()) { sptr listener(new (std::nothrow) SharingDhIdListenerCb()); int32_t ret = DInputSAManager::GetInstance().dInputSinkProxy_->RegisterSharingDhIdListener(listener); if (ret == DH_SUCCESS) { - isSharingDhIdsReg = true; + isSharingDhIdsReg_.store(true); std::lock_guard lock(operationMutex_); sharingDhIdListeners_.insert(listener); } else { @@ -207,24 +208,24 @@ void DistributedInputClient::CheckWhiteListCallback() return; } std::lock_guard lock(DInputSAManager::GetInstance().sourceMutex_); - if (!isAddWhiteListCbReg) { + if (!isAddWhiteListCbReg_.load()) { sptr addCallback(new (std::nothrow) AddWhiteListInfosCb()); int32_t ret = DInputSAManager::GetInstance().dInputSourceProxy_->RegisterAddWhiteListCallback(addCallback); if (ret == DH_SUCCESS) { - isAddWhiteListCbReg = true; + isAddWhiteListCbReg_.store(true); std::lock_guard lock(operationMutex_); addWhiteListCallbacks_.insert(addCallback); } else { DHLOGE("CheckWhiteListCallback client RegisterAddWhiteListCallback fail"); } } - if (!isDelWhiteListCbReg) { + if (!isDelWhiteListCbReg_.load()) { sptr delCallback(new (std::nothrow) DelWhiteListInfosCb()); int32_t ret = DInputSAManager::GetInstance().dInputSourceProxy_->RegisterDelWhiteListCallback(delCallback); if (ret == DH_SUCCESS) { - isDelWhiteListCbReg = true; + isDelWhiteListCbReg_.store(true); std::lock_guard lock(operationMutex_); delWhiteListCallbacks_.insert(delCallback); } else { @@ -240,9 +241,9 @@ void DistributedInputClient::CheckKeyStateCallback() return; } std::lock_guard lock(DInputSAManager::GetInstance().sourceMutex_); - if (!isSimulationEventCbReg && regSimulationEventListener_ != nullptr) { + if (!isSimulationEventCbReg_.load() && regSimulationEventListener_ != nullptr) { DInputSAManager::GetInstance().dInputSourceProxy_->RegisterSimulationEventListener(regSimulationEventListener_); - isSimulationEventCbReg = true; + isSimulationEventCbReg_.store(true); } } @@ -253,12 +254,12 @@ void DistributedInputClient::CheckSinkScreenInfoCallback() return; } std::lock_guard lock(DInputSAManager::GetInstance().sinkMutex_); - if (!isGetSinkScreenInfosCbReg) { + if (!isGetSinkScreenInfosCbReg_.load()) { sptr callback(new (std::nothrow) GetSinkScreenInfosCb()); int32_t ret = DInputSAManager::GetInstance().dInputSinkProxy_->RegisterGetSinkScreenInfosCallback(callback); if (ret == DH_SUCCESS) { - isGetSinkScreenInfosCbReg = true; + isGetSinkScreenInfosCbReg_.store(true); std::lock_guard lock(operationMutex_); getSinkScreenInfosCallbacks_.insert(callback); } else { @@ -291,7 +292,7 @@ int32_t DistributedInputClient::ReleaseSource() return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL; } - serverType = DInputServerType::NULL_SERVER_TYPE; + serverType_ = DInputServerType::NULL_SERVER_TYPE; inputTypes_ = DInputDeviceType::NONE; regNodeListener_ = nullptr; unregNodeListener_ = nullptr; @@ -312,7 +313,7 @@ int32_t DistributedInputClient::ReleaseSink() if (!DInputSAManager::GetInstance().GetDInputSinkProxy()) { return ERR_DH_INPUT_CLIENT_GET_SINK_PROXY_FAIL; } - serverType = DInputServerType::NULL_SERVER_TYPE; + serverType_ = DInputServerType::NULL_SERVER_TYPE; inputTypes_ = DInputDeviceType::NONE; { std::lock_guard lock(operationMutex_); @@ -338,13 +339,13 @@ int32_t DistributedInputClient::RegisterDistributedHardware(const std::string &d } { std::lock_guard lock(DistributedInputClient::GetInstance().operationMutex_); - for (auto iter : dHardWareFwkRstInfos) { + for (auto iter : dHardWareFwkRstInfos_) { if (iter.devId == devId && iter.dhId == dhId) { return ERR_DH_INPUT_CLIENT_REGISTER_FAIL; } } DHardWareFwkRegistInfo info {devId, dhId, callback}; - dHardWareFwkRstInfos.push_back(info); + dHardWareFwkRstInfos_.push_back(info); } std::lock_guard lock(DInputSAManager::GetInstance().sourceMutex_); return DInputSAManager::GetInstance().dInputSourceProxy_->RegisterDistributedHardware(devId, dhId, parameters, @@ -365,13 +366,13 @@ int32_t DistributedInputClient::UnregisterDistributedHardware(const std::string } { std::lock_guard lock(DistributedInputClient::GetInstance().operationMutex_); - for (auto iter : dHardWareFwkUnRstInfos) { + for (auto iter : dHardWareFwkUnRstInfos_) { if (iter.devId == devId && iter.dhId == dhId) { return ERR_DH_INPUT_CLIENT_UNREGISTER_FAIL; } } DHardWareFwkUnRegistInfo info {devId, dhId, callback}; - dHardWareFwkUnRstInfos.push_back(info); + dHardWareFwkUnRstInfos_.push_back(info); } std::lock_guard lock(DInputSAManager::GetInstance().sourceMutex_); return DInputSAManager::GetInstance().dInputSourceProxy_->UnregisterDistributedHardware(devId, dhId, @@ -579,7 +580,7 @@ bool DistributedInputClient::IsNeedFilterOut(const std::string &deviceId, const bool DistributedInputClient::IsTouchEventNeedFilterOut(const TouchScreenEvent &event) { std::lock_guard lock(operationMutex_); - for (const auto &info : screenTransInfos) { + for (const auto &info : screenTransInfos_) { DHLOGI("sinkProjPhyWidth: %{public}d sinkProjPhyHeight: %{public}d", info.sinkProjPhyWidth, info.sinkProjPhyHeight); if ((event.absX >= info.sinkWinPhyX) && (event.absX <= (info.sinkWinPhyX + info.sinkProjPhyWidth)) @@ -609,17 +610,17 @@ int32_t DistributedInputClient::RegisterSimulationEventListener(sptr lock(DInputSAManager::GetInstance().sourceMutex_); int32_t ret = DInputSAManager::GetInstance().dInputSourceProxy_->RegisterSimulationEventListener(listener); if (ret == DH_SUCCESS) { - isSimulationEventCbReg = true; + isSimulationEventCbReg_.store(true); DInputSAManager::GetInstance().AddSimEventListenerToCache(listener); } else { - isSimulationEventCbReg = false; + isSimulationEventCbReg_.store(false); regSimulationEventListener_ = listener; DHLOGE("RegisterSimulationEventListener Failed, ret = %{public}d", ret); } @@ -693,7 +694,7 @@ void DistributedInputClient::DelWhiteListInfos(const std::string &deviceId) cons void DistributedInputClient::UpdateSinkScreenInfos(const std::string &strJson) { std::lock_guard lock(operationMutex_); - screenTransInfos.clear(); + screenTransInfos_.clear(); nlohmann::json inputData = nlohmann::json::parse(strJson, nullptr, false); if (inputData.is_discarded()) { DHLOGE("InputData parse failed!"); @@ -712,8 +713,8 @@ void DistributedInputClient::UpdateSinkScreenInfos(const std::string &strJson) continue; } TransformInfo tmp{info[0], info[1], info[2], info[3]}; - screenTransInfos.emplace_back(tmp); - DHLOGI("screenTransInfos size %{public}zu", screenTransInfos.size()); + screenTransInfos_.emplace_back(tmp); + DHLOGI("screenTransInfos_ size %{public}zu", screenTransInfos_.size()); } } diff --git a/interfaces/ipc/test/fuzztest/distributedinputstub_fuzzer/BUILD.gn b/interfaces/ipc/test/fuzztest/distributedinputstub_fuzzer/BUILD.gn index 4aeb961..05ad188 100644 --- a/interfaces/ipc/test/fuzztest/distributedinputstub_fuzzer/BUILD.gn +++ b/interfaces/ipc/test/fuzztest/distributedinputstub_fuzzer/BUILD.gn @@ -26,9 +26,7 @@ ohos_fuzztest("DistributedInputStubFuzzTest") { "${av_transport_path}/common/include", "${innerkits_path}/include", "${innerkits_path}/ipc/include", - "${innerkits_path}/src", "${ipc_path}/include", - "${ipc_path}/src", "${services_source_path}/sourcemanager/include", "${frameworks_path}/include", "${distributedinput_path}/inputdevicehandler/include", diff --git a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp index db6e65c..a0b47b0 100644 --- a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp +++ b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp @@ -393,6 +393,10 @@ void DistributedInputSinkManager::DInputSinkListener::OnRelayStartDhidRemoteInpu void DistributedInputSinkManager::DInputSinkListener::OnRelayStopDhidRemoteInput(const int32_t &toSrcSessionId, const int32_t &toSinkSessionId, const std::string &deviceId, const std::string &strDhids) { + if (sinkManagerObj_ == nullptr) { + DHLOGE("sinkManagerObj is null."); + return; + } DHLOGI("onRelayStopDhidRemoteInput called, toSinkSessionId: %{public}d", toSinkSessionId); std::vector stopIndeedDhIds; std::vector stopOnCmdDhIds; @@ -423,10 +427,6 @@ void DistributedInputSinkManager::DInputSinkListener::OnRelayStopDhidRemoteInput DHLOGE("Not all devices are stopped."); return; } - if (sinkManagerObj_ == nullptr) { - DHLOGE("sinkManagerObj is null."); - return; - } DistributedInputSinkSwitch::GetInstance().StopAllSwitch(); sinkManagerObj_->SetInputTypes(static_cast(DInputDeviceType::NONE)); if (DistributedInputSinkSwitch::GetInstance().GetSwitchOpenedSession() == @@ -865,6 +865,10 @@ int32_t DistributedInputSinkManager::ProjectWindowListener::ParseMessage(const s int32_t DistributedInputSinkManager::ProjectWindowListener::UpdateSinkScreenInfoCache(const std::string &srcDevId, const uint64_t srcWinId, const SinkScreenInfo &sinkScreenInfoTmp) { + if (sinkManagerObj_ == nullptr) { + DHLOGE("sinkManagerObj is null."); + return ERR_DH_INPUT_SERVER_SINK_MANAGER_IS_NULL; + } std::string srcScreenInfoKey = DInputContext::GetInstance().GetScreenInfoKey(srcDevId, srcWinId); SinkScreenInfo sinkScreenInfo = DInputContext::GetInstance().GetSinkScreenInfo(srcScreenInfoKey); sinkScreenInfo.sinkShowWinId = sinkScreenInfoTmp.sinkShowWinId; @@ -885,7 +889,7 @@ int32_t DistributedInputSinkManager::ProjectWindowListener::UpdateSinkScreenInfo sinkScreenInfo.sinkPhyWidth, sinkScreenInfo.sinkPhyHeight); int32_t ret = DInputContext::GetInstance().UpdateSinkScreenInfo(srcScreenInfoKey, sinkScreenInfo); std::lock_guard lock(sinkManagerObj_->mutex_); - if ((ret == DH_SUCCESS) && (sinkManagerObj_!= nullptr) && (sinkManagerObj_->GetSinkScreenInfosCbackSize() > 0)) { + if ((ret == DH_SUCCESS) && (sinkManagerObj_->GetSinkScreenInfosCbackSize() > 0)) { sinkManagerObj_->CallBackScreenInfoChange(); } return ret; diff --git a/services/source/inputinject/src/distributed_input_node_manager.cpp b/services/source/inputinject/src/distributed_input_node_manager.cpp index 7828cd1..c78bf3b 100644 --- a/services/source/inputinject/src/distributed_input_node_manager.cpp +++ b/services/source/inputinject/src/distributed_input_node_manager.cpp @@ -202,6 +202,10 @@ void DistributedInputNodeManager::DInputNodeManagerEventHandler::ScanAllNode( const AppExecFwk::InnerEvent::Pointer &event) { DHLOGI("ScanAllNode enter."); + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); diff --git a/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp b/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp index 4ed70d8..e2d917b 100644 --- a/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp +++ b/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp @@ -47,6 +47,10 @@ DInputSourceManagerEventHandler::~DInputSourceManagerEventHandler() void DInputSourceManagerEventHandler::NotifyRegisterCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -83,6 +87,10 @@ void DInputSourceManagerEventHandler::NotifyRegisterCallback(const AppExecFwk::I void DInputSourceManagerEventHandler::NotifyUnregisterCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -108,6 +116,10 @@ void DInputSourceManagerEventHandler::NotifyUnregisterCallback(const AppExecFwk: void DInputSourceManagerEventHandler::NotifyPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -131,6 +143,10 @@ void DInputSourceManagerEventHandler::NotifyPrepareCallback(const AppExecFwk::In void DInputSourceManagerEventHandler::NotifyUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -154,6 +170,10 @@ void DInputSourceManagerEventHandler::NotifyUnprepareCallback(const AppExecFwk:: void DInputSourceManagerEventHandler::NotifyStartCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -184,6 +204,10 @@ void DInputSourceManagerEventHandler::NotifyStartCallback(const AppExecFwk::Inne void DInputSourceManagerEventHandler::NotifyStopCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -225,6 +249,10 @@ void DInputSourceManagerEventHandler::NotifyStopCallback(const AppExecFwk::Inner void DInputSourceManagerEventHandler::NotifyStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -248,6 +276,10 @@ void DInputSourceManagerEventHandler::NotifyStartDhidCallback(const AppExecFwk:: void DInputSourceManagerEventHandler::NotifyStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -271,6 +303,10 @@ void DInputSourceManagerEventHandler::NotifyStopDhidCallback(const AppExecFwk::I void DInputSourceManagerEventHandler::NotifyKeyStateCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -297,6 +333,10 @@ void DInputSourceManagerEventHandler::NotifyKeyStateCallback(const AppExecFwk::I void DInputSourceManagerEventHandler::NotifyStartServerCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -316,6 +356,10 @@ void DInputSourceManagerEventHandler::NotifyStartServerCallback(const AppExecFwk void DInputSourceManagerEventHandler::NotifyRelayPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -338,6 +382,10 @@ void DInputSourceManagerEventHandler::NotifyRelayPrepareCallback(const AppExecFw void DInputSourceManagerEventHandler::NotifyRelayUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -360,6 +408,10 @@ void DInputSourceManagerEventHandler::NotifyRelayUnprepareCallback(const AppExec void DInputSourceManagerEventHandler::NotifyRelayPrepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -396,6 +448,10 @@ void DInputSourceManagerEventHandler::NotifyRelayPrepareRemoteInput(const AppExe void DInputSourceManagerEventHandler::NotifyRelayUnprepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -428,6 +484,10 @@ void DInputSourceManagerEventHandler::NotifyRelayUnprepareRemoteInput(const AppE void DInputSourceManagerEventHandler::NotifyRelayStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -452,6 +512,10 @@ void DInputSourceManagerEventHandler::NotifyRelayStartDhidCallback(const AppExec void DInputSourceManagerEventHandler::NotifyRelayStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -476,6 +540,10 @@ void DInputSourceManagerEventHandler::NotifyRelayStopDhidCallback(const AppExecF void DInputSourceManagerEventHandler::NotifyRelayStartTypeCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -500,6 +568,10 @@ void DInputSourceManagerEventHandler::NotifyRelayStartTypeCallback(const AppExec void DInputSourceManagerEventHandler::NotifyRelayStopTypeCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); diff --git a/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp b/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp index df24e9e..44a15ef 100644 --- a/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp +++ b/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp @@ -33,11 +33,11 @@ DistributedInputClient &DistributedInputClient::GetInstance() void DistributedInputClient::RegisterDInputCb::OnResult( const std::string &devId, const std::string &dhId, const int32_t &status) { - auto iter = DistributedInputClient::GetInstance().dHardWareFwkRstInfos.begin(); - for (; iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos.end(); ++iter) { + auto iter = DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.begin(); + for (; iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { iter->callback->OnRegisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.erase(iter); return; } } @@ -46,11 +46,11 @@ void DistributedInputClient::RegisterDInputCb::OnResult( void DistributedInputClient::UnregisterDInputCb::OnResult( const std::string &devId, const std::string &dhId, const int32_t &status) { - auto iter = DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.begin(); - for (; iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.end(); ++iter) { + auto iter = DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.begin(); + for (; iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { iter->callback->OnUnregisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.erase(iter); return; } } diff --git a/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp b/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp index ecf6c16..7d97f9d 100644 --- a/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp +++ b/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp @@ -34,11 +34,11 @@ DistributedInputClient &DistributedInputClient::GetInstance() void DistributedInputClient::RegisterDInputCb::OnResult( const std::string &devId, const std::string &dhId, const int32_t &status) { - auto iter = DistributedInputClient::GetInstance().dHardWareFwkRstInfos.begin(); - for (; iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos.end(); ++iter) { + auto iter = DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.begin(); + for (; iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { iter->callback->OnRegisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.erase(iter); return; } } @@ -47,11 +47,11 @@ void DistributedInputClient::RegisterDInputCb::OnResult( void DistributedInputClient::UnregisterDInputCb::OnResult( const std::string &devId, const std::string &dhId, const int32_t &status) { - auto iter = DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.begin(); - for (; iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.end(); ++iter) { + auto iter = DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.begin(); + for (; iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { iter->callback->OnUnregisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.erase(iter); return; } } diff --git a/test/fuzztest/distributedinputsourcetransport_fuzzer/distributed_input_source_transport_fuzzer.cpp b/test/fuzztest/distributedinputsourcetransport_fuzzer/distributed_input_source_transport_fuzzer.cpp index 452f36c..1426b91 100644 --- a/test/fuzztest/distributedinputsourcetransport_fuzzer/distributed_input_source_transport_fuzzer.cpp +++ b/test/fuzztest/distributedinputsourcetransport_fuzzer/distributed_input_source_transport_fuzzer.cpp @@ -32,7 +32,7 @@ namespace OHOS { namespace DistributedHardware { void OpenInputSoftbusFuzzTest(const uint8_t *data, size_t size) { - if ((data == nullptr) || (size < sizeof(int32_t))) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/test/fuzztest/distributedinputtransportbase_fuzzer/distributed_input_transport_base_fuzzer.cpp b/test/fuzztest/distributedinputtransportbase_fuzzer/distributed_input_transport_base_fuzzer.cpp index ffeac36..24bdce9 100644 --- a/test/fuzztest/distributedinputtransportbase_fuzzer/distributed_input_transport_base_fuzzer.cpp +++ b/test/fuzztest/distributedinputtransportbase_fuzzer/distributed_input_transport_base_fuzzer.cpp @@ -31,7 +31,7 @@ namespace OHOS { namespace DistributedHardware { void StartSessionFuzzTest(const uint8_t *data, size_t size) { - if ((data == nullptr) || (size < sizeof(int32_t))) { + if ((data == nullptr) || (size == 0)) { return; } -- Gitee From 285209cb4a0fb2a75d1627277221b397a501a242 Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Thu, 17 Oct 2024 14:32:52 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=88=86?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E5=9B=9E=E5=90=885.0.1-release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- bundle.json | 3 +- common/include/dinput_errcode.h | 1 - common/include/white_list_util.cpp | 29 ++++++++++++++----- common/include/white_list_util.h | 6 ++-- dfx_utils/BUILD.gn | 1 - .../ipc/src/distributed_input_client.cpp | 4 +-- services/sink/sinkmanager/BUILD.gn | 2 -- .../distributed_input_source_manager.h | 4 ++- .../src/distributed_input_source_manager.cpp | 12 ++++++-- services/source/transport/BUILD.gn | 2 -- services/state/BUILD.gn | 1 - ...tributed_input_source_transport_fuzzer.cpp | 2 +- ...istributed_input_transport_base_fuzzer.cpp | 2 +- 13 files changed, 43 insertions(+), 26 deletions(-) diff --git a/bundle.json b/bundle.json index 0c80f8b..265b5bb 100755 --- a/bundle.json +++ b/bundle.json @@ -44,8 +44,7 @@ "hitrace", "graphic_surface", "window_manager", - "openssl", - "graphic_2d" + "openssl" ] }, "build": { diff --git a/common/include/dinput_errcode.h b/common/include/dinput_errcode.h index ce0f8d7..61b5044 100644 --- a/common/include/dinput_errcode.h +++ b/common/include/dinput_errcode.h @@ -44,7 +44,6 @@ namespace DistributedInput { // whilte list error code constexpr int32_t ERR_DH_INPUT_WHILTELIST_INIT_FAIL = -61001; constexpr int32_t ERR_DH_INPUT_WHILTELIST_GET_WHILTELIST_FAIL = -61002; - constexpr int32_t ERR_DH_INPUT_WHILTELIST_FILE_PATH_IS_NULL = -61003; // handler error code constexpr int32_t ERR_DH_INPUT_HANDLER_GET_DEVICE_ID_FAIL = -63000; diff --git a/common/include/white_list_util.cpp b/common/include/white_list_util.cpp index 07cb3e8..31c6f1d 100644 --- a/common/include/white_list_util.cpp +++ b/common/include/white_list_util.cpp @@ -17,8 +17,6 @@ #include #include -#include -#include #include "config_policy_utils.h" @@ -60,19 +58,34 @@ WhiteListUtil &WhiteListUtil::GetInstance(void) return instance; } -int32_t WhiteListUtil::Init() +bool WhiteListUtil::GetWhiteListCfgFile(std::ifstream &ifs) { char buf[MAX_PATH_LEN] = {0}; char path[PATH_MAX + 1] = {0x00}; char *whiteListFilePath = GetOneCfgFile(WHITELIST_FILE_PATH, buf, MAX_PATH_LEN); + if (whiteListFilePath == nullptr) { + DHLOGE("whiteListFilePath is null."); + return false; + } + if (strlen(whiteListFilePath) == 0 || strlen(whiteListFilePath) > PATH_MAX || realpath(whiteListFilePath, path) == nullptr) { DHLOGE("File connicailization failed."); - return ERR_DH_INPUT_WHILTELIST_INIT_FAIL; + return false; } - std::ifstream inFile(path, std::ios::in | std::ios::binary); - if (!inFile.is_open()) { + + ifs.open(path, std::ios::in | std::ios::binary); + if (!ifs.is_open()) { DHLOGE("WhiteListUtil Init error, file open fail path=%{public}s", path); + return false; + } + return true; +} + +int32_t WhiteListUtil::Init() +{ + std::ifstream ifs; + if (!GetWhiteListCfgFile(ifs)) { return ERR_DH_INPUT_WHILTELIST_INIT_FAIL; } @@ -81,7 +94,7 @@ int32_t WhiteListUtil::Init() TYPE_WHITE_LIST_VEC vecWhiteList; std::string line; std::size_t lineNum = 0; - while (getline(inFile, line)) { + while (getline(ifs, line)) { if ((++lineNum > MAX_LINE_NUM) || !IsValidLine(line)) { DHLOGE("whitelist cfg file has too many lines or too complicated. lineNum is %{public}zu", lineNum); break; @@ -106,7 +119,7 @@ int32_t WhiteListUtil::Init() vecCombinationKey.clear(); } } - inFile.close(); + ifs.close(); std::string localNetworkId = GetLocalDeviceInfo().networkId; if (!localNetworkId.empty()) { SyncWhiteList(localNetworkId, vecWhiteList); diff --git a/common/include/white_list_util.h b/common/include/white_list_util.h index f184737..7426aa8 100644 --- a/common/include/white_list_util.h +++ b/common/include/white_list_util.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -18,6 +18,8 @@ #include #include +#include +#include #include "constants_dinput.h" @@ -47,7 +49,7 @@ public: int32_t ClearWhiteList(const std::string &deviceId); int32_t ClearWhiteList(void); int32_t GetWhiteList(const std::string &deviceId, TYPE_WHITE_LIST_VEC &vecWhiteList); - + bool GetWhiteListCfgFile(std::ifstream &ifs); /* * check is event in white list of deviceId * diff --git a/dfx_utils/BUILD.gn b/dfx_utils/BUILD.gn index 5ed35ce..fe8af2d 100755 --- a/dfx_utils/BUILD.gn +++ b/dfx_utils/BUILD.gn @@ -59,7 +59,6 @@ ohos_shared_library("libdinput_dfx_utils") { "hilog:libhilog", "hisysevent:libhisysevent", "ipc:ipc_core", - "json:nlohmann_json_static", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] diff --git a/interfaces/ipc/src/distributed_input_client.cpp b/interfaces/ipc/src/distributed_input_client.cpp index 233635b..b0cea8f 100644 --- a/interfaces/ipc/src/distributed_input_client.cpp +++ b/interfaces/ipc/src/distributed_input_client.cpp @@ -59,7 +59,7 @@ void DistributedInputClient::RegisterDInputCb::OnResult( DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.begin(); iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.end(); ++iter) { - if (iter->devId == devId && iter->dhId == dhId && (iter->callback != nullptr)) { + if (iter->devId == devId && iter->dhId == dhId && iter->callback != nullptr) { iter->callback->OnRegisterResult(devId, dhId, status, ""); DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.erase(iter); return; @@ -75,7 +75,7 @@ void DistributedInputClient::UnregisterDInputCb::OnResult( DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.begin(); iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.end(); ++iter) { - if (iter->devId == devId && iter->dhId == dhId && (iter->callback != nullptr)) { + if (iter->devId == devId && iter->dhId == dhId && iter->callback != nullptr) { iter->callback->OnUnregisterResult(devId, dhId, status, ""); DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.erase(iter); return; diff --git a/services/sink/sinkmanager/BUILD.gn b/services/sink/sinkmanager/BUILD.gn index 0c65940..a8122e3 100644 --- a/services/sink/sinkmanager/BUILD.gn +++ b/services/sink/sinkmanager/BUILD.gn @@ -80,9 +80,7 @@ ohos_shared_library("libdinput_sink") { "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", - "dsoftbus:softbus_client", "eventhandler:libeventhandler", - "graphic_2d:librender_service_base", "graphic_surface:surface", "hilog:libhilog", "hisysevent:libhisysevent", diff --git a/services/source/sourcemanager/include/distributed_input_source_manager.h b/services/source/sourcemanager/include/distributed_input_source_manager.h index 30cb312..d13859b 100644 --- a/services/source/sourcemanager/include/distributed_input_source_manager.h +++ b/services/source/sourcemanager/include/distributed_input_source_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -458,6 +458,8 @@ private: std::mutex regDisHardwareMutex_; std::mutex prepareMutex_; std::mutex startStopMutex_; + std::mutex startMutex_; + std::mutex stopMutex_; std::mutex simEventMutex_; std::mutex whiteListMutex_; diff --git a/services/source/sourcemanager/src/distributed_input_source_manager.cpp b/services/source/sourcemanager/src/distributed_input_source_manager.cpp index 34a2b86..ad2ea56 100644 --- a/services/source/sourcemanager/src/distributed_input_source_manager.cpp +++ b/services/source/sourcemanager/src/distributed_input_source_manager.cpp @@ -550,6 +550,7 @@ int32_t DistributedInputSourceManager::StartRemoteInput( } DHLOGI("Start called, deviceId: %{public}s, inputTypes: %{public}d", GetAnonyString(deviceId).c_str(), inputTypes); + std::lock_guard startlock(startMutex_); for (auto iter : staCallbacks_) { if (iter.devId == deviceId && iter.inputTypes == inputTypes) { callback->OnResult(deviceId, inputTypes, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL); @@ -594,6 +595,7 @@ int32_t DistributedInputSourceManager::StopRemoteInput( } DHLOGI("Stop called, deviceId: %{public}s, inputTypes: %{public}d", GetAnonyString(deviceId).c_str(), inputTypes); + std::lock_guard stoplock(stopMutex_); for (auto iter : stpCallbacks_) { if (iter.devId == deviceId && iter.inputTypes == inputTypes) { callback->OnResult(deviceId, inputTypes, ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL); @@ -648,7 +650,7 @@ int32_t DistributedInputSourceManager::StartRemoteInput(const std::string &srcId if (srcId != localNetworkId) { return RelayStartRemoteInputByType(srcId, sinkId, inputTypes, callback); } - + std::lock_guard startlock(startMutex_); DInputClientStartInfo info {sinkId, inputTypes, callback}; staCallbacks_.push_back(info); DeviceMap_[sinkId] = DINPUT_SOURCE_SWITCH_OFF; // when sink device start success,set DINPUT_SOURCE_SWITCH_ON @@ -692,7 +694,7 @@ int32_t DistributedInputSourceManager::StopRemoteInput(const std::string &srcId, if (srcId != localNetworkId) { return RelayStopRemoteInputByType(srcId, sinkId, inputTypes, callback); } - + std::lock_guard stoplock(stopMutex_); DInputClientStopInfo info {sinkId, inputTypes, callback}; stpCallbacks_.push_back(info); int32_t ret = DistributedInputSourceTransport::GetInstance().StopRemoteInput(sinkId, inputTypes); @@ -1285,6 +1287,7 @@ void DistributedInputSourceManager::RunStartCallback( const std::string &devId, const uint32_t &inputTypes, const int32_t &status) { FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); + std::lock_guard startlock(startMutex_); for (auto iter = staCallbacks_.begin(); iter != staCallbacks_.end(); ++iter) { if (iter->devId == devId && iter->inputTypes == inputTypes) { DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_START_MSG"); @@ -1299,6 +1302,7 @@ void DistributedInputSourceManager::RunStopCallback( const std::string &devId, const uint32_t &inputTypes, const int32_t &status) { FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); + std::lock_guard stoplock(stopMutex_); for (auto iter = stpCallbacks_.begin(); iter != stpCallbacks_.end(); ++iter) { if (iter->devId == devId && iter->inputTypes == inputTypes) { DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_STOP_MSG"); @@ -1359,6 +1363,7 @@ void DistributedInputSourceManager::RunRelayStartDhidCallback(const std::string SplitStringToVector(dhids, INPUT_STRING_SPLIT_POINT, dhidsVec); DHLOGI("ProcessEvent DINPUT_SOURCE_MANAGER_RELAY_STARTDHID_RESULT_MMI dhIds:%{public}s, vec-size:%{public}zu", dhids.c_str(), dhidsVec.size()); + std::lock_guard lock(startStopMutex_); bool isCbRun = false; sptr cb = nullptr; for (auto iter = relayStaDhidCallbacks_.begin(); iter != relayStaDhidCallbacks_.end(); ++iter) { @@ -1383,6 +1388,7 @@ void DistributedInputSourceManager::RunRelayStopDhidCallback(const std::string & { std::vector dhidsVec; SplitStringToVector(dhids, INPUT_STRING_SPLIT_POINT, dhidsVec); + std::lock_guard lock(startStopMutex_); bool isCbRun = false; sptr cb = nullptr; for (auto iter = relayStpDhidCallbacks_.begin(); iter != relayStpDhidCallbacks_.end(); ++iter) { @@ -1405,6 +1411,7 @@ void DistributedInputSourceManager::RunRelayStopDhidCallback(const std::string & void DistributedInputSourceManager::RunRelayStartTypeCallback(const std::string &srcId, const std::string &sinkId, const int32_t status, uint32_t inputTypes) { + std::lock_guard lock(startStopMutex_); bool isCbRun = false; FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_START_START, DINPUT_START_TASK); for (std::vector::iterator iter = @@ -1426,6 +1433,7 @@ void DistributedInputSourceManager::RunRelayStartTypeCallback(const std::string void DistributedInputSourceManager::RunRelayStopTypeCallback(const std::string &srcId, const std::string &sinkId, const int32_t status, uint32_t inputTypes) { + std::lock_guard lock(startStopMutex_); bool isCbRun = false; FinishAsyncTrace(DINPUT_HITRACE_LABEL, DINPUT_STOP_START, DINPUT_STOP_TASK); for (std::vector::iterator iter = diff --git a/services/source/transport/BUILD.gn b/services/source/transport/BUILD.gn index f5431b6..2d97d2a 100755 --- a/services/source/transport/BUILD.gn +++ b/services/source/transport/BUILD.gn @@ -64,11 +64,9 @@ ohos_shared_library("libdinput_source_trans") { "distributed_hardware_fwk:distributed_av_sender", "distributed_hardware_fwk:distributedhardwareutils", "distributed_hardware_fwk:libdhfwk_sdk", - "dsoftbus:softbus_client", "eventhandler:libeventhandler", "hilog:libhilog", "hitrace:hitrace_meter", - "ipc:ipc_core", "json:nlohmann_json_static", "libevdev:libevdev", "samgr:samgr_proxy", diff --git a/services/state/BUILD.gn b/services/state/BUILD.gn index 20e77df..0e83172 100644 --- a/services/state/BUILD.gn +++ b/services/state/BUILD.gn @@ -70,7 +70,6 @@ ohos_shared_library("libdinput_sink_state") { "hilog:libhilog", "hitrace:hitrace_meter", "ipc:ipc_core", - "json:nlohmann_json_static", "libevdev:libevdev", "safwk:system_ability_fwk", "samgr:samgr_proxy", diff --git a/test/fuzztest/distributedinputsourcetransport_fuzzer/distributed_input_source_transport_fuzzer.cpp b/test/fuzztest/distributedinputsourcetransport_fuzzer/distributed_input_source_transport_fuzzer.cpp index 1426b91..e76a24a 100644 --- a/test/fuzztest/distributedinputsourcetransport_fuzzer/distributed_input_source_transport_fuzzer.cpp +++ b/test/fuzztest/distributedinputsourcetransport_fuzzer/distributed_input_source_transport_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 diff --git a/test/fuzztest/distributedinputtransportbase_fuzzer/distributed_input_transport_base_fuzzer.cpp b/test/fuzztest/distributedinputtransportbase_fuzzer/distributed_input_transport_base_fuzzer.cpp index 24bdce9..c0c3bbd 100644 --- a/test/fuzztest/distributedinputtransportbase_fuzzer/distributed_input_transport_base_fuzzer.cpp +++ b/test/fuzztest/distributedinputtransportbase_fuzzer/distributed_input_transport_base_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 -- Gitee From 356572b97b1e37de8339d0a94aca5f1416a38bdf Mon Sep 17 00:00:00 2001 From: jiangzhijun8 Date: Thu, 24 Oct 2024 16:36:14 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=88=86?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E5=9B=9E=E5=90=885.0.1-release=20pr209?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jiangzhijun8 --- utils/BUILD.gn | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/BUILD.gn b/utils/BUILD.gn index af7c746..626a105 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -61,12 +61,11 @@ ohos_shared_library("libdinput_utils") { "hilog:libhilog", "hisysevent:libhisysevent", "ipc:ipc_core", + "json:nlohmann_json_static", "openssl:libcrypto_shared", "samgr:samgr_proxy", ] - public_external_deps = [ "json:nlohmann_json_static" ] - subsystem_name = "distributedhardware" part_name = "distributed_input" -- Gitee From 50232f162c0afb0f272c98302f92341a86cf06d1 Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Sat, 28 Dec 2024 09:51:12 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E5=9B=9E=E5=90=885.0.1-Release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- services/common/include/dinput_softbus_define.h | 4 ++-- .../transportbase/src/distributed_input_transport_base.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/common/include/dinput_softbus_define.h b/services/common/include/dinput_softbus_define.h index 70dd253..e9b1579 100644 --- a/services/common/include/dinput_softbus_define.h +++ b/services/common/include/dinput_softbus_define.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -35,7 +35,7 @@ namespace DistributedInput { }; const int32_t ENCRYPT_TAG_LEN = 32; - const int32_t MSG_MAX_SIZE = 45 * 1024; + const uint32_t MSG_MAX_SIZE = 45 * 1024; const uint32_t SESSION_NAME_SIZE_MAX = 256; const uint32_t DEVICE_ID_SIZE_MAX = 65; diff --git a/services/transportbase/src/distributed_input_transport_base.cpp b/services/transportbase/src/distributed_input_transport_base.cpp index ad8a335..278ea32 100644 --- a/services/transportbase/src/distributed_input_transport_base.cpp +++ b/services/transportbase/src/distributed_input_transport_base.cpp @@ -466,7 +466,7 @@ bool DistributedInputTransportBase::CheckRecivedData(const std::string &message) void DistributedInputTransportBase::OnBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen) { - if (sessionId < 0 || data == nullptr || dataLen <= 0) { + if (sessionId < 0 || data == nullptr || dataLen == 0 || dataLen > MSG_MAX_SIZE) { DHLOGE("OnBytesReceived param check failed"); return; } -- Gitee