diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp index 3e76949b11cc90114da6c177edb1d1b97cbe54ca..1c3798a463f75ff823a79c402f2dae46ed0bcd18 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -320,11 +320,11 @@ void DsoftbusInputPlugin::DataEnqueue(std::shared_ptr &buffer) AVTRANS_LOGE("buffer is nullptr."); return; } - if (GetReDumpFlag() == true) { + if (GetReDumpFlag()) { std::remove(SCREEN_FILE_NAME_BEFOREENCODING.c_str()); SetReDumpFlagFalse(); } - if (GetDumpFlag() == true) { + if (GetDumpFlag()) { auto bufferData = buffer->GetMemory(); if (bufferData != nullptr) { DumpBufferToFile(SCREEN_FILE_NAME_BEFOREENCODING, diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp index 7fc142cfd230198c789531b34c019a452ef2b550..6f2210d99e50fda78f17a8244b560057e992f35a 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp @@ -254,11 +254,11 @@ Status DsoftbusOutputPlugin::PushData(const std::string &inPort, std::shared_ptr AVTRANS_LOGE("Buffer is nullptr."); return Status::ERROR_NULL_POINTER; } - if (GetReDumpFlag() == true) { + if (GetReDumpFlag()) { std::remove(SCREEN_FILE_NAME_AFTERCODING.c_str()); SetReDumpFlagFalse(); } - if (GetDumpFlag() == true) { + if (GetDumpFlag()) { auto bufferData = buffer->GetMemory(); DumpBufferToFile(SCREEN_FILE_NAME_AFTERCODING, const_cast(bufferData->GetReadOnlyData()), bufferData->GetSize()); diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/output_controller_listener.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/output_controller_listener.h index babab49469309a5bd49865b25b320d9aa02368f5..1f05f509be7ec7e63c715a871ebb5a5c26f19d65 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/output_controller_listener.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/output_controller_listener.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -15,9 +15,11 @@ #ifndef OHOS_OUTPUT_CONTROLLER_LISTENER_H #define OHOS_OUTPUT_CONTROLLER_LISTENER_H + +#include + #include "controllable_output.h" #include "plugin_buffer.h" -#include namespace OHOS { namespace DistributedHardware { diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/time_statistician.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/time_statistician.h index b8715626271ab316564e054702c598fbd38f71ba..2b045a352c98f8aecdc49568d980cfebfd474e2e 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/time_statistician.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/include/time_statistician.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -16,8 +16,10 @@ #ifndef OHOS_TIME_STATISTICIAN_H #define OHOS_TIME_STATISTICIAN_H -#include "plugin_buffer.h" #include + +#include "plugin_buffer.h" + namespace OHOS { namespace DistributedHardware { using namespace OHOS::Media; diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller.cpp index 258c004a4378e3a3ac1b5081ab0ece65bca80e79..d5dc265f24f0bebc8de966851bf2ae4d6b6dbc25 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -13,9 +13,11 @@ * limitations under the License. */ -#include -#include #include "output_controller.h" + +#include +#include + #include "av_trans_constants.h" #include "av_trans_errno.h" diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller_listener.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller_listener.cpp index 348b5116dc44e19f13d17d9ab6f981ff090fdcdd..962e890466b43b268287fd80ae4247499fc8c746 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller_listener.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/output_control/src/output_controller_listener.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -12,8 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "av_trans_log.h" + #include "output_controller_listener.h" + +#include "av_trans_log.h" #include "output_controller_constants.h" namespace OHOS { diff --git a/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/include/histreamer_ability_querier_test.h b/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/include/histreamer_ability_querier_test.h index f65d492b71c0c5eb5a12c442f7f3110241a6e1c3..35aa1723bc00d44b6722c9c57540d2634ef761a9 100644 --- a/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/include/histreamer_ability_querier_test.h +++ b/av_transport/av_trans_handler/histreamer_ability_querier/test/unittest/common/include/histreamer_ability_querier_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -16,9 +16,10 @@ #ifndef OHOS_DISTRIBUTED_HARDWARE_HISTREAMER_ABILITY_QUERIER_TEST_H #define OHOS_DISTRIBUTED_HARDWARE_HISTREAMER_ABILITY_QUERIER_TEST_H -#include "cJSON.h" #include +#include "cJSON.h" + namespace OHOS { namespace DistributedHardware { class HistreamerAbilityQuerierTest : public testing::Test { diff --git a/av_transport/common/include/av_trans_log.h b/av_transport/common/include/av_trans_log.h index 0453a4101171fa4049da80218a272e95e9587811..afb6c2c85dd291e1b6e1ccbf1a1d4ff81650d8e1 100644 --- a/av_transport/common/include/av_trans_log.h +++ b/av_transport/common/include/av_trans_log.h @@ -17,10 +17,11 @@ #define OHOS_AV_TRANSPORT_LOG_H #include -#include "hilog/log.h" #include #include +#include "hilog/log.h" + namespace OHOS { namespace DistributedHardware { #undef LOG_TAG diff --git a/interfaces/kits/napi/src/native_distributedhardwarefwk_js.cpp b/interfaces/kits/napi/src/native_distributedhardwarefwk_js.cpp index 0115070831a06d818324d8e8b739c5377b974412..ab12ee5379d2965383f1a84246e3d58dbc52ab28 100644 --- a/interfaces/kits/napi/src/native_distributedhardwarefwk_js.cpp +++ b/interfaces/kits/napi/src/native_distributedhardwarefwk_js.cpp @@ -38,7 +38,7 @@ const int32_t DH_NAPI_ARGS_TWO = 2; enum DHBussinessErrorCode { // Permission verify failed. ERR_NO_PERMISSION = 201, - //The caller is not a system application. + // The caller is not a system application. ERR_NOT_SYSTEM_APP = 202, // Input parameter error. ERR_INVALID_PARAMS = 401, diff --git a/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h b/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h index cdb9e2b901e03d130febd5391fd6a16a1271a2f5..09b9cfdb6377f023c10b7261d2999a18fda815ae 100644 --- a/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h +++ b/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h @@ -78,10 +78,10 @@ public: bool FetchNeedRefreshTask(const std::pair &taskKey, TaskParam &taskParam); class ComponentManagerEventHandler : public AppExecFwk::EventHandler { - public: - ComponentManagerEventHandler(const std::shared_ptr &runner); - ~ComponentManagerEventHandler() override = default; - void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; + public: + ComponentManagerEventHandler(const std::shared_ptr &runner); + ~ComponentManagerEventHandler() override = default; + void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; }; std::shared_ptr GetEventHandler(); diff --git a/services/distributedhardwarefwkservice/include/distributed_hardware_manager.h b/services/distributedhardwarefwkservice/include/distributed_hardware_manager.h index 4751766bf4efe60e591b718cf23de9219a32ca06..8ed117585e7871932eb5f5a7977f838bacaa03cf 100644 --- a/services/distributedhardwarefwkservice/include/distributed_hardware_manager.h +++ b/services/distributedhardwarefwkservice/include/distributed_hardware_manager.h @@ -40,8 +40,8 @@ public: int32_t Dump(const std::vector &argsStr, std::string &result) override; private: - std::atomic isLocalInit{false}; - std::atomic isAllInit{false}; + std::atomic isLocalInit_{false}; + std::atomic isAllInit_{false}; std::mutex dhInitMgrMutex_; }; } // namespace DistributedHardware diff --git a/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h b/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h index 81b657b42843e8f5f80a19f102d924e66193694d..3ff6c59bfcab49055564276c33ff198b929cd3d7 100644 --- a/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h +++ b/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h @@ -46,7 +46,7 @@ private: void ExitDHFWK(); private: - std::atomic isInit = false; + std::atomic isInit_ = false; std::atomic flagUnInit_ = false; }; } // namespace DistributedHardware diff --git a/services/distributedhardwarefwkservice/include/resourcemanager/db_adapter.h b/services/distributedhardwarefwkservice/include/resourcemanager/db_adapter.h index c9c161ad124f1fcb844cd28c1cd617e451633cd4..4f5aae439c336d2eda1689d41b8ea64c6c45e3e6 100644 --- a/services/distributedhardwarefwkservice/include/resourcemanager/db_adapter.h +++ b/services/distributedhardwarefwkservice/include/resourcemanager/db_adapter.h @@ -77,8 +77,8 @@ private: std::shared_ptr kvStoragePtr_; std::shared_ptr dataChangeListener_; std::mutex dbAdapterMutex_; - bool isAutoSync {false}; - DistributedKv::DataType dataType {DistributedKv::DataType::TYPE_DYNAMICAL}; + bool isAutoSync_ {false}; + DistributedKv::DataType dataType_ {DistributedKv::DataType::TYPE_DYNAMICAL}; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/distributedhardwarefwkservice/include/transport/dh_comm_tool.h b/services/distributedhardwarefwkservice/include/transport/dh_comm_tool.h index ac7bace674e9fef73b2f0e572cee1800d3d9641a..a6d87c0a4c7d43095fdb0c0e90f5ca4fcc549e0a 100644 --- a/services/distributedhardwarefwkservice/include/transport/dh_comm_tool.h +++ b/services/distributedhardwarefwkservice/include/transport/dh_comm_tool.h @@ -52,14 +52,14 @@ public: FullCapsRsp ParseAndSaveRemoteDHCaps(const std::string &remoteCaps); class DHCommToolEventHandler : public AppExecFwk::EventHandler { - public: - DHCommToolEventHandler(const std::shared_ptr &runner, - std::shared_ptr dhCommToolPtr); - ~DHCommToolEventHandler() override = default; - void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; - private: - void ProcessFullCapsRsp(const FullCapsRsp &capsRsp, const std::shared_ptr dhCommToolPtr); - std::weak_ptr dhCommToolWPtr_; + public: + DHCommToolEventHandler(const std::shared_ptr &runner, + std::shared_ptr dhCommToolPtr); + ~DHCommToolEventHandler() override = default; + void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; + private: + void ProcessFullCapsRsp(const FullCapsRsp &capsRsp, const std::shared_ptr dhCommToolPtr); + std::weak_ptr dhCommToolWPtr_; }; std::shared_ptr GetEventHandler(); const std::shared_ptr GetDHTransportPtr(); diff --git a/services/distributedhardwarefwkservice/include/utils/dh_context.h b/services/distributedhardwarefwkservice/include/utils/dh_context.h index 5dccad6c090ca90973e76e3fe4989b7fd344fd01..73e0eefc6663996797286886708b894a04690ded 100644 --- a/services/distributedhardwarefwkservice/include/utils/dh_context.h +++ b/services/distributedhardwarefwkservice/include/utils/dh_context.h @@ -89,12 +89,12 @@ public: std::string GetDeviceIdByDBGetPrefix(const std::string &prefix); class CommonEventHandler : public AppExecFwk::EventHandler { - public: - CommonEventHandler(const std::shared_ptr &runner); - ~CommonEventHandler() override = default; + public: + CommonEventHandler(const std::shared_ptr &runner); + ~CommonEventHandler() override = default; - bool PostTask(const Callback &callback, const std::string &name = std::string(), int64_t delayTime = 0); - void RemoveTask(const std::string &name); + bool PostTask(const Callback &callback, const std::string &name = std::string(), int64_t delayTime = 0); + void RemoveTask(const std::string &name); }; std::shared_ptr GetEventHandler(); diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager.cpp index 950ae64f91d10a3ff72ae10749ea862b10454285..7280add30125e71a2929f7a12b8b0991833cdaa3 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager.cpp @@ -47,7 +47,7 @@ IMPLEMENT_SINGLE_INSTANCE(DistributedHardwareManager); int32_t DistributedHardwareManager::LocalInit() { DHLOGI("DHFWK Local Init begin"); - if (isLocalInit) { + if (isLocalInit_.load()) { DHLOGI("Local init already finish"); return DH_FWK_SUCCESS; } @@ -60,7 +60,7 @@ int32_t DistributedHardwareManager::LocalInit() LocalHardwareManager::GetInstance().Init(); DeviceParamMgr::GetInstance().QueryDeviceDataSyncMode(); DHLOGI("DHFWK Local Init end"); - isLocalInit = true; + isLocalInit_.store(true); return DH_FWK_SUCCESS; } @@ -68,14 +68,14 @@ int32_t DistributedHardwareManager::Initialize() { DHLOGI("DHFWK Normal Init begin"); std::lock_guard lock(dhInitMgrMutex_); - if (isAllInit) { + if (isAllInit_.load()) { DHLOGI("DHMgr init already finish"); return DH_FWK_SUCCESS; } LocalInit(); ComponentManager::GetInstance().Init(); DHLOGI("DHFWK Normal Init end"); - isAllInit = true; + isAllInit_.store(true); return DH_FWK_SUCCESS; } @@ -90,8 +90,8 @@ int32_t DistributedHardwareManager::Release() CapabilityInfoManager::GetInstance()->UnInit(); MetaInfoManager::GetInstance()->UnInit(); LocalCapabilityInfoManager::GetInstance()->UnInit(); - isAllInit = false; - isLocalInit = false; + isAllInit_.store(false); + isLocalInit_.store(false); return DH_FWK_SUCCESS; } diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 9a706bcb6f4a184a48f5f31e359b89dd830bbf48..45f651f122800b82ed78ecf7eedc5d299e1bb7d5 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -22,11 +22,14 @@ #include #include +#include "iservice_registry.h" +#include "system_ability_definition.h" + #include "dm_device_info.h" +#include "device_manager.h" #include "anonymous_string.h" #include "constants.h" -#include "device_manager.h" #include "dh_context.h" #include "dh_utils_hisysevent.h" #include "dh_utils_hitrace.h" @@ -34,10 +37,8 @@ #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" #include "distributed_hardware_manager.h" -#include "iservice_registry.h" #include "device_param_mgr.h" #include "meta_info_manager.h" -#include "system_ability_definition.h" namespace OHOS { namespace DistributedHardware { @@ -79,7 +80,7 @@ bool DistributedHardwareManagerFactory::Init() DHLOGE("Initialize failed, errCode = %{public}d", initResult); return false; } - isInit = true; + isInit_.store(true); DHLOGI("success"); return true; } @@ -93,7 +94,7 @@ void DistributedHardwareManagerFactory::UnInit() // release all the resources synchronously DistributedHardwareManager::GetInstance().Release(); - isInit = false; + isInit_.store(false); flagUnInit_.store(false); DHTraceEnd(); CheckExitSAOrNot(); @@ -145,7 +146,7 @@ void DistributedHardwareManagerFactory::CheckExitSAOrNot() bool DistributedHardwareManagerFactory::IsInit() { - return isInit.load(); + return isInit_.load(); } int32_t DistributedHardwareManagerFactory::SendOnLineEvent(const std::string &networkId, const std::string &uuid, @@ -171,7 +172,7 @@ int32_t DistributedHardwareManagerFactory::SendOnLineEvent(const std::string &ne DHContext::GetInstance().AddOnlineDevice(udid, uuid, networkId); - if (!isInit && !Init()) { + if (!isInit_.load() && !Init()) { DHLOGE("distributedHardwareMgr is null"); return ERR_DH_FWK_HARDWARE_MANAGER_INIT_FAILED; } @@ -194,7 +195,7 @@ int32_t DistributedHardwareManagerFactory::SendOffLineEvent(const std::string &n if (!IsIdLengthValid(networkId) || !IsIdLengthValid(uuid) || !IsIdLengthValid(udid)) { return ERR_DH_FWK_PARA_INVALID; } - if (!isInit && !Init()) { + if (!isInit_.load() && !Init()) { DHLOGE("distributedHardwareMgr is null"); return ERR_DH_FWK_HARDWARE_MANAGER_INIT_FAILED; } diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp index 17f6a8c5df8ae0e3b4c9452257cbc2a2dfdbb8f2..c7883862569b35b20ae9919f3db7ec8b9a97f9b1 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp @@ -18,15 +18,16 @@ #include #include "accesstoken_kit.h" +#include "ipc_skeleton.h" +#include "tokenid_kit.h" + #include "anonymous_string.h" #include "constants.h" #include "dhardware_ipc_interface_code.h" #include "dh_context.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" -#include "ipc_skeleton.h" #include "publisher_listener_proxy.h" -#include "tokenid_kit.h" namespace OHOS { namespace DistributedHardware { diff --git a/services/distributedhardwarefwkservice/src/publisher/publisher_item.cpp b/services/distributedhardwarefwkservice/src/publisher/publisher_item.cpp index e900767ec3e6dca9d951024d4463552da676ab27..55de2a0137968bf3c2cb88b0fed8e6a63b47e0f5 100644 --- a/services/distributedhardwarefwkservice/src/publisher/publisher_item.cpp +++ b/services/distributedhardwarefwkservice/src/publisher/publisher_item.cpp @@ -13,8 +13,9 @@ * limitations under the License. */ -#include "constants.h" #include "publisher_item.h" + +#include "constants.h" #include "dh_utils_tool.h" #include "distributed_hardware_log.h" diff --git a/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp b/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp index 0dfd8be36cd0917ad6ecfd5fe35a586d886a2304..bb5dd9800fd35f8600bc927d4adb1c8289e40b2d 100644 --- a/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp +++ b/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp @@ -98,8 +98,8 @@ DistributedKv::Status DBAdapter::GetLocalKvStorePtr() int32_t DBAdapter::Init(bool isAutoSync, DistributedKv::DataType dataType) { - this->isAutoSync = isAutoSync; - this->dataType = dataType; + this->isAutoSync_ = isAutoSync; + this->dataType_ = dataType; DHLOGI("Init DB, storeId: %{public}s, dataType: %{public}d", storeId_.storeId.c_str(), static_cast(dataType)); std::lock_guard lock(dbAdapterMutex_); @@ -131,10 +131,10 @@ int32_t DBAdapter::Init(bool isAutoSync, DistributedKv::DataType dataType) int32_t DBAdapter::InitLocal() { - this->isAutoSync = false; - this->dataType = DistributedKv::DataType::TYPE_STATICS; + this->isAutoSync_ = false; + this->dataType_ = DistributedKv::DataType::TYPE_STATICS; DHLOGI("Init local DB, storeId: %{public}s, dataType: %{public}d", - storeId_.storeId.c_str(), static_cast(this->dataType)); + storeId_.storeId.c_str(), static_cast(this->dataType_)); std::lock_guard lock(dbAdapterMutex_); int32_t tryTimes = MAX_INIT_RETRY_TIMES; while (tryTimes > 0) { @@ -164,7 +164,7 @@ void DBAdapter::UnInit() return; } UnRegisterKvStoreDeathListener(); - if (this->isAutoSync) { + if (this->isAutoSync_) { UnRegisterChangeListener(); } kvStoragePtr_.reset(); @@ -179,8 +179,8 @@ int32_t DBAdapter::ReInit(bool isAutoSync) return ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL; } kvStoragePtr_.reset(); - DistributedKv::Status status = this->isAutoSync ? - GetKvStorePtr(isAutoSync, this->dataType) : GetLocalKvStorePtr(); + DistributedKv::Status status = this->isAutoSync_ ? + GetKvStorePtr(isAutoSync, this->dataType_) : GetLocalKvStorePtr(); if (status != DistributedKv::Status::SUCCESS || !kvStoragePtr_) { DHLOGW("Get kvStoragePtr_ failed, status: %{public}d", status); return ERR_DH_FWK_RESOURCE_KV_STORAGE_OPERATION_FAIL; @@ -243,7 +243,7 @@ int32_t DBAdapter::GetDataByKey(const std::string &key, std::string &data) return ERR_DH_FWK_PARA_INVALID; } DHLOGI("Get data by key: %{public}s, storeId: %{public}s, dataType: %{public}d", - GetAnonyString(key).c_str(), storeId_.storeId.c_str(), static_cast(this->dataType)); + GetAnonyString(key).c_str(), storeId_.storeId.c_str(), static_cast(this->dataType_)); std::lock_guard lock(dbAdapterMutex_); if (kvStoragePtr_ == nullptr) { DHLOGE("kvStoragePtr_ is null"); @@ -253,11 +253,11 @@ int32_t DBAdapter::GetDataByKey(const std::string &key, std::string &data) DistributedKv::Value kvValue; DistributedKv::Status status = kvStoragePtr_->Get(kvKey, kvValue); if (status == DistributedKv::Status::NOT_FOUND) { - if (this->dataType == DistributedKv::DataType::TYPE_DYNAMICAL) { + if (this->dataType_ == DistributedKv::DataType::TYPE_DYNAMICAL) { SyncByNotFound(key); } #ifdef DHARDWARE_OPEN_SOURCE - if (this->dataType == DistributedKv::DataType::TYPE_STATICS && this->storeId_.storeId == GLOBAL_META_INFO) { + if (this->dataType_ == DistributedKv::DataType::TYPE_STATICS && this->storeId_.storeId == GLOBAL_META_INFO) { SyncByNotFound(key); } #endif @@ -273,7 +273,7 @@ int32_t DBAdapter::GetDataByKey(const std::string &key, std::string &data) int32_t DBAdapter::GetDataByKeyPrefix(const std::string &keyPrefix, std::vector &values) { DHLOGI("Get data by key prefix: %{public}s, storeId: %{public}s, dataType: %{public}d", - GetAnonyString(keyPrefix).c_str(), storeId_.storeId.c_str(), static_cast(this->dataType)); + GetAnonyString(keyPrefix).c_str(), storeId_.storeId.c_str(), static_cast(this->dataType_)); std::lock_guard lock(dbAdapterMutex_); if (kvStoragePtr_ == nullptr) { DHLOGE("kvStoragePtr_ is null"); @@ -284,11 +284,11 @@ int32_t DBAdapter::GetDataByKeyPrefix(const std::string &keyPrefix, std::vector< std::vector allEntries; DistributedKv::Status status = kvStoragePtr_->GetEntries(allEntryKeyPrefix, allEntries); if (status == DistributedKv::Status::SUCCESS && allEntries.size() == 0) { - if (this->dataType == DistributedKv::DataType::TYPE_DYNAMICAL) { + if (this->dataType_ == DistributedKv::DataType::TYPE_DYNAMICAL) { SyncByNotFound(keyPrefix); } #ifdef DHARDWARE_OPEN_SOURCE - if (this->dataType == DistributedKv::DataType::TYPE_STATICS && this->storeId_.storeId == GLOBAL_META_INFO) { + if (this->dataType_ == DistributedKv::DataType::TYPE_STATICS && this->storeId_.storeId == GLOBAL_META_INFO) { SyncByNotFound(keyPrefix); } #endif @@ -455,9 +455,9 @@ void DBAdapter::OnRemoteDied() bool DBAdapter::DBDiedOpt(int32_t ×) { // init kvStore. - if (this->ReInit(this->isAutoSync) == DH_FWK_SUCCESS) { + if (this->ReInit(this->isAutoSync_) == DH_FWK_SUCCESS) { // register data change listener again. - if (this->isAutoSync) { + if (this->isAutoSync_) { this->RegisterChangeListener(); } this->SyncDBForRecover(); diff --git a/services/distributedhardwarefwkservice/src/task/task_factory.cpp b/services/distributedhardwarefwkservice/src/task/task_factory.cpp index 7b931f35f72bb26e6cfc4735c57181d72c11338b..85ccf565c72a34c262a9bb92d0ba127c56efd955 100644 --- a/services/distributedhardwarefwkservice/src/task/task_factory.cpp +++ b/services/distributedhardwarefwkservice/src/task/task_factory.cpp @@ -52,7 +52,7 @@ std::shared_ptr TaskFactory::CreateTask(TaskType taskType, TaskParam taskP break; } case TaskType::OFF_LINE: { - task = std::make_shared(taskParam.networkId, taskParam.uuid, taskParam.uuid, + task = std::make_shared(taskParam.networkId, taskParam.uuid, taskParam.udid, taskParam.dhId, taskParam.dhType); break; } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/access_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/access_manager_test.cpp index 129a3963c454d6ae00606bf539ff9c48e46f4b89..57917eb693369bab314b12db21db4f49d3a488e6 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/access_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/access_manager_test.cpp @@ -46,7 +46,7 @@ public: void AccessManagerTest::SetUp() { - DistributedHardwareManagerFactory::GetInstance().isInit = true; + DistributedHardwareManagerFactory::GetInstance().isInit_.store(true); } void AccessManagerTest::TearDown() {} diff --git a/utils/include/log/dh_log.h b/utils/include/log/dh_log.h index d8f2ab13746c705bd1930883c42bc21868eb7e79..109cda7994cba1a7fb189164432730ee23f64af0 100644 --- a/utils/include/log/dh_log.h +++ b/utils/include/log/dh_log.h @@ -16,9 +16,10 @@ #ifndef OHOS_DH_LOG_H #define OHOS_DH_LOG_H -#include "hilog/log.h" #include +#include "hilog/log.h" + namespace OHOS { namespace DistributedHardware { #undef LOG_TAG diff --git a/utils/src/dh_utils_tool.cpp b/utils/src/dh_utils_tool.cpp index 326030862a424b6e2a8c12fd754fe0c25e38acc8..455e031f2120bc1f7ad58738ca8967edf0e3f0d5 100644 --- a/utils/src/dh_utils_tool.cpp +++ b/utils/src/dh_utils_tool.cpp @@ -62,7 +62,10 @@ std::string GetRandomID() static std::uniform_int_distribution dist(0ULL, 0xFFFFFFFFFFFFFFFFULL); uint64_t ab = dist(rd); uint64_t cd = dist(rd); - uint32_t a, b, c, d; + uint32_t a; + uint32_t b; + uint32_t c; + uint32_t d; std::stringstream ss; ab = (ab & 0xFFFFFFFFFFFF0FFFULL) | 0x0000000000004000ULL; cd = (cd & 0x3FFFFFFFFFFFFFFFULL) | 0x8000000000000000ULL; @@ -126,7 +129,7 @@ std::string Sha256(const std::string& in) out[i * DOUBLE_TIMES + 1] = hexCode[value & MASK]; } out[SHA256_DIGEST_LENGTH * DOUBLE_TIMES] = 0; - return reinterpret_cast(out); + return std::string(reinterpret_cast(out)); } DeviceInfo GetLocalDeviceInfo()