diff --git a/bundle.json b/bundle.json index 0c80f8be60152752633253e2c90e61fa9d2ba9cd..265b5bbf418d9352c2805619d1761617487a5720 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/constants_dinput.h b/common/include/constants_dinput.h index 6979e8358adf37b3f8bb08086ede5063eb63333a..d33bffea0f14374b61b4453f53f977f974411d7f 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/dinput_errcode.h b/common/include/dinput_errcode.h index a950bf09029b51a49a2d67c2fa62038d79d31ec9..61b50448b29213b2913e866c8cafb492c5edae4f 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; @@ -68,6 +67,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/common/include/input_hub.cpp b/common/include/input_hub.cpp index 77ee319bbd58df04ad677f5b87e0a78336bcce95..6288aa7f27d1a38209374d02234332f0a84f59bd 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); @@ -1071,7 +1076,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 +1092,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; diff --git a/common/include/white_list_util.cpp b/common/include/white_list_util.cpp index 07cb3e88c43ff01f61fc4d44aeee2ff319d69e0f..31c6f1d4c348df2d8864c8b7111c720544bd77a6 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 f184737d64d1afc68797a176cda094d00299e777..7426aa86ba3d64026cc7214ee12f7b4fa958954e 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 9a03a9d5e97cb89035db8a168908e403eabb4928..fe8af2de5b8b1b3115a5e309c3d70ecda738945d 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 = [ @@ -53,12 +59,16 @@ ohos_shared_library("libdinput_dfx_utils") { "hilog:libhilog", "hisysevent:libhisysevent", "ipc:ipc_core", - "json:nlohmann_json_static", "safwk:system_ability_fwk", "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 18db9b3a2d54d8a4f8cec549e28168e057f904c8..5c36f6a5c291ddba11d11f1da6005fbd6ea56181 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/inputdevicehandler/include/distributed_input_handler.h b/inputdevicehandler/include/distributed_input_handler.h index 3ec7e17b9b0ff491d33232570874b7b4acf93574..04cf0a097fa9f80994277e69be2ac8101e218090 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 7582ebc9bf1c63568c737501b0a4479942561d99..2a5f7bd2b9b92c231e4c12d1cf5c1c2579f0cf2b 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 47765dc141da3858fe673b52bf711a502c13bd22..7228a77fe7fcf5e86bbf5ab17b1dc36b3e61f85e 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/BUILD.gn b/interfaces/inner_kits/BUILD.gn index 6240ed4981bd0c02811be1741201c2db8d45ab19..bcbcb96146ffbbc488738ad87f5ede788e433964 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/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp b/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp index a466428ec33d46d47b81ce525d56373ac8da76f3..6f08b93883193bbeaa8215a2d5ec4340feb4a007 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 6792393451a12a637d97543cccb58d100791c660..2abc95f6c409ef3efb085682b6ad104544913e44 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 6fe7865e44e89485f7f52eb69e6f6202a31dcf63..0e2ad78d208f0f075ab709ba75f02679035a8618 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 9f03e486f51a3b73144a30f42576e22255f101f1..bb72e37d05d0501aef8b26844cccede7cafb17a3 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 a1faa31acaf32a940aa7612fdc1a210dd1e08832..b0cea8fda5e5546d84051ad8feb14e5dfc67b6e3 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)) { + 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)) { + 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/addwhitelistinfoscallbackunittest/BUILD.gn b/interfaces/ipc/test/addwhitelistinfoscallbackunittest/BUILD.gn index a4e88ea9df5c7d120ee3d39926e2f82bfe33d59b..df605cf378e64ba9feed46f5cd8dc30521f04b11 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 eebbae10fe83354be486ce3b506d5304bfdb8f73..80d3d10d6f8e3f397a81b31f47f82e83eafa8f7b 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 1d134a56364769811ab4fe7a92c2845d9c089d06..9a2b0af55434ea8dcffa2b3c6121475972e93ad0 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 4aeb9613401742cd2fbf1439111f2a11dbdf2395..aa269350e6197be8555613506c5e2abb6ccb5791 100644 --- a/interfaces/ipc/test/fuzztest/distributedinputstub_fuzzer/BUILD.gn +++ b/interfaces/ipc/test/fuzztest/distributedinputstub_fuzzer/BUILD.gn @@ -23,12 +23,9 @@ 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", "${ipc_path}/include", - "${ipc_path}/src", "${services_source_path}/sourcemanager/include", "${frameworks_path}/include", "${distributedinput_path}/inputdevicehandler/include", @@ -39,8 +36,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 +105,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 7091aae4ed0426080072b3da4eed990d9fbde0e3..d18c30d4f885211e1a8a958db32418cfb85f17e7 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 9f28278e00637fb83a19f167ff156a4454f31187..1acd7b13af9e505a07dab6947f2e9e50b9c816cb 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/common/include/dinput_softbus_define.h b/services/common/include/dinput_softbus_define.h index 70dd253ac072f925df4ab79688052c81c197fb1c..e9b1579dff318a92aade13291af84fc2a112651c 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/sink/inputcollector/BUILD.gn b/services/sink/inputcollector/BUILD.gn index 37115311d9203016206cba760f4e6228299dbfce..57cb89159092e389a0de4cb4d8c531a3a6f0b4ff 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 806b1bdfc98e5b67ea82ffdb77b7333b9430aecc..a8122e3c4909efd97be3b80ad712614032250ea2 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", @@ -74,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", @@ -88,7 +92,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/sinkmanager/src/distributed_input_sink_manager.cpp b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp index db6e65c52db7f08431f0c0b096070f7bcd47c287..a0b47b0a66a9339aa7a891bc9815c5b86a5b7350 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/sink/transport/BUILD.gn b/services/sink/transport/BUILD.gn index 05d4afa7ab345b34dcb801723265bea31c9dac5e..d82ddc2bc28aa3dc11fa774e787e390ce4f0bf5a 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/sink/transport/src/distributed_input_sink_transport.cpp b/services/sink/transport/src/distributed_input_sink_transport.cpp index 5b5374937f2a65c8087a2f0a556d0ade443e04fc..df1842d34a1a9be6d7b40929eac6bad145d56f69 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/BUILD.gn b/services/source/inputinject/BUILD.gn index 91829be7d54a6ac893f1ba6ba39fe5c0f84f9682..0c84f71d0bdcd6a83d7951a10b5dc3e7ad10296c 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/src/distributed_input_node_manager.cpp b/services/source/inputinject/src/distributed_input_node_manager.cpp index af1f751494e1c8e79087b3ed5e250323aff2819a..c78bf3b2bce6215742b41507e663836dae1a8c60 100644 --- a/services/source/inputinject/src/distributed_input_node_manager.cpp +++ b/services/source/inputinject/src/distributed_input_node_manager.cpp @@ -202,7 +202,15 @@ 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."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *(it); std::string devId = innerMsg[INPUT_NODE_DEVID]; diff --git a/services/source/inputinject/test/sourceinjectunittest/BUILD.gn b/services/source/inputinject/test/sourceinjectunittest/BUILD.gn index 29a542b23199b394244cff446d2a73848153c29f..8bcdd98402f24386aa98b0902b4d27ca65f40bcf 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 11f8a32537335a0ff3028f7b3dfc8e17fdbeda02..aa02846825ffc0a613edd4d3defea3cb90b6e540 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/include/distributed_input_source_manager.h b/services/source/sourcemanager/include/distributed_input_source_manager.h index 30cb31280e3d304983182854b8d342c707b6e3f3..d13859b5a5bc4ee51867e9fac37ce1f56e1dd0ce 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/dinput_source_manager_event_handler.cpp b/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp index 0039c9085a5b581abcbe017219e91db1992930d9..e2d917b457e2e42f7a659267ef26cf332d2c0254 100644 --- a/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp +++ b/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp @@ -47,7 +47,15 @@ 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."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -79,7 +87,15 @@ 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."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -100,7 +116,15 @@ 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."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -119,7 +143,15 @@ 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."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -138,7 +170,15 @@ 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."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -164,7 +204,15 @@ 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."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -201,7 +249,15 @@ 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."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -220,7 +276,15 @@ 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."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -239,7 +303,15 @@ 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."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -261,7 +333,15 @@ 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."); + return; + } auto it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_RESULT)) { @@ -276,7 +356,15 @@ 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."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -294,7 +382,15 @@ 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."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -312,7 +408,15 @@ 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."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -344,7 +448,15 @@ 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."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsString(innerMsg, INPUT_SOURCEMANAGER_KEY_DEVID) || @@ -372,7 +484,15 @@ 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."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -392,7 +512,15 @@ 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."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -412,7 +540,15 @@ 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."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || @@ -432,7 +568,15 @@ 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."); + return; + } nlohmann::json::iterator it = dataMsg->begin(); nlohmann::json innerMsg = *it; if (!IsInt32(innerMsg, INPUT_SOURCEMANAGER_KEY_VALUE) || diff --git a/services/source/sourcemanager/src/distributed_input_source_manager.cpp b/services/source/sourcemanager/src/distributed_input_source_manager.cpp index 34a2b86793fd2d6a61232a09a87b46c9c5007db4..ad2ea5641512856cef0ec1c2e9f51239cd82520e 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/sourcemanager/test/sourcemanagerunittest/BUILD.gn b/services/source/sourcemanager/test/sourcemanagerunittest/BUILD.gn index eb21b670dc4ef69c9c263847292147527cd4905b..9049c4d9b6fe788529369ff3f06bed93df3e73d1 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 874649db056fe41972e9bebea69ee80b86db5e74..2d97d2ac536fa4aac11587d2ab43baae5f24c76d 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", @@ -58,17 +64,20 @@ 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", ] - 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 9decfe38d0367f02f05c05b3587d240b10079d72..10d33f331ef8f9611c3eee39ba146483cb6d3e95 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 8b01a01fa44fe1a58be841f3a36bacddb7429be6..0e831720b9e6705170bc475e6601f9c71d4518c4 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", @@ -64,13 +70,17 @@ 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", ] - 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 439a74d5742ad8e18cad3547161467e361a6c84a..622f14e736ffdda4bdf8824205a4e43b434c667b 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/src/distributed_input_transport_base.cpp b/services/transportbase/src/distributed_input_transport_base.cpp index ad8a335471226f235cfdfdb62effb286879e57e3..278ea32845f75eaff45f1230da86a37218ac50db 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; } diff --git a/services/transportbase/test/transbaseunittest/BUILD.gn b/services/transportbase/test/transbaseunittest/BUILD.gn index c95459eebfda69dded17221b5557712c183493f7..14c9a6d4cbe93acc9222ecf33cfb40657923fc66 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 a49104dee22a4d0a1ac63561596a3b9e8425d65b..b9a2c76946e8abfe8d815cb747becfb6ab6796de 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 51356ca9d2acc92e7226c62aea85466f287ea265..60c928e8064fa00f174f853dbcb3204c48ba96bb 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/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp b/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp index df24e9e67a4115df6254267683111f786c6f365f..44a15efdef56176bea1c27074e7490068878dd5a 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/BUILD.gn b/sourcehandler/BUILD.gn index d054e1d67eff2db49a12b3b0779b31de92094c4e..1ba3d8803ee9c891598e01c397c38c0666fbcb67 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 4a973203c60c075636fdf23f04651c8c7cc3f911..1552a55dae7763af643697ab03bff9c7258cac08 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/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp b/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp index ecf6c162a51ce8fa15f2f629efaf3c1986dffeee..7d97f9d10cca149920079577d57cbd22afeee0be 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/dinputconfigdh_fuzzer/BUILD.gn b/test/fuzztest/dinputconfigdh_fuzzer/BUILD.gn index 618ff369ecbf5366f17c48d1818ff33a2b3cfdf8..9e19f17628ea1c6cc4e0a13c7d65f59a25617810 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 a32520f94775967478bc1e34dc9518153bc72637..59a5609c7f247faacb2f56916a4b620f05f0b555 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 47708c91a9cd1d1802686bb1ea2500271c21a0c0..5851cfc3adf120677e0835c14440e4679aadeda4 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 712c7393f1968bc8fc616c03a1c0ff72a9e7915d..e01d84a61205238e35bbb66a13a31b5b1c049a53 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 6118282ae8b3a8c2bccb3eb57af3d119ea214d86..dbc16d71534a93faa399911f2d891055983dc6c1 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 dee65b3a7bbec08df94ed848ca812c4e8d99706d..da48302924e0e4639a83175e9f2eea4324c4bcc8 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 b3368268e12718699713783dfa04b95ce5011087..feed3f09b3322e8299a9d59fe3e00f1f4fed9faa 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 244ac95a83ccc5e233e41b83c0ba50a47571cd65..6f6dbdf94073a3070fb2faafe7708af1f389e6b3 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 e0385bb734d8a06e68d9d14995f68d8152182b50..ed010c2231e1c2ffd47a51c2617b4d80cb44511b 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 5446ceef6e404d127393c85f7051d45de1d71f54..903bd0989cdbf5e57f037e273a9cd6e88d2c7550 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 cda17bf0287bc70bf4b1203faea9f5da4fb11c66..bdc0ac2f9e9a40e45328623247ad4c537b0290f1 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 c49970bd21d4a00ce2d0f2278c838f567610f0d5..d64cc59d6f4f57c28c207ee75cf599e4001fced4 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/distributedinputsourcetransport_fuzzer/distributed_input_source_transport_fuzzer.cpp b/test/fuzztest/distributedinputsourcetransport_fuzzer/distributed_input_source_transport_fuzzer.cpp index 452f36c6cebfe581da4028623d8b9e67d13ebb81..e76a24a3cdf51b5878bc5dd9dd90c9cb6858379b 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 @@ -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/BUILD.gn b/test/fuzztest/distributedinputtransportbase_fuzzer/BUILD.gn index ef8e18b2dd1a600592f1a59a8f831df656572151..455674a774dd33bf3845c6ce2e015f8ed3cb52d5 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/test/fuzztest/distributedinputtransportbase_fuzzer/distributed_input_transport_base_fuzzer.cpp b/test/fuzztest/distributedinputtransportbase_fuzzer/distributed_input_transport_base_fuzzer.cpp index ffeac3614a2f9a812d707c9893cb48ebcf0b9646..c0c3bbd205ef73d6263cfd307ffeb5bc2d7f5d1d 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 @@ -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; } diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 085b405ae3ddb696a3f15e79041b4ff082bc8569..626a105bfda983df839254dba8b1e6c1db381af5 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", @@ -54,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" diff --git a/utils/test/unittest/BUILD.gn b/utils/test/unittest/BUILD.gn index 8e736870d970f0d31cc2db934783ea3cf4b2333b..8907d486391fe94409eec4a1787743f48637a97d 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",