diff --git a/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp b/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp index 8d2b5b18a4cffa308930ca541bbbc9d8f576e55d..4a5e5a3cc5f08768032a924f16146639c26e8c52 100644 --- a/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp +++ b/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp @@ -569,6 +569,7 @@ ErrorCode AVInputFilter::PushData(const std::string& inPort, const AVBufferPtr& ErrorCode AVInputFilter::SetEventCallBack() { + std::lock_guard lock(inputFilterMutex_); if (plugin_ == nullptr) { AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_NULL_POINTER ; @@ -578,6 +579,7 @@ ErrorCode AVInputFilter::SetEventCallBack() ErrorCode AVInputFilter::SetDataCallBack() { + std::lock_guard lock(inputFilterMutex_); if (plugin_ == nullptr) { AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_NULL_POINTER; @@ -588,6 +590,7 @@ ErrorCode AVInputFilter::SetDataCallBack() void AVInputFilter::OnDataCallback(std::shared_ptr buffer) { + std::lock_guard lock(inputFilterMutex_); if (buffer == nullptr) { AVTRANS_LOGE("buffer is nullptr!"); return; diff --git a/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp b/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp index 5397403c3208f22be2ec2052984077d022458304..3e9072afb344027deb49f9580798b432d605eaae 100644 --- a/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp +++ b/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp @@ -329,6 +329,7 @@ ErrorCode AVOutputFilter::SetPluginParams() ErrorCode AVOutputFilter::SetEventCallBack() { + std::lock_guard lock(outputFilterMutex_); if (plugin_ == nullptr) { AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; @@ -339,6 +340,7 @@ ErrorCode AVOutputFilter::SetEventCallBack() ErrorCode AVOutputFilter::SetDataCallBack() { + std::lock_guard lock(outputFilterMutex_); if (plugin_ == nullptr) { AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; @@ -349,6 +351,7 @@ ErrorCode AVOutputFilter::SetDataCallBack() void AVOutputFilter::OnDataCallback(std::shared_ptr buffer) { + std::lock_guard lock(outputFilterMutex_); if (buffer == nullptr) { AVTRANS_LOGE("buffer is nullptr!"); return; 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 0616d654bb359c7aa3008cb648702384c6b640a5..62e7ae33e0731a15326eeb88bff7b7d848bee884 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 @@ -121,7 +121,6 @@ Status DsoftbusInputPlugin::Reset() std::lock_guard lock(paramsMapMutex_); paramsMap_.clear(); if (bufferPopTask_) { - isrunning_.store(false); bufferPopTask_->Stop(); bufferPopTask_.reset(); } @@ -140,7 +139,6 @@ Status DsoftbusInputPlugin::Start() return Status::ERROR_WRONG_STATE; } DataQueueClear(dataQueue_); - isrunning_.store(true); bufferPopTask_->Start(); SetCurrentState(State::RUNNING); return Status::OK; @@ -154,7 +152,6 @@ Status DsoftbusInputPlugin::Stop() return Status::ERROR_WRONG_STATE; } SetCurrentState(State::PREPARED); - isrunning_.store(false); bufferPopTask_->Stop(); DataQueueClear(dataQueue_); return Status::OK; @@ -312,16 +309,15 @@ void DsoftbusInputPlugin::DataEnqueue(std::shared_ptr &buffer) void DsoftbusInputPlugin::HandleData() { - AVTRANS_LOGI("HandleData enter."); - while (isrunning_) { - if (GetCurrentState() != State::RUNNING) { - continue; - } + while (GetCurrentState() == State::RUNNING) { std::shared_ptr buffer; { std::unique_lock lock(dataQueueMtx_); dataCond_.wait_for(lock, std::chrono::milliseconds(PLUGIN_TASK_WAIT_TIME), [this]() { return !dataQueue_.empty(); }); + if (GetCurrentState() != State::RUNNING) { + return; + } if (dataQueue_.empty()) { continue; } @@ -334,7 +330,6 @@ void DsoftbusInputPlugin::HandleData() } dataCb_(buffer); } - AVTRANS_LOGI("HandleData end."); } void DsoftbusInputPlugin::DataQueueClear(std::queue> &queue) diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.h index ddf2f2d47b2991c2f0f23ffe875a0ae5f62393ac..ff5c8605092bb0c628617011eec89f4fee1e58d6 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.h @@ -109,7 +109,6 @@ private: std::atomic state_ = State::CREATED; Callback* eventsCb_ = nullptr; AVDataCallback dataCb_; - std::atomic isrunning_ = false; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp index a62e621a93689670c2059f5dbb73e48571830c18..27e20845fdb4559d57f4a49ac2e70fae359fc7eb 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp @@ -94,7 +94,7 @@ Status DsoftbusInputAudioPlugin::Prepare() } if (!bufferPopTask_) { - bufferPopTask_ = std::make_shared("audioBufferQueuePopThread"); + bufferPopTask_ = std::make_shared("videoBufferQueuePopThread"); bufferPopTask_->RegisterHandler([this] { HandleData(); }); } SetCurrentState(State::PREPARED); @@ -111,7 +111,6 @@ Status DsoftbusInputAudioPlugin::Reset() paramsMap_.clear(); } if (bufferPopTask_) { - isrunning_.store(false); bufferPopTask_->Stop(); bufferPopTask_.reset(); } @@ -130,7 +129,6 @@ Status DsoftbusInputAudioPlugin::Start() return Status::ERROR_WRONG_STATE; } DataQueueClear(dataQueue_); - isrunning_.store(true); bufferPopTask_->Start(); SetCurrentState(State::RUNNING); return Status::OK; @@ -144,7 +142,6 @@ Status DsoftbusInputAudioPlugin::Stop() return Status::ERROR_WRONG_STATE; } SetCurrentState(State::PREPARED); - isrunning_.store(false); DataQueueClear(dataQueue_); bufferPopTask_->Stop(); return Status::OK; @@ -277,16 +274,15 @@ void DsoftbusInputAudioPlugin::DataEnqueue(std::shared_ptr &buffer) void DsoftbusInputAudioPlugin::HandleData() { - AVTRANS_LOGI("HandleData enter."); - while (isrunning_) { - if (GetCurrentState() != State::RUNNING) { - continue; - } + while (GetCurrentState() == State::RUNNING) { std::shared_ptr buffer; { std::unique_lock lock(dataQueueMtx_); dataCond_.wait_for(lock, std::chrono::milliseconds(PLUGIN_TASK_WAIT_TIME), [this]() { return !dataQueue_.empty(); }); + if (GetCurrentState() != State::RUNNING) { + return; + } if (dataQueue_.empty()) { continue; } @@ -299,7 +295,6 @@ void DsoftbusInputAudioPlugin::HandleData() } dataCb_(buffer); } - AVTRANS_LOGI("HandleData end."); } void DsoftbusInputAudioPlugin::DataQueueClear(std::queue> &queue) diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.h index efe29f8c4838423a7e46bf0d796dc7b442696aff..9ea9d88cb22598df8e324a98a041a49bd53c4dd5 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.h @@ -100,7 +100,6 @@ private: std::queue> dataQueue_; std::map paramsMap_; std::atomic state_ = State::CREATED; - std::atomic isrunning_ = false; Callback* eventsCb_ = nullptr; AVDataCallback dataCb_; }; diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp index 643beae867cb6bfde2c4d486f35e80ad8f4f83b3..7ce74b21190184d3d7dc3d548b318c70dd133c9f 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp @@ -134,7 +134,6 @@ Status DaudioOutputPlugin::Reset() AVTRANS_LOGI("Reset enter"); eventcallback_ = nullptr; if (sendPlayTask_) { - isrunning_.store(false); sendPlayTask_->Stop(); sendPlayTask_.reset(); } @@ -186,7 +185,6 @@ Status DaudioOutputPlugin::Start() return Status::ERROR_WRONG_STATE; } DataQueueClear(outputBuffer_); - isrunning_.store(true); sendPlayTask_->Start(); SetCurrentState(State::RUNNING); return Status::OK; @@ -200,7 +198,6 @@ Status DaudioOutputPlugin::Stop() return Status::ERROR_WRONG_STATE; } SetCurrentState(State::PREPARED); - isrunning_.store(false); sendPlayTask_->Stop(); DataQueueClear(outputBuffer_); return Status::OK; @@ -257,16 +254,15 @@ Status DaudioOutputPlugin::PushData(const std::string &inPort, std::shared_ptr

buffer; { std::unique_lock lock(dataQueueMtx_); dataCond_.wait_for(lock, std::chrono::milliseconds(PLUGIN_TASK_WAIT_TIME), [this]() { return !outputBuffer_.empty(); }); + if (GetCurrentState() != State::RUNNING) { + return; + } if (outputBuffer_.empty()) { continue; } @@ -280,7 +276,6 @@ void DaudioOutputPlugin::HandleData() datacallback_(buffer); WriteMasterClockToMemory(buffer); } - AVTRANS_LOGI("HandleData end."); } void DaudioOutputPlugin::WriteMasterClockToMemory(const std::shared_ptr &buffer) diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.h index 4480c7b45a3e84e1fa2c058834ec09162dbdecc0..cb71fded85006abc1175fe7e6f60728d01ae4a52 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.h @@ -98,7 +98,6 @@ private: std::shared_ptr resample_ {nullptr}; uint32_t smIndex_ = 0; std::mutex sharedMemMtx_; - std::atomic isrunning_ = false; AVTransSharedMemory sharedMemory_ = AVTransSharedMemory{ 0, 0, "" }; }; } // namespace DistributedHardware diff --git a/common/log/include/distributed_hardware_log.h b/common/log/include/distributed_hardware_log.h index 51c06a5614e8c65c52eab776de7f67c0b8627820..486b47de0bc911f00dd1f87fe935c10c689d71ce 100644 --- a/common/log/include/distributed_hardware_log.h +++ b/common/log/include/distributed_hardware_log.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 @@ -16,23 +16,25 @@ #ifndef OHOS_DISTRIBUTED_HARDWARE_LOG_H #define OHOS_DISTRIBUTED_HARDWARE_LOG_H -#include - -#include "dh_log.h" +#include "hilog/log.h" +#include namespace OHOS { namespace DistributedHardware { -#define DHLOGD(fmt, ...) DHLog(DH_LOG_DEBUG, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#undef LOG_TAG +#define LOG_TAG "DHFWK" + +#define DHLOGD(fmt, ...) HILOG_DEBUG(LOG_CORE, \ + "[%{public}s][%{public}s]:" fmt, DH_LOG_TAG, __FUNCTION__, ##__VA_ARGS__) -#define DHLOGI(fmt, ...) DHLog(DH_LOG_INFO, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#define DHLOGI(fmt, ...) HILOG_INFO(LOG_CORE, \ + "[%{public}s][%{public}s]:" fmt, DH_LOG_TAG, __FUNCTION__, ##__VA_ARGS__) -#define DHLOGW(fmt, ...) DHLog(DH_LOG_WARN, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#define DHLOGW(fmt, ...) HILOG_WARN(LOG_CORE, \ + "[%{public}s][%{public}s]:" fmt, DH_LOG_TAG, __FUNCTION__, ##__VA_ARGS__) -#define DHLOGE(fmt, ...) DHLog(DH_LOG_ERROR, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#define DHLOGE(fmt, ...) HILOG_ERROR(LOG_CORE, \ + "[%{public}s][%{public}s]:" fmt, DH_LOG_TAG, __FUNCTION__, ##__VA_ARGS__) } // namespace DistributedHardware } // namespace OHOS #endif diff --git a/interfaces/inner_kits/BUILD.gn b/interfaces/inner_kits/BUILD.gn index ab02f8000545ad8a9102ef027ad896518da06bb5..b62cadb10895f566eeb59b25558e5e9932701d7e 100644 --- a/interfaces/inner_kits/BUILD.gn +++ b/interfaces/inner_kits/BUILD.gn @@ -67,6 +67,7 @@ ohos_shared_library("libdhfwk_sdk") { external_deps = [ "c_utils:utils", + "hilog:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", @@ -74,7 +75,7 @@ ohos_shared_library("libdhfwk_sdk") { cflags_cc = [ "-DHILOG_ENABLE" ] - innerapi_tags = [ "platformsdk" ] subsystem_name = "distributedhardware" + part_name = "distributed_hardware_fwk" } diff --git a/interfaces/inner_kits/src/distributed_hardware_fwk_kit.cpp b/interfaces/inner_kits/src/distributed_hardware_fwk_kit.cpp index 294dabdfa64cd1a3d8f1aa410859e32a426a760c..46dc94f3aea1939076a8c33dfed2e52ba4ba681b 100644 --- a/interfaces/inner_kits/src/distributed_hardware_fwk_kit.cpp +++ b/interfaces/inner_kits/src/distributed_hardware_fwk_kit.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 @@ -41,17 +41,17 @@ DistributedHardwareFwkKit::~DistributedHardwareFwkKit() int32_t DistributedHardwareFwkKit::RegisterPublisherListener(const DHTopic topic, sptr listener) { - DHLOGI("Register publisher listener, topic: %" PRIu32 ", is DHFWK online: %s", + DHLOGI("Register publisher listener, topic: %{public}" PRIu32 ", is DHFWK online: %{public}s", (uint32_t)topic, isDHFWKOnLine_ ? "true" : "false"); if (!IsDHTopicValid(topic)) { - DHLOGE("Topic invalid, topic: %" PRIu32, (uint32_t)topic); + DHLOGE("Topic invalid, topic: %{public}" PRIu32, (uint32_t)topic); return ERR_DH_FWK_PARA_INVALID; } int32_t ret = DH_FWK_SUCCESS; if (DHFWKSAManager::GetInstance().GetDHFWKProxy() != nullptr) { ret = DHFWKSAManager::GetInstance().GetDHFWKProxy()->RegisterPublisherListener(topic, listener); - DHLOGI("Register publisher listener to DHFWK, ret: %" PRId32, ret); + DHLOGI("Register publisher listener to DHFWK, ret: %{public}" PRId32, ret); if (ret == DH_FWK_SUCCESS) { return DHFWKSAManager::GetInstance().AddPublisherListenerToCache(topic, listener); } @@ -65,17 +65,17 @@ int32_t DistributedHardwareFwkKit::RegisterPublisherListener(const DHTopic topic int32_t DistributedHardwareFwkKit::UnregisterPublisherListener(const DHTopic topic, sptr listener) { - DHLOGI("Unregister publisher listener, topic: %" PRIu32 ", is DHFWK online: %s", + DHLOGI("Unregister publisher listener, topic: %{public}" PRIu32 ", is DHFWK online: %{public}s", (uint32_t)topic, isDHFWKOnLine_ ? "true" : "false"); if (!IsDHTopicValid(topic)) { - DHLOGE("Topic invalid, topic: %" PRIu32, (uint32_t)topic); + DHLOGE("Topic invalid, topic: %{public}" PRIu32, (uint32_t)topic); return ERR_DH_FWK_PARA_INVALID; } int32_t ret = DH_FWK_SUCCESS; if (DHFWKSAManager::GetInstance().GetDHFWKProxy() != nullptr) { ret = DHFWKSAManager::GetInstance().GetDHFWKProxy()->UnregisterPublisherListener(topic, listener); - DHLOGI("Unregister publisher listener to DHFWK, ret: %" PRId32, ret); + DHLOGI("Unregister publisher listener to DHFWK, ret: %{public}" PRId32, ret); } DHFWKSAManager::GetInstance().RemovePublisherListenerFromCache(topic, listener); @@ -84,9 +84,9 @@ int32_t DistributedHardwareFwkKit::UnregisterPublisherListener(const DHTopic top int32_t DistributedHardwareFwkKit::PublishMessage(const DHTopic topic, const std::string &message) { - DHLOGI("Publish message, topic: %" PRIu32, (uint32_t)topic); + DHLOGI("Publish message, topic: %{public}" PRIu32, (uint32_t)topic); if (!IsDHTopicValid(topic)) { - DHLOGE("Topic invalid, topic: %" PRIu32, (uint32_t)topic); + DHLOGE("Topic invalid, topic: %{public}" PRIu32, (uint32_t)topic); return ERR_DH_FWK_PARA_INVALID; } if (message.empty() || message.size() > MAX_MESSAGE_LEN) { @@ -100,7 +100,7 @@ int32_t DistributedHardwareFwkKit::PublishMessage(const DHTopic topic, const std } int32_t ret = DHFWKSAManager::GetInstance().GetDHFWKProxy()->PublishMessage(topic, message); - DHLOGI("Publish message to DHFWK, ret: %" PRId32, ret); + DHLOGI("Publish message to DHFWK, ret: %{public}" PRId32, ret); return ret; } @@ -112,7 +112,7 @@ bool DistributedHardwareFwkKit::IsDHTopicValid(DHTopic topic) void DistributedHardwareFwkKit::OnDHFWKOnLine(bool isOnLine) { - DHLOGI("Receive DHFWK online callback, %s", (isOnLine ? "true" : "false")); + DHLOGI("Receive DHFWK online callback, %{public}s", (isOnLine ? "true" : "false")); isDHFWKOnLine_ = isOnLine; } @@ -123,9 +123,9 @@ bool DistributedHardwareFwkKit::IsQueryLocalSysSpecTypeValid(QueryLocalSysSpecTy std::string DistributedHardwareFwkKit::QueryLocalSysSpec(enum QueryLocalSysSpecType spec) { - DHLOGI("Query Local Sys Spec, %d", (uint32_t)spec); + DHLOGI("Query Local Sys Spec, %{public}d", (uint32_t)spec); if (!IsQueryLocalSysSpecTypeValid(spec)) { - DHLOGE("Topic invalid, topic: %" PRIu32, (uint32_t)spec); + DHLOGE("Topic invalid, topic: %{public}" PRIu32, (uint32_t)spec); return ""; } @@ -139,7 +139,7 @@ std::string DistributedHardwareFwkKit::QueryLocalSysSpec(enum QueryLocalSysSpecT int32_t DistributedHardwareFwkKit::InitializeAVCenter(const TransRole &transRole, int32_t &engineId) { - DHLOGI("Initialize av control center, transRole: %" PRIu32, (uint32_t)transRole); + DHLOGI("Initialize av control center, transRole: %{public}" PRIu32, (uint32_t)transRole); if (DHFWKSAManager::GetInstance().GetDHFWKProxy() == nullptr) { DHLOGI("DHFWK not online or get proxy failed, can not initializeA av control center"); @@ -151,7 +151,7 @@ int32_t DistributedHardwareFwkKit::InitializeAVCenter(const TransRole &transRole int32_t DistributedHardwareFwkKit::ReleaseAVCenter(int32_t engineId) { - DHLOGI("Release av control center, engineId: %" PRId32, engineId); + DHLOGI("Release av control center, engineId: %{public}" PRId32, engineId); if (DHFWKSAManager::GetInstance().GetDHFWKProxy() == nullptr) { DHLOGI("DHFWK not online or get proxy failed, can not release av control center"); @@ -164,7 +164,7 @@ int32_t DistributedHardwareFwkKit::ReleaseAVCenter(int32_t engineId) int32_t DistributedHardwareFwkKit::CreateControlChannel(int32_t engineId, const std::string &peerDevId) { - DHLOGI("Create av control center channel, engineId: %" PRId32 ", peerDevId=%s.", engineId, + DHLOGI("Create av control center channel, engineId: %{public}" PRId32 ", peerDevId=%{public}s.", engineId, GetAnonyString(peerDevId).c_str()); if (DHFWKSAManager::GetInstance().GetDHFWKProxy() == nullptr) { @@ -177,7 +177,8 @@ int32_t DistributedHardwareFwkKit::CreateControlChannel(int32_t engineId, const int32_t DistributedHardwareFwkKit::NotifyAVCenter(int32_t engineId, const AVTransEvent &event) { - DHLOGI("Notify av control center, engineId: %" PRId32 ", event type=%" PRId32, engineId, event.type); + DHLOGI("Notify av control center, engineId: %{public}" PRId32 ", event type=%{public}" PRId32, engineId, + event.type); if (DHFWKSAManager::GetInstance().GetDHFWKProxy() == nullptr) { DHLOGI("DHFWK not online or get proxy failed, can not notity av control center event."); @@ -190,7 +191,7 @@ int32_t DistributedHardwareFwkKit::NotifyAVCenter(int32_t engineId, const AVTran int32_t DistributedHardwareFwkKit::RegisterCtlCenterCallback(int32_t engineId, const sptr &callback) { - DHLOGI("Register av control center callback. engineId: %" PRId32, engineId); + DHLOGI("Register av control center callback. engineId: %{public}" PRId32, engineId); if (DHFWKSAManager::GetInstance().GetDHFWKProxy() == nullptr) { DHLOGI("DHFWK not online or get proxy failed, can not register av control center callback."); @@ -202,7 +203,8 @@ int32_t DistributedHardwareFwkKit::RegisterCtlCenterCallback(int32_t engineId, int32_t DistributedHardwareFwkKit::PauseDistributedHardware(DHType dhType, const std::string &networkId) { - DHLOGI("Pause distributed hardware dhType %u, networkId %s", (uint32_t)dhType, GetAnonyString(networkId).c_str()); + DHLOGI("Pause distributed hardware dhType %{public}u, networkId %{public}s", (uint32_t)dhType, + GetAnonyString(networkId).c_str()); if (DHFWKSAManager::GetInstance().GetDHFWKProxy() == nullptr) { DHLOGI("DHFWK not online or get proxy failed, can not register av control center callback."); @@ -214,7 +216,8 @@ int32_t DistributedHardwareFwkKit::PauseDistributedHardware(DHType dhType, const int32_t DistributedHardwareFwkKit::ResumeDistributedHardware(DHType dhType, const std::string &networkId) { - DHLOGI("Resume distributed hardware dhType %u, networkId %s", (uint32_t)dhType, GetAnonyString(networkId).c_str()); + DHLOGI("Resume distributed hardware dhType %{public}u, networkId %{public}s", (uint32_t)dhType, + GetAnonyString(networkId).c_str()); if (DHFWKSAManager::GetInstance().GetDHFWKProxy() == nullptr) { DHLOGI("DHFWK not online or get proxy failed, can not register av control center callback."); @@ -226,7 +229,8 @@ int32_t DistributedHardwareFwkKit::ResumeDistributedHardware(DHType dhType, cons int32_t DistributedHardwareFwkKit::StopDistributedHardware(DHType dhType, const std::string &networkId) { - DHLOGI("Stop distributed hardware dhType %u, networkId %s", (uint32_t)dhType, GetAnonyString(networkId).c_str()); + DHLOGI("Stop distributed hardware dhType %{public}u, networkId %{public}s", (uint32_t)dhType, + GetAnonyString(networkId).c_str()); if (DHFWKSAManager::GetInstance().GetDHFWKProxy() == nullptr) { DHLOGI("DHFWK not online or get proxy failed, can not register av control center callback."); diff --git a/interfaces/inner_kits/src/ipc/dhfwk_sa_manager.cpp b/interfaces/inner_kits/src/ipc/dhfwk_sa_manager.cpp index ec82da2ad6247f2a3922d081167b0684d78e5272..ae595b0af0476b21cc7374b759c8f82ad5c9be85 100644 --- a/interfaces/inner_kits/src/ipc/dhfwk_sa_manager.cpp +++ b/interfaces/inner_kits/src/ipc/dhfwk_sa_manager.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 @@ -54,10 +54,10 @@ void DHFWKSAManager::RegisterAbilityListener() } if (!isSubscribeDHFWKSAChangeListener) { - DHLOGI("try subscribe sa change listener, sa id: %d", DISTRIBUTED_HARDWARE_SA_ID); + DHLOGI("try subscribe sa change listener, sa id: %{public}d", DISTRIBUTED_HARDWARE_SA_ID); int32_t ret = saMgr->SubscribeSystemAbility(DISTRIBUTED_HARDWARE_SA_ID, saListener_); if (ret != 0) { - DHLOGE("subscribe DHFWK sa change listener failed, ret: %d", ret); + DHLOGE("subscribe DHFWK sa change listener failed, ret: %{public}d", ret); return; } isSubscribeDHFWKSAChangeListener = true; @@ -104,7 +104,7 @@ void DHFWKSAManager::SystemAbilityListener::OnAddSystemAbility(int32_t systemAbi { (void)deviceId; if (systemAbilityId != DISTRIBUTED_HARDWARE_SA_ID) { - DHLOGW("Receive SA Start, but sa id is not DHFWK, id: %" PRId32, systemAbilityId); + DHLOGW("Receive SA Start, but sa id is not DHFWK, id: %{public}" PRId32, systemAbilityId); return; } @@ -118,14 +118,14 @@ void DHFWKSAManager::SystemAbilityListener::OnAddSystemAbility(int32_t systemAbi if (DHFWKSAManager::GetInstance().RestoreListener() != DH_FWK_SUCCESS) { DHLOGE("Partial listeners failed to restore"); } - DHLOGI("sa %" PRId32 " started", systemAbilityId); + DHLOGI("sa %{public}" PRId32 " started", systemAbilityId); } void DHFWKSAManager::SystemAbilityListener::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) { (void)deviceId; if (systemAbilityId != DISTRIBUTED_HARDWARE_SA_ID) { - DHLOGW("Receive SA Stop, but sa id is not DHFWK, id: %" PRId32, systemAbilityId); + DHLOGW("Receive SA Stop, but sa id is not DHFWK, id: %{public}" PRId32, systemAbilityId); return; } @@ -140,7 +140,7 @@ void DHFWKSAManager::SystemAbilityListener::OnRemoveSystemAbility(int32_t system DHFWKSAManager::GetInstance().saStateCallback(false); } } - DHLOGI("sa %" PRId32 " stopped", systemAbilityId); + DHLOGI("sa %{public}" PRId32 " stopped", systemAbilityId); } int32_t DHFWKSAManager::RestoreListener() @@ -158,7 +158,7 @@ int32_t DHFWKSAManager::RestoreListener() DHFWKSAManager::GetInstance().GetDHFWKProxy()->RegisterPublisherListener(entry.first, listener); if (ret != DH_FWK_SUCCESS) { ret = innerRet; - DHLOGE("Register publisher listener failed, topic: %" PRIu32, (uint32_t)entry.first); + DHLOGE("Register publisher listener failed, topic: %{public}" PRIu32, (uint32_t)entry.first); } } } @@ -170,7 +170,7 @@ int32_t DHFWKSAManager::RestoreListener() DHFWKSAManager::GetInstance().GetDHFWKProxy()->RegisterCtlCenterCallback(entry.first, entry.second); if (innerRet != DH_FWK_SUCCESS) { ret = innerRet; - DHLOGE("Restore register av control center callback failed, engineId: %" PRId32, entry.first); + DHLOGE("Restore register av control center callback failed, engineId: %{public}" PRId32, entry.first); } } } diff --git a/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp b/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp index d49eee92a1571160d7f2074c9b76d2682e0bfa5f..c8374af4bdb87033ece35a898cd3815679fcfe8f 100644 --- a/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.cpp +++ b/interfaces/inner_kits/src/ipc/distributed_hardware_proxy.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 @@ -73,13 +73,13 @@ int32_t DistributedHardwareProxy::RegisterPublisherListener(const DHTopic topic, int32_t ret = remote->SendRequest(static_cast(DHMsgInterfaceCode::REG_PUBLISHER_LISTNER), data, reply, option); if (ret != NO_ERROR) { - DHLOGE("Send Request failed, ret: %d", ret); + DHLOGE("Send Request failed, ret: %{public}d", ret); return ERR_DH_FWK_SERVICE_IPC_SEND_REQUEST_FAIL; } ret = reply.ReadInt32(); if (ret != DH_FWK_SUCCESS) { - DHLOGE("Register Publisher Listener failed, ret: %d", ret); + DHLOGE("Register Publisher Listener failed, ret: %{public}d", ret); } return ret; @@ -122,13 +122,13 @@ int32_t DistributedHardwareProxy::UnregisterPublisherListener(const DHTopic topi int32_t ret = remote->SendRequest(static_cast(DHMsgInterfaceCode::UNREG_PUBLISHER_LISTENER), data, reply, option); if (ret != NO_ERROR) { - DHLOGE("Send Request failed, ret: %d", ret); + DHLOGE("Send Request failed, ret: %{public}d", ret); return ERR_DH_FWK_SERVICE_IPC_SEND_REQUEST_FAIL; } ret = reply.ReadInt32(); if (ret != DH_FWK_SUCCESS) { - DHLOGE("Unregister Publisher Listener failed, ret: %d", ret); + DHLOGE("Unregister Publisher Listener failed, ret: %{public}d", ret); } return ret; @@ -169,13 +169,13 @@ int32_t DistributedHardwareProxy::PublishMessage(const DHTopic topic, const std: int32_t ret = remote->SendRequest(static_cast(DHMsgInterfaceCode::PUBLISH_MESSAGE), data, reply, option); if (ret != NO_ERROR) { - DHLOGE("Send Request failed, ret: %d", ret); + DHLOGE("Send Request failed, ret: %{public}d", ret); return ERR_DH_FWK_SERVICE_IPC_SEND_REQUEST_FAIL; } ret = reply.ReadInt32(); if (ret != DH_FWK_SUCCESS) { - DHLOGE("PublishMessage failed, ret: %d", ret); + DHLOGE("PublishMessage failed, ret: %{public}d", ret); } return ret; @@ -209,12 +209,12 @@ std::string DistributedHardwareProxy::QueryLocalSysSpec(QueryLocalSysSpecType sp int32_t ret = remote->SendRequest(static_cast(DHMsgInterfaceCode::QUERY_LOCAL_SYS_SPEC), data, reply, option); if (ret != NO_ERROR) { - DHLOGE("Send Request failed, ret: %d", ret); + DHLOGE("Send Request failed, ret: %{public}d", ret); return ""; } std::string specStr = reply.ReadString(); - DHLOGI("Query local sys spec %" PRIu32 ", get: %s", (uint32_t)spec, specStr.c_str()); + DHLOGI("Query local sys spec %{public}" PRIu32 ", get: %{public}s", (uint32_t)spec, specStr.c_str()); return specStr; } @@ -240,7 +240,7 @@ int32_t DistributedHardwareProxy::InitializeAVCenter(const TransRole &transRole, } int32_t ret = remote->SendRequest(static_cast(DHMsgInterfaceCode::INIT_CTL_CEN), data, reply, option); if (ret != NO_ERROR) { - DHLOGE("Send Request failed, ret: %d", ret); + DHLOGE("Send Request failed, ret: %{public}d", ret); return ERR_DH_AVT_SERVICE_IPC_SEND_REQUEST_FAIL; } engineId = reply.ReadInt32(); @@ -270,7 +270,7 @@ int32_t DistributedHardwareProxy::ReleaseAVCenter(int32_t engineId) } int32_t ret = remote->SendRequest(static_cast(DHMsgInterfaceCode::RELEASE_CTL_CEN), data, reply, option); if (ret != NO_ERROR) { - DHLOGE("Send Request failed, ret: %d", ret); + DHLOGE("Send Request failed, ret: %{public}d", ret); return ERR_DH_AVT_SERVICE_IPC_SEND_REQUEST_FAIL; } @@ -304,7 +304,7 @@ int32_t DistributedHardwareProxy::CreateControlChannel(int32_t engineId, const s int32_t ret = remote->SendRequest(static_cast(DHMsgInterfaceCode::CREATE_CTL_CEN_CHANNEL), data, reply, option); if (ret != NO_ERROR) { - DHLOGE("Send Request failed, ret: %d", ret); + DHLOGE("Send Request failed, ret: %{public}d", ret); return ERR_DH_AVT_SERVICE_IPC_SEND_REQUEST_FAIL; } @@ -345,7 +345,7 @@ int32_t DistributedHardwareProxy::NotifyAVCenter(int32_t engineId, const AVTrans } int32_t ret = remote->SendRequest(static_cast(DHMsgInterfaceCode::NOTIFY_AV_EVENT), data, reply, option); if (ret != NO_ERROR) { - DHLOGE("Send Request failed, ret: %d", ret); + DHLOGE("Send Request failed, ret: %{public}d", ret); return ERR_DH_AVT_SERVICE_IPC_SEND_REQUEST_FAIL; } @@ -379,7 +379,7 @@ int32_t DistributedHardwareProxy::RegisterCtlCenterCallback(int32_t engineId, int32_t ret = remote->SendRequest(static_cast(DHMsgInterfaceCode::REGISTER_CTL_CEN_CALLBACK), data, reply, option); if (ret != NO_ERROR) { - DHLOGE("Send Request failed, ret: %d", ret); + DHLOGE("Send Request failed, ret: %{public}d", ret); return ERR_DH_AVT_SERVICE_IPC_SEND_REQUEST_FAIL; } @@ -408,7 +408,7 @@ int32_t DistributedHardwareProxy::NotifySourceRemoteSinkStarted(std::string &dev int32_t ret = remote->SendRequest( static_cast(DHMsgInterfaceCode::NOTIFY_SOURCE_DEVICE_REMOTE_DMSDP_STARTED), data, reply, option); if (ret != NO_ERROR) { - DHLOGE("Send Request failed, ret: %d", ret); + DHLOGE("Send Request failed, ret: %{public}d", ret); return ERR_DH_AVT_SERVICE_IPC_SEND_REQUEST_FAIL; } DHLOGI("DistributedHardwareProxy NotifySourceRemoteSinkStarted End"); @@ -443,7 +443,7 @@ int32_t DistributedHardwareProxy::PauseDistributedHardware(DHType dhType, const int32_t ret = remote->SendRequest(static_cast(DHMsgInterfaceCode::PAUSE_DISTRIBUTED_HARDWARE), data, reply, option); if (ret != NO_ERROR) { - DHLOGE("Send Request failed, ret: %d", ret); + DHLOGE("Send Request failed, ret: %{public}d", ret); return ERR_DH_AVT_SERVICE_IPC_SEND_REQUEST_FAIL; } @@ -478,7 +478,7 @@ int32_t DistributedHardwareProxy::ResumeDistributedHardware(DHType dhType, const int32_t ret = remote->SendRequest(static_cast(DHMsgInterfaceCode::RESUME_DISTRIBUTED_HARDWARE), data, reply, option); if (ret != NO_ERROR) { - DHLOGE("Send Request failed, ret: %d", ret); + DHLOGE("Send Request failed, ret: %{public}d", ret); return ERR_DH_AVT_SERVICE_IPC_SEND_REQUEST_FAIL; } @@ -513,7 +513,7 @@ int32_t DistributedHardwareProxy::StopDistributedHardware(DHType dhType, const s int32_t ret = remote->SendRequest(static_cast(DHMsgInterfaceCode::STOP_DISTRIBUTED_HARDWARE), data, reply, option); if (ret != NO_ERROR) { - DHLOGE("Send Request failed, ret: %d", ret); + DHLOGE("Send Request failed, ret: %{public}d", ret); return ERR_DH_AVT_SERVICE_IPC_SEND_REQUEST_FAIL; } diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index 8231809ce6929a45badaef60745ee06ad422ae62..6fb289f26997e5209361f0eb45cec8a771a1570a 100644 --- a/interfaces/kits/napi/BUILD.gn +++ b/interfaces/kits/napi/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -49,6 +49,7 @@ ohos_shared_library("hardwaremanager") { external_deps = [ "access_token:libtokenid_sdk", "bundle_framework:appexecfwk_base", + "hilog:libhilog", "ipc:ipc_core", "napi:ace_napi", ] diff --git a/interfaces/kits/napi/src/native_distributedhardwarefwk_js.cpp b/interfaces/kits/napi/src/native_distributedhardwarefwk_js.cpp index ac4ecbb588ec4a698c7e3d462a91bb2d9d503533..1882ee7fa016d6a8078c40858d9e8b116258563e 100644 --- a/interfaces/kits/napi/src/native_distributedhardwarefwk_js.cpp +++ b/interfaces/kits/napi/src/native_distributedhardwarefwk_js.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 @@ -90,7 +90,7 @@ void DistributedHardwareManager::JsObjectToString(const napi_env &env, const nap size_t result = 0; NAPI_CALL_RETURN_VOID(env, napi_get_value_string_utf8(env, field, dest, destLen, &result)); } else { - DHLOGE("devicemanager napi js to str no property: %s", fieldStr.c_str()); + DHLOGE("devicemanager napi js to str no property: %{public}s", fieldStr.c_str()); } } @@ -110,7 +110,7 @@ void DistributedHardwareManager::JsObjectToInt(const napi_env &env, const napi_v } napi_get_value_int32(env, field, &fieldRef); } else { - DHLOGE("devicemanager napi js to int no property: %s", fieldStr.c_str()); + DHLOGE("devicemanager napi js to int no property: %{public}s", fieldStr.c_str()); } } @@ -156,7 +156,7 @@ napi_value DistributedHardwareManager::PauseDistributedHardware(napi_env env, na napi_create_promise(env, &deferred, &promise); int32_t ret = dhFwkKit->PauseDistributedHardware(dhType, std::string(networkId)); if (ret != 0) { - DHLOGE("PauseDistributedHardware for DHType: %u filed", (uint32_t)dhType); + DHLOGE("PauseDistributedHardware for DHType: %{public}u filed", (uint32_t)dhType); } return promise; } else if (argc == DH_NAPI_ARGS_TWO) { // callback @@ -165,7 +165,7 @@ napi_value DistributedHardwareManager::PauseDistributedHardware(napi_env env, na } int32_t ret = dhFwkKit->PauseDistributedHardware(dhType, std::string(networkId)); if (ret != 0) { - DHLOGE("PauseDistributedHardware for DHType: %u filed", (uint32_t)dhType); + DHLOGE("PauseDistributedHardware for DHType: %{public}u filed", (uint32_t)dhType); } } napi_get_undefined(env, &result); @@ -208,7 +208,7 @@ napi_value DistributedHardwareManager::ResumeDistributedHardware(napi_env env, n napi_create_promise(env, &deferred, &promise); int32_t ret = dhFwkKit->ResumeDistributedHardware(dhType, std::string(networkId)); if (ret != 0) { - DHLOGE("ResumeDistributedHardware for DHType: %u filed", (uint32_t)dhType); + DHLOGE("ResumeDistributedHardware for DHType: %{public}u filed", (uint32_t)dhType); } return promise; } else if (argc == DH_NAPI_ARGS_TWO) { // callback @@ -217,7 +217,7 @@ napi_value DistributedHardwareManager::ResumeDistributedHardware(napi_env env, n } int32_t ret = dhFwkKit->ResumeDistributedHardware(dhType, std::string(networkId)); if (ret != 0) { - DHLOGE("ResumeDistributedHardware for DHType: %u filed", (uint32_t)dhType); + DHLOGE("ResumeDistributedHardware for DHType: %{public}u filed", (uint32_t)dhType); } } napi_get_undefined(env, &result); @@ -260,7 +260,7 @@ napi_value DistributedHardwareManager::StopDistributedHardware(napi_env env, nap napi_create_promise(env, &deferred, &promise); int32_t ret = dhFwkKit->StopDistributedHardware(dhType, std::string(networkId)); if (ret != 0) { - DHLOGE("StopDistributedHardware for DHType: %u filed", (uint32_t)dhType); + DHLOGE("StopDistributedHardware for DHType: %{public}u filed", (uint32_t)dhType); } return promise; } else if (argc == DH_NAPI_ARGS_TWO) { // callback @@ -269,7 +269,7 @@ napi_value DistributedHardwareManager::StopDistributedHardware(napi_env env, nap } int32_t ret = dhFwkKit->StopDistributedHardware(dhType, std::string(networkId)); if (ret != 0) { - DHLOGE("StopDistributedHardware for DHType: %u filed", (uint32_t)dhType); + DHLOGE("StopDistributedHardware for DHType: %{public}u filed", (uint32_t)dhType); } } napi_get_undefined(env, &result); diff --git a/services/distributedhardwarefwkservice/src/accessmanager/access_manager.cpp b/services/distributedhardwarefwkservice/src/accessmanager/access_manager.cpp index d4a3b724e831a27fa859e23a6b11b67a0f9cd149..248aa050e12e7488f6650a8fda4a5fd69be53c3b 100644 --- a/services/distributedhardwarefwkservice/src/accessmanager/access_manager.cpp +++ b/services/distributedhardwarefwkservice/src/accessmanager/access_manager.cpp @@ -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 @@ -109,10 +109,10 @@ void AccessManager::OnRemoteDied() for (int32_t tryCount = 0; tryCount < DH_RETRY_INIT_DM_COUNT; ++tryCount) { usleep(DH_RETRY_INIT_DM_INTERVAL_US); if (Init() == DH_FWK_SUCCESS) { - DHLOGI("DeviceManager onDied, try to init success, tryCount = %d", tryCount); + DHLOGI("DeviceManager onDied, try to init success, tryCount = %{public}d", tryCount); return; } - DHLOGW("DeviceManager onDied, try to init failed, tryCount = %d", tryCount); + DHLOGW("DeviceManager onDied, try to init failed, tryCount = %{public}d", tryCount); } DHLOGE("DeviceManager onDied, try to init has reached the maximum, but still failed"); return; @@ -127,8 +127,9 @@ void AccessManager::OnDeviceOnline(const DmDeviceInfo &deviceInfo) void AccessManager::OnDeviceOffline(const DmDeviceInfo &deviceInfo) { std::lock_guard lock(accessMutex_); - DHLOGI("start, networkId = %s, deviceName = %s, deviceTypeId = %d", GetAnonyString(deviceInfo.networkId).c_str(), - GetAnonyString(deviceInfo.deviceName).c_str(), deviceInfo.deviceTypeId); + DHLOGI("start, networkId = %{public}s, deviceName = %{public}s, deviceTypeId = %{public}d", + GetAnonyString(deviceInfo.networkId).c_str(), GetAnonyString(deviceInfo.deviceName).c_str(), + deviceInfo.deviceTypeId); auto networkId = std::string(deviceInfo.networkId); if (networkId.size() == 0 || networkId.size() > MAX_ID_LEN) { @@ -147,15 +148,16 @@ void AccessManager::OnDeviceOffline(const DmDeviceInfo &deviceInfo) auto ret = DistributedHardwareManagerFactory::GetInstance().SendOffLineEvent(networkId, uuid, deviceInfo.deviceTypeId); - DHLOGI("offline result = %d, networkId = %s, uuid = %s", ret, GetAnonyString(networkId).c_str(), - GetAnonyString(uuid).c_str()); + DHLOGI("offline result = %{public}d, networkId = %{public}s, uuid = %{public}s", ret, + GetAnonyString(networkId).c_str(), GetAnonyString(uuid).c_str()); } void AccessManager::OnDeviceReady(const DmDeviceInfo &deviceInfo) { std::lock_guard lock(accessMutex_); - DHLOGI("start, networkId = %s, deviceName = %s, deviceTypeId = %d", GetAnonyString(deviceInfo.networkId).c_str(), - GetAnonyString(deviceInfo.deviceName).c_str(), deviceInfo.deviceTypeId); + DHLOGI("start, networkId = %{public}s, deviceName = %{public}s, deviceTypeId = %{public}d", + GetAnonyString(deviceInfo.networkId).c_str(), GetAnonyString(deviceInfo.deviceName).c_str(), + deviceInfo.deviceTypeId); auto networkId = std::string(deviceInfo.networkId); if (networkId.size() == 0 || networkId.size() > MAX_ID_LEN) { @@ -169,8 +171,8 @@ void AccessManager::OnDeviceReady(const DmDeviceInfo &deviceInfo) } auto ret = DistributedHardwareManagerFactory::GetInstance().SendOnLineEvent(networkId, uuid, deviceInfo.deviceTypeId); - DHLOGI("online result = %d, networkId = %s, uuid = %s", ret, GetAnonyString(networkId).c_str(), - GetAnonyString(uuid).c_str()); + DHLOGI("online result = %{public}d, networkId = %{public}s, uuid = %{public}s", ret, + GetAnonyString(networkId).c_str(), GetAnonyString(uuid).c_str()); } void AccessManager::OnDeviceChanged(const DmDeviceInfo &deviceInfo) @@ -190,8 +192,8 @@ void AccessManager::SendTrustedDeviceOnline() for (const auto &deviceInfo : deviceList) { const auto networkId = std::string(deviceInfo.networkId); const auto uuid = GetUUIDBySoftBus(networkId); - DHLOGI("Send trusted device online, networkId = %s, uuid = %s", GetAnonyString(networkId).c_str(), - GetAnonyString(uuid).c_str()); + DHLOGI("Send trusted device online, networkId = %{public}s, uuid = %{public}s", + GetAnonyString(networkId).c_str(), GetAnonyString(uuid).c_str()); DistributedHardwareManagerFactory::GetInstance().SendOnLineEvent(networkId, uuid, deviceInfo.deviceTypeId); } } diff --git a/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp index 22d0c2a7f09333e942a57fe370f2fdb16402ffbf..904c7c609f38c6c0fac6335a1ad5a162c43e56f3 100644 --- a/services/distributedhardwarefwkservice/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkservice/src/componentloader/component_loader.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 @@ -233,7 +233,7 @@ int32_t ComponentLoader::GetCompPathAndVersion(const std::string &jsonStr, std:: std::vector vecJsnCfg = jsonCfg.at(COMPONENTSLOAD_DISTRIBUTED_COMPONENTS).get>(); - DHLOGI("get distributed_components CompConfig size is %zu", vecJsnCfg.size()); + DHLOGI("get distributed_components CompConfig size is %{public}zu", vecJsnCfg.size()); if (vecJsnCfg.size() == 0 || vecJsnCfg.size() > MAX_COMP_SIZE) { DHLOGE("CompConfig size is invalid!"); return ERR_DH_FWK_PARA_INVALID; @@ -280,7 +280,7 @@ void *ComponentLoader::GetHandler(const std::string &soName) } void *pHandler = dlopen(path, RTLD_LAZY | RTLD_NODELETE); if (pHandler == nullptr) { - DHLOGE("%s handler load failed, failed reason : %s", path, dlerror()); + DHLOGE("%{public}s handler load failed, failed reason : %{public}s", path, dlerror()); HiSysEventWriteMsg(DHFWK_INIT_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, "dhfwk so open failed, soname : " + soName); return nullptr; @@ -311,7 +311,7 @@ void ComponentLoader::GetAllHandler(std::map &dhtypeMap) int32_t ComponentLoader::GetHardwareHandler(const DHType dhType, IHardwareHandler *&hardwareHandlerPtr) { if (compHandlerMap_.find(dhType) == compHandlerMap_.end()) { - DHLOGE("DHType not exist, dhType: %" PRIu32, (uint32_t)dhType); + DHLOGE("DHType not exist, dhType: %{public}" PRIu32, (uint32_t)dhType); return ERR_DH_FWK_LOADER_HANDLER_IS_NULL; } @@ -323,7 +323,7 @@ int32_t ComponentLoader::GetHardwareHandler(const DHType dhType, IHardwareHandle GetHardwareClass getHardwareClassHandler = (GetHardwareClass)dlsym(compHandlerMap_[dhType].hardwareHandler, COMPONENT_LOADER_GET_HARDWARE_HANDLER.c_str()); if (getHardwareClassHandler == nullptr) { - DHLOGE("get getHardwareClassHandler is null, failed reason : %s", dlerror()); + DHLOGE("get getHardwareClassHandler is null, failed reason : %{public}s", dlerror()); dlclose(compHandlerMap_[dhType].hardwareHandler); compHandlerMap_[dhType].hardwareHandler = nullptr; return ERR_DH_FWK_LOADER_HANDLER_IS_NULL; @@ -335,7 +335,7 @@ int32_t ComponentLoader::GetHardwareHandler(const DHType dhType, IHardwareHandle int32_t ComponentLoader::GetSource(const DHType dhType, IDistributedHardwareSource *&sourcePtr) { if (compHandlerMap_.find(dhType) == compHandlerMap_.end()) { - DHLOGE("DHType not exist, dhType: %" PRIu32, (uint32_t)dhType); + DHLOGE("DHType not exist, dhType: %{public}" PRIu32, (uint32_t)dhType); return ERR_DH_FWK_LOADER_HANDLER_IS_NULL; } @@ -347,7 +347,7 @@ int32_t ComponentLoader::GetSource(const DHType dhType, IDistributedHardwareSour GetSourceHardwareClass getSourceHardClassHandler = (GetSourceHardwareClass)dlsym( compHandlerMap_[dhType].sourceHandler, COMPONENT_LOADER_GET_SOURCE_HANDLER.c_str()); if (getSourceHardClassHandler == nullptr) { - DHLOGE("get getSourceHardClassHandler is null, failed reason : %s", dlerror()); + DHLOGE("get getSourceHardClassHandler is null, failed reason : %{public}s", dlerror()); dlclose(compHandlerMap_[dhType].sourceHandler); compHandlerMap_[dhType].sourceHandler = nullptr; return ERR_DH_FWK_LOADER_HANDLER_IS_NULL; @@ -359,7 +359,7 @@ int32_t ComponentLoader::GetSource(const DHType dhType, IDistributedHardwareSour int32_t ComponentLoader::GetSink(const DHType dhType, IDistributedHardwareSink *&sinkPtr) { if (compHandlerMap_.find(dhType) == compHandlerMap_.end()) { - DHLOGE("DHType not exist, dhType: %" PRIu32, (uint32_t)dhType); + DHLOGE("DHType not exist, dhType: %{public}" PRIu32, (uint32_t)dhType); return ERR_DH_FWK_LOADER_HANDLER_IS_NULL; } @@ -371,7 +371,7 @@ int32_t ComponentLoader::GetSink(const DHType dhType, IDistributedHardwareSink * GetSinkHardwareClass getSinkHardwareClassHandler = (GetSinkHardwareClass)dlsym(compHandlerMap_[dhType].sinkHandler, COMPONENT_LOADER_GET_SINK_HANDLER.c_str()); if (getSinkHardwareClassHandler == nullptr) { - DHLOGE("get getSinkHardwareClassHandler is null, failed reason : %s", dlerror()); + DHLOGE("get getSinkHardwareClassHandler is null, failed reason : %{public}s", dlerror()); dlclose(compHandlerMap_[dhType].sinkHandler); compHandlerMap_[dhType].sinkHandler = nullptr; return ERR_DH_FWK_LOADER_HANDLER_IS_NULL; @@ -387,7 +387,7 @@ std::string ComponentLoader::Readfile(const std::string &filePath) std::string sAll = ""; infile.open(filePath); if (!infile.is_open()) { - DHLOGE("filePath: %s Readfile fail", filePath.c_str()); + DHLOGE("filePath: %{public}s Readfile fail", filePath.c_str()); return sAll; } @@ -467,7 +467,7 @@ int32_t ComponentLoader::ReleaseHardwareHandler(const DHType dhType) } int32_t ret = ReleaseHandler(compHandlerMap_[dhType].hardwareHandler); if (ret) { - DHLOGE("fail, dhType: %#X", dhType); + DHLOGE("fail, dhType: %{public}#X", dhType); HiSysEventWriteReleaseMsg(DHFWK_RELEASE_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, dhType, ret, "dhfwk release hardware handler failed."); } @@ -481,7 +481,7 @@ int32_t ComponentLoader::ReleaseSource(const DHType dhType) } int32_t ret = ReleaseHandler(compHandlerMap_[dhType].sourceHandler); if (ret) { - DHLOGE("fail, dhType: %#X", dhType); + DHLOGE("fail, dhType: %{public}#X", dhType); HiSysEventWriteReleaseMsg(DHFWK_RELEASE_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, dhType, ret, "dhfwk release source failed."); } @@ -495,7 +495,7 @@ int32_t ComponentLoader::ReleaseSink(const DHType dhType) } int32_t ret = ReleaseHandler(compHandlerMap_[dhType].sinkHandler); if (ret) { - DHLOGE("fail, dhType: %#X", dhType); + DHLOGE("fail, dhType: %{public}#X", dhType); HiSysEventWriteReleaseMsg(DHFWK_RELEASE_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, dhType, ret, "dhfwk release sink failed."); } @@ -505,7 +505,7 @@ int32_t ComponentLoader::ReleaseSink(const DHType dhType) bool ComponentLoader::IsDHTypeExist(DHType dhType) { if (compHandlerMap_.find(dhType) == compHandlerMap_.end()) { - DHLOGE("fail, dhType: %#X not exist", dhType); + DHLOGE("fail, dhType: %{public}#X not exist", dhType); return false; } return true; @@ -514,7 +514,7 @@ bool ComponentLoader::IsDHTypeExist(DHType dhType) int32_t ComponentLoader::GetSourceSaId(const DHType dhType) { if (compHandlerMap_.find(dhType) == compHandlerMap_.end()) { - DHLOGE("DHType not exist, dhType: %" PRIu32, (uint32_t)dhType); + DHLOGE("DHType not exist, dhType: %{public}" PRIu32, (uint32_t)dhType); return DEFAULT_SA_ID; } return compHandlerMap_[dhType].sourceSaId; diff --git a/services/distributedhardwarefwkservice/src/componentmanager/component_disable.cpp b/services/distributedhardwarefwkservice/src/componentmanager/component_disable.cpp index 9eceb3d03bfccc3ccce15ef6e2869ee800244951..c70b14cd0dced2a33eb380fce3350d8afdb627fb 100644 --- a/services/distributedhardwarefwkservice/src/componentmanager/component_disable.cpp +++ b/services/distributedhardwarefwkservice/src/componentmanager/component_disable.cpp @@ -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 @@ -33,17 +33,18 @@ ComponentDisable::~ComponentDisable() {} int32_t ComponentDisable::Disable(const std::string &networkId, const std::string &dhId, IDistributedHardwareSource *handler) { - DHLOGD("networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); + DHLOGD("networkId = %{public}s dhId = %{public}s.", GetAnonyString(networkId).c_str(), + GetAnonyString(dhId).c_str()); if (handler == nullptr) { - DHLOGE("handler is null, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), + DHLOGE("handler is null, networkId = %{public}s dhId = %{public}s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); return ERR_DH_FWK_PARA_INVALID; } auto ret = handler->UnregisterDistributedHardware(networkId, dhId, shared_from_this()); if (ret != DH_FWK_SUCCESS) { - DHLOGE("UnregisterDistributedHardware failed, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), - GetAnonyString(dhId).c_str()); + DHLOGE("UnregisterDistributedHardware failed, networkId = %{public}s dhId = %{public}s.", + GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, GetAnonyString(dhId), ret, "dhfwk unregister distributed hardware failed."); return ERR_DH_FWK_COMPONENT_UNREGISTER_FAILED; @@ -54,7 +55,7 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin auto waitStatus = conVar_.wait_for(lock, std::chrono::milliseconds(DISABLE_TIMEOUT_MS), [this]() { return status_ != std::numeric_limits::max(); }); if (!waitStatus) { - DHLOGE("disable timeout, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), + DHLOGE("disable timeout, networkId = %{public}s dhId = %{public}s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_UNREGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, GetAnonyString(dhId), ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT, @@ -68,11 +69,11 @@ int32_t ComponentDisable::OnUnregisterResult(const std::string &networkId, const const std::string &data) { if (status == DH_FWK_SUCCESS) { - DHLOGI("disable success, networkId = %s, dhId = %s.", GetAnonyString(networkId).c_str(), + DHLOGI("disable success, networkId = %{public}s, dhId = %{public}s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); } else { - DHLOGE("disable failed, networkId = %s, dhId = %s, status = %d.", GetAnonyString(networkId).c_str(), - GetAnonyString(dhId).c_str(), status); + DHLOGE("disable failed, networkId = %{public}s, dhId = %{public}s, status = %{public}d.", + GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str(), status); } std::unique_lock lock(mutex_); diff --git a/services/distributedhardwarefwkservice/src/componentmanager/component_enable.cpp b/services/distributedhardwarefwkservice/src/componentmanager/component_enable.cpp index a24426c0afc4ee91f2fa0537b56952aae355935c..d0f757b0338e78b278ab59f2e54cfedfac71eb06 100644 --- a/services/distributedhardwarefwkservice/src/componentmanager/component_enable.cpp +++ b/services/distributedhardwarefwkservice/src/componentmanager/component_enable.cpp @@ -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 @@ -33,17 +33,18 @@ ComponentEnable::~ComponentEnable() {} int32_t ComponentEnable::Enable(const std::string &networkId, const std::string &dhId, const EnableParam ¶m, IDistributedHardwareSource *handler) { - DHLOGD("networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); + DHLOGD("networkId = %{public}s dhId = %{public}s.", GetAnonyString(networkId).c_str(), + GetAnonyString(dhId).c_str()); if (handler == nullptr) { - DHLOGE("handler is null, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), + DHLOGE("handler is null, networkId = %{public}s dhId = %{public}s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); return ERR_DH_FWK_PARA_INVALID; } auto ret = handler->RegisterDistributedHardware(networkId, dhId, param, shared_from_this()); if (ret != DH_FWK_SUCCESS) { - DHLOGE("RegisterDistributedHardware failed, networkId = %s dhId = %s.", GetAnonyString(networkId).c_str(), - GetAnonyString(dhId).c_str()); + DHLOGE("RegisterDistributedHardware failed, networkId = %{public}s dhId = %{public}s.", + GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, GetAnonyString(dhId), ret, "dhfwk register distributed hardware failed."); return ERR_DH_FWK_COMPONENT_REGISTER_FAILED; @@ -54,7 +55,7 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string auto waitStatus = conVar_.wait_for(lock, std::chrono::milliseconds(ENABLE_TIMEOUT_MS), [this]() { return status_ != std::numeric_limits::max(); }); if (!waitStatus) { - DHLOGE("enable timeout, networkId = %s dhId = %s", GetAnonyString(networkId).c_str(), + DHLOGE("enable timeout, networkId = %{public}s dhId = %{public}s", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); HiSysEventWriteCompMgrFailedMsg(DHFWK_DH_REGISTER_FAIL, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, GetAnonyString(dhId), ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT, @@ -68,11 +69,11 @@ int32_t ComponentEnable::OnRegisterResult(const std::string &networkId, const st const std::string &data) { if (status == DH_FWK_SUCCESS) { - DHLOGI("enable success, networkId = %s, dhId = %s.", GetAnonyString(networkId).c_str(), + DHLOGI("enable success, networkId = %{public}s, dhId = %{public}s.", GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str()); } else { - DHLOGE("enable failed, networkId = %s, dhId = %s, status = %d.", GetAnonyString(networkId).c_str(), - GetAnonyString(dhId).c_str(), status); + DHLOGE("enable failed, networkId = %{public}s, dhId = %{public}s, status = %{public}d.", + GetAnonyString(networkId).c_str(), GetAnonyString(dhId).c_str(), status); } std::unique_lock lock(mutex_); diff --git a/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp index 4b021b66c2db2ca0be73b51c4db7e041012c7b67..5d07175039242456ba02e0d3610b1e94766f7268 100644 --- a/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkservice/src/componentmanager/component_manager.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 @@ -190,10 +190,10 @@ ActionResult ComponentManager::StartSource() ActionResult ComponentManager::StartSource(DHType dhType) { - DHLOGI("Start Source, dhType: %" PRIu32, (uint32_t)dhType); + DHLOGI("Start Source, dhType: %{public}" PRIu32, (uint32_t)dhType); std::unordered_map> futures; if (compSource_.find(dhType) == compSource_.end()) { - DHLOGE("Component for DHType: %" PRIu32 " not init source handler", (uint32_t)dhType); + DHLOGE("Component for DHType: %{public}" PRIu32 " not init source handler", (uint32_t)dhType); return futures; } @@ -234,10 +234,10 @@ ActionResult ComponentManager::StartSink() ActionResult ComponentManager::StartSink(DHType dhType) { - DHLOGI("Start Sink, dhType: %" PRIu32, (uint32_t)dhType); + DHLOGI("Start Sink, dhType: %{public}" PRIu32, (uint32_t)dhType); std::unordered_map> futures; if (compSink_.find(dhType) == compSink_.end()) { - DHLOGE("Component for DHType: %" PRIu32 " not init sink handler", (uint32_t)dhType); + DHLOGE("Component for DHType: %{public}" PRIu32 " not init sink handler", (uint32_t)dhType); return futures; } @@ -282,7 +282,7 @@ ActionResult ComponentManager::StopSink() IHardwareHandler *hardwareHandler = nullptr; status = ComponentLoader::GetInstance().GetHardwareHandler(item.first, hardwareHandler); if (status != DH_FWK_SUCCESS || hardwareHandler == nullptr) { - DHLOGE("GetHardwareHandler %#X failed", item.first); + DHLOGE("GetHardwareHandler %{public}#X failed", item.first); return status; } hardwareHandler->UnRegisterPluginListener(); @@ -302,7 +302,8 @@ bool ComponentManager::WaitForResult(const Action &action, ActionResult actionsR std::future_status status = iter.second.wait_for(std::chrono::seconds(UNINIT_COMPONENT_TIMEOUT_SECONDS)); if (status == std::future_status::ready) { auto result = iter.second.get(); - DHLOGI("action = %d, compType = %#X, READY, ret = %d.", static_cast(action), iter.first, result); + DHLOGI("action = %{public}d, compType = %{public}#X, READY, ret = %{public}d.", + static_cast(action), iter.first, result); if (result != DH_FWK_SUCCESS) { ret = false; DHLOGE("there is error, but want to continue."); @@ -310,14 +311,14 @@ bool ComponentManager::WaitForResult(const Action &action, ActionResult actionsR } if (status == std::future_status::timeout) { - DHLOGI("action = %d, compType = %#X, TIMEOUT", static_cast(action), iter.first); + DHLOGI("action = %{public}d, compType = %{public}#X, TIMEOUT", static_cast(action), iter.first); if (action == Action::STOP_SOURCE || action == Action::STOP_SINK) { isUnInitTimeOut_ = true; } } if (status == std::future_status::deferred) { - DHLOGI("action = %d, compType = %#X, DEFERRED", static_cast(action), iter.first); + DHLOGI("action = %{public}d, compType = %{public}#X, DEFERRED", static_cast(action), iter.first); } } DHLOGD("end."); @@ -331,11 +332,11 @@ bool ComponentManager::InitCompSource() IDistributedHardwareSource *sourcePtr = nullptr; auto ret = ComponentLoader::GetInstance().GetSource(type, sourcePtr); if (ret != DH_FWK_SUCCESS) { - DHLOGW("GetSource failed, compType = %#X, ret = %d.", type, ret); + DHLOGW("GetSource failed, compType = %{public}#X, ret = %{public}d.", type, ret); continue; } if (sourcePtr == nullptr) { - DHLOGW("sourcePtr is null, compType = %#X.", type); + DHLOGW("sourcePtr is null, compType = %{public}#X.", type); continue; } compSource_.insert(std::make_pair(type, sourcePtr)); @@ -355,11 +356,11 @@ bool ComponentManager::InitCompSink() IDistributedHardwareSink *sinkPtr = nullptr; auto ret = ComponentLoader::GetInstance().GetSink(type, sinkPtr); if (ret != DH_FWK_SUCCESS) { - DHLOGW("GetSink failed, compType = %#X, ret = %d.", type, ret); + DHLOGW("GetSink failed, compType = %{public}#X, ret = %{public}d.", type, ret); continue; } if (sinkPtr == nullptr) { - DHLOGW("sinkPtr is null, compType = %#X.", type); + DHLOGW("sinkPtr is null, compType = %{public}#X.", type); continue; } compSink_.insert(std::make_pair(type, sinkPtr)); @@ -373,14 +374,14 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string DHLOGI("start."); auto find = compSource_.find(dhType); if (find == compSource_.end()) { - DHLOGE("can not find handler for dhId = %s.", GetAnonyString(dhId).c_str()); + DHLOGE("can not find handler for dhId = %{public}s.", GetAnonyString(dhId).c_str()); return ERR_DH_FWK_PARA_INVALID; } EnableParam param; auto ret = GetEnableParam(networkId, uuid, dhId, dhType, param); if (ret != DH_FWK_SUCCESS) { - DHLOGE("GetEnableParam failed, uuid = %s, dhId = %s, errCode = %d", GetAnonyString(uuid).c_str(), - GetAnonyString(dhId).c_str(), ret); + DHLOGE("GetEnableParam failed, uuid = %{public}s, dhId = %{public}s, errCode = %{public}d", + GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str(), ret); if (RetryGetEnableParam(networkId, uuid, dhId, dhType, param) != DH_FWK_SUCCESS) { return ret; } @@ -403,19 +404,19 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < ENABLE_RETRY_MAX_TIMES; retryCount++) { if (!DHContext::GetInstance().IsDeviceOnline(uuid)) { - DHLOGE("device is already offline, no need try enable, uuid = %s", GetAnonyString(uuid).c_str()); + DHLOGE("device is already offline, no need try enable, uuid= %{public}s", GetAnonyString(uuid).c_str()); return result; } if (compEnable->Enable(networkId, dhId, param, find->second) == DH_FWK_SUCCESS) { - DHLOGE("enable success, retryCount = %d", retryCount); + DHLOGE("enable success, retryCount = %{public}d", retryCount); EnabledCompsDump::GetInstance().DumpEnabledComp(networkId, dhType, dhId); return DH_FWK_SUCCESS; } - DHLOGE("enable failed, retryCount = %d", retryCount); + DHLOGE("enable failed, retryCount = %{public}d", retryCount); } return result; } - DHLOGI("enable result is %d, uuid = %s, dhId = %s", result, GetAnonyString(uuid).c_str(), + DHLOGI("enable result is %{public}d, uuid = %{public}s, dhId = %{public}s", result, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str()); EnabledCompsDump::GetInstance().DumpEnabledComp(networkId, dhType, dhId); @@ -427,15 +428,15 @@ int32_t ComponentManager::RetryGetEnableParam(const std::string &networkId, cons { for (int32_t retryCount = 0; retryCount < ENABLE_RETRY_MAX_TIMES; retryCount++) { if (!DHContext::GetInstance().IsDeviceOnline(uuid)) { - DHLOGE("device is already offline, no need try GetEnableParam, uuid = %s", + DHLOGE("device is already offline, no need try GetEnableParam, uuid = %{public}s", GetAnonyString(uuid).c_str()); return ERR_DH_FWK_COMPONENT_ENABLE_FAILED; } if (GetEnableParam(networkId, uuid, dhId, dhType, param) == DH_FWK_SUCCESS) { - DHLOGE("GetEnableParam success, retryCount = %d", retryCount); + DHLOGE("GetEnableParam success, retryCount = %{public}d", retryCount); break; } - DHLOGE("GetEnableParam failed, retryCount = %d", retryCount); + DHLOGE("GetEnableParam failed, retryCount = %{public}d", retryCount); usleep(ENABLE_PARAM_RETRY_TIME); } return DH_FWK_SUCCESS; @@ -446,7 +447,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin { auto find = compSource_.find(dhType); if (find == compSource_.end()) { - DHLOGE("can not find handler for dhId = %s.", GetAnonyString(dhId).c_str()); + DHLOGE("can not find handler for dhId = %{public}s.", GetAnonyString(dhId).c_str()); return ERR_DH_FWK_PARA_INVALID; } @@ -455,19 +456,20 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < DISABLE_RETRY_MAX_TIMES; retryCount++) { if (DHContext::GetInstance().IsDeviceOnline(uuid)) { - DHLOGE("device is already online, no need try disable, uuid = %s", GetAnonyString(uuid).c_str()); + DHLOGE("device is already online, no need try disable, uuid = %{public}s", + GetAnonyString(uuid).c_str()); return result; } if (compDisable->Disable(networkId, dhId, find->second) == DH_FWK_SUCCESS) { - DHLOGE("disable success, retryCount = %d", retryCount); + DHLOGE("disable success, retryCount = %{public}d", retryCount); EnabledCompsDump::GetInstance().DumpDisabledComp(networkId, dhType, dhId); return DH_FWK_SUCCESS; } - DHLOGE("disable failed, retryCount = %d", retryCount); + DHLOGE("disable failed, retryCount = %{public}d", retryCount); } return result; } - DHLOGI("disable result is %d, uuid = %s, dhId = %s", result, GetAnonyString(uuid).c_str(), + DHLOGI("disable result is %{public}d, uuid = %{public}s, dhId = %{public}s", result, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str()); EnabledCompsDump::GetInstance().DumpDisabledComp(networkId, dhType, dhId); @@ -481,7 +483,7 @@ DHType ComponentManager::GetDHType(const std::string &uuid, const std::string &d if ((ret == DH_FWK_SUCCESS) && (capability != nullptr)) { return capability->GetDHType(); } - DHLOGE("get dhType failed, uuid = %s, dhId = %s", GetAnonyString(uuid).c_str(), + DHLOGE("get dhType failed, uuid = %{public}s, dhId = %{public}s", GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str()); return DHType::UNKNOWN; } @@ -492,8 +494,8 @@ int32_t ComponentManager::GetEnableParam(const std::string &networkId, const std std::shared_ptr capability = nullptr; auto ret = CapabilityInfoManager::GetInstance()->GetCapability(GetDeviceIdByUUID(uuid), dhId, capability); if ((ret != DH_FWK_SUCCESS) || (capability == nullptr)) { - DHLOGE("GetCapability failed, uuid =%s, dhId = %s, errCode = %d", GetAnonyString(uuid).c_str(), - GetAnonyString(dhId).c_str(), ret); + DHLOGE("GetCapability failed, uuid =%{public}s, dhId = %{public}s, errCode = %{public}d", + GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str(), ret); return ret; } DeviceInfo sourceDeviceInfo = GetLocalDeviceInfo(); @@ -510,7 +512,7 @@ int32_t ComponentManager::GetEnableParam(const std::string &networkId, const std std::string sourceVersion(""); ret = GetVersion(sourceNetworkId, sourceDeviceInfo.uuid, dhType, sourceVersion, false); if (ret != DH_FWK_SUCCESS) { - DHLOGE("Get source version failed, uuid = %s, dhId = %s, dhType = %#X,", + DHLOGE("Get source version failed, uuid = %{public}s, dhId = %{public}s, dhType = %{public}#X,", GetAnonyString(sourceDeviceInfo.uuid).c_str(), GetAnonyString(sourceDHId).c_str(), dhType); return ERR_DH_FWK_COMPONENT_GET_SINK_VERSION_FAILED; } @@ -519,16 +521,17 @@ int32_t ComponentManager::GetEnableParam(const std::string &networkId, const std std::string sinkVersion(""); ret = GetVersion(networkId, uuid, dhType, sinkVersion, true); if (ret != DH_FWK_SUCCESS) { - DHLOGE("Get sink version failed, uuid = %s, dhId = %s, dhType = %#X,", GetAnonyString(uuid).c_str(), - GetAnonyString(dhId).c_str(), dhType); + DHLOGE("Get sink version failed, uuid = %{public}s, dhId = %{public}s, dhType = %{public}#X,", + GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str(), dhType); return ERR_DH_FWK_COMPONENT_GET_SINK_VERSION_FAILED; } param.sinkVersion = sinkVersion; param.subtype = capability->GetDHSubtype(); - DHLOGI("success. dhType = %#X, sink uuid =%s, sink dhId = %s, sinVersion = %s, source uuid =%s, source dhId = %s, " - "sourceVersion = %s, subtype = %s", dhType, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str(), - param.sinkVersion.c_str(), GetAnonyString(sourceDeviceInfo.uuid).c_str(), - GetAnonyString(sourceDHId).c_str(), param.sourceVersion.c_str(), param.subtype.c_str()); + DHLOGI("success. dhType = %{public}#X, sink uuid =%{public}s, sink dhId = %{public}s, sinVersion = %{public}s, " + "source uuid =%{public}s, source dhId = %{public}s, sourceVersion = %{public}s, subtype = %{public}s", dhType, + GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str(), param.sinkVersion.c_str(), + GetAnonyString(sourceDeviceInfo.uuid).c_str(), GetAnonyString(sourceDHId).c_str(), param.sourceVersion.c_str(), + param.subtype.c_str()); return DH_FWK_SUCCESS; } @@ -539,12 +542,13 @@ int32_t ComponentManager::GetVersionFromVerMgr(const std::string &uuid, const DH CompVersion compversion; int32_t ret = VersionManager::GetInstance().GetCompVersion(uuid, dhType, compversion); if (ret != DH_FWK_SUCCESS) { - DHLOGE("Get version Manager failed, uuid =%s, dhType = %#X, errCode = %d", + DHLOGE("Get version Manager failed, uuid =%{public}s, dhType = %{public}#X, errCode = %{public}d", GetAnonyString(uuid).c_str(), dhType, ret); return ret; } - DHLOGI("Get version mgr success, sinkVersion = %s, sourceVersion = %s,uuid = %s, dhType = %#X", - compversion.sinkVersion.c_str(), compversion.sourceVersion.c_str(), GetAnonyString(uuid).c_str(), dhType); + DHLOGI("Get version mgr success, sinkVersion = %{public}s, sourceVersion = %{public}s,uuid = %{public}s, " + "dhType = %{public}#X", compversion.sinkVersion.c_str(), compversion.sourceVersion.c_str(), + GetAnonyString(uuid).c_str(), dhType); version = isSink ? compversion.sinkVersion : compversion.sourceVersion; return DH_FWK_SUCCESS; } @@ -555,17 +559,18 @@ int32_t ComponentManager::GetVersionFromVerInfoMgr(const std::string &uuid, cons VersionInfo versionInfo; int32_t ret = VersionInfoManager::GetInstance()->GetVersionInfoByDeviceId(GetDeviceIdByUUID(uuid), versionInfo); if (ret != DH_FWK_SUCCESS) { - DHLOGE("Get Version info Manager failed, uuid =%s, dhType = %#X, errCode = %d", + DHLOGE("Get Version info Manager failed, uuid =%{public}s, dhType = %{public}#X, errCode = %{public}d", GetAnonyString(uuid).c_str(), dhType, ret); return ret; } auto iter = versionInfo.compVersions.find(dhType); if (iter == versionInfo.compVersions.end()) { - DHLOGE("can not find component version for dhType = %d", dhType); + DHLOGE("can not find component version for dhType = %{public}d", dhType); return ERR_DH_FWK_COMPONENT_DHTYPE_NOT_FOUND; } - DHLOGI("Get version info mgr success, sinkVersion = %s, sourceVersion = %s, uuid = %s, dhType = %#X", - iter->second.sinkVersion.c_str(), iter->second.sourceVersion.c_str(), GetAnonyString(uuid).c_str(), dhType); + DHLOGI("Get version info mgr success, sinkVersion = %{public}s, sourceVersion = %{public}s, uuid = %{public}s, " + "dhType = %{public}#X", iter->second.sinkVersion.c_str(), iter->second.sourceVersion.c_str(), + GetAnonyString(uuid).c_str(), dhType); UpdateVersionCache(uuid, versionInfo); version = isSink ? iter->second.sinkVersion : iter->second.sourceVersion; return DH_FWK_SUCCESS; @@ -625,16 +630,16 @@ void ComponentManager::DoRecover(DHType dhType) void ComponentManager::ReStartSA(DHType dhType) { - DHLOGI("Restart SA for DHType %" PRIu32, (uint32_t)dhType); + DHLOGI("Restart SA for DHType %{public}" PRIu32, (uint32_t)dhType); auto sourceResult = StartSource(dhType); auto sinkResult = StartSink(dhType); if (!WaitForResult(Action::START_SOURCE, sourceResult)) { - DHLOGE("ReStartSource failed, DHType: %" PRIu32, (uint32_t)dhType); + DHLOGE("ReStartSource failed, DHType: %{public}" PRIu32, (uint32_t)dhType); } if (!WaitForResult(Action::START_SINK, sinkResult)) { - DHLOGE("ReStartSink failed, DHType: %" PRIu32, (uint32_t)dhType); + DHLOGE("ReStartSink failed, DHType: %{public}" PRIu32, (uint32_t)dhType); } DHLOGI("Finish Restart"); } @@ -646,14 +651,14 @@ void ComponentManager::RecoverDistributedHardware(DHType dhType) for (const auto &capInfo : capabilityMap) { std::string uuid = DHContext::GetInstance().GetUUIDByDeviceId(capInfo.second->GetDeviceId()); if (uuid.empty()) { - DHLOGE("Can not find uuid by capability deviceId: %s", + DHLOGE("Can not find uuid by capability deviceId: %{public}s", GetAnonyString(capInfo.second->GetDeviceId()).c_str()); continue; } std::string networkId = DHContext::GetInstance().GetNetworkIdByUUID(uuid); if (networkId.empty()) { - DHLOGI("Can not find network id by uuid: %s", GetAnonyString(uuid).c_str()); + DHLOGI("Can not find network id by uuid: %{public}s", GetAnonyString(uuid).c_str()); continue; } diff --git a/services/distributedhardwarefwkservice/src/componentmanager/component_monitor.cpp b/services/distributedhardwarefwkservice/src/componentmanager/component_monitor.cpp index 94ba8e63e0f9dd5c178197ecc540b50921495d1c..f80e6d68e043ac325571977c9dacb8dab74b3d61 100644 --- a/services/distributedhardwarefwkservice/src/componentmanager/component_monitor.cpp +++ b/services/distributedhardwarefwkservice/src/componentmanager/component_monitor.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 @@ -47,36 +47,36 @@ ComponentMonitor::~ComponentMonitor() void ComponentMonitor::CompSystemAbilityListener::OnAddSystemAbility(int32_t saId, const std::string &deviceId) { - DHLOGI("OnAddSystemAbility, saId: %d, deviceId: %s", saId, GetAnonyString(deviceId).c_str()); + DHLOGI("OnAddSystemAbility, saId: %{public}d, deviceId: %{public}s", saId, GetAnonyString(deviceId).c_str()); } void ComponentMonitor::CompSystemAbilityListener::OnRemoveSystemAbility(int32_t saId, const std::string &deviceId) { - DHLOGI("OnRemoveSystemAbility, saId: %d, deviceId: %s", saId, GetAnonyString(deviceId).c_str()); + DHLOGI("OnRemoveSystemAbility, saId: %{public}d, deviceId: %{public}s", saId, GetAnonyString(deviceId).c_str()); DHType dhType = ComponentLoader::GetInstance().GetDHTypeBySrcSaId(saId); if (dhType == DHType::UNKNOWN) { - DHLOGE("Can not find DHType by sa Id: %d", saId); + DHLOGE("Can not find DHType by sa Id: %{public}d", saId); return; } auto processNameIter = saIdProcessNameMap_.find(saId); if (processNameIter == saIdProcessNameMap_.end()) { - DHLOGE("SaId not been find, SaId : %d", saId); + DHLOGE("SaId not been find, SaId : %{public}d", saId); return; } ServiceWaitForStatus(((*processNameIter).second).c_str(), ServiceStatus::SERVICE_STOPPED, WAIT_SERVICE_STATUS_TIMEOUT); - DHLOGI("Try Recover Component, dhType: %" PRIu32, (uint32_t)dhType); + DHLOGI("Try Recover Component, dhType: %{public}" PRIu32, (uint32_t)dhType); ComponentManager::GetInstance().Recover(dhType); } void ComponentMonitor::AddSAMonitor(int32_t saId) { - DHLOGI("Try add sa monitor, saId: %" PRIu32, saId); + DHLOGI("Try add sa monitor, saId: %{public}" PRIu32, saId); std::lock_guard lock(saListenersMtx_); if (saListeners_.find(saId) != saListeners_.end()) { - DHLOGW("SaId is in monitor, id: %" PRIu32, saId); + DHLOGW("SaId is in monitor, id: %{public}" PRIu32, saId); return; } @@ -90,7 +90,7 @@ void ComponentMonitor::AddSAMonitor(int32_t saId) int32_t ret = systemAbilityManager->SubscribeSystemAbility(saId, listener); if (ret != DH_FWK_SUCCESS) { - DHLOGE("subscribe sa change listener failed: %d", ret); + DHLOGE("subscribe sa change listener failed: %{public}d", ret); return; } @@ -101,10 +101,10 @@ void ComponentMonitor::AddSAMonitor(int32_t saId) void ComponentMonitor::RemoveSAMonitor(int32_t saId) { - DHLOGI("Try remove sa monitor, saId: %" PRIu32, saId); + DHLOGI("Try remove sa monitor, saId: %{public}" PRIu32, saId); std::lock_guard lock(saListenersMtx_); if (saListeners_.find(saId) == saListeners_.end()) { - DHLOGW("can not find sa listener info, id: %" PRIu32, saId); + DHLOGW("can not find sa listener info, id: %{public}" PRIu32, saId); return; } @@ -117,7 +117,7 @@ void ComponentMonitor::RemoveSAMonitor(int32_t saId) int32_t ret = systemAbilityManager->UnSubscribeSystemAbility(saId, saListeners_[saId]); if (ret != DH_FWK_SUCCESS) { - DHLOGE("unsubscribe sa change listener failed: %d", ret); + DHLOGE("unsubscribe sa change listener failed: %{public}d", ret); return; } diff --git a/services/distributedhardwarefwkservice/src/componentmanager/component_privacy.cpp b/services/distributedhardwarefwkservice/src/componentmanager/component_privacy.cpp index 3a041da906c9ca98c184abde41a85a16ccea432c..c72de60ce8b658621cb38f167579e137606c4c5a 100644 --- a/services/distributedhardwarefwkservice/src/componentmanager/component_privacy.cpp +++ b/services/distributedhardwarefwkservice/src/componentmanager/component_privacy.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 @@ -138,7 +138,7 @@ int32_t ComponentPrivacy::StartPrivacePage(const std::string &subtype, const std return ERR_DH_FWK_POINTER_IS_NULL; } int32_t result = abilityManager->StartAbility(want); - DHLOGI("performance time: StartPrivacePage result = %d", result); + DHLOGI("performance time: StartPrivacePage result = %{public}d", result); return result; } @@ -164,7 +164,7 @@ int32_t ComponentPrivacy::StopPrivacePage(const std::string &subtype) return ERR_DH_FWK_POINTER_IS_NULL; } int32_t result = abilityManager->StartAbility(want); - DHLOGI("performance time: StopPrivacePage result = %d", result); + DHLOGI("performance time: StopPrivacePage result = %{public}d", result); return result; } @@ -202,7 +202,7 @@ void ComponentPrivacy::ComponentEventHandler::ProcessEvent(const AppExecFwk::Inn { auto iter = eventFuncMap_.find(event->GetInnerEventId()); if (iter == eventFuncMap_.end()) { - DHLOGE("ComponentEventHandler Event Id %d is undefined.", event->GetInnerEventId()); + DHLOGE("ComponentEventHandler Event Id %{public}d is undefined.", event->GetInnerEventId()); return; } compEventFunc &func = iter->second; diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager.cpp index a6af4c8143a4cd98b220464cdeeba953f56b36d0..04f6ededfb901c68d329d7047d030a3ec312e52a 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager.cpp @@ -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 @@ -90,7 +90,8 @@ int32_t DistributedHardwareManager::SendOnLineEvent(const std::string &networkId return ERR_DH_FWK_PARA_INVALID; } - DHLOGI("networkId = %s, uuid = %s", GetAnonyString(networkId).c_str(), GetAnonyString(uuid).c_str()); + DHLOGI("networkId = %{public}s, uuid = %{public}s", GetAnonyString(networkId).c_str(), + GetAnonyString(uuid).c_str()); TaskParam taskParam = { .networkId = networkId, @@ -113,7 +114,8 @@ int32_t DistributedHardwareManager::SendOffLineEvent(const std::string &networkI return ERR_DH_FWK_PARA_INVALID; } - DHLOGI("networkId = %s, uuid = %s", GetAnonyString(networkId).c_str(), GetAnonyString(uuid).c_str()); + DHLOGI("networkId = %{public}s, uuid = %{public}s", GetAnonyString(networkId).c_str(), + GetAnonyString(uuid).c_str()); TaskParam taskParam = { .networkId = networkId, @@ -142,7 +144,7 @@ int32_t DistributedHardwareManager::GetComponentVersion(std::unordered_mapUnloadSystemAbility(DISTRIBUTED_HARDWARE_SA_ID); if (ret != DH_FWK_SUCCESS) { - DHLOGE("systemAbilityMgr UnLoadSystemAbility failed, ret: %d", ret); + DHLOGE("systemAbilityMgr UnLoadSystemAbility failed, ret: %{public}d", ret); return; } DHLOGI("systemAbilityMgr UnLoadSystemAbility success"); @@ -98,7 +98,8 @@ void DistributedHardwareManagerFactory::CheckExitSAOrNot() for (const auto &deviceInfo : deviceList) { const auto networkId = std::string(deviceInfo.networkId); const auto uuid = GetUUIDBySoftBus(networkId); - DHLOGI("Send trusted device online, networkId = %s, uuid = %s", GetAnonyString(networkId).c_str(), + DHLOGI("Send trusted device online, networkId = %{public}s, uuid = %{public}s", + GetAnonyString(networkId).c_str(), GetAnonyString(uuid).c_str()); std::thread(&DistributedHardwareManagerFactory::SendOnLineEvent, this, networkId, uuid, deviceInfo.deviceTypeId).detach(); @@ -123,7 +124,7 @@ int32_t DistributedHardwareManagerFactory::SendOnLineEvent(const std::string &ne } if (DHContext::GetInstance().IsDeviceOnline(uuid)) { - DHLOGW("device is already online, uuid = %s", GetAnonyString(uuid).c_str()); + DHLOGW("device is already online, uuid = %{public}s", GetAnonyString(uuid).c_str()); return ERR_DH_FWK_HARDWARE_MANAGER_DEVICE_REPEAT_ONLINE; } @@ -136,7 +137,7 @@ int32_t DistributedHardwareManagerFactory::SendOnLineEvent(const std::string &ne auto onlineResult = DistributedHardwareManager::GetInstance().SendOnLineEvent(networkId, uuid, deviceType); if (onlineResult != DH_FWK_SUCCESS) { - DHLOGE("online failed, errCode = %d", onlineResult); + DHLOGE("online failed, errCode = %{public}d", onlineResult); return onlineResult; } return DH_FWK_SUCCESS; @@ -156,14 +157,14 @@ int32_t DistributedHardwareManagerFactory::SendOffLineEvent(const std::string &n } if (!DHContext::GetInstance().IsDeviceOnline(uuid)) { - DHLOGE("Device not online, networkId: %s, uuid: %s", + DHLOGE("Device not online, networkId: %{public}s, uuid: %{public}s", GetAnonyString(networkId).c_str(), GetAnonyString(uuid).c_str()); return ERR_DH_FWK_HARDWARE_MANAGER_DEVICE_REPEAT_OFFLINE; } auto offlineResult = DistributedHardwareManager::GetInstance().SendOffLineEvent(networkId, uuid, deviceType); if (offlineResult != DH_FWK_SUCCESS) { - DHLOGE("offline failed, errCode = %d", offlineResult); + DHLOGE("offline failed, errCode = %{public}d", offlineResult); return offlineResult; } diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp index e624c3e07adac0510bc61ff9dff6f694eff60133..6a74c24602fb5fc3c2fcfb124725a108b7fae722 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_service.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_service.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 @@ -148,7 +148,8 @@ std::string DistributedHardwareService::QueryLocalSysSpec(const QueryLocalSysSpe break; } - DHLOGE("QueryLocalSysSpec targetKey: %s, targetDhType: %" PRIu32, targetKey.c_str(), (uint32_t)targetDhType); + DHLOGE("QueryLocalSysSpec targetKey: %{public}s, targetDhType: %{public}" PRIu32, targetKey.c_str(), + (uint32_t)targetDhType); if (targetDhType == DHType::UNKNOWN) { DHLOGE("Can not find matched dhtype"); return ""; @@ -174,12 +175,12 @@ std::string DistributedHardwareService::QueryDhSysSpec(const std::string &target { nlohmann::json attrJson = nlohmann::json::parse(attrs, nullptr, false); if (attrJson.is_discarded()) { - DHLOGE("attrs json is invalid, attrs: %s", attrs.c_str()); + DHLOGE("attrs json is invalid, attrs: %{public}s", attrs.c_str()); return ""; } if (!IsString(attrJson, targetKey)) { - DHLOGE("Attrs Json not contains key: %s", targetKey.c_str()); + DHLOGE("Attrs Json not contains key: %{public}s", targetKey.c_str()); return ""; } return attrJson.at(targetKey).get(); @@ -231,10 +232,10 @@ int DistributedHardwareService::Dump(int32_t fd, const std::vectorDump(argsStr, result); if (ret != DH_FWK_SUCCESS) { - DHLOGE("Dump error, ret = %d", ret); + DHLOGE("Dump error, ret = %{public}d", ret); } - if (dprintf(fd, "%s\n", result.c_str()) < 0) { + if (dprintf(fd, "%{public}s\n", result.c_str()) < 0) { DHLOGE("Hidump dprintf error"); ret = ERR_DH_FWK_HIDUMP_DPRINTF_ERROR; } @@ -246,12 +247,12 @@ int32_t DistributedHardwareService::PauseDistributedHardware(DHType dhType, cons { std::map sinkMap = ComponentManager::GetInstance().GetDHSinkInstance(); if (sinkMap.find(dhType) == sinkMap.end()) { - DHLOGE("PauseDistributedHardware for DHType: %u not init sink handler", (uint32_t)dhType); + DHLOGE("PauseDistributedHardware for DHType: %{public}u not init sink handler", (uint32_t)dhType); return ERR_DH_FWK_PARA_INVALID; } int32_t ret = sinkMap[dhType]->PauseDistributedHardware(networkId); if (ret != 0) { - DHLOGE("PauseDistributedHardware for DHType: %u failed, ret: %d", (uint32_t)dhType, ret); + DHLOGE("PauseDistributedHardware for DHType: %{public}u failed, ret: %{public}d", (uint32_t)dhType, ret); return ret; } return DH_FWK_SUCCESS; @@ -261,12 +262,12 @@ int32_t DistributedHardwareService::ResumeDistributedHardware(DHType dhType, con { std::map sinkMap = ComponentManager::GetInstance().GetDHSinkInstance(); if (sinkMap.find(dhType) == sinkMap.end()) { - DHLOGE("ResumeDistributedHardware for DHType: %u not init sink handler", (uint32_t)dhType); + DHLOGE("ResumeDistributedHardware for DHType: %{public}u not init sink handler", (uint32_t)dhType); return ERR_DH_FWK_PARA_INVALID; } int32_t ret = sinkMap[dhType]->ResumeDistributedHardware(networkId); if (ret != 0) { - DHLOGE("ResumeDistributedHardware for DHType: %u failed, ret: %d", (uint32_t)dhType, ret); + DHLOGE("ResumeDistributedHardware for DHType: %{public}u failed, ret: %{public}d", (uint32_t)dhType, ret); return ret; } return DH_FWK_SUCCESS; @@ -276,12 +277,12 @@ int32_t DistributedHardwareService::StopDistributedHardware(DHType dhType, const { std::map sinkMap = ComponentManager::GetInstance().GetDHSinkInstance(); if (sinkMap.find(dhType) == sinkMap.end()) { - DHLOGE("StopDistributedHardware for DHType: %u not init sink handler", (uint32_t)dhType); + DHLOGE("StopDistributedHardware for DHType: %{public}u not init sink handler", (uint32_t)dhType); return ERR_DH_FWK_PARA_INVALID; } int32_t ret = sinkMap[dhType]->StopDistributedHardware(networkId); if (ret != 0) { - DHLOGE("StopDistributedHardware for DHType: %u failed, ret: %d", (uint32_t)dhType, ret); + DHLOGE("StopDistributedHardware for DHType: %{public}u failed, ret: %{public}d", (uint32_t)dhType, ret); return ret; } return DH_FWK_SUCCESS; diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp index 75ebf95b7609a821877866373dfe6cc1786ea53b..f55fe34257a0b18ca12987367b75ede87f70435c 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_stub.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_stub.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 @@ -86,7 +86,7 @@ int32_t DistributedHardwareStub::RegisterPublisherListenerInner(MessageParcel &d { uint32_t topicInt = data.ReadUint32(); if (!ValidTopic(topicInt)) { - DHLOGE("Topic invalid: %" PRIu32, topicInt); + DHLOGE("Topic invalid: %{public}" PRIu32, topicInt); reply.WriteInt32(ERR_DH_FWK_PARA_INVALID); return ERR_DH_FWK_PARA_INVALID; } @@ -98,7 +98,7 @@ int32_t DistributedHardwareStub::RegisterPublisherListenerInner(MessageParcel &d reply.WriteInt32(ERR_DH_FWK_PARA_INVALID); return ERR_DH_FWK_PARA_INVALID; } - DHLOGI("Register listener, topic: %" PRIu32, (uint32_t)topic); + DHLOGI("Register listener, topic: %{public}" PRIu32, (uint32_t)topic); RegisterPublisherListener(topic, listener); reply.WriteInt32(DH_FWK_SUCCESS); return DH_FWK_SUCCESS; @@ -108,7 +108,7 @@ int32_t DistributedHardwareStub::UnregisterPublisherListenerInner(MessageParcel { uint32_t topicInt = data.ReadUint32(); if (!ValidTopic(topicInt)) { - DHLOGE("Topic invalid: %" PRIu32, topicInt); + DHLOGE("Topic invalid: %{public}" PRIu32, topicInt); reply.WriteInt32(ERR_DH_FWK_PARA_INVALID); return ERR_DH_FWK_PARA_INVALID; } @@ -120,7 +120,7 @@ int32_t DistributedHardwareStub::UnregisterPublisherListenerInner(MessageParcel reply.WriteInt32(ERR_DH_FWK_PARA_INVALID); return ERR_DH_FWK_PARA_INVALID; } - DHLOGI("Unregister listener, topic: %" PRIu32, (uint32_t)topic); + DHLOGI("Unregister listener, topic: %{public}" PRIu32, (uint32_t)topic); UnregisterPublisherListener(topic, listener); reply.WriteInt32(DH_FWK_SUCCESS); return DH_FWK_SUCCESS; @@ -130,14 +130,14 @@ int32_t DistributedHardwareStub::PublishMessageInner(MessageParcel &data, Messag { uint32_t topicInt = data.ReadUint32(); if (!ValidTopic(topicInt)) { - DHLOGE("Topic invalid: %" PRIu32, topicInt); + DHLOGE("Topic invalid: %{public}" PRIu32, topicInt); reply.WriteInt32(ERR_DH_FWK_PARA_INVALID); return ERR_DH_FWK_PARA_INVALID; } DHTopic topic = (DHTopic)topicInt; std::string message = data.ReadString(); - DHLOGI("Publish message, topic: %" PRIu32, (uint32_t)topic); + DHLOGI("Publish message, topic: %{public}" PRIu32, (uint32_t)topic); PublishMessage(topic, message); reply.WriteInt32(DH_FWK_SUCCESS); return DH_FWK_SUCCESS; @@ -147,15 +147,15 @@ int32_t DistributedHardwareStub::QueryLocalSysSpecInner(MessageParcel &data, Mes { uint32_t specInt = data.ReadUint32(); if (!ValidQueryLocalSpec(specInt)) { - DHLOGE("Spec invalid: %" PRIu32, specInt); + DHLOGE("Spec invalid: %{public}" PRIu32, specInt); reply.WriteInt32(ERR_DH_FWK_PARA_INVALID); return ERR_DH_FWK_PARA_INVALID; } QueryLocalSysSpecType spec = (QueryLocalSysSpecType)specInt; - DHLOGI("Query Local Sys Spec: %" PRIu32, (uint32_t)spec); + DHLOGI("Query Local Sys Spec: %{public}" PRIu32, (uint32_t)spec); std::string res = QueryLocalSysSpec(spec); - DHLOGI("Get Local spec: %s", res.c_str()); + DHLOGI("Get Local spec: %{public}s", res.c_str()); reply.WriteString(res); return DH_FWK_SUCCESS; } diff --git a/services/distributedhardwarefwkservice/src/ipc/publisher_listener_proxy.cpp b/services/distributedhardwarefwkservice/src/ipc/publisher_listener_proxy.cpp index 2dc55ec9abbb7a7149ae76ee542be043bc61d77b..11fdf70a7863b72dcfd2bfc571c5a9c3487e4c9b 100644 --- a/services/distributedhardwarefwkservice/src/ipc/publisher_listener_proxy.cpp +++ b/services/distributedhardwarefwkservice/src/ipc/publisher_listener_proxy.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 @@ -64,7 +64,7 @@ void PublisherListenerProxy::OnMessage(const DHTopic topic, const std::string& m int32_t ret = remote->SendRequest( static_cast(IPublisherListener::Message::ON_MESSAGE), data, reply, option); if (ret != 0) { - DHLOGE("PublisherListenerProxy send requeset failed, ret: %d", ret); + DHLOGE("PublisherListenerProxy send requeset failed, ret: %{public}d", ret); return; } } diff --git a/services/distributedhardwarefwkservice/src/localhardwaremanager/local_hardware_manager.cpp b/services/distributedhardwarefwkservice/src/localhardwaremanager/local_hardware_manager.cpp index 5fd8e130dd64b342a55085bfa1b35e68a49cd4af..2c5ca8a243c97caccf69b871a2d20ed615d5a6a1 100644 --- a/services/distributedhardwarefwkservice/src/localhardwaremanager/local_hardware_manager.cpp +++ b/services/distributedhardwarefwkservice/src/localhardwaremanager/local_hardware_manager.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 @@ -53,11 +53,11 @@ void LocalHardwareManager::Init() IHardwareHandler *hardwareHandler = nullptr; int32_t status = ComponentLoader::GetInstance().GetHardwareHandler(dhType, hardwareHandler); if (status != DH_FWK_SUCCESS || hardwareHandler == nullptr) { - DHLOGE("GetHardwareHandler %#X failed", dhType); + DHLOGE("GetHardwareHandler %{public}#X failed", dhType); continue; } if (hardwareHandler->Initialize() != DH_FWK_SUCCESS) { - DHLOGE("Initialize %#X failed", dhType); + DHLOGE("Initialize %{public}#X failed", dhType); continue; } @@ -75,10 +75,11 @@ void LocalHardwareManager::Init() hardwareHandler->RegisterPluginListener(listener); } int64_t singleQueryEndTime = GetCurrentTime(); - DHLOGI("query %#X hardware cost time: %ld ms", dhType, singleQueryEndTime - singleQueryStartTime); + DHLOGI("query %{public}#X hardware cost time: %{public}" PRIu64 " ms", + dhType, singleQueryEndTime - singleQueryStartTime); } int64_t allQueryEndTime = GetCurrentTime(); - DHLOGI("query all local hardware cost time: %ld ms", allQueryEndTime - allQueryStartTime); + DHLOGI("query all local hardware cost time: %{public}" PRIu64 " ms", allQueryEndTime - allQueryStartTime); std::vector> capabilityInfos; for (const auto &localDHItems : localDHItemsMap_) { AddLocalCapabilityInfo(localDHItems.second, localDHItems.first, capabilityInfos); @@ -98,13 +99,13 @@ void LocalHardwareManager::QueryLocalHardware(const DHType dhType, IHardwareHand std::vector dhItems; int32_t retryTimes = QUERY_RETRY_MAX_TIMES; while (retryTimes > 0) { - DHLOGI("Query hardwareHandler retry times left: %d, dhType: %#X", retryTimes, dhType); + DHLOGI("Query hardwareHandler retry times left: %{public}d, dhType: %{public}#X", retryTimes, dhType); dhItems = hardwareHandler->Query(); if (dhItems.empty()) { - DHLOGE("Query hardwareHandler and obtain empty, dhType: %#X", dhType); + DHLOGE("Query hardwareHandler and obtain empty, dhType: %{public}#X", dhType); usleep(QUERY_INTERVAL_TIME); } else { - DHLOGI("Query hardwareHandler success, dhType: %#X!", dhType); + DHLOGI("Query hardwareHandler success, dhType: %{public}#X!", dhType); /* * Failed to delete data when the device restarts or other exception situation. @@ -147,19 +148,21 @@ void LocalHardwareManager::CheckNonExistCapabilityInfo(const std::vector DHLOGE("capabilityInfo value is nullptr"); continue; } - DHLOGI("The key in allLocalCapabilityInfos is %s", capabilityValue->GetAnonymousKey().c_str()); + DHLOGI("The key in allLocalCapabilityInfos is %{public}s", capabilityValue->GetAnonymousKey().c_str()); bool isExist = false; for (auto dhItem : dhItems) { - DHLOGI("This data key is: %s, dhItem: %s", capabilityValue->GetAnonymousKey().c_str(), + DHLOGI("This data key is: %{public}s, dhItem: %{public}s", capabilityValue->GetAnonymousKey().c_str(), GetAnonyString(dhItem.dhId).c_str()); if (capabilityValue->GetDHId() == dhItem.dhId) { - DHLOGI("This data is exist, no need removed key: %s", capabilityValue->GetAnonymousKey().c_str()); + DHLOGI("This data is exist, no need removed key: %{public}s", + capabilityValue->GetAnonymousKey().c_str()); isExist = true; break; } } if (!isExist) { - DHLOGI("This data is non-exist, it should be removed, key: %s", capabilityValue->GetAnonymousKey().c_str()); + DHLOGI("This data is non-exist, it should be removed, key: %{public}s", + capabilityValue->GetAnonymousKey().c_str()); CapabilityInfoManager::GetInstance()->RemoveCapabilityInfoByKey(capabilityValue->GetKey()); } } @@ -174,7 +177,7 @@ void LocalHardwareManager::GetLocalCapabilityMapByPrefix(const DHType dhType, Ca return; } if (DHTypePrefixMap.find(dhType) == DHTypePrefixMap.end()) { - DHLOGE("DHTypePrefixMap can not find dhType: %#X", dhType); + DHLOGE("DHTypePrefixMap can not find dhType: %{public}#X", dhType); return; } std::string prefix = DHTypePrefixMap.find(dhType)->second; diff --git a/services/distributedhardwarefwkservice/src/localhardwaremanager/plugin_listener_impl.cpp b/services/distributedhardwarefwkservice/src/localhardwaremanager/plugin_listener_impl.cpp index 5424af283ac7eaa98ac35ece5e74a91628b24ea5..103b836c50b73f4970f74e9cba1827624a371c03 100644 --- a/services/distributedhardwarefwkservice/src/localhardwaremanager/plugin_listener_impl.cpp +++ b/services/distributedhardwarefwkservice/src/localhardwaremanager/plugin_listener_impl.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 @@ -35,7 +35,7 @@ void PluginListenerImpl::PluginHardware(const std::string &dhId, const std::stri DHLOGE("Param is invalid!"); return; } - DHLOGI("plugin start, dhId: %s", GetAnonyString(dhId).c_str()); + DHLOGI("plugin start, dhId: %{public}s", GetAnonyString(dhId).c_str()); if (DHContext::GetInstance().IsSleeping()) { DHLOGI("System is in sleeping, drop it"); return; @@ -50,7 +50,7 @@ void PluginListenerImpl::PluginHardware(const std::string &dhId, const std::stri CapabilityInfoManager::GetInstance()->AddCapability(capabilityInfos); Publisher::GetInstance().PublishMessage(DHTopic::TOPIC_PHY_DEV_PLUGIN, dhId); - DHLOGI("plugin end, dhId: %s", GetAnonyString(dhId).c_str()); + DHLOGI("plugin end, dhId: %{public}s", GetAnonyString(dhId).c_str()); } void PluginListenerImpl::UnPluginHardware(const std::string &dhId) @@ -59,7 +59,7 @@ void PluginListenerImpl::UnPluginHardware(const std::string &dhId) DHLOGE("DhId is invalid!"); return; } - DHLOGI("unplugin start, dhId: %s", GetAnonyString(dhId).c_str()); + DHLOGI("unplugin start, dhId: %{public}s", GetAnonyString(dhId).c_str()); if (DHContext::GetInstance().IsSleeping()) { DHLOGI("System is in sleeping, drop it"); return; @@ -68,12 +68,12 @@ void PluginListenerImpl::UnPluginHardware(const std::string &dhId) std::shared_ptr capability = nullptr; auto ret = CapabilityInfoManager::GetInstance()->GetCapability(deviceId, dhId, capability); if ((ret != DH_FWK_SUCCESS) || (capability == nullptr)) { - DHLOGE("GetCapability failed, deviceId =%s, dhId = %s, errCode = %d", + DHLOGE("GetCapability failed, deviceId =%{public}s, dhId = %{public}s, errCode = %{public}d", GetAnonyString(deviceId).c_str(), GetAnonyString(dhId).c_str(), ret); return; } CapabilityInfoManager::GetInstance()->RemoveCapabilityInfoByKey(capability->GetKey()); - DHLOGI("unplugin end, dhId: %s", GetAnonyString(dhId).c_str()); + DHLOGI("unplugin end, dhId: %{public}s", GetAnonyString(dhId).c_str()); } } // namespace DistributedHardware } // namespace OHOS diff --git a/services/distributedhardwarefwkservice/src/lowlatency/low_latency.cpp b/services/distributedhardwarefwkservice/src/lowlatency/low_latency.cpp index 6ba13a818496d12cf2f5666856fb22b9ab108f34..d8a6ba67e9246fec25c3340d89134a194106fe1a 100644 --- a/services/distributedhardwarefwkservice/src/lowlatency/low_latency.cpp +++ b/services/distributedhardwarefwkservice/src/lowlatency/low_latency.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 @@ -47,15 +47,15 @@ LowLatency::~LowLatency() void LowLatency::EnableLowLatency(DHType dhType) { - DHLOGI("Start EnableLowLatency dhType: %#X", dhType); + DHLOGI("Start EnableLowLatency dhType: %{public}#X", dhType); if (dhType <= DHType::UNKNOWN || dhType >= DHType::MAX_DH) { - DHLOGE("DHType is invalid, dhType: %" PRIu32, (uint32_t)dhType); + DHLOGE("DHType is invalid, dhType: %{public}" PRIu32, (uint32_t)dhType); return; } std::lock_guard lock(lowLatencyMutex_); - DHLOGI("lowLatencySwitchSet size: %zu", lowLatencySwitchSet_.size()); + DHLOGI("lowLatencySwitchSet size: %{public}zu", lowLatencySwitchSet_.size()); if (lowLatencySwitchSet_.empty() && lowLatencyTimer_ != nullptr) { - DHLOGD("Open LowLatency dhType: %#X", dhType); + DHLOGD("Open LowLatency dhType: %{public}#X", dhType); lowLatencyTimer_->StartTimer(); } if (lowLatencySwitchSet_.size() >= MAX_SWITCH_SIZE) { @@ -63,23 +63,23 @@ void LowLatency::EnableLowLatency(DHType dhType) return; } lowLatencySwitchSet_.insert(dhType); - DHLOGI("End EnableLowLatency dhType: %#X", dhType); + DHLOGI("End EnableLowLatency dhType: %{public}#X", dhType); } void LowLatency::DisableLowLatency(DHType dhType) { - DHLOGI("Start DisableLowLatency dhType: %#X", dhType); + DHLOGI("Start DisableLowLatency dhType: %{public}#X", dhType); if (dhType <= DHType::UNKNOWN || dhType >= DHType::MAX_DH) { - DHLOGE("DHType is invalid, dhType: %" PRIu32, (uint32_t)dhType); + DHLOGE("DHType is invalid, dhType: %{public}" PRIu32, (uint32_t)dhType); return; } std::lock_guard lock(lowLatencyMutex_); lowLatencySwitchSet_.erase(dhType); if (lowLatencySwitchSet_.empty() && lowLatencyTimer_ != nullptr) { - DHLOGD("Close LowLatency dhType: %#X", dhType); + DHLOGD("Close LowLatency dhType: %{public}#X", dhType); lowLatencyTimer_->StopTimer(); } - DHLOGI("End DisableLowLatency dhType: %#X", dhType); + DHLOGI("End DisableLowLatency dhType: %{public}#X", dhType); } void LowLatency::CloseLowLatency() diff --git a/services/distributedhardwarefwkservice/src/lowlatency/low_latency_listener.cpp b/services/distributedhardwarefwkservice/src/lowlatency/low_latency_listener.cpp index ec0bd52d660318f83d45f36e4f3d3e4c3e998251..d02be644b31f605b5216d3459ebd339ce555157c 100644 --- a/services/distributedhardwarefwkservice/src/lowlatency/low_latency_listener.cpp +++ b/services/distributedhardwarefwkservice/src/lowlatency/low_latency_listener.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 @@ -42,7 +42,7 @@ void LowLatencyListener::OnMessage(const DHTopic topic, const std::string& messa (void) message; #ifdef DHARDWARE_LOW_LATENCY if (topic <= DHTopic::TOPIC_MIN || topic >= DHTopic::TOPIC_MAX) { - DHLOGE("Topic is invalid, topic: %" PRIu32, (uint32_t)topic); + DHLOGE("Topic is invalid, topic: %{public}" PRIu32, (uint32_t)topic); return; } if (message.size() == 0 || message.size() > MAX_MESSAGE_LEN) { diff --git a/services/distributedhardwarefwkservice/src/publisher/publisher_item.cpp b/services/distributedhardwarefwkservice/src/publisher/publisher_item.cpp index 282767c82667c502c9d44e45b46eb429f1cecf14..fd757809ff46b6221dc521ac409b53f4e78cda3c 100644 --- a/services/distributedhardwarefwkservice/src/publisher/publisher_item.cpp +++ b/services/distributedhardwarefwkservice/src/publisher/publisher_item.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 @@ -25,12 +25,12 @@ PublisherItem::PublisherItem() : topic_(DHTopic::TOPIC_MIN) PublisherItem::PublisherItem(DHTopic topic) : topic_(topic) { - DHLOGE("Ctor PublisherItem, topic: %d", topic); + DHLOGE("Ctor PublisherItem, topic: %{public}d", topic); } PublisherItem::~PublisherItem() { - DHLOGE("Dtor PublisherItem, topic: %d", topic_); + DHLOGE("Dtor PublisherItem, topic: %{public}d", topic_); std::lock_guard lock(mutex_); listeners_.clear(); } diff --git a/services/distributedhardwarefwkservice/src/resourcemanager/capability_info_manager.cpp b/services/distributedhardwarefwkservice/src/resourcemanager/capability_info_manager.cpp index 42d9d3763c2e33a9c62f364ebfa1c6b7a467504c..33bb1842fa6a9965bbcefbb381d1f4852ab54d19 100644 --- a/services/distributedhardwarefwkservice/src/resourcemanager/capability_info_manager.cpp +++ b/services/distributedhardwarefwkservice/src/resourcemanager/capability_info_manager.cpp @@ -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 @@ -75,7 +75,7 @@ void CapabilityInfoManager::CapabilityInfoManagerEventHandler::ProcessEvent( selfPtr->SyncRemoteCapabilityInfos(); break; default: - DHLOGE("event is undefined, id is %d", eventId); + DHLOGE("event is undefined, id is %{public}d", eventId); break; } } @@ -120,7 +120,7 @@ int32_t CapabilityInfoManager::UnInit() int32_t CapabilityInfoManager::SyncDeviceInfoFromDB(const std::string &deviceId) { - DHLOGI("Sync DeviceInfo from DB, deviceId: %s", GetAnonyString(deviceId).c_str()); + DHLOGI("Sync DeviceInfo from DB, deviceId: %{public}s", GetAnonyString(deviceId).c_str()); std::lock_guard lock(capInfoMgrMutex_); if (dbAdapterPtr_ == nullptr) { DHLOGE("dbAdapterPtr_ is null"); @@ -128,7 +128,7 @@ int32_t CapabilityInfoManager::SyncDeviceInfoFromDB(const std::string &deviceId) } std::vector dataVector; if (dbAdapterPtr_->GetDataByKeyPrefix(deviceId, dataVector) != DH_FWK_SUCCESS) { - DHLOGE("Query data from DB by deviceId failed, id: %s", GetAnonyString(deviceId).c_str()); + DHLOGE("Query data from DB by deviceId failed, id: %{public}s", GetAnonyString(deviceId).c_str()); return ERR_DH_FWK_RESOURCE_DB_ADAPTER_OPERATION_FAIL; } if (dataVector.size() == 0 || dataVector.size() > MAX_DB_RECORD_SIZE) { @@ -176,7 +176,7 @@ int32_t CapabilityInfoManager::SyncRemoteCapabilityInfos() continue; } if (!DHContext::GetInstance().IsDeviceOnline(deviceId)) { - DHLOGE("offline device, no need sync to memory, deviceId : %s ", GetAnonyString(deviceId).c_str()); + DHLOGE("offline device, no need sync to memory, deviceId : %{public}s ", GetAnonyString(deviceId).c_str()); continue; } globalCapInfoMap_[capabilityInfo->GetKey()] = capabilityInfo; @@ -207,10 +207,10 @@ int32_t CapabilityInfoManager::AddCapability(const std::vectorGetDataByKey(key, data) == DH_FWK_SUCCESS && CapabilityUtils::IsCapInfoJsonEqual(data, resInfo->ToJsonString())) { - DHLOGD("this record is exist, Key: %s", resInfo->GetAnonymousKey().c_str()); + DHLOGD("this record is exist, Key: %{public}s", resInfo->GetAnonymousKey().c_str()); continue; } - DHLOGI("AddCapability, Key: %s", resInfo->GetAnonymousKey().c_str()); + DHLOGI("AddCapability, Key: %{public}s", resInfo->GetAnonymousKey().c_str()); keys.push_back(key); values.push_back(resInfo->ToJsonString()); } @@ -233,7 +233,7 @@ int32_t CapabilityInfoManager::AddCapabilityInMem(const std::vectorGetKey(); - DHLOGI("AddCapabilityInMem, Key: %s", resInfo->GetAnonymousKey().c_str()); + DHLOGI("AddCapabilityInMem, Key: %{public}s", resInfo->GetAnonymousKey().c_str()); globalCapInfoMap_[key] = resInfo; } return DH_FWK_SUCCESS; @@ -245,7 +245,7 @@ int32_t CapabilityInfoManager::RemoveCapabilityInfoInDB(const std::string &devic DHLOGE("DeviceId is invalid!"); return ERR_DH_FWK_PARA_INVALID; } - DHLOGI("Remove capability device info, deviceId: %s", GetAnonyString(deviceId).c_str()); + DHLOGI("Remove capability device info, deviceId: %{public}s", GetAnonyString(deviceId).c_str()); std::lock_guard lock(capInfoMgrMutex_); if (dbAdapterPtr_ == nullptr) { DHLOGE("dbAdapterPtr_ is null"); @@ -257,12 +257,12 @@ int32_t CapabilityInfoManager::RemoveCapabilityInfoInDB(const std::string &devic iter++; continue; } - DHLOGI("Clear globalCapInfoMap_ iter: %s", GetAnonyString(iter->first).c_str()); + DHLOGI("Clear globalCapInfoMap_ iter: %{public}s", GetAnonyString(iter->first).c_str()); globalCapInfoMap_.erase(iter++); } // 2. Delete the corresponding record from the database(use UUID). if (dbAdapterPtr_->RemoveDeviceData(deviceId) != DH_FWK_SUCCESS) { - DHLOGE("Remove capability Device Data failed, deviceId: %s", GetAnonyString(deviceId).c_str()); + DHLOGE("Remove capability Device Data failed, deviceId: %{public}s", GetAnonyString(deviceId).c_str()); return ERR_DH_FWK_RESOURCE_DB_ADAPTER_OPERATION_FAIL; } return DH_FWK_SUCCESS; @@ -270,7 +270,7 @@ int32_t CapabilityInfoManager::RemoveCapabilityInfoInDB(const std::string &devic int32_t CapabilityInfoManager::RemoveCapabilityInfoByKey(const std::string &key) { - DHLOGI("Remove capability device info, key: %s", GetAnonyString(key).c_str()); + DHLOGI("Remove capability device info, key: %{public}s", GetAnonyString(key).c_str()); std::lock_guard lock(capInfoMgrMutex_); if (dbAdapterPtr_ == nullptr) { DHLOGE("dbAdapterPtr_ is null"); @@ -281,7 +281,7 @@ int32_t CapabilityInfoManager::RemoveCapabilityInfoByKey(const std::string &key) // 2. Delete the corresponding record from the database.(use key) if (dbAdapterPtr_->RemoveDataByKey(key) != DH_FWK_SUCCESS) { - DHLOGE("Remove capability Device Data failed, key: %s", GetAnonyString(key).c_str()); + DHLOGE("Remove capability Device Data failed, key: %{public}s", GetAnonyString(key).c_str()); return ERR_DH_FWK_RESOURCE_DB_ADAPTER_OPERATION_FAIL; } return DH_FWK_SUCCESS; @@ -289,7 +289,7 @@ int32_t CapabilityInfoManager::RemoveCapabilityInfoByKey(const std::string &key) int32_t CapabilityInfoManager::RemoveCapabilityInfoInMem(const std::string &deviceId) { - DHLOGI("remove capability device info in memory, deviceId: %s", GetAnonyString(deviceId).c_str()); + DHLOGI("remove capability device info in memory, deviceId: %{public}s", GetAnonyString(deviceId).c_str()); std::lock_guard lock(capInfoMgrMutex_); for (auto iter = globalCapInfoMap_.begin(); iter != globalCapInfoMap_.end();) { if (!CapabilityUtils::IsCapKeyMatchDeviceId(iter->first, deviceId)) { @@ -352,7 +352,7 @@ void CapabilityInfoManager::HandleCapabilityAddChange(const std::vectorGetKey(); - DHLOGI("Add capability key: %s", capPtr->GetAnonymousKey().c_str()); + DHLOGI("Add capability key: %{public}s", capPtr->GetAnonymousKey().c_str()); globalCapInfoMap_[keyString] = capPtr; std::string uuid = DHContext::GetInstance().GetUUIDByDeviceId(capPtr->GetDeviceId()); if (uuid.empty()) { @@ -361,7 +361,7 @@ void CapabilityInfoManager::HandleCapabilityAddChange(const std::vectorGetKey(); - DHLOGI("Update capability key: %s", capPtr->GetAnonymousKey().c_str()); + DHLOGI("Update capability key: %{public}s", capPtr->GetAnonymousKey().c_str()); globalCapInfoMap_[keyString] = capPtr; } } @@ -409,7 +409,7 @@ void CapabilityInfoManager::HandleCapabilityDeleteChange(const std::vectorGetAnonymousKey().c_str()); + DHLOGI("Delete capability key: %{public}s", capPtr->GetAnonymousKey().c_str()); globalCapInfoMap_.erase(keyString); } } @@ -496,7 +496,7 @@ int32_t CapabilityInfoManager::GetCapability(const std::string &deviceId, const std::lock_guard lock(capInfoMgrMutex_); std::string key = CapabilityUtils::GetCapabilityKey(deviceId, dhId); if (globalCapInfoMap_.find(key) == globalCapInfoMap_.end()) { - DHLOGE("Can not find capability In globalCapInfoMap_: %s", GetAnonyString(deviceId).c_str()); + DHLOGE("Can not find capability In globalCapInfoMap_: %{public}s", GetAnonyString(deviceId).c_str()); return ERR_DH_FWK_RESOURCE_CAPABILITY_MAP_NOT_FOUND; } capPtr = globalCapInfoMap_[key]; @@ -512,7 +512,7 @@ int32_t CapabilityInfoManager::GetDataByKey(const std::string &key, std::shared_ } std::string data; if (dbAdapterPtr_->GetDataByKey(key, data) != DH_FWK_SUCCESS) { - DHLOGE("Query capability info from db failed, key: %s", GetAnonyString(key).c_str()); + DHLOGE("Query capability info from db failed, key: %{public}s", GetAnonyString(key).c_str()); return ERR_DH_FWK_RESOURCE_DB_ADAPTER_OPERATION_FAIL; } return CapabilityUtils::GetCapabilityByValue(data, capInfoPtr); @@ -539,7 +539,7 @@ int32_t CapabilityInfoManager::GetDataByKeyPrefix(const std::string &keyPrefix, } std::vector dataVector; if (dbAdapterPtr_->GetDataByKeyPrefix(keyPrefix, dataVector) != DH_FWK_SUCCESS) { - DHLOGE("Query capability info from db failed, key: %s", GetAnonyString(keyPrefix).c_str()); + DHLOGE("Query capability info from db failed, key: %{public}s", GetAnonyString(keyPrefix).c_str()); return ERR_DH_FWK_RESOURCE_DB_ADAPTER_OPERATION_FAIL; } if (dataVector.size() == 0 || dataVector.size() > MAX_DB_RECORD_SIZE) { @@ -553,7 +553,7 @@ int32_t CapabilityInfoManager::GetDataByKeyPrefix(const std::string &keyPrefix, continue; } if (capabilityInfo->FromJsonString(data) != DH_FWK_SUCCESS) { - DHLOGE("Wrong data: %s", GetAnonyString(data).c_str()); + DHLOGE("Wrong data: %{public}s", GetAnonyString(data).c_str()); continue; } capabilityMap[capabilityInfo->GetKey()] = capabilityInfo; diff --git a/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp b/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp index 6775bdc8adb4fe1e88bbb33fb7e3777f11f3c342..0dc1e4df89b80e957c80a4a53c9497b76c6a5f5e 100644 --- a/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp +++ b/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp @@ -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 @@ -47,7 +47,7 @@ DBAdapter::DBAdapter(const std::string &appId, const std::string &storeId, this->appId_.appId = appId; this->storeId_.storeId = storeId; this->dataChangeListener_ = changeListener; - DHLOGI("DBAdapter Constructor Success, appId: %s, storeId: %s", appId.c_str(), storeId.c_str()); + DHLOGI("DBAdapter Constructor Success, appId: %{public}s, storeId: %{public}s", appId.c_str(), storeId.c_str()); } DBAdapter::~DBAdapter() @@ -75,7 +75,7 @@ DistributedKv::Status DBAdapter::GetKvStorePtr() int32_t DBAdapter::Init() { - DHLOGI("Init DB, storeId: %s", storeId_.storeId.c_str()); + DHLOGI("Init DB, storeId: %{public}s", storeId_.storeId.c_str()); std::lock_guard lock(dbAdapterMutex_); int32_t tryTimes = MAX_INIT_RETRY_TIMES; while (tryTimes > 0) { @@ -86,7 +86,7 @@ int32_t DBAdapter::Init() RegisterKvStoreDeathListener(); return DH_FWK_SUCCESS; } - DHLOGD("CheckKvStore, left times: %d", tryTimes); + DHLOGD("CheckKvStore, left times: %{public}d", tryTimes); usleep(INIT_RETRY_SLEEP_INTERVAL); tryTimes--; } @@ -112,7 +112,7 @@ void DBAdapter::UnInit() int32_t DBAdapter::ReInit() { - DHLOGI("ReInit DB, storeId: %s", storeId_.storeId.c_str()); + DHLOGI("ReInit DB, storeId: %{public}s", storeId_.storeId.c_str()); std::lock_guard lock(dbAdapterMutex_); if (kvStoragePtr_ == nullptr) { DHLOGE("kvStoragePtr_ is null"); @@ -121,7 +121,7 @@ int32_t DBAdapter::ReInit() kvStoragePtr_.reset(); DistributedKv::Status status = GetKvStorePtr(); if (status != DistributedKv::Status::SUCCESS || !kvStoragePtr_) { - DHLOGW("Get kvStoragePtr_ failed, status: %d", status); + DHLOGW("Get kvStoragePtr_ failed, status: %{public}d", status); return ERR_DH_FWK_RESOURCE_KV_STORAGE_OPERATION_FAIL; } RegisterKvStoreDeathListener(); @@ -130,7 +130,7 @@ int32_t DBAdapter::ReInit() int32_t DBAdapter::GetDataByKey(const std::string &key, std::string &data) { - DHLOGI("Get data by key: %s", GetAnonyString(key).c_str()); + DHLOGI("Get data by key: %{public}s", GetAnonyString(key).c_str()); std::lock_guard lock(dbAdapterMutex_); if (kvStoragePtr_ == nullptr) { DHLOGE("kvStoragePtr_ is null"); @@ -140,7 +140,7 @@ 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::SUCCESS) { - DHLOGE("Query from db failed, key: %s", GetAnonyString(key).c_str()); + DHLOGE("Query from db failed, key: %{public}s", GetAnonyString(key).c_str()); return ERR_DH_FWK_RESOURCE_KV_STORAGE_OPERATION_FAIL; } data = kvValue.ToString(); @@ -149,7 +149,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: %s", GetAnonyString(keyPrefix).c_str()); + DHLOGI("Get data by key prefix: %{public}s", GetAnonyString(keyPrefix).c_str()); std::lock_guard lock(dbAdapterMutex_); if (kvStoragePtr_ == nullptr) { DHLOGE("kvStoragePtr_ is null"); @@ -161,7 +161,7 @@ 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) { - DHLOGE("Query data by keyPrefix failed, prefix: %s", + DHLOGE("Query data by keyPrefix failed, prefix: %{public}s", GetAnonyString(keyPrefix).c_str()); return ERR_DH_FWK_RESOURCE_KV_STORAGE_OPERATION_FAIL; } @@ -190,7 +190,7 @@ int32_t DBAdapter::PutData(const std::string &key, const std::string &value) DistributedKv::Value kvValue(value); DistributedKv::Status status = kvStoragePtr_->Put(kvKey, kvValue); if (status == DistributedKv::Status::IPC_ERROR) { - DHLOGE("Put kv to db failed, ret: %d", status); + DHLOGE("Put kv to db failed, ret: %{public}d", status); return ERR_DH_FWK_RESOURCE_KV_STORAGE_OPERATION_FAIL; } return DH_FWK_SUCCESS; @@ -216,7 +216,7 @@ int32_t DBAdapter::PutDataBatch(const std::vector &keys, const std: } DistributedKv::Status status = kvStoragePtr_->PutBatch(entries); if (status != DistributedKv::Status::SUCCESS) { - DHLOGE("Put kv batch to db failed, ret: %d", status); + DHLOGE("Put kv batch to db failed, ret: %{public}d", status); return ERR_DH_FWK_RESOURCE_KV_STORAGE_OPERATION_FAIL; } DHLOGI("Put kv batch to db success"); @@ -225,7 +225,7 @@ int32_t DBAdapter::PutDataBatch(const std::vector &keys, const std: void DBAdapter::SyncDBForRecover() { - DHLOGI("Sync store id: %s after db recover", storeId_.storeId.c_str()); + DHLOGI("Sync store id: %{public}s after db recover", storeId_.storeId.c_str()); if (storeId_.storeId == GLOBAL_CAPABILITY_ID) { AppExecFwk::InnerEvent::Pointer msgEvent = AppExecFwk::InnerEvent::Get(EVENT_CAPABILITY_INFO_DB_RECOVER); CapabilityInfoManager::GetInstance()->GetEventHandler()->SendEvent(msgEvent, @@ -249,7 +249,7 @@ int32_t DBAdapter::RegisterChangeListener() DistributedKv::Status status = kvStoragePtr_->SubscribeKvStore(DistributedKv::SubscribeType::SUBSCRIBE_TYPE_REMOTE, dataChangeListener_); if (status == DistributedKv::Status::IPC_ERROR) { - DHLOGE("Register db data change listener failed, ret: %d", status); + DHLOGE("Register db data change listener failed, ret: %{public}d", status); return ERR_DH_FWK_RESOURCE_REGISTER_DB_FAILED; } return DH_FWK_SUCCESS; @@ -265,7 +265,7 @@ int32_t DBAdapter::UnRegisterChangeListener() DistributedKv::Status status = kvStoragePtr_->UnSubscribeKvStore( DistributedKv::SubscribeType::SUBSCRIBE_TYPE_REMOTE, dataChangeListener_); if (status == DistributedKv::Status::IPC_ERROR) { - DHLOGE("UnRegister db data change listener failed, ret: %d", status); + DHLOGE("UnRegister db data change listener failed, ret: %{public}d", status); return ERR_DH_FWK_RESOURCE_UNREGISTER_DB_FAILED; } return DH_FWK_SUCCESS; @@ -294,7 +294,7 @@ void DBAdapter::OnRemoteDied() // register data change listener again. this->RegisterChangeListener(); this->SyncDBForRecover(); - DHLOGE("Current times is %d", times); + DHLOGE("Current times is %{public}d", times); break; } times++; @@ -310,11 +310,11 @@ void DBAdapter::DeleteKvStore() std::lock_guard lock(dbAdapterMutex_); DistributedKv::Status status = kvDataMgr_.DeleteKvStore(appId_, storeId_); if (status != DistributedKv::Status::SUCCESS) { - DHLOGE("DeleteKvStore error, appId: %s, storeId: %s, status: %d", + DHLOGE("DeleteKvStore error, appId: %{public}s, storeId: %{public}s, status: %{public}d", appId_.appId.c_str(), storeId_.storeId.c_str(), status); return; } - DHLOGI("DeleteKvStore success appId: %s", appId_.appId.c_str()); + DHLOGI("DeleteKvStore success appId: %{public}s", appId_.appId.c_str()); } int32_t DBAdapter::RemoveDeviceData(const std::string &deviceId) @@ -326,10 +326,10 @@ int32_t DBAdapter::RemoveDeviceData(const std::string &deviceId) } DistributedKv::Status status = kvStoragePtr_->RemoveDeviceData(deviceId); if (status != DistributedKv::Status::SUCCESS) { - DHLOGE("Remove device data failed, deviceId: %s", GetAnonyString(deviceId).c_str()); + DHLOGE("Remove device data failed, deviceId: %{public}s", GetAnonyString(deviceId).c_str()); return ERR_DH_FWK_RESOURCE_KV_STORAGE_OPERATION_FAIL; } - DHLOGD("Remove device data success, deviceId: %s", GetAnonyString(deviceId).c_str()); + DHLOGD("Remove device data success, deviceId: %{public}s", GetAnonyString(deviceId).c_str()); return DH_FWK_SUCCESS; } diff --git a/services/distributedhardwarefwkservice/src/resourcemanager/version_info_manager.cpp b/services/distributedhardwarefwkservice/src/resourcemanager/version_info_manager.cpp index 3ee76d2639af38640c40c17bc9ac151c4a5edbc2..476f1d51d5b85765f934fa5eaea74b7097e00ce7 100644 --- a/services/distributedhardwarefwkservice/src/resourcemanager/version_info_manager.cpp +++ b/services/distributedhardwarefwkservice/src/resourcemanager/version_info_manager.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 @@ -61,7 +61,7 @@ void VersionInfoManager::VersionInfoManagerEventHandler::ProcessEvent(const AppE selfPtr->SyncRemoteVersionInfos(); break; default: - DHLOGE("event is undefined, id is %d", eventId); + DHLOGE("event is undefined, id is %{public}d", eventId); break; } } @@ -122,13 +122,13 @@ int32_t VersionInfoManager::AddVersion(const VersionInfo &versionInfo) std::string data(""); dbAdapterPtr_->GetDataByKey(versionInfo.deviceId, data); if (data.compare(versionInfo.ToJsonString()) == 0) { - DHLOGI("dhversion already stored, Key: %s", GetAnonyString(versionInfo.deviceId).c_str()); + DHLOGI("dhversion already stored, Key: %{public}s", GetAnonyString(versionInfo.deviceId).c_str()); return DH_FWK_SUCCESS; } std::string key = versionInfo.deviceId; std::string value = versionInfo.ToJsonString(); - DHLOGI("AddVersion, Key: %s", GetAnonyString(versionInfo.deviceId).c_str()); + DHLOGI("AddVersion, Key: %{public}s", GetAnonyString(versionInfo.deviceId).c_str()); if (dbAdapterPtr_->PutData(key, value) != DH_FWK_SUCCESS) { DHLOGE("Fail to storage to kv"); return ERR_DH_FWK_RESOURCE_DB_ADAPTER_OPERATION_FAIL; @@ -145,7 +145,7 @@ int32_t VersionInfoManager::GetVersionInfoByDeviceId(const std::string &deviceId } std::string data(""); if (dbAdapterPtr_->GetDataByKey(deviceId, data) != DH_FWK_SUCCESS) { - DHLOGE("Query data from DB by deviceId failed, deviceId: %s", GetAnonyString(deviceId).c_str()); + DHLOGE("Query data from DB by deviceId failed, deviceId: %{public}s", GetAnonyString(deviceId).c_str()); return ERR_DH_FWK_RESOURCE_DB_ADAPTER_OPERATION_FAIL; } return versionInfo.FromJsonString(data); @@ -155,7 +155,7 @@ void VersionInfoManager::UpdateVersionCache(const VersionInfo &versionInfo) { std::string uuid = DHContext::GetInstance().GetUUIDByDeviceId(versionInfo.deviceId); if (uuid.empty()) { - DHLOGI("Find uuid failed, deviceId: %s", GetAnonyString(versionInfo.deviceId).c_str()); + DHLOGI("Find uuid failed, deviceId: %{public}s", GetAnonyString(versionInfo.deviceId).c_str()); return; } DHVersion dhVersion; @@ -167,7 +167,7 @@ void VersionInfoManager::UpdateVersionCache(const VersionInfo &versionInfo) int32_t VersionInfoManager::RemoveVersionInfoByDeviceId(const std::string &deviceId) { - DHLOGI("Remove version device info, key: %s", GetAnonyString(deviceId).c_str()); + DHLOGI("Remove version device info, key: %{public}s", GetAnonyString(deviceId).c_str()); std::lock_guard lock(verInfoMgrMutex_); if (dbAdapterPtr_ == nullptr) { DHLOGE("dbAdapterPtr_ is null"); @@ -175,16 +175,16 @@ int32_t VersionInfoManager::RemoveVersionInfoByDeviceId(const std::string &devic } if (dbAdapterPtr_->RemoveDataByKey(deviceId) != DH_FWK_SUCCESS) { - DHLOGE("Remove version info failed, key: %s", GetAnonyString(deviceId).c_str()); + DHLOGE("Remove version info failed, key: %{public}s", GetAnonyString(deviceId).c_str()); return ERR_DH_FWK_RESOURCE_DB_ADAPTER_OPERATION_FAIL; } std::string uuid = DHContext::GetInstance().GetUUIDByDeviceId(deviceId); if (uuid.empty()) { - DHLOGI("Find uuid failed, deviceId: %s", GetAnonyString(deviceId).c_str()); + DHLOGI("Find uuid failed, deviceId: %{public}s", GetAnonyString(deviceId).c_str()); return ERR_DH_FWK_RESOURCE_UUID_NOT_FOUND; } - DHLOGI("Delete version ,uuid: %s", GetAnonyString(uuid).c_str()); + DHLOGI("Delete version ,uuid: %{public}s", GetAnonyString(uuid).c_str()); VersionManager::GetInstance().RemoveDHVersion(uuid); return DH_FWK_SUCCESS; @@ -192,7 +192,7 @@ int32_t VersionInfoManager::RemoveVersionInfoByDeviceId(const std::string &devic int32_t VersionInfoManager::SyncVersionInfoFromDB(const std::string &deviceId) { - DHLOGI("Sync versionInfo from DB, deviceId: %s", GetAnonyString(deviceId).c_str()); + DHLOGI("Sync versionInfo from DB, deviceId: %{public}s", GetAnonyString(deviceId).c_str()); std::lock_guard lock(verInfoMgrMutex_); if (dbAdapterPtr_ == nullptr) { DHLOGE("dbAdapterPtr_ is null"); @@ -200,11 +200,11 @@ int32_t VersionInfoManager::SyncVersionInfoFromDB(const std::string &deviceId) } std::string data(""); if (dbAdapterPtr_->GetDataByKey(deviceId, data) != DH_FWK_SUCCESS) { - DHLOGE("Query data from DB by deviceId failed, deviceId: %s", GetAnonyString(deviceId).c_str()); + DHLOGE("Query data from DB by deviceId failed, deviceId: %{public}s", GetAnonyString(deviceId).c_str()); return ERR_DH_FWK_RESOURCE_DB_ADAPTER_OPERATION_FAIL; } - DHLOGI("Query data from DB by deviceId success, deviceId: %s", GetAnonyString(deviceId).c_str()); + DHLOGI("Query data from DB by deviceId success, deviceId: %{public}s", GetAnonyString(deviceId).c_str()); VersionInfo versionInfo; int32_t ret = versionInfo.FromJsonString(data); if (ret != DH_FWK_SUCCESS) { @@ -243,7 +243,7 @@ int32_t VersionInfoManager::SyncRemoteVersionInfos() continue; } if (!DHContext::GetInstance().IsDeviceOnline(deviceId)) { - DHLOGE("Offline device, no need sync to memory, deviceId : %s ", + DHLOGE("Offline device, no need sync to memory, deviceId : %{public}s ", GetAnonyString(deviceId).c_str()); continue; } @@ -309,10 +309,10 @@ void VersionInfoManager::HandleVersionDeleteChange(const std::vector { TaskStep::DO_DISABLE }); - DHLOGD("id = %s, uuid = %s", GetId().c_str(), GetAnonyString(uuid).c_str()); + DHLOGD("id = %{public}s, uuid = %{public}s", GetId().c_str(), GetAnonyString(uuid).c_str()); } DisableTask::~DisableTask() { - DHLOGD("id = %s, uuid = %s", GetId().c_str(), GetAnonyString(GetUUID()).c_str()); + DHLOGD("id = %{public}s, uuid = %{public}s", GetId().c_str(), GetAnonyString(GetUUID()).c_str()); } void DisableTask::DoTask() @@ -57,7 +57,7 @@ void DisableTask::DoTaskInner() if (ret != DH_FWK_SUCCESS) { DHLOGE("DoTaskInner setname failed."); } - DHLOGD("id = %s, uuid = %s, dhId = %s", GetId().c_str(), GetAnonyString(GetUUID()).c_str(), + DHLOGD("id = %{public}s, uuid = %{public}s, dhId = %{public}s", GetId().c_str(), GetAnonyString(GetUUID()).c_str(), GetAnonyString(GetDhId()).c_str()); SetTaskState(TaskState::RUNNING); @@ -72,7 +72,7 @@ void DisableTask::DoTaskInner() auto offLineTask = std::static_pointer_cast(father); offLineTask->NotifyFatherFinish(GetId()); } - DHLOGD("finish disable task, remove it, id = %s", GetId().c_str()); + DHLOGD("finish disable task, remove it, id = %{public}s", GetId().c_str()); TaskBoard::GetInstance().RemoveTask(GetId()); if (result == DH_FWK_SUCCESS) { std::string enabledDeviceKey = CapabilityUtils::GetCapabilityKey(GetDeviceIdByUUID(GetUUID()), GetDhId()); @@ -84,8 +84,9 @@ int32_t DisableTask::UnRegisterHardware() { DHCompMgrTraceStart(GetAnonyString(GetNetworkId()), GetAnonyString(GetDhId()), DH_DISABLE_START); auto result = ComponentManager::GetInstance().Disable(GetNetworkId(), GetUUID(), GetDhId(), GetDhType()); - DHLOGI("disable task %s, id = %s, uuid = %s, dhId = %s", (result == DH_FWK_SUCCESS) ? "success" : "failed", - GetId().c_str(), GetAnonyString(GetUUID()).c_str(), GetAnonyString(GetDhId()).c_str()); + DHLOGI("disable task %{public}s, id = %{public}s, uuid = %{public}s, dhId = %{public}s", + (result == DH_FWK_SUCCESS) ? "success" : "failed", GetId().c_str(), GetAnonyString(GetUUID()).c_str(), + GetAnonyString(GetDhId()).c_str()); DHTraceEnd(); return result; } diff --git a/services/distributedhardwarefwkservice/src/task/enable_task.cpp b/services/distributedhardwarefwkservice/src/task/enable_task.cpp index 6d5c346a60c0ef716094796277aeb45b9c726147..cdf314d834390e476c72faa09dd02d0c3914b38e 100644 --- a/services/distributedhardwarefwkservice/src/task/enable_task.cpp +++ b/services/distributedhardwarefwkservice/src/task/enable_task.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 @@ -37,12 +37,12 @@ EnableTask::EnableTask(const std::string &networkId, const std::string &uuid, co { SetTaskType(TaskType::ENABLE); SetTaskSteps(std::vector { TaskStep::DO_ENABLE }); - DHLOGD("id = %s, uuid = %s", GetId().c_str(), GetAnonyString(uuid).c_str()); + DHLOGD("id = %{public}s, uuid = %{public}s", GetId().c_str(), GetAnonyString(uuid).c_str()); } EnableTask::~EnableTask() { - DHLOGD("id = %s, uuid = %s", GetId().c_str(), GetAnonyString(GetUUID()).c_str()); + DHLOGD("id = %{public}s, uuid = %{public}s", GetId().c_str(), GetAnonyString(GetUUID()).c_str()); } void EnableTask::DoTask() @@ -56,13 +56,13 @@ void EnableTask::DoTaskInner() if (ret != DH_FWK_SUCCESS) { DHLOGE("DoTaskInner setname failed."); } - DHLOGD("id = %s, uuid = %s, dhId = %s", GetId().c_str(), GetAnonyString(GetUUID()).c_str(), + DHLOGD("id = %{public}s, uuid = %{public}s, dhId = %{public}s", GetId().c_str(), GetAnonyString(GetUUID()).c_str(), GetAnonyString(GetDhId()).c_str()); SetTaskState(TaskState::RUNNING); auto result = RegisterHardware(); auto state = (result == DH_FWK_SUCCESS) ? TaskState::SUCCESS : TaskState::FAIL; SetTaskState(state); - DHLOGD("finish enable task, remove it, id = %s", GetId().c_str()); + DHLOGD("finish enable task, remove it, id = %{public}s", GetId().c_str()); if (result == DH_FWK_SUCCESS) { TaskParam taskParam = { .networkId = GetNetworkId(), @@ -80,8 +80,9 @@ int32_t EnableTask::RegisterHardware() { DHCompMgrTraceStart(GetAnonyString(GetNetworkId()), GetAnonyString(GetDhId()), DH_ENABLE_START); auto result = ComponentManager::GetInstance().Enable(GetNetworkId(), GetUUID(), GetDhId(), GetDhType()); - DHLOGI("enable task %s, id = %s, uuid = %s, dhId = %s", (result == DH_FWK_SUCCESS) ? "success" : "failed", - GetId().c_str(), GetAnonyString(GetUUID()).c_str(), GetAnonyString(GetDhId()).c_str()); + DHLOGI("enable task %{public}s, id = %{public}s, uuid = %{public}s, dhId = %{public}s", + (result == DH_FWK_SUCCESS) ? "success" : "failed", GetId().c_str(), GetAnonyString(GetUUID()).c_str(), + GetAnonyString(GetDhId()).c_str()); DHTraceEnd(); return result; } diff --git a/services/distributedhardwarefwkservice/src/task/monitor_task_timer.cpp b/services/distributedhardwarefwkservice/src/task/monitor_task_timer.cpp index e8a1e0d59fcce9ff8c7606c3638ad4da477ae97b..6bc274558d62878706ab7d59fa4db57dc2c15aa5 100644 --- a/services/distributedhardwarefwkservice/src/task/monitor_task_timer.cpp +++ b/services/distributedhardwarefwkservice/src/task/monitor_task_timer.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 @@ -52,9 +52,10 @@ void MonitorTaskTimer::ExecuteInner() continue; } if (CapabilityInfoManager::GetInstance()->GetDataByKey(capabilityKey, capInfoPtr) != DH_FWK_SUCCESS) { - DHLOGI("CapabilityInfoManager can not find this key in DB, key: %s, networkId: %s, uuid: %s, dhId: %s", - GetAnonyString(capabilityKey).c_str(), GetAnonyString(taskParam.networkId).c_str(), - GetAnonyString(taskParam.uuid).c_str(), GetAnonyString(taskParam.dhId).c_str()); + DHLOGI("CapabilityInfoManager can not find this key in DB, key: %{public}s, networkId: %{public}s, " + "uuid: %{public}s, dhId: %{public}s", GetAnonyString(capabilityKey).c_str(), + GetAnonyString(taskParam.networkId).c_str(), GetAnonyString(taskParam.uuid).c_str(), + GetAnonyString(taskParam.dhId).c_str()); auto task = TaskFactory::GetInstance().CreateTask(TaskType::DISABLE, taskParam, nullptr); TaskExecutor::GetInstance().PushTask(task); } diff --git a/services/distributedhardwarefwkservice/src/task/offline_task.cpp b/services/distributedhardwarefwkservice/src/task/offline_task.cpp index dcfdaa79859639a49d11928f02b2a53e2d23ccc4..6fa6aadcafe49e18f17ed0f41a4671bc898cadc4 100644 --- a/services/distributedhardwarefwkservice/src/task/offline_task.cpp +++ b/services/distributedhardwarefwkservice/src/task/offline_task.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 @@ -39,12 +39,12 @@ OffLineTask::OffLineTask(const std::string &networkId, const std::string &uuid, this->SetTaskType(TaskType::OFF_LINE); this->SetTaskSteps({TaskStep::UNREGISTER_OFFLINE_DISTRIBUTED_HARDWARE, TaskStep::WAIT_UNREGISTGER_COMPLETE, TaskStep::CLEAR_OFFLINE_INFO}); - DHLOGD("id = %s, uuid = %s", GetId().c_str(), GetAnonyString(uuid).c_str()); + DHLOGD("id = %{public}s, uuid = %{public}s", GetId().c_str(), GetAnonyString(uuid).c_str()); } OffLineTask::~OffLineTask() { - DHLOGD("id = %s, uuid = %s", GetId().c_str(), GetAnonyString(GetUUID()).c_str()); + DHLOGD("id = %{public}s, uuid = %{public}s", GetId().c_str(), GetAnonyString(GetUUID()).c_str()); } void OffLineTask::DoTask() @@ -58,7 +58,8 @@ void OffLineTask::DoTaskInner() if (ret != DH_FWK_SUCCESS) { DHLOGE("DoTaskInner setname failed."); } - DHLOGD("start offline task, id = %s, uuid = %s", GetId().c_str(), GetAnonyString(GetUUID()).c_str()); + DHLOGD("start offline task, id = %{public}s, uuid = %{public}s", GetId().c_str(), + GetAnonyString(GetUUID()).c_str()); this->SetTaskState(TaskState::RUNNING); for (const auto& step : this->GetTaskSteps()) { switch (step) { @@ -81,17 +82,19 @@ void OffLineTask::DoTaskInner() } this->SetTaskState(TaskState::SUCCESS); - DHLOGD("Finish OffLine task, remove it, id: %s", GetId().c_str()); + DHLOGD("Finish OffLine task, remove it, id: %{public}s", GetId().c_str()); TaskBoard::GetInstance().RemoveTask(this->GetId()); } void OffLineTask::CreateDisableTask() { - DHLOGI("networkId = %s, uuid = %s", GetAnonyString(GetNetworkId()).c_str(), GetAnonyString(GetUUID()).c_str()); + DHLOGI("networkId = %{public}s, uuid = %{public}s", GetAnonyString(GetNetworkId()).c_str(), + GetAnonyString(GetUUID()).c_str()); std::vector> capabilityInfos; CapabilityInfoManager::GetInstance()->GetCapabilitiesByDeviceId(GetDeviceIdByUUID(GetUUID()), capabilityInfos); if (capabilityInfos.empty()) { - DHLOGE("capabilityInfos is empty, can not create disableTask, uuid = %s", GetAnonyString(GetUUID()).c_str()); + DHLOGE("capabilityInfos is empty, can not create disableTask, uuid = %{public}s", + GetAnonyString(GetUUID()).c_str()); return; } for (const auto &iter : capabilityInfos) { @@ -120,10 +123,11 @@ void OffLineTask::WaitDisableTaskFinish() void OffLineTask::ClearOffLineInfo() { - DHLOGI("start clear resource when device offline, uuid = %s", GetAnonyString(GetUUID()).c_str()); + DHLOGI("start clear resource when device offline, uuid = %{public}s", GetAnonyString(GetUUID()).c_str()); auto ret = CapabilityInfoManager::GetInstance()->RemoveCapabilityInfoInMem(GetDeviceIdByUUID(GetUUID())); if (ret != DH_FWK_SUCCESS) { - DHLOGE("RemoveCapabilityInfoInMem failed, uuid = %s, errCode = %d", GetAnonyString(GetUUID()).c_str(), ret); + DHLOGE("RemoveCapabilityInfoInMem failed, uuid = %{public}s, errCode = %{public}d", + GetAnonyString(GetUUID()).c_str(), ret); } } diff --git a/services/distributedhardwarefwkservice/src/task/online_task.cpp b/services/distributedhardwarefwkservice/src/task/online_task.cpp index 3b3ae0a69c8c7028053e9da97ecf01573ad7955a..44511ded8a96d77504b09457c1b290fe8d0e9435 100644 --- a/services/distributedhardwarefwkservice/src/task/online_task.cpp +++ b/services/distributedhardwarefwkservice/src/task/online_task.cpp @@ -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 @@ -35,17 +35,17 @@ OnLineTask::OnLineTask(const std::string &networkId, const std::string &uuid, co { SetTaskType(TaskType::ON_LINE); SetTaskSteps(std::vector { TaskStep::SYNC_ONLINE_INFO, TaskStep::REGISTER_ONLINE_DISTRIBUTED_HARDWARE }); - DHLOGD("id = %s, uuid = %s", GetId().c_str(), GetAnonyString(uuid).c_str()); + DHLOGD("id = %{public}s, uuid = %{public}s", GetId().c_str(), GetAnonyString(uuid).c_str()); } OnLineTask::~OnLineTask() { - DHLOGD("id = %s, uuid = %s", GetId().c_str(), GetAnonyString(GetUUID()).c_str()); + DHLOGD("id = %{public}s, uuid = %{public}s", GetId().c_str(), GetAnonyString(GetUUID()).c_str()); } void OnLineTask::DoTask() { - DHLOGD("start online task, id = %s, uuid = %s", GetId().c_str(), GetAnonyString(GetUUID()).c_str()); + DHLOGD("start online task, id = %{public}s, uuid = %{public}s", GetId().c_str(), GetAnonyString(GetUUID()).c_str()); this->SetTaskState(TaskState::RUNNING); for (const auto& step : this->GetTaskSteps()) { switch (step) { @@ -63,7 +63,7 @@ void OnLineTask::DoTask() } } SetTaskState(TaskState::SUCCESS); - DHLOGD("finish online task, remove it, id = %s.", GetId().c_str()); + DHLOGD("finish online task, remove it, id = %{public}s.", GetId().c_str()); TaskBoard::GetInstance().RemoveTask(this->GetId()); } @@ -71,22 +71,26 @@ void OnLineTask::DoSyncInfo() { auto ret = CapabilityInfoManager::GetInstance()->SyncDeviceInfoFromDB(GetDeviceIdByUUID(GetUUID())); if (ret != DH_FWK_SUCCESS) { - DHLOGE("SyncDeviceInfoFromDB failed, uuid = %s, errCode = %d", GetAnonyString(GetUUID()).c_str(), ret); + DHLOGE("SyncDeviceInfoFromDB failed, uuid = %{public}s, errCode = %{public}d", + GetAnonyString(GetUUID()).c_str(), ret); } ret = VersionInfoManager::GetInstance()->SyncVersionInfoFromDB(GetDeviceIdByUUID(GetUUID())); if (ret != DH_FWK_SUCCESS) { - DHLOGE("SyncVersionInfoFromDB failed, uuid = %s, errCode = %d", GetAnonyString(GetUUID()).c_str(), ret); + DHLOGE("SyncVersionInfoFromDB failed, uuid = %{public}s, errCode = %{public}d", + GetAnonyString(GetUUID()).c_str(), ret); } } void OnLineTask::CreateEnableTask() { - DHLOGI("networkId = %s, uuid = %s", GetAnonyString(GetNetworkId()).c_str(), GetAnonyString(GetUUID()).c_str()); + DHLOGI("networkId = %{public}s, uuid = %{public}s", GetAnonyString(GetNetworkId()).c_str(), + GetAnonyString(GetUUID()).c_str()); std::vector> capabilityInfos; CapabilityInfoManager::GetInstance()->GetCapabilitiesByDeviceId(GetDeviceIdByUUID(GetUUID()), capabilityInfos); if (capabilityInfos.empty()) { - DHLOGE("capabilityInfos is empty, can not create enableTask, uuid = %s", GetAnonyString(GetUUID()).c_str()); + DHLOGE("capabilityInfos is empty, can not create enableTask, uuid = %{public}s", + GetAnonyString(GetUUID()).c_str()); return; } for (const auto &iter : capabilityInfos) { diff --git a/services/distributedhardwarefwkservice/src/task/task_board.cpp b/services/distributedhardwarefwkservice/src/task/task_board.cpp index 9e313b7e4711a659de9bd716649450fa3d730f17..98d675290ceb44793b547a2881d1249291b18d58 100644 --- a/services/distributedhardwarefwkservice/src/task/task_board.cpp +++ b/services/distributedhardwarefwkservice/src/task/task_board.cpp @@ -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 @@ -59,9 +59,9 @@ void TaskBoard::AddTask(std::shared_ptr task) } std::lock_guard lock(tasksMtx_); - DHLOGI("Add task, id: %s", task->GetId().c_str()); + DHLOGI("Add task, id: %{public}s", task->GetId().c_str()); if (this->tasks_.find(task->GetId()) != this->tasks_.end()) { - DHLOGE("Task id duplicate, id: %s", task->GetId().c_str()); + DHLOGE("Task id duplicate, id: %{public}s", task->GetId().c_str()); return; } this->tasks_.emplace(task->GetId(), task); @@ -70,7 +70,7 @@ void TaskBoard::AddTask(std::shared_ptr task) void TaskBoard::RemoveTask(std::string taskId) { std::lock_guard lock(tasksMtx_); - DHLOGI("Remove task, id: %s", taskId.c_str()); + DHLOGI("Remove task, id: %{public}s", taskId.c_str()); RemoveTaskInner(taskId); if (tasks_.empty()) { conVar_.notify_one(); @@ -107,14 +107,14 @@ void TaskBoard::DumpAllTasks(std::vector &taskInfos) void TaskBoard::SaveEnabledDevice(const std::string &enabledDeviceKey, const TaskParam &taskParam) { std::lock_guard lock(enabledDevicesMutex_); - DHLOGI("SaveEnabledDevice key is %s", GetAnonyString(enabledDeviceKey).c_str()); + DHLOGI("SaveEnabledDevice key is %{public}s", GetAnonyString(enabledDeviceKey).c_str()); enabledDevices_[enabledDeviceKey] = taskParam; } void TaskBoard::RemoveEnabledDevice(const std::string &enabledDeviceKey) { std::lock_guard lock(enabledDevicesMutex_); - DHLOGI("RemoveEnabledDevice key is %s", GetAnonyString(enabledDeviceKey).c_str()); + DHLOGI("RemoveEnabledDevice key is %{public}s", GetAnonyString(enabledDeviceKey).c_str()); enabledDevices_.erase(enabledDeviceKey); } diff --git a/services/distributedhardwarefwkservice/src/task/task_executor.cpp b/services/distributedhardwarefwkservice/src/task/task_executor.cpp index 8b3e0e59186a46d393e1362e4ada062c24309911..7bc0b4c3cdcbba6894899fa319c904472aa60ef2 100644 --- a/services/distributedhardwarefwkservice/src/task/task_executor.cpp +++ b/services/distributedhardwarefwkservice/src/task/task_executor.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 @@ -49,7 +49,7 @@ void TaskExecutor::PushTask(const std::shared_ptr& task) } { - DHLOGI("Push task: %s", task->GetId().c_str()); + DHLOGI("Push task: %{public}s", task->GetId().c_str()); std::unique_lock lock(taskQueueMtx_); if (taskQueue_.size() > MAX_TASK_QUEUE_LENGTH) { DHLOGE("Task queue is full"); @@ -73,7 +73,7 @@ std::shared_ptr TaskExecutor::PopTask() if (!taskQueue_.empty()) { task = taskQueue_.front(); taskQueue_.pop(); - DHLOGI("Pop task: %s", task->GetId().c_str()); + DHLOGI("Pop task: %{public}s", task->GetId().c_str()); } return task; @@ -96,7 +96,7 @@ void TaskExecutor::TriggerTask() task->DoTask(); }; - DHLOGI("Post task to EventBus: %s", task->GetId().c_str()); + DHLOGI("Post task to EventBus: %{public}s", task->GetId().c_str()); DHContext::GetInstance().GetEventHandler()->PostTask(taskFunc, task->GetId()); } } diff --git a/services/distributedhardwarefwkservice/src/task/task_factory.cpp b/services/distributedhardwarefwkservice/src/task/task_factory.cpp index 9886365a96447eebce65ce3552f1e17f368ddc38..d20aecb3af5b2638bca63969977ce8e00d36bc22 100644 --- a/services/distributedhardwarefwkservice/src/task/task_factory.cpp +++ b/services/distributedhardwarefwkservice/src/task/task_factory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 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 @@ -31,7 +31,7 @@ namespace DistributedHardware { IMPLEMENT_SINGLE_INSTANCE(TaskFactory); std::shared_ptr TaskFactory::CreateTask(TaskType taskType, TaskParam taskParam, std::shared_ptr fatherTask) { - DHLOGI("taskType = %d, networkId = %s, uuid = %s, dhId = %s", + DHLOGI("taskType = %{public}d, networkId = %{public}s, uuid = %{public}s, dhId = %{public}s", static_cast(taskType), GetAnonyString(taskParam.networkId).c_str(), GetAnonyString(taskParam.uuid).c_str(), GetAnonyString(taskParam.dhId).c_str()); std::shared_ptr task = nullptr; @@ -53,7 +53,7 @@ std::shared_ptr TaskFactory::CreateTask(TaskType taskType, TaskParam taskP break; } default: { - DHLOGE("CreateTask type invalid, type: %d", taskType); + DHLOGE("CreateTask type invalid, type: %{public}d", taskType); return nullptr; } } diff --git a/services/distributedhardwarefwkservice/src/utils/dh_context.cpp b/services/distributedhardwarefwkservice/src/utils/dh_context.cpp index 0deec491e58fc1f2b46d5033aba4f57245ef065c..52af479f648bfacbb2b1098425392bfe44eddb35 100644 --- a/services/distributedhardwarefwkservice/src/utils/dh_context.cpp +++ b/services/distributedhardwarefwkservice/src/utils/dh_context.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 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 @@ -56,7 +56,7 @@ void DHContext::RegisterPowerStateLinstener() void DHContext::DHFWKPowerStateCallback::OnPowerStateChanged(PowerMgr::PowerState state) { - DHLOGI("DHFWK OnPowerStateChanged state: %u", static_cast(state)); + DHLOGI("DHFWK OnPowerStateChanged state: %{public}u", static_cast(state)); if (state == PowerMgr::PowerState::SLEEP || state == PowerMgr::PowerState::HIBERNATE || state == PowerMgr::PowerState::SHUTDOWN) { DHLOGI("DHFWK set in sleeping"); @@ -146,7 +146,7 @@ std::string DHContext::GetNetworkIdByUUID(const std::string &uuid) { std::unique_lock lock(onlineDevMutex_); if (onlineDeviceMap_.find(uuid) == onlineDeviceMap_.end()) { - DHLOGE("Can not find networkId, uuid: %s", GetAnonyString(uuid).c_str()); + DHLOGE("Can not find networkId, uuid: %{public}s", GetAnonyString(uuid).c_str()); return ""; } return onlineDeviceMap_[uuid]; @@ -158,7 +158,7 @@ std::string DHContext::GetUUIDByNetworkId(const std::string &networkId) auto iter = std::find_if(onlineDeviceMap_.begin(), onlineDeviceMap_.end(), [networkId](const auto &item) {return networkId.compare(item.second) == 0; }); if (iter == onlineDeviceMap_.end()) { - DHLOGE("Can not find uuid, networkId: %s", GetAnonyString(networkId).c_str()); + DHLOGE("Can not find uuid, networkId: %{public}s", GetAnonyString(networkId).c_str()); return ""; } return iter->first; @@ -168,7 +168,7 @@ std::string DHContext::GetUUIDByDeviceId(const std::string &deviceId) { std::unique_lock lock(onlineDevMutex_); if (deviceIdUUIDMap_.find(deviceId) == deviceIdUUIDMap_.end()) { - DHLOGE("Can not find uuid, deviceId: %s", GetAnonyString(deviceId).c_str()); + DHLOGE("Can not find uuid, deviceId: %{public}s", GetAnonyString(deviceId).c_str()); return ""; } return deviceIdUUIDMap_[deviceId]; diff --git a/services/distributedhardwarefwkservice/src/versionmanager/version_manager.cpp b/services/distributedhardwarefwkservice/src/versionmanager/version_manager.cpp index 34e39e4745b181695548f16ffd509ca63e155ac7..8cd7b0340a2f7537fc07a72938fd5b09523017b2 100644 --- a/services/distributedhardwarefwkservice/src/versionmanager/version_manager.cpp +++ b/services/distributedhardwarefwkservice/src/versionmanager/version_manager.cpp @@ -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 @@ -51,7 +51,8 @@ void VersionManager::UnInit() void VersionManager::ShowLocalVersion(const DHVersion &dhVersion) const { for (const auto &item : dhVersion.compVersions) { - DHLOGI("LocalDHVersion = %s, DHtype = %#X, handlerVersion = %s, sourceVersion = %s, sinkVersion = %s", + DHLOGI("LocalDHVersion = %{public}s, DHtype = %{public}#X, handlerVersion = %{public}s, " + "sourceVersion = %{public}s, sinkVersion = %{public}s", dhVersion.dhVersion.c_str(), item.first, item.second.handlerVersion.c_str(), item.second.sourceVersion.c_str(), item.second.sinkVersion.c_str()); } @@ -59,7 +60,7 @@ void VersionManager::ShowLocalVersion(const DHVersion &dhVersion) const int32_t VersionManager::AddDHVersion(const std::string &uuid, const DHVersion &dhVersion) { - DHLOGI("addDHVersion uuid: %s", GetAnonyString(uuid).c_str()); + DHLOGI("addDHVersion uuid: %{public}s", GetAnonyString(uuid).c_str()); std::lock_guard lock(versionMutex_); dhVersions_[uuid] = dhVersion; return DH_FWK_SUCCESS; @@ -67,11 +68,11 @@ int32_t VersionManager::AddDHVersion(const std::string &uuid, const DHVersion &d int32_t VersionManager::RemoveDHVersion(const std::string &uuid) { - DHLOGI("uuid: %s", GetAnonyString(uuid).c_str()); + DHLOGI("uuid: %{public}s", GetAnonyString(uuid).c_str()); std::lock_guard lock(versionMutex_); std::unordered_map::iterator iter = dhVersions_.find(uuid); if (iter == dhVersions_.end()) { - DHLOGE("there is no uuid: %s, remove fail", GetAnonyString(uuid).c_str()); + DHLOGE("there is no uuid: %{public}s, remove fail", GetAnonyString(uuid).c_str()); return ERR_DH_FWK_VERSION_DEVICE_ID_NOT_EXIST; } dhVersions_.erase(iter); @@ -80,11 +81,11 @@ int32_t VersionManager::RemoveDHVersion(const std::string &uuid) int32_t VersionManager::GetDHVersion(const std::string &uuid, DHVersion &dhVersion) { - DHLOGI("uuid: %s", GetAnonyString(uuid).c_str()); + DHLOGI("uuid: %{public}s", GetAnonyString(uuid).c_str()); std::lock_guard lock(versionMutex_); std::unordered_map::iterator iter = dhVersions_.find(uuid); if (iter == dhVersions_.end()) { - DHLOGE("there is no uuid: %s, get version fail", GetAnonyString(uuid).c_str()); + DHLOGE("there is no uuid: %{public}s, get version fail", GetAnonyString(uuid).c_str()); return ERR_DH_FWK_VERSION_DEVICE_ID_NOT_EXIST; } else { dhVersion = dhVersions_[uuid]; @@ -97,15 +98,15 @@ int32_t VersionManager::GetCompVersion(const std::string &uuid, const DHType dhT DHVersion dhVersion; int32_t ret = GetDHVersion(uuid, dhVersion); if (ret != DH_FWK_SUCCESS) { - DHLOGE("GetDHVersion fail, uuid: %s", GetAnonyString(uuid).c_str()); + DHLOGE("GetDHVersion fail, uuid: %{public}s", GetAnonyString(uuid).c_str()); return ret; } if (dhVersion.compVersions.find(dhType) == dhVersion.compVersions.end()) { - DHLOGE("not find dhType: %#X", dhType); + DHLOGE("not find dhType: %{public}#X", dhType); return ERR_DH_FWK_TYPE_NOT_EXIST; } - DHLOGI("GetCompVersion success, uuid: %s, dhType: %#X", GetAnonyString(uuid).c_str(), dhType); + DHLOGI("GetCompVersion success, uuid: %{public}s, dhType: %{public}#X", GetAnonyString(uuid).c_str(), dhType); compVersion = dhVersion.compVersions[dhType]; return DH_FWK_SUCCESS; } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn index dcbc89f51c542572f8ebb0cc8ed5ae663d8437f7..278e6b9fbf4e0f26d52b416d1e6664d55fe0ad98 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -58,6 +58,7 @@ ohos_unittest("AccessManagerTest") { "c_utils:utils", "device_manager:devicemanagersdk", "eventhandler:libeventhandler", + "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", "init:libbegetutil", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/componentloader/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/componentloader/BUILD.gn index 193efc0564c1c6c49a4f3b21d390ee9a18f62f11..8098e21229fa22b024606f2d8e98d034d5070622 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/componentloader/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/componentloader/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -52,6 +52,7 @@ ohos_unittest("ComponentLoaderTest") { external_deps = [ "config_policy:configpolicy_util", + "hilog:libhilog", "hitrace:hitrace_meter", "kv_store:distributeddata_inner", "power_manager:powermgr_client", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_manager/src/component_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_manager/src/component_manager_test.cpp index de2f4f9d3eed94aaa28393918ed76673c529c22d..4f89b9bb7e7c8ef86adf939b7e108113900efc7e 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_manager/src/component_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/componentmanager/component_manager/src/component_manager_test.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 @@ -75,7 +75,7 @@ void ComponentManagerTest::SetUpTestCase(void) { auto ret = mkdir(DATABASE_DIR.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); if (ret != 0) { - DHLOGE("mkdir failed, path: %s, errno : %d", DATABASE_DIR.c_str(), errno); + DHLOGE("mkdir failed, path: %{public}s, errno : %{public}d", DATABASE_DIR.c_str(), errno); } } @@ -83,7 +83,7 @@ void ComponentManagerTest::TearDownTestCase(void) { auto ret = remove(DATABASE_DIR.c_str()); if (ret != 0) { - DHLOGE("remove dir failed, path: %s, errno : %d", DATABASE_DIR.c_str(), errno); + DHLOGE("remove dir failed, path: %{public}s, errno : %{public}d", DATABASE_DIR.c_str(), errno); } } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/dbadapter/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/dbadapter/BUILD.gn index 370032e45e1d19d459678aa2af231ae873ab6741..a902eaedf5c44d905c3b999bbce0e1d548b5f8fe 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/dbadapter/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/dbadapter/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -60,6 +60,7 @@ ohos_unittest("DbAdapterTest") { external_deps = [ "c_utils:utils", "eventhandler:libeventhandler", + "hilog:libhilog", "kv_store:distributeddata_inner", "power_manager:powermgr_client", "safwk:system_ability_fwk", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/dbadapter/src/db_adapter_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/dbadapter/src/db_adapter_test.cpp index a9d9e78c7f1d1fe0a8f1ba7e5dd9a67fc49d39e3..af555e29a351ef094466fd4ee2a43817947f90cd 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/dbadapter/src/db_adapter_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/dbadapter/src/db_adapter_test.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 @@ -98,7 +98,7 @@ void DbAdapterTest::SetUpTestCase(void) { auto ret = mkdir(DATABASE_DIR.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); if (ret != 0) { - DHLOGE("mkdir failed, path: %s, errno : %d", DATABASE_DIR.c_str(), errno); + DHLOGE("mkdir failed, path: %{public}s, errno : %{public}d", DATABASE_DIR.c_str(), errno); } std::shared_ptr changeListener = std::make_shared(); g_dbAdapterPtr = std::make_shared(APP_ID, GLOBAL_CAPABILITY_ID, changeListener); @@ -117,7 +117,7 @@ void DbAdapterTest::TearDownTestCase(void) auto ret = remove(DATABASE_DIR.c_str()); if (ret != 0) { - DHLOGE("remove dir failed, path: %s, errno : %d", DATABASE_DIR.c_str(), errno); + DHLOGE("remove dir failed, path: %{public}s, errno : %{public}d", DATABASE_DIR.c_str(), errno); } } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/BUILD.gn index 15157c635abe9ebe3f05df39a943b1536646d6c2..0a98aad96a584a1ce599139c221f58fbcab357e9 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -50,6 +50,7 @@ ohos_unittest("ResourceManagerTest") { external_deps = [ "c_utils:utils", "eventhandler:libeventhandler", + "hilog:libhilog", "kv_store:distributeddata_inner", "power_manager:powermgr_client", "safwk:system_ability_fwk", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/src/resource_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/src/resource_manager_test.cpp index 32ac7c31207fcc36eb0f3dc4478b8fca9569404b..dd3a1e4d80100aa3a1902c4be991d10c39631ac7 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/src/resource_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/resourcemanager/src/resource_manager_test.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 @@ -104,7 +104,7 @@ void ResourceManagerTest::SetUpTestCase(void) { auto ret = mkdir(DATABASE_DIR.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); if (ret != 0) { - DHLOGE("mkdir failed, path: %s, errno : %d", DATABASE_DIR.c_str(), errno); + DHLOGE("mkdir failed, path: %{public}s, errno : %{public}d", DATABASE_DIR.c_str(), errno); } } @@ -112,7 +112,7 @@ void ResourceManagerTest::TearDownTestCase(void) { auto ret = remove(DATABASE_DIR.c_str()); if (ret != 0) { - DHLOGE("remove dir failed, path: %s, errno : %d", DATABASE_DIR.c_str(), errno); + DHLOGE("remove dir failed, path: %{public}s, errno : %{public}d", DATABASE_DIR.c_str(), errno); } } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/task/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/task/BUILD.gn index cbb8b49fea44eea0172cfd37275b59610e82dd30..2df3111e4e03541eefb2c42f6f126d7b69e7dd25 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/task/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/task/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -53,7 +53,10 @@ ohos_unittest("DHTaskTest") { "//third_party/googletest:gtest_main", ] - external_deps = [ "c_utils:utils" ] + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + ] defines = [ "HI_LOG_ENABLE", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/task/src/mock_online_task.cpp b/services/distributedhardwarefwkservice/test/unittest/common/task/src/mock_online_task.cpp index 1d749ebdfe2eaf9ca20958e8003e5d91cbf7df95..06f598fb90a35204dfa088e153b307ca9a171a21 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/task/src/mock_online_task.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/task/src/mock_online_task.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 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 @@ -27,7 +27,7 @@ namespace DistributedHardware { MockOnLineTask::MockOnLineTask(const std::string &networkId, const std::string &uuid, const std::string &dhId, const DHType dhType) : OnLineTask(networkId, uuid, dhId, dhType) { - DHLOGI("Ctor MockOnLineTask: %s, type: %d", this->GetId().c_str(), this->GetTaskType()); + DHLOGI("Ctor MockOnLineTask: %{public}s, type: %{public}d", this->GetId().c_str(), this->GetTaskType()); } void MockOnLineTask::DoSyncInfo() diff --git a/services/distributedhardwarefwkservice/test/unittest/common/task/src/mock_task_factory.cpp b/services/distributedhardwarefwkservice/test/unittest/common/task/src/mock_task_factory.cpp index 45ef5439a17081873386dc697b34264b65140986..32dad6c19172d92edbbf5d4b904db3ed80d3fc62 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/task/src/mock_task_factory.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/task/src/mock_task_factory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 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 @@ -51,7 +51,7 @@ std::shared_ptr MockTaskFactory::CreateTask(TaskType taskType, TaskParam t break; } default: { - DHLOGE("CreateTask type invalid, type: %d", taskType); + DHLOGE("CreateTask type invalid, type: %{public}d", taskType); return nullptr; } } diff --git a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/BUILD.gn index d9cfa77b9048e86aa1aa717efb1e6a01933bc670..75392ebaaca9660e9879cab44c3205b5912b6456 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -51,6 +51,7 @@ ohos_unittest("VersioninfoManagerTest") { external_deps = [ "c_utils:utils", "eventhandler:libeventhandler", + "hilog:libhilog", "kv_store:distributeddata_inner", "power_manager:powermgr_client", "safwk:system_ability_fwk", diff --git a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/src/version_info_manager_test.cpp b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/src/version_info_manager_test.cpp index db1694ab6f619914d3e8291d497bbd39f6fa5416..79d5db4fe8e81689c5840919378bbca528a07f60 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/src/version_info_manager_test.cpp +++ b/services/distributedhardwarefwkservice/test/unittest/common/versioninfomanager/versioninfomanager/src/version_info_manager_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 @@ -103,7 +103,7 @@ void VersionInfoManagerTest::SetUpTestCase(void) { auto ret = mkdir(DATABASE_DIR.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); if (ret != 0) { - DHLOGE("mkdir failed, path: %s, errno : %d", DATABASE_DIR.c_str(), errno); + DHLOGE("mkdir failed, path: %{public}s, errno : %{public}d", DATABASE_DIR.c_str(), errno); } g_versionInfos = CreateVersionInfos(); @@ -113,7 +113,7 @@ void VersionInfoManagerTest::TearDownTestCase(void) { auto ret = remove(DATABASE_DIR.c_str()); if (ret != 0) { - DHLOGE("remove dir failed, path: %s, errno : %d", DATABASE_DIR.c_str(), errno); + DHLOGE("remove dir failed, path: %{public}s, errno : %{public}d", DATABASE_DIR.c_str(), errno); } } diff --git a/utils/BUILD.gn b/utils/BUILD.gn index fafba85a0c4050f8673c54050a8dcb2b50d59a5e..b61bf8022a99ae19aaafeeff90d36b45e8beb89e 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -50,7 +50,6 @@ ohos_shared_library("distributedhardwareutils") { "src/dh_utils_tool.cpp", "src/histreamer_ability_parser.cpp", "src/histreamer_query_tool.cpp", - "src/log/dh_log.cpp", ] deps = [ "//third_party/openssl:libcrypto_shared" ] @@ -71,7 +70,7 @@ ohos_shared_library("distributedhardwareutils") { "safwk:system_ability_fwk", ] - innerapi_tags = [ "platformsdk" ] subsystem_name = "distributedhardware" + part_name = "distributed_hardware_fwk" } diff --git a/utils/include/eventbus/event_bus.h b/utils/include/eventbus/event_bus.h index a050daa8d5760feeafd9a7ed77b1c0ea8957f0eb..4369ad424234056023671db4378ab802a7c5d527 100644 --- a/utils/include/eventbus/event_bus.h +++ b/utils/include/eventbus/event_bus.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 @@ -63,7 +63,7 @@ public: explicit EventBus(const std::string &threadName) { - ULOGI("ctor EventBus threadName: %s", threadName.c_str()); + ULOGI("ctor EventBus threadName: %{public}s", threadName.c_str()); if (eventbusHandler_ == nullptr) { eventThread_ = std::thread(&EventBus::StartEventWithName, this, threadName); std::unique_lock lock(eventMutex_); diff --git a/utils/include/log/dh_log.h b/utils/include/log/dh_log.h index 0b38bb6e8f93c2d6976c9682572c09eb4d0f857d..d8f2ab13746c705bd1930883c42bc21868eb7e79 100644 --- a/utils/include/log/dh_log.h +++ b/utils/include/log/dh_log.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 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 @@ -16,28 +16,25 @@ #ifndef OHOS_DH_LOG_H #define OHOS_DH_LOG_H +#include "hilog/log.h" +#include + namespace OHOS { namespace DistributedHardware { -typedef enum { - DH_LOG_DEBUG, - DH_LOG_INFO, - DH_LOG_WARN, - DH_LOG_ERROR, -} DHLogLevel; - -void DHLog(DHLogLevel logLevel, const char *fmt, ...); +#undef LOG_TAG +#define LOG_TAG "DHFWK" -#define ULOGD(fmt, ...) DHLog(DH_LOG_DEBUG, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#define ULOGD(fmt, ...) HILOG_DEBUG(LOG_CORE, \ + "[%{public}s][%{public}s]:" fmt, DH_LOG_TAG, __FUNCTION__, ##__VA_ARGS__) -#define ULOGI(fmt, ...) DHLog(DH_LOG_INFO, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#define ULOGI(fmt, ...) HILOG_INFO(LOG_CORE, \ + "[%{public}s][%{public}s]:" fmt, DH_LOG_TAG, __FUNCTION__, ##__VA_ARGS__) -#define ULOGW(fmt, ...) DHLog(DH_LOG_WARN, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#define ULOGW(fmt, ...) HILOG_WARN(LOG_CORE, \ + "[%{public}s][%{public}s]:" fmt, DH_LOG_TAG, __FUNCTION__, ##__VA_ARGS__) -#define ULOGE(fmt, ...) DHLog(DH_LOG_ERROR, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) +#define ULOGE(fmt, ...) HILOG_ERROR(LOG_CORE, \ + "[%{public}s][%{public}s]:" fmt, DH_LOG_TAG, __FUNCTION__, ##__VA_ARGS__) } // namespace DistributedHardware } // namespace OHOS #endif diff --git a/utils/src/dh_utils_hisysevent.cpp b/utils/src/dh_utils_hisysevent.cpp index be99ff09a218129c360e3799044ddb9385aec69c..60d6ec20a9c88a891356848aad63da2aa8b3402e 100644 --- a/utils/src/dh_utils_hisysevent.cpp +++ b/utils/src/dh_utils_hisysevent.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 @@ -30,7 +30,7 @@ void HiSysEventWriteMsg(const std::string &status, const OHOS::HiviewDFX::HiSysE eventType, "MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); + DHLOGE("Write HiSysEvent error, res:%{public}d", res); } } @@ -44,7 +44,7 @@ void HiSysEventWriteErrCodeMsg(const std::string &status, const OHOS::HiviewDFX: "ERR_CODE", errCode, "ERR_MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); + DHLOGE("Write HiSysEvent error, res:%{public}d", res); } } @@ -65,7 +65,7 @@ void HiSysEventWriteReleaseMsg(const std::string &status, const OHOS::HiviewDFX: "ERR_CODE", errCode, "ERR_MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); + DHLOGE("Write HiSysEvent error, res:%{public}d", res); } } @@ -79,7 +79,7 @@ void HiSysEventWriteCompOfflineMsg(const std::string &status, const OHOS::Hiview "NETWORKID", anonyNetworkId.c_str(), "MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); + DHLOGE("Write HiSysEvent error, res:%{public}d", res); } } @@ -94,7 +94,7 @@ void HiSysEventWriteCompMgrFailedMsg(const std::string &status, const OHOS::Hivi "ERR_CODE", errCode, "ERR_MSG", msg.c_str()); if (res != DH_FWK_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); + DHLOGE("Write HiSysEvent error, res:%{public}d", res); } } } // namespace DistributedHardware diff --git a/utils/src/dh_utils_tool.cpp b/utils/src/dh_utils_tool.cpp index 0533742a2cd974d42ec3d5081b4b9a020b3e526d..213a131c30a9dd015c5ea74b97966706b0e3c934 100644 --- a/utils/src/dh_utils_tool.cpp +++ b/utils/src/dh_utils_tool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 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 @@ -117,7 +117,7 @@ DeviceInfo GetLocalDeviceInfo() auto info = std::make_unique(); auto ret = GetLocalNodeDeviceInfo(DH_FWK_PKG_NAME.c_str(), info.get()); if (ret != DH_FWK_SUCCESS) { - DHLOGE("GetLocalNodeDeviceInfo failed, errCode = %d", ret); + DHLOGE("GetLocalNodeDeviceInfo failed, errCode = %{public}d", ret); return devInfo; } devInfo.uuid = GetUUIDBySoftBus(info->networkId); diff --git a/utils/src/histreamer_ability_parser.cpp b/utils/src/histreamer_ability_parser.cpp index 072aa7a2e8631d78c2102ae4cb48633fbe754c3f..4f1849f89e9120fc856f21daafe407c371b1f563 100644 --- a/utils/src/histreamer_ability_parser.cpp +++ b/utils/src/histreamer_ability_parser.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 @@ -304,7 +304,7 @@ template void FromJson(const std::string &key, const nlohmann::json &jsonObject, std::vector &objs) { if (jsonObject.find(key) == jsonObject.end()) { - DHLOGE("JSONObject key invalid, key: %s", key.c_str()); + DHLOGE("JSONObject key invalid, key: %{public}s", key.c_str()); return; } for (auto &json : jsonObject[key]) { diff --git a/utils/src/histreamer_query_tool.cpp b/utils/src/histreamer_query_tool.cpp index 76b3795fba5664dc2abb8ccff06e222e41dcb8d0..9513112498b11435fef44607205405caabb699b3 100644 --- a/utils/src/histreamer_query_tool.cpp +++ b/utils/src/histreamer_query_tool.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 @@ -54,14 +54,14 @@ void HiStreamerQueryTool::Init() DHLOGI("Start Init HiStreamer Query SO"); void *pHandler = dlopen(LIB_LOAD_PATH.c_str(), RTLD_LAZY | RTLD_NODELETE); if (pHandler == nullptr) { - DHLOGE("libhistreamer_ability_querier.z.so handler load failed, failed reason : %s", dlerror()); + DHLOGE("libhistreamer_ability_querier.z.so handler load failed, failed reason : %{public}s", dlerror()); return; } queryAudioEncoderFunc = (QueryAudioEncoderFunc)dlsym(pHandler, QueryAudioEncoderFuncName.c_str()); if (queryAudioEncoderFunc == nullptr) { - DHLOGE("get QueryAudioEncoderAbilityStr is null, failed reason : %s", dlerror()); + DHLOGE("get QueryAudioEncoderAbilityStr is null, failed reason : %{public}s", dlerror()); dlclose(pHandler); return; } @@ -69,7 +69,7 @@ void HiStreamerQueryTool::Init() queryAudioDecoderFunc = (QueryAudioDecoderFunc)dlsym(pHandler, QueryAudioDecoderFuncName.c_str()); if (queryAudioDecoderFunc == nullptr) { - DHLOGE("get QueryAudioDecoderAbilityStr is null, failed reason : %s", dlerror()); + DHLOGE("get QueryAudioDecoderAbilityStr is null, failed reason : %{public}s", dlerror()); dlclose(pHandler); return; } @@ -77,7 +77,7 @@ void HiStreamerQueryTool::Init() queryVideoEncoderFunc = (QueryVideoEncoderFunc)dlsym(pHandler, QueryVideoEncoderFuncName.c_str()); if (queryVideoEncoderFunc == nullptr) { - DHLOGE("get QueryVideoEncoderAbilityStr is null, failed reason : %s", dlerror()); + DHLOGE("get QueryVideoEncoderAbilityStr is null, failed reason : %{public}s", dlerror()); dlclose(pHandler); return; } @@ -85,7 +85,7 @@ void HiStreamerQueryTool::Init() queryVideoDecoderFunc = (QueryVideoDecoderFunc)dlsym(pHandler, QueryVideoDecoderFuncName.c_str()); if (queryVideoDecoderFunc == nullptr) { - DHLOGE("get QueryVideoDecoderAbilityStr is null, failed reason : %s", dlerror()); + DHLOGE("get QueryVideoDecoderAbilityStr is null, failed reason : %{public}s", dlerror()); dlclose(pHandler); return; } diff --git a/utils/test/unittest/common/eventbus/BUILD.gn b/utils/test/unittest/common/eventbus/BUILD.gn index 244fae686832ff62ed01a178516f739847347fc5..5364833809b48065c5417e84eb630f47b25ec8df 100644 --- a/utils/test/unittest/common/eventbus/BUILD.gn +++ b/utils/test/unittest/common/eventbus/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -45,6 +45,7 @@ ohos_unittest("EventBusTest") { external_deps = [ "c_utils:utils", "eventhandler:libeventhandler", + "hilog:libhilog", ] }