From f4330eefe3919eb9b728f6b2282e61e908d40e2d Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Sun, 13 Oct 2024 11:04:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9=E5=9B=9E?= =?UTF-8?q?=E5=90=885.0.1-release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- common/include/dinput_errcode.h | 1 + .../include/distributed_input_handler.h | 8 +- .../src/distributed_input_handler.cpp | 18 ++-- .../distributed_input_handler_test.cpp | 14 ++-- .../mock/mock_distributed_input_client.cpp | 12 +-- interfaces/ipc/include/dinput_sa_manager.h | 10 +-- .../ipc/include/distributed_input_client.h | 20 ++--- interfaces/ipc/src/dinput_sa_manager.cpp | 32 +++---- .../ipc/src/distributed_input_client.cpp | 83 ++++++++++--------- .../distributedinputstub_fuzzer/BUILD.gn | 2 - .../src/distributed_input_sink_manager.cpp | 14 ++-- .../src/distributed_input_node_manager.cpp | 4 + .../dinput_source_manager_event_handler.cpp | 72 ++++++++++++++++ .../mock/mock_distributed_input_client.cpp | 12 +-- .../mock/mock_distributed_input_client.cpp | 12 +-- ...tributed_input_source_transport_fuzzer.cpp | 2 +- ...istributed_input_transport_base_fuzzer.cpp | 2 +- 17 files changed, 199 insertions(+), 119 deletions(-) diff --git a/common/include/dinput_errcode.h b/common/include/dinput_errcode.h index a950bf0..ce0f8d7 100644 --- a/common/include/dinput_errcode.h +++ b/common/include/dinput_errcode.h @@ -68,6 +68,7 @@ namespace DistributedInput { constexpr int32_t ERR_DH_INPUT_SERVER_SINK_MANAGER_START_MSG_IS_BAD = -64015; constexpr int32_t ERR_DH_INPUT_SERVER_SINK_MANAGER_STOP_MSG_IS_BAD = -64016; constexpr int32_t ERR_DH_INPUT_SERVER_SINK_MANAGER_RELEASE_FAIL = -64017; + constexpr int32_t ERR_DH_INPUT_SERVER_SINK_MANAGER_IS_NULL = -64018; // service source error code constexpr int32_t ERR_DH_INPUT_SERVER_SOURCE_INJECT_REGISTER_FAIL = -65000; constexpr int32_t ERR_DH_INPUT_SERVER_SOURCE_INJECT_UNREGISTER_FAIL = -65001; diff --git a/inputdevicehandler/include/distributed_input_handler.h b/inputdevicehandler/include/distributed_input_handler.h index 3ec7e17..04cf0a0 100644 --- a/inputdevicehandler/include/distributed_input_handler.h +++ b/inputdevicehandler/include/distributed_input_handler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -60,14 +60,14 @@ private: pthread_t collectThreadID_; bool isCollectingEvents_; - bool isStartCollectEventThread; + bool isStartCollectEventThread_; static void *CollectEventsThread(void *param); void StartInputMonitorDeviceThread(); void StopInputMonitorDeviceThread(); // The event queue. - static const int inputDeviceBufferSize = 32; - InputDeviceEvent mEventBuffer[inputDeviceBufferSize] = {}; + static const int inputDeviceBufferSize_ = 32; + InputDeviceEvent mEventBuffer_[inputDeviceBufferSize_] = {}; std::mutex operationMutex_; std::unique_ptr inputHub_; }; diff --git a/inputdevicehandler/src/distributed_input_handler.cpp b/inputdevicehandler/src/distributed_input_handler.cpp index 7582ebc..2a5f7bd 100644 --- a/inputdevicehandler/src/distributed_input_handler.cpp +++ b/inputdevicehandler/src/distributed_input_handler.cpp @@ -42,7 +42,7 @@ namespace DistributedHardware { namespace DistributedInput { IMPLEMENT_SINGLE_INSTANCE(DistributedInputHandler); DistributedInputHandler::DistributedInputHandler() - : collectThreadID_(-1), isCollectingEvents_(false), isStartCollectEventThread(false) + : collectThreadID_(-1), isCollectingEvents_(false), isStartCollectEventThread_(false) { inputHub_ = std::make_unique(true); this->m_listener = nullptr; @@ -88,9 +88,9 @@ void DistributedInputHandler::StructTransJson(const InputDevice &pBuf, std::stri int32_t DistributedInputHandler::Initialize() { - if (!isStartCollectEventThread) { + if (!isStartCollectEventThread_) { InitCollectEventsThread(); - isStartCollectEventThread = true; + isStartCollectEventThread_ = true; } return DH_SUCCESS; } @@ -196,7 +196,7 @@ void DistributedInputHandler::StartInputMonitorDeviceThread() return; } while (isCollectingEvents_) { - size_t count = inputHub_->StartCollectInputHandler(mEventBuffer, inputDeviceBufferSize); + size_t count = inputHub_->StartCollectInputHandler(mEventBuffer_, inputDeviceBufferSize_); if (count > 0) { DHLOGI("Count: %{public}zu", count); for (size_t iCnt = 0; iCnt < count; iCnt++) { @@ -212,18 +212,18 @@ void DistributedInputHandler::StartInputMonitorDeviceThread() void DistributedInputHandler::NotifyHardWare(int iCnt) { - switch (mEventBuffer[iCnt].type) { + switch (mEventBuffer_[iCnt].type) { case DeviceType::DEVICE_ADDED: if (this->m_listener != nullptr) { std::string hdInfo; - StructTransJson(mEventBuffer[iCnt].deviceInfo, hdInfo); + StructTransJson(mEventBuffer_[iCnt].deviceInfo, hdInfo); std::string subtype = "input"; - this->m_listener->PluginHardware(mEventBuffer[iCnt].deviceInfo.descriptor, hdInfo, subtype); + this->m_listener->PluginHardware(mEventBuffer_[iCnt].deviceInfo.descriptor, hdInfo, subtype); } break; case DeviceType::DEVICE_REMOVED: if (this->m_listener != nullptr) { - this->m_listener->UnPluginHardware(mEventBuffer[iCnt].deviceInfo.descriptor); + this->m_listener->UnPluginHardware(mEventBuffer_[iCnt].deviceInfo.descriptor); } break; default: @@ -238,7 +238,7 @@ void DistributedInputHandler::StopInputMonitorDeviceThread() return; } isCollectingEvents_ = false; - isStartCollectEventThread = false; + isStartCollectEventThread_ = false; inputHub_->StopCollectInputHandler(); if (collectThreadID_ != (pthread_t)(-1)) { DHLOGI("DistributedInputHandler::Wait collect thread exit"); diff --git a/inputdevicehandler/test/inputhandlertest/distributed_input_handler_test.cpp b/inputdevicehandler/test/inputhandlertest/distributed_input_handler_test.cpp index 47765dc..7228a77 100644 --- a/inputdevicehandler/test/inputhandlertest/distributed_input_handler_test.cpp +++ b/inputdevicehandler/test/inputhandlertest/distributed_input_handler_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -64,14 +64,14 @@ HWTEST_F(DInputHandlerTest, FindDevicesInfoByType_001, testing::ext::TestSize.Le dInputHandler.StartInputMonitorDeviceThread(); InputDevice inputDevice; - dInputHandler.mEventBuffer[0].type = DeviceType::DEVICE_ADDED; - dInputHandler.mEventBuffer[0].deviceInfo = inputDevice; + dInputHandler.mEventBuffer_[0].type = DeviceType::DEVICE_ADDED; + dInputHandler.mEventBuffer_[0].deviceInfo = inputDevice; dInputHandler.NotifyHardWare(0); - dInputHandler.mEventBuffer[1].type = DeviceType::DEVICE_REMOVED; - dInputHandler.mEventBuffer[1].deviceInfo = inputDevice; + dInputHandler.mEventBuffer_[1].type = DeviceType::DEVICE_REMOVED; + dInputHandler.mEventBuffer_[1].deviceInfo = inputDevice; dInputHandler.NotifyHardWare(1); - dInputHandler.mEventBuffer[2].type = DeviceType::FINISHED_DEVICE_SCAN; - dInputHandler.mEventBuffer[2].deviceInfo = inputDevice; + dInputHandler.mEventBuffer_[2].type = DeviceType::FINISHED_DEVICE_SCAN; + dInputHandler.mEventBuffer_[2].deviceInfo = inputDevice; dInputHandler.NotifyHardWare(2); std::map ret = dInputHandler.QueryExtraInfo(); EXPECT_EQ(0, ret.size()); diff --git a/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp b/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp index a466428..6f08b93 100644 --- a/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp +++ b/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp @@ -38,11 +38,11 @@ DistributedInputClient &DistributedInputClient::GetInstance() void DistributedInputClient::RegisterDInputCb::OnResult( const std::string &devId, const std::string &dhId, const int32_t &status) { - auto iter = DistributedInputClient::GetInstance().dHardWareFwkRstInfos.begin(); - for (; iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos.end(); ++iter) { + auto iter = DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.begin(); + for (; iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { iter->callback->OnRegisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.erase(iter); return; } } @@ -51,11 +51,11 @@ void DistributedInputClient::RegisterDInputCb::OnResult( void DistributedInputClient::UnregisterDInputCb::OnResult( const std::string &devId, const std::string &dhId, const int32_t &status) { - auto iter = DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.begin(); - for (; iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.end(); ++iter) { + auto iter = DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.begin(); + for (; iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { iter->callback->OnUnregisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.erase(iter); return; } } diff --git a/interfaces/ipc/include/dinput_sa_manager.h b/interfaces/ipc/include/dinput_sa_manager.h index 6792393..2abc95f 100644 --- a/interfaces/ipc/include/dinput_sa_manager.h +++ b/interfaces/ipc/include/dinput_sa_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -71,10 +71,10 @@ private: ~DInputSAManager() = default; public: - std::atomic dInputSourceSAOnline = false; - std::atomic dInputSinkSAOnline = false; - std::atomic isSubscribeSrcSAChangeListener = false; - std::atomic isSubscribeSinkSAChangeListener = false; + std::atomic dInputSourceSAOnline_ = false; + std::atomic dInputSinkSAOnline_ = false; + std::atomic isSubscribeSrcSAChangeListener_ = false; + std::atomic isSubscribeSinkSAChangeListener_ = false; std::mutex sinkMutex_; std::mutex sourceMutex_; std::mutex handlerMutex_; diff --git a/interfaces/ipc/include/distributed_input_client.h b/interfaces/ipc/include/distributed_input_client.h index 6fe7865..0e2ad78 100644 --- a/interfaces/ipc/include/distributed_input_client.h +++ b/interfaces/ipc/include/distributed_input_client.h @@ -179,7 +179,7 @@ private: private: static std::shared_ptr instance; - DInputServerType serverType = DInputServerType::NULL_SERVER_TYPE; + DInputServerType serverType_ = DInputServerType::NULL_SERVER_TYPE; DInputDeviceType inputTypes_ = DInputDeviceType::NONE; std::set> addWhiteListCallbacks_; @@ -193,12 +193,12 @@ private: std::shared_ptr eventHandler_; - std::atomic isAddWhiteListCbReg; - std::atomic isDelWhiteListCbReg; - std::atomic isNodeMonitorCbReg; - std::atomic isSimulationEventCbReg; - std::atomic isSharingDhIdsReg; - std::atomic isGetSinkScreenInfosCbReg; + std::atomic isAddWhiteListCbReg_; + std::atomic isDelWhiteListCbReg_; + std::atomic isNodeMonitorCbReg_; + std::atomic isSimulationEventCbReg_; + std::atomic isSharingDhIdsReg_; + std::atomic isGetSinkScreenInfosCbReg_; struct DHardWareFwkRegistInfo { std::string devId; @@ -212,9 +212,9 @@ private: std::shared_ptr callback = nullptr; }; - std::vector dHardWareFwkRstInfos; - std::vector dHardWareFwkUnRstInfos; - std::vector screenTransInfos; + std::vector dHardWareFwkRstInfos_; + std::vector dHardWareFwkUnRstInfos_; + std::vector screenTransInfos_; std::mutex operationMutex_; std::mutex sharingDhIdsMtx_; diff --git a/interfaces/ipc/src/dinput_sa_manager.cpp b/interfaces/ipc/src/dinput_sa_manager.cpp index 9f03e48..bb72e37 100644 --- a/interfaces/ipc/src/dinput_sa_manager.cpp +++ b/interfaces/ipc/src/dinput_sa_manager.cpp @@ -30,7 +30,7 @@ const uint32_t DINPUT_CLIENT_HANDLER_MSG_DELAY_TIME = 100; // million seconds void DInputSAManager::SystemAbilityListener::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) { if (systemAbilityId == DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID) { - DInputSAManager::GetInstance().dInputSourceSAOnline.store(false); + DInputSAManager::GetInstance().dInputSourceSAOnline_.store(false); { std::lock_guard lock(DInputSAManager::GetInstance().sourceMutex_); DInputSAManager::GetInstance().dInputSourceProxy_ = nullptr; @@ -48,7 +48,7 @@ void DInputSAManager::SystemAbilityListener::OnRemoveSystemAbility(int32_t syste } if (systemAbilityId == DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID) { - DInputSAManager::GetInstance().dInputSinkSAOnline.store(false); + DInputSAManager::GetInstance().dInputSinkSAOnline_.store(false); { std::lock_guard lock(DInputSAManager::GetInstance().sinkMutex_); DInputSAManager::GetInstance().dInputSinkProxy_ = nullptr; @@ -70,7 +70,7 @@ void DInputSAManager::SystemAbilityListener::OnRemoveSystemAbility(int32_t syste void DInputSAManager::SystemAbilityListener::OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) { if (systemAbilityId == DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID) { - DInputSAManager::GetInstance().dInputSourceSAOnline.store(true); + DInputSAManager::GetInstance().dInputSourceSAOnline_.store(true); std::lock_guard lock(DInputSAManager::GetInstance().handlerMutex_); if (DInputSAManager::GetInstance().eventHandler_ != nullptr) { DHLOGI("SendEvent DINPUT_CLIENT_CHECK_SOURCE_CALLBACK_REGISTER_MSG"); @@ -82,7 +82,7 @@ void DInputSAManager::SystemAbilityListener::OnAddSystemAbility(int32_t systemAb } if (systemAbilityId == DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID) { - DInputSAManager::GetInstance().dInputSinkSAOnline.store(true); + DInputSAManager::GetInstance().dInputSinkSAOnline_.store(true); std::lock_guard lock(DInputSAManager::GetInstance().handlerMutex_); if (DInputSAManager::GetInstance().eventHandler_ != nullptr) { DHLOGI("SendEvent DINPUT_CLIENT_CHECK_SINK_CALLBACK_REGISTER_MSG"); @@ -106,7 +106,7 @@ void DInputSAManager::Init() return; } - if (!isSubscribeSrcSAChangeListener.load()) { + if (!isSubscribeSrcSAChangeListener_.load()) { DHLOGI("try subscribe source sa change listener, saId:%{public}d", DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID); int32_t ret = systemAbilityManager->SubscribeSystemAbility(DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID, saListenerCallback); @@ -114,10 +114,10 @@ void DInputSAManager::Init() DHLOGE("subscribe source sa change failed: %{public}d", ret); return; } - isSubscribeSrcSAChangeListener.store(true); + isSubscribeSrcSAChangeListener_.store(true); } - if (!isSubscribeSinkSAChangeListener.load()) { + if (!isSubscribeSinkSAChangeListener_.load()) { DHLOGI("try subscribe sink sa change listener, saId:%{public}d", DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID); int32_t ret = systemAbilityManager->SubscribeSystemAbility(DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID, saListenerCallback); @@ -125,7 +125,7 @@ void DInputSAManager::Init() DHLOGE("subscribe sink sa change failed: %{public}d", ret); return; } - isSubscribeSinkSAChangeListener.store(true); + isSubscribeSinkSAChangeListener_.store(true); } } @@ -137,9 +137,9 @@ void DInputSAManager::RegisterEventHandler(std::shared_ptr lock(DInputSAManager::GetInstance().sourceMutex_); - if (!isSubscribeSrcSAChangeListener.load()) { + if (!isSubscribeSrcSAChangeListener_.load()) { sptr systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (!systemAbilityManager) { @@ -154,11 +154,11 @@ bool DInputSAManager::GetDInputSourceProxy() DHLOGE("subscribe source sa change failed: %{public}d", ret); return false; } - isSubscribeSrcSAChangeListener.store(true); + isSubscribeSrcSAChangeListener_.store(true); } } - if (dInputSourceSAOnline.load() && !dInputSourceProxy_) { + if (dInputSourceSAOnline_.load() && !dInputSourceProxy_) { std::lock_guard lock(DInputSAManager::GetInstance().sourceMutex_); if (dInputSourceProxy_ != nullptr) { DHLOGI("dinput source proxy has already got."); @@ -208,9 +208,9 @@ bool DInputSAManager::SetDInputSourceProxy(const sptr &remoteObje bool DInputSAManager::GetDInputSinkProxy() { - if (!isSubscribeSinkSAChangeListener.load()) { + if (!isSubscribeSinkSAChangeListener_.load()) { std::lock_guard lock(DInputSAManager::GetInstance().sinkMutex_); - if (!isSubscribeSinkSAChangeListener.load()) { + if (!isSubscribeSinkSAChangeListener_.load()) { sptr systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (!systemAbilityManager) { @@ -225,11 +225,11 @@ bool DInputSAManager::GetDInputSinkProxy() DHLOGE("subscribe sink sa change failed: %{public}d", ret); return false; } - isSubscribeSinkSAChangeListener.store(true); + isSubscribeSinkSAChangeListener_.store(true); } } - if (dInputSinkSAOnline.load() && !dInputSinkProxy_) { + if (dInputSinkSAOnline_.load() && !dInputSinkProxy_) { std::lock_guard lock(DInputSAManager::GetInstance().sinkMutex_); if (dInputSinkProxy_ != nullptr) { DHLOGI("dinput sink proxy has already got."); diff --git a/interfaces/ipc/src/distributed_input_client.cpp b/interfaces/ipc/src/distributed_input_client.cpp index a1faa31..233635b 100644 --- a/interfaces/ipc/src/distributed_input_client.cpp +++ b/interfaces/ipc/src/distributed_input_client.cpp @@ -34,8 +34,9 @@ namespace OHOS { namespace DistributedHardware { namespace DistributedInput { std::shared_ptr DistributedInputClient::instance = std::make_shared(); -DistributedInputClient::DistributedInputClient() : isAddWhiteListCbReg(false), isDelWhiteListCbReg(false), - isNodeMonitorCbReg(false), isSimulationEventCbReg(false), isSharingDhIdsReg(false), isGetSinkScreenInfosCbReg(false) +DistributedInputClient::DistributedInputClient() : isAddWhiteListCbReg_(false), isDelWhiteListCbReg_(false), + isNodeMonitorCbReg_(false), isSimulationEventCbReg_(false), isSharingDhIdsReg_(false), + isGetSinkScreenInfosCbReg_(false) { DHLOGI("DistributedInputClient init start"); std::shared_ptr runner = AppExecFwk::EventRunner::Create(true); @@ -55,12 +56,12 @@ void DistributedInputClient::RegisterDInputCb::OnResult( { std::lock_guard lock(DistributedInputClient::GetInstance().operationMutex_); for (std::vector::iterator iter = - DistributedInputClient::GetInstance().dHardWareFwkRstInfos.begin(); - iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos.end(); + DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.begin(); + iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId && (iter->callback != nullptr)) { iter->callback->OnRegisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.erase(iter); return; } } @@ -71,12 +72,12 @@ void DistributedInputClient::UnregisterDInputCb::OnResult( { std::lock_guard lock(DistributedInputClient::GetInstance().operationMutex_); for (std::vector::iterator iter = - DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.begin(); - iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.end(); + DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.begin(); + iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId && (iter->callback != nullptr)) { iter->callback->OnUnregisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.erase(iter); return; } } @@ -147,26 +148,26 @@ void DistributedInputClient::DInputClientEventHandler::ProcessEvent(const AppExe if (eventId == DINPUT_CLIENT_CLEAR_SOURCE_CALLBACK_REGISTER_MSG) { DHLOGI("Source SA exit, clear callback flag"); - DistributedInputClient::GetInstance().isAddWhiteListCbReg = false; - DistributedInputClient::GetInstance().isDelWhiteListCbReg = false; - DistributedInputClient::GetInstance().isNodeMonitorCbReg = false; - DistributedInputClient::GetInstance().isSimulationEventCbReg = false; + DistributedInputClient::GetInstance().isAddWhiteListCbReg_.store(false); + DistributedInputClient::GetInstance().isDelWhiteListCbReg_.store(false); + DistributedInputClient::GetInstance().isNodeMonitorCbReg_.store(false); + DistributedInputClient::GetInstance().isSimulationEventCbReg_.store(false); return; } if (eventId == DINPUT_CLIENT_CLEAR_SINK_CALLBACK_REGISTER_MSG) { DHLOGI("Sink SA exit, clear callback flag"); - DistributedInputClient::GetInstance().isSharingDhIdsReg = false; + DistributedInputClient::GetInstance().isSharingDhIdsReg_.store(false); return; } } void DistributedInputClient::CheckSourceRegisterCallback() { - DHLOGI("CheckSourceRegisterCallback called, isAddWhiteListCbReg[%{public}d], isDelWhiteListCbReg[%{public}d], " - "isNodeMonitorCbReg[%{public}d], isSimulationEventCbReg[%{public}d]", - isAddWhiteListCbReg.load(), isDelWhiteListCbReg.load(), isNodeMonitorCbReg.load(), - isSimulationEventCbReg.load()); + DHLOGI("CheckSourceRegisterCallback called, isAddWhiteListCbReg_[%{public}d], isDelWhiteListCbReg_[%{public}d], " + "isNodeMonitorCbReg_[%{public}d], isSimulationEventCbReg_[%{public}d]", + isAddWhiteListCbReg_.load(), isDelWhiteListCbReg_.load(), isNodeMonitorCbReg_.load(), + isSimulationEventCbReg_.load()); CheckWhiteListCallback(); CheckKeyStateCallback(); @@ -174,7 +175,7 @@ void DistributedInputClient::CheckSourceRegisterCallback() void DistributedInputClient::CheckSinkRegisterCallback() { - DHLOGI("CheckSinkRegisterCallback called, isSharingDhIdsReg[%{public}d]", isSharingDhIdsReg.load()); + DHLOGI("CheckSinkRegisterCallback called, isSharingDhIdsReg_[%{public}d]", isSharingDhIdsReg_.load()); CheckSharingDhIdsCallback(); CheckSinkScreenInfoCallback(); } @@ -186,12 +187,12 @@ void DistributedInputClient::CheckSharingDhIdsCallback() return; } std::lock_guard lock(DInputSAManager::GetInstance().sinkMutex_); - if (!isSharingDhIdsReg) { + if (!isSharingDhIdsReg_.load()) { sptr listener(new (std::nothrow) SharingDhIdListenerCb()); int32_t ret = DInputSAManager::GetInstance().dInputSinkProxy_->RegisterSharingDhIdListener(listener); if (ret == DH_SUCCESS) { - isSharingDhIdsReg = true; + isSharingDhIdsReg_.store(true); std::lock_guard lock(operationMutex_); sharingDhIdListeners_.insert(listener); } else { @@ -207,24 +208,24 @@ void DistributedInputClient::CheckWhiteListCallback() return; } std::lock_guard lock(DInputSAManager::GetInstance().sourceMutex_); - if (!isAddWhiteListCbReg) { + if (!isAddWhiteListCbReg_.load()) { sptr addCallback(new (std::nothrow) AddWhiteListInfosCb()); int32_t ret = DInputSAManager::GetInstance().dInputSourceProxy_->RegisterAddWhiteListCallback(addCallback); if (ret == DH_SUCCESS) { - isAddWhiteListCbReg = true; + isAddWhiteListCbReg_.store(true); std::lock_guard lock(operationMutex_); addWhiteListCallbacks_.insert(addCallback); } else { DHLOGE("CheckWhiteListCallback client RegisterAddWhiteListCallback fail"); } } - if (!isDelWhiteListCbReg) { + if (!isDelWhiteListCbReg_.load()) { sptr delCallback(new (std::nothrow) DelWhiteListInfosCb()); int32_t ret = DInputSAManager::GetInstance().dInputSourceProxy_->RegisterDelWhiteListCallback(delCallback); if (ret == DH_SUCCESS) { - isDelWhiteListCbReg = true; + isDelWhiteListCbReg_.store(true); std::lock_guard lock(operationMutex_); delWhiteListCallbacks_.insert(delCallback); } else { @@ -240,9 +241,9 @@ void DistributedInputClient::CheckKeyStateCallback() return; } std::lock_guard lock(DInputSAManager::GetInstance().sourceMutex_); - if (!isSimulationEventCbReg && regSimulationEventListener_ != nullptr) { + if (!isSimulationEventCbReg_.load() && regSimulationEventListener_ != nullptr) { DInputSAManager::GetInstance().dInputSourceProxy_->RegisterSimulationEventListener(regSimulationEventListener_); - isSimulationEventCbReg = true; + isSimulationEventCbReg_.store(true); } } @@ -253,12 +254,12 @@ void DistributedInputClient::CheckSinkScreenInfoCallback() return; } std::lock_guard lock(DInputSAManager::GetInstance().sinkMutex_); - if (!isGetSinkScreenInfosCbReg) { + if (!isGetSinkScreenInfosCbReg_.load()) { sptr callback(new (std::nothrow) GetSinkScreenInfosCb()); int32_t ret = DInputSAManager::GetInstance().dInputSinkProxy_->RegisterGetSinkScreenInfosCallback(callback); if (ret == DH_SUCCESS) { - isGetSinkScreenInfosCbReg = true; + isGetSinkScreenInfosCbReg_.store(true); std::lock_guard lock(operationMutex_); getSinkScreenInfosCallbacks_.insert(callback); } else { @@ -291,7 +292,7 @@ int32_t DistributedInputClient::ReleaseSource() return ERR_DH_INPUT_CLIENT_GET_SOURCE_PROXY_FAIL; } - serverType = DInputServerType::NULL_SERVER_TYPE; + serverType_ = DInputServerType::NULL_SERVER_TYPE; inputTypes_ = DInputDeviceType::NONE; regNodeListener_ = nullptr; unregNodeListener_ = nullptr; @@ -312,7 +313,7 @@ int32_t DistributedInputClient::ReleaseSink() if (!DInputSAManager::GetInstance().GetDInputSinkProxy()) { return ERR_DH_INPUT_CLIENT_GET_SINK_PROXY_FAIL; } - serverType = DInputServerType::NULL_SERVER_TYPE; + serverType_ = DInputServerType::NULL_SERVER_TYPE; inputTypes_ = DInputDeviceType::NONE; { std::lock_guard lock(operationMutex_); @@ -338,13 +339,13 @@ int32_t DistributedInputClient::RegisterDistributedHardware(const std::string &d } { std::lock_guard lock(DistributedInputClient::GetInstance().operationMutex_); - for (auto iter : dHardWareFwkRstInfos) { + for (auto iter : dHardWareFwkRstInfos_) { if (iter.devId == devId && iter.dhId == dhId) { return ERR_DH_INPUT_CLIENT_REGISTER_FAIL; } } DHardWareFwkRegistInfo info {devId, dhId, callback}; - dHardWareFwkRstInfos.push_back(info); + dHardWareFwkRstInfos_.push_back(info); } std::lock_guard lock(DInputSAManager::GetInstance().sourceMutex_); return DInputSAManager::GetInstance().dInputSourceProxy_->RegisterDistributedHardware(devId, dhId, parameters, @@ -365,13 +366,13 @@ int32_t DistributedInputClient::UnregisterDistributedHardware(const std::string } { std::lock_guard lock(DistributedInputClient::GetInstance().operationMutex_); - for (auto iter : dHardWareFwkUnRstInfos) { + for (auto iter : dHardWareFwkUnRstInfos_) { if (iter.devId == devId && iter.dhId == dhId) { return ERR_DH_INPUT_CLIENT_UNREGISTER_FAIL; } } DHardWareFwkUnRegistInfo info {devId, dhId, callback}; - dHardWareFwkUnRstInfos.push_back(info); + dHardWareFwkUnRstInfos_.push_back(info); } std::lock_guard lock(DInputSAManager::GetInstance().sourceMutex_); return DInputSAManager::GetInstance().dInputSourceProxy_->UnregisterDistributedHardware(devId, dhId, @@ -579,7 +580,7 @@ bool DistributedInputClient::IsNeedFilterOut(const std::string &deviceId, const bool DistributedInputClient::IsTouchEventNeedFilterOut(const TouchScreenEvent &event) { std::lock_guard lock(operationMutex_); - for (const auto &info : screenTransInfos) { + for (const auto &info : screenTransInfos_) { DHLOGI("sinkProjPhyWidth: %{public}d sinkProjPhyHeight: %{public}d", info.sinkProjPhyWidth, info.sinkProjPhyHeight); if ((event.absX >= info.sinkWinPhyX) && (event.absX <= (info.sinkWinPhyX + info.sinkProjPhyWidth)) @@ -609,17 +610,17 @@ int32_t DistributedInputClient::RegisterSimulationEventListener(sptr lock(DInputSAManager::GetInstance().sourceMutex_); int32_t ret = DInputSAManager::GetInstance().dInputSourceProxy_->RegisterSimulationEventListener(listener); if (ret == DH_SUCCESS) { - isSimulationEventCbReg = true; + isSimulationEventCbReg_.store(true); DInputSAManager::GetInstance().AddSimEventListenerToCache(listener); } else { - isSimulationEventCbReg = false; + isSimulationEventCbReg_.store(false); regSimulationEventListener_ = listener; DHLOGE("RegisterSimulationEventListener Failed, ret = %{public}d", ret); } @@ -693,7 +694,7 @@ void DistributedInputClient::DelWhiteListInfos(const std::string &deviceId) cons void DistributedInputClient::UpdateSinkScreenInfos(const std::string &strJson) { std::lock_guard lock(operationMutex_); - screenTransInfos.clear(); + screenTransInfos_.clear(); nlohmann::json inputData = nlohmann::json::parse(strJson, nullptr, false); if (inputData.is_discarded()) { DHLOGE("InputData parse failed!"); @@ -712,8 +713,8 @@ void DistributedInputClient::UpdateSinkScreenInfos(const std::string &strJson) continue; } TransformInfo tmp{info[0], info[1], info[2], info[3]}; - screenTransInfos.emplace_back(tmp); - DHLOGI("screenTransInfos size %{public}zu", screenTransInfos.size()); + screenTransInfos_.emplace_back(tmp); + DHLOGI("screenTransInfos_ size %{public}zu", screenTransInfos_.size()); } } diff --git a/interfaces/ipc/test/fuzztest/distributedinputstub_fuzzer/BUILD.gn b/interfaces/ipc/test/fuzztest/distributedinputstub_fuzzer/BUILD.gn index 4aeb961..05ad188 100644 --- a/interfaces/ipc/test/fuzztest/distributedinputstub_fuzzer/BUILD.gn +++ b/interfaces/ipc/test/fuzztest/distributedinputstub_fuzzer/BUILD.gn @@ -26,9 +26,7 @@ ohos_fuzztest("DistributedInputStubFuzzTest") { "${av_transport_path}/common/include", "${innerkits_path}/include", "${innerkits_path}/ipc/include", - "${innerkits_path}/src", "${ipc_path}/include", - "${ipc_path}/src", "${services_source_path}/sourcemanager/include", "${frameworks_path}/include", "${distributedinput_path}/inputdevicehandler/include", diff --git a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp index db6e65c..a0b47b0 100644 --- a/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp +++ b/services/sink/sinkmanager/src/distributed_input_sink_manager.cpp @@ -393,6 +393,10 @@ void DistributedInputSinkManager::DInputSinkListener::OnRelayStartDhidRemoteInpu void DistributedInputSinkManager::DInputSinkListener::OnRelayStopDhidRemoteInput(const int32_t &toSrcSessionId, const int32_t &toSinkSessionId, const std::string &deviceId, const std::string &strDhids) { + if (sinkManagerObj_ == nullptr) { + DHLOGE("sinkManagerObj is null."); + return; + } DHLOGI("onRelayStopDhidRemoteInput called, toSinkSessionId: %{public}d", toSinkSessionId); std::vector stopIndeedDhIds; std::vector stopOnCmdDhIds; @@ -423,10 +427,6 @@ void DistributedInputSinkManager::DInputSinkListener::OnRelayStopDhidRemoteInput DHLOGE("Not all devices are stopped."); return; } - if (sinkManagerObj_ == nullptr) { - DHLOGE("sinkManagerObj is null."); - return; - } DistributedInputSinkSwitch::GetInstance().StopAllSwitch(); sinkManagerObj_->SetInputTypes(static_cast(DInputDeviceType::NONE)); if (DistributedInputSinkSwitch::GetInstance().GetSwitchOpenedSession() == @@ -865,6 +865,10 @@ int32_t DistributedInputSinkManager::ProjectWindowListener::ParseMessage(const s int32_t DistributedInputSinkManager::ProjectWindowListener::UpdateSinkScreenInfoCache(const std::string &srcDevId, const uint64_t srcWinId, const SinkScreenInfo &sinkScreenInfoTmp) { + if (sinkManagerObj_ == nullptr) { + DHLOGE("sinkManagerObj is null."); + return ERR_DH_INPUT_SERVER_SINK_MANAGER_IS_NULL; + } std::string srcScreenInfoKey = DInputContext::GetInstance().GetScreenInfoKey(srcDevId, srcWinId); SinkScreenInfo sinkScreenInfo = DInputContext::GetInstance().GetSinkScreenInfo(srcScreenInfoKey); sinkScreenInfo.sinkShowWinId = sinkScreenInfoTmp.sinkShowWinId; @@ -885,7 +889,7 @@ int32_t DistributedInputSinkManager::ProjectWindowListener::UpdateSinkScreenInfo sinkScreenInfo.sinkPhyWidth, sinkScreenInfo.sinkPhyHeight); int32_t ret = DInputContext::GetInstance().UpdateSinkScreenInfo(srcScreenInfoKey, sinkScreenInfo); std::lock_guard lock(sinkManagerObj_->mutex_); - if ((ret == DH_SUCCESS) && (sinkManagerObj_!= nullptr) && (sinkManagerObj_->GetSinkScreenInfosCbackSize() > 0)) { + if ((ret == DH_SUCCESS) && (sinkManagerObj_->GetSinkScreenInfosCbackSize() > 0)) { sinkManagerObj_->CallBackScreenInfoChange(); } return ret; diff --git a/services/source/inputinject/src/distributed_input_node_manager.cpp b/services/source/inputinject/src/distributed_input_node_manager.cpp index 7828cd1..c78bf3b 100644 --- a/services/source/inputinject/src/distributed_input_node_manager.cpp +++ b/services/source/inputinject/src/distributed_input_node_manager.cpp @@ -202,6 +202,10 @@ void DistributedInputNodeManager::DInputNodeManagerEventHandler::ScanAllNode( const AppExecFwk::InnerEvent::Pointer &event) { DHLOGI("ScanAllNode enter."); + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); diff --git a/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp b/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp index 4ed70d8..e2d917b 100644 --- a/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp +++ b/services/source/sourcemanager/src/dinput_source_manager_event_handler.cpp @@ -47,6 +47,10 @@ DInputSourceManagerEventHandler::~DInputSourceManagerEventHandler() void DInputSourceManagerEventHandler::NotifyRegisterCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -83,6 +87,10 @@ void DInputSourceManagerEventHandler::NotifyRegisterCallback(const AppExecFwk::I void DInputSourceManagerEventHandler::NotifyUnregisterCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -108,6 +116,10 @@ void DInputSourceManagerEventHandler::NotifyUnregisterCallback(const AppExecFwk: void DInputSourceManagerEventHandler::NotifyPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -131,6 +143,10 @@ void DInputSourceManagerEventHandler::NotifyPrepareCallback(const AppExecFwk::In void DInputSourceManagerEventHandler::NotifyUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -154,6 +170,10 @@ void DInputSourceManagerEventHandler::NotifyUnprepareCallback(const AppExecFwk:: void DInputSourceManagerEventHandler::NotifyStartCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -184,6 +204,10 @@ void DInputSourceManagerEventHandler::NotifyStartCallback(const AppExecFwk::Inne void DInputSourceManagerEventHandler::NotifyStopCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -225,6 +249,10 @@ void DInputSourceManagerEventHandler::NotifyStopCallback(const AppExecFwk::Inner void DInputSourceManagerEventHandler::NotifyStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -248,6 +276,10 @@ void DInputSourceManagerEventHandler::NotifyStartDhidCallback(const AppExecFwk:: void DInputSourceManagerEventHandler::NotifyStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -271,6 +303,10 @@ void DInputSourceManagerEventHandler::NotifyStopDhidCallback(const AppExecFwk::I void DInputSourceManagerEventHandler::NotifyKeyStateCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -297,6 +333,10 @@ void DInputSourceManagerEventHandler::NotifyKeyStateCallback(const AppExecFwk::I void DInputSourceManagerEventHandler::NotifyStartServerCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -316,6 +356,10 @@ void DInputSourceManagerEventHandler::NotifyStartServerCallback(const AppExecFwk void DInputSourceManagerEventHandler::NotifyRelayPrepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -338,6 +382,10 @@ void DInputSourceManagerEventHandler::NotifyRelayPrepareCallback(const AppExecFw void DInputSourceManagerEventHandler::NotifyRelayUnprepareCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -360,6 +408,10 @@ void DInputSourceManagerEventHandler::NotifyRelayUnprepareCallback(const AppExec void DInputSourceManagerEventHandler::NotifyRelayPrepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -396,6 +448,10 @@ void DInputSourceManagerEventHandler::NotifyRelayPrepareRemoteInput(const AppExe void DInputSourceManagerEventHandler::NotifyRelayUnprepareRemoteInput(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -428,6 +484,10 @@ void DInputSourceManagerEventHandler::NotifyRelayUnprepareRemoteInput(const AppE void DInputSourceManagerEventHandler::NotifyRelayStartDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -452,6 +512,10 @@ void DInputSourceManagerEventHandler::NotifyRelayStartDhidCallback(const AppExec void DInputSourceManagerEventHandler::NotifyRelayStopDhidCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -476,6 +540,10 @@ void DInputSourceManagerEventHandler::NotifyRelayStopDhidCallback(const AppExecF void DInputSourceManagerEventHandler::NotifyRelayStartTypeCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); @@ -500,6 +568,10 @@ void DInputSourceManagerEventHandler::NotifyRelayStartTypeCallback(const AppExec void DInputSourceManagerEventHandler::NotifyRelayStopTypeCallback(const AppExecFwk::InnerEvent::Pointer &event) { + if (event == nullptr) { + DHLOGE("event is null."); + return; + } std::shared_ptr dataMsg = event->GetSharedObject(); if (dataMsg == nullptr) { DHLOGE("dataMsg is null."); diff --git a/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp b/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp index df24e9e..44a15ef 100644 --- a/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp +++ b/sinkhandler/test/unittest/mock/mock_distributed_input_client.cpp @@ -33,11 +33,11 @@ DistributedInputClient &DistributedInputClient::GetInstance() void DistributedInputClient::RegisterDInputCb::OnResult( const std::string &devId, const std::string &dhId, const int32_t &status) { - auto iter = DistributedInputClient::GetInstance().dHardWareFwkRstInfos.begin(); - for (; iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos.end(); ++iter) { + auto iter = DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.begin(); + for (; iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { iter->callback->OnRegisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.erase(iter); return; } } @@ -46,11 +46,11 @@ void DistributedInputClient::RegisterDInputCb::OnResult( void DistributedInputClient::UnregisterDInputCb::OnResult( const std::string &devId, const std::string &dhId, const int32_t &status) { - auto iter = DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.begin(); - for (; iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.end(); ++iter) { + auto iter = DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.begin(); + for (; iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { iter->callback->OnUnregisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.erase(iter); return; } } diff --git a/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp b/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp index ecf6c16..7d97f9d 100644 --- a/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp +++ b/sourcehandler/test/unittest/mock/mock_distributed_input_client.cpp @@ -34,11 +34,11 @@ DistributedInputClient &DistributedInputClient::GetInstance() void DistributedInputClient::RegisterDInputCb::OnResult( const std::string &devId, const std::string &dhId, const int32_t &status) { - auto iter = DistributedInputClient::GetInstance().dHardWareFwkRstInfos.begin(); - for (; iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos.end(); ++iter) { + auto iter = DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.begin(); + for (; iter != DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { iter->callback->OnRegisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkRstInfos_.erase(iter); return; } } @@ -47,11 +47,11 @@ void DistributedInputClient::RegisterDInputCb::OnResult( void DistributedInputClient::UnregisterDInputCb::OnResult( const std::string &devId, const std::string &dhId, const int32_t &status) { - auto iter = DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.begin(); - for (; iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.end(); ++iter) { + auto iter = DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.begin(); + for (; iter != DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.end(); ++iter) { if (iter->devId == devId && iter->dhId == dhId) { iter->callback->OnUnregisterResult(devId, dhId, status, ""); - DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos.erase(iter); + DistributedInputClient::GetInstance().dHardWareFwkUnRstInfos_.erase(iter); return; } } diff --git a/test/fuzztest/distributedinputsourcetransport_fuzzer/distributed_input_source_transport_fuzzer.cpp b/test/fuzztest/distributedinputsourcetransport_fuzzer/distributed_input_source_transport_fuzzer.cpp index 452f36c..1426b91 100644 --- a/test/fuzztest/distributedinputsourcetransport_fuzzer/distributed_input_source_transport_fuzzer.cpp +++ b/test/fuzztest/distributedinputsourcetransport_fuzzer/distributed_input_source_transport_fuzzer.cpp @@ -32,7 +32,7 @@ namespace OHOS { namespace DistributedHardware { void OpenInputSoftbusFuzzTest(const uint8_t *data, size_t size) { - if ((data == nullptr) || (size < sizeof(int32_t))) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/test/fuzztest/distributedinputtransportbase_fuzzer/distributed_input_transport_base_fuzzer.cpp b/test/fuzztest/distributedinputtransportbase_fuzzer/distributed_input_transport_base_fuzzer.cpp index ffeac36..24bdce9 100644 --- a/test/fuzztest/distributedinputtransportbase_fuzzer/distributed_input_transport_base_fuzzer.cpp +++ b/test/fuzztest/distributedinputtransportbase_fuzzer/distributed_input_transport_base_fuzzer.cpp @@ -31,7 +31,7 @@ namespace OHOS { namespace DistributedHardware { void StartSessionFuzzTest(const uint8_t *data, size_t size) { - if ((data == nullptr) || (size < sizeof(int32_t))) { + if ((data == nullptr) || (size == 0)) { return; } -- Gitee