From 11434cf28644a64db938096f11bd12854e983753 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 25 May 2022 20:11:43 +0800 Subject: [PATCH 01/34] add hitrace Signed-off-by: wanderer-dl122 --- .../BUILD.gn | 1 + .../include/utils/dh_hitrace.h | 30 +++++++++++++++++++ .../componentmanager/component_disable.cpp | 3 ++ .../src/componentmanager/component_enable.cpp | 3 ++ 4 files changed, 37 insertions(+) create mode 100644 services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index 6e3b3a20..99a90650 100644 --- a/services/distributedhardwarefwkserviceimpl/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/BUILD.gn @@ -83,6 +83,7 @@ ohos_shared_library("distributedhardwarefwksvr_impl") { "bundle_framework:appexecfwk_core", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", + "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h b/services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h new file mode 100644 index 00000000..89a7139b --- /dev/null +++ b/services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DH_HITRACE_H +#define OHOS_DH_HITRACE_H + +#include + +#include "hitrace_meter.h" + +namespace OHOS { +namespace DistributedHardware { +constexpr uint64_t DHFWK_HITRACE_LABEL = HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK; + +const std::string DH_FWK_COMPONENT_ENABLE_START = "DH_FWK_COMPONENT_ENABLE_START"; +const std::string DH_FWK_COMPONENT_DISABLE_START = "DH_FWK_COMPONENT_DISABLE_START"; +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp index 9cb2c82e..009fa3bd 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp @@ -19,6 +19,7 @@ #include "constants.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" +#include "dh_hitrace.h" namespace OHOS { namespace DistributedHardware { @@ -39,6 +40,7 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin return ERR_DH_FWK_PARA_INVALID; } + StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_DISABLE_START); 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(), @@ -55,6 +57,7 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin GetAnonyString(dhId).c_str()); return ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT; } + FinishTrace(DHFWK_HITRACE_LABEL); return (status_ == DH_FWK_SUCCESS) ? DH_FWK_SUCCESS : ERR_DH_FWK_COMPONENT_DISABLE_FAILED; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp index ebbf1cbc..c53cbdc9 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp @@ -19,6 +19,7 @@ #include "constants.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" +#include "dh_hitrace.h" namespace OHOS { namespace DistributedHardware { @@ -39,6 +40,7 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string return ERR_DH_FWK_PARA_INVALID; } + StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_ENABLE_START); 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(), @@ -55,6 +57,7 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string GetAnonyString(dhId).c_str()); return ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT; } + FinishTrace(DHFWK_HITRACE_LABEL); return (status_ == DH_FWK_SUCCESS) ? DH_FWK_SUCCESS : ERR_DH_FWK_COMPONENT_ENABLE_FAILED; } -- Gitee From f31cb66661c81a8e40bc12b0d865acab739e829e Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 09:10:30 +0800 Subject: [PATCH 02/34] add hitrace Signed-off-by: wanderer-dl122 --- .../include/utils/dh_hitrace.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h b/services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h index 89a7139b..988a4e20 100644 --- a/services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h +++ b/services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h @@ -27,4 +27,5 @@ constexpr uint64_t DHFWK_HITRACE_LABEL = HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK; const std::string DH_FWK_COMPONENT_ENABLE_START = "DH_FWK_COMPONENT_ENABLE_START"; const std::string DH_FWK_COMPONENT_DISABLE_START = "DH_FWK_COMPONENT_DISABLE_START"; } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS +#endif \ No newline at end of file -- Gitee From 47bc93cd2462a9b1b91c914b8d28c48e26cad463 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 09:17:45 +0800 Subject: [PATCH 03/34] add hitrace Signed-off-by: wanderer-dl122 --- .../include/utils/dh_hitrace.h | 2 ++ .../src/componentloader/component_loader.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h b/services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h index 988a4e20..3d5daeae 100644 --- a/services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h +++ b/services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h @@ -26,6 +26,8 @@ constexpr uint64_t DHFWK_HITRACE_LABEL = HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK; const std::string DH_FWK_COMPONENT_ENABLE_START = "DH_FWK_COMPONENT_ENABLE_START"; const std::string DH_FWK_COMPONENT_DISABLE_START = "DH_FWK_COMPONENT_DISABLE_START"; +const std::string DH_FWK_COMPONENT_LOAD_START = "DH_FWK_COMPONENT_LOAD_START"; +const std::string DH_FWK_COMPONENT_RELEASE_START = "DH_FWK_COMPONENT_RELEASE_START"; } // namespace DistributedHardware } // namespace OHOS #endif \ No newline at end of file diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 86a00f59..b93976fb 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -65,7 +65,9 @@ std::map g_mapDhTypeName = { int32_t ComponentLoader::Init() { + StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_LOAD_START); return ParseConfig(); + FinishTrace(DHFWK_HITRACE_LABEL); } std::vector ComponentLoader::GetAllCompTypes() @@ -270,6 +272,7 @@ int32_t ComponentLoader::ReleaseHandler(void *&handler) int32_t ComponentLoader::UnInit() { DHLOGI("release all handler"); + StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_RELEASE_START); int32_t ret = DH_FWK_SUCCESS; for (std::map::iterator iter = compHandlerMap_.begin(); iter != compHandlerMap_.end(); iter++) { @@ -278,6 +281,7 @@ int32_t ComponentLoader::UnInit() ret += ReleaseSink(iter->first); } compHandlerMap_.clear(); + FinishTrace(DHFWK_HITRACE_LABEL); return ret; } -- Gitee From 956986c018826d8cbabdeda507749024a4f7ed1d Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 26 May 2022 09:42:04 +0800 Subject: [PATCH 04/34] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/componentloader/component_loader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index b93976fb..b3de9f2b 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -22,6 +22,7 @@ #include "nlohmann/json.hpp" #include "constants.h" +#include "dh_hitrace.h" #include "distributed_hardware_log.h" #include "hidump_helper.h" -- Gitee From 1432ec7040159b8a8247aa70eaa01e8e3c9034b6 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 21:00:43 +0800 Subject: [PATCH 05/34] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/componentloader/component_loader.cpp | 6 ++++-- .../src/componentmanager/component_disable.cpp | 4 +--- .../src/componentmanager/component_enable.cpp | 3 +-- .../src/componentmanager/component_manager.cpp | 9 +++++++++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index b3de9f2b..1a778cc2 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -66,9 +66,7 @@ std::map g_mapDhTypeName = { int32_t ComponentLoader::Init() { - StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_LOAD_START); return ParseConfig(); - FinishTrace(DHFWK_HITRACE_LABEL); } std::vector ComponentLoader::GetAllCompTypes() @@ -245,6 +243,8 @@ int32_t ComponentLoader::ParseConfig() std::map dhtypeMap; int32_t ret; DHLOGI("ParseConfig start"); + StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_LOAD_START); + std::string jsonStr = Readfile(COMPONENTSLOAD_PROFILE_PATH); if (jsonStr.length() == 0) { DHLOGE("profile is empty return"); @@ -252,6 +252,8 @@ int32_t ComponentLoader::ParseConfig() } ret = GetCompPathAndVersion(jsonStr, dhtypeMap); GetAllHandler(dhtypeMap); + + FinishTrace(DHFWK_HITRACE_LABEL); return ret; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp index 009fa3bd..4de5fbd7 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp @@ -19,7 +19,6 @@ #include "constants.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" -#include "dh_hitrace.h" namespace OHOS { namespace DistributedHardware { @@ -40,7 +39,6 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin return ERR_DH_FWK_PARA_INVALID; } - StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_DISABLE_START); 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(), @@ -57,7 +55,7 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin GetAnonyString(dhId).c_str()); return ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT; } - FinishTrace(DHFWK_HITRACE_LABEL); + return (status_ == DH_FWK_SUCCESS) ? DH_FWK_SUCCESS : ERR_DH_FWK_COMPONENT_DISABLE_FAILED; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp index c53cbdc9..8c111065 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp @@ -40,7 +40,6 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string return ERR_DH_FWK_PARA_INVALID; } - StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_ENABLE_START); 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(), @@ -57,7 +56,7 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string GetAnonyString(dhId).c_str()); return ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT; } - FinishTrace(DHFWK_HITRACE_LABEL); + return (status_ == DH_FWK_SUCCESS) ? DH_FWK_SUCCESS : ERR_DH_FWK_COMPONENT_ENABLE_FAILED; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index e4335167..280c9d9c 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -25,6 +25,7 @@ #include "component_loader.h" #include "constants.h" #include "dh_context.h" +#include "dh_hitrace.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -249,7 +250,11 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string } } auto compEnable = std::make_shared(); + + StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_ENABLE_START); auto result = compEnable->Enable(networkId, dhId, param, find->second); + FinishTrace(DHFWK_HITRACE_LABEL); + if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < ENABLE_RETRY_MAX_TIMES; retryCount++) { if (!DHContext::GetInstance().IsDeviceOnline(uuid)) { @@ -280,7 +285,11 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin return ERR_DH_FWK_PARA_INVALID; } auto compDisable = std::make_shared(); + + StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_DISABLE_START); auto result = compDisable->Disable(networkId, dhId, find->second); + FinishTrace(DHFWK_HITRACE_LABEL); + if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < DISABLE_RETRY_MAX_TIMES; retryCount++) { if (DHContext::GetInstance().IsDeviceOnline(uuid)) { -- Gitee From c340ecc9f2b22b7515a99129ddad61300540fa21 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 21:08:34 +0800 Subject: [PATCH 06/34] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/componentloader/component_loader.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 1a778cc2..762188d2 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -66,7 +66,11 @@ std::map g_mapDhTypeName = { int32_t ComponentLoader::Init() { - return ParseConfig(); + StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_LOAD_START); + int32_t ret = ParseConfig(); + FinishTrace(DHFWK_HITRACE_LABEL); + + return ret; } std::vector ComponentLoader::GetAllCompTypes() @@ -243,7 +247,6 @@ int32_t ComponentLoader::ParseConfig() std::map dhtypeMap; int32_t ret; DHLOGI("ParseConfig start"); - StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_LOAD_START); std::string jsonStr = Readfile(COMPONENTSLOAD_PROFILE_PATH); if (jsonStr.length() == 0) { @@ -253,7 +256,6 @@ int32_t ComponentLoader::ParseConfig() ret = GetCompPathAndVersion(jsonStr, dhtypeMap); GetAllHandler(dhtypeMap); - FinishTrace(DHFWK_HITRACE_LABEL); return ret; } -- Gitee From ae8d13580953e7dcee263b11a099f9bdba2d0fa4 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 27 May 2022 21:10:31 +0800 Subject: [PATCH 07/34] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/componentloader/component_loader.cpp | 2 -- .../src/componentmanager/component_disable.cpp | 1 - .../src/componentmanager/component_enable.cpp | 2 -- 3 files changed, 5 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 762188d2..07d4ab8a 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -247,7 +247,6 @@ int32_t ComponentLoader::ParseConfig() std::map dhtypeMap; int32_t ret; DHLOGI("ParseConfig start"); - std::string jsonStr = Readfile(COMPONENTSLOAD_PROFILE_PATH); if (jsonStr.length() == 0) { DHLOGE("profile is empty return"); @@ -255,7 +254,6 @@ int32_t ComponentLoader::ParseConfig() } ret = GetCompPathAndVersion(jsonStr, dhtypeMap); GetAllHandler(dhtypeMap); - return ret; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp index 4de5fbd7..9cb2c82e 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_disable.cpp @@ -55,7 +55,6 @@ int32_t ComponentDisable::Disable(const std::string &networkId, const std::strin GetAnonyString(dhId).c_str()); return ERR_DH_FWK_COMPONENT_DISABLE_TIMEOUT; } - return (status_ == DH_FWK_SUCCESS) ? DH_FWK_SUCCESS : ERR_DH_FWK_COMPONENT_DISABLE_FAILED; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp index 8c111065..ebbf1cbc 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_enable.cpp @@ -19,7 +19,6 @@ #include "constants.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" -#include "dh_hitrace.h" namespace OHOS { namespace DistributedHardware { @@ -56,7 +55,6 @@ int32_t ComponentEnable::Enable(const std::string &networkId, const std::string GetAnonyString(dhId).c_str()); return ERR_DH_FWK_COMPONENT_ENABLE_TIMEOUT; } - return (status_ == DH_FWK_SUCCESS) ? DH_FWK_SUCCESS : ERR_DH_FWK_COMPONENT_ENABLE_FAILED; } -- Gitee From 20afcde29ee07256808489576c173377a4a9fadd Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 30 May 2022 11:28:32 +0800 Subject: [PATCH 08/34] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/componentmanager/component_manager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index 280c9d9c..90bdcad7 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -253,7 +253,6 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_ENABLE_START); auto result = compEnable->Enable(networkId, dhId, param, find->second); - FinishTrace(DHFWK_HITRACE_LABEL); if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < ENABLE_RETRY_MAX_TIMES; retryCount++) { @@ -264,6 +263,7 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string if (compEnable->Enable(networkId, dhId, param, find->second) == DH_FWK_SUCCESS) { DHLOGE("enable success, retryCount = %d", retryCount); EnabledCompsDump::GetInstance().DumpEnabledComp(uuid, dhType, dhId); + FinishTrace(DHFWK_HITRACE_LABEL); return DH_FWK_SUCCESS; } DHLOGE("enable failed, retryCount = %d", retryCount); @@ -272,6 +272,8 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string } DHLOGI("enable result is %d, uuid = %s, dhId = %s", result, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str()); + + FinishTrace(DHFWK_HITRACE_LABEL); EnabledCompsDump::GetInstance().DumpEnabledComp(uuid, dhType, dhId); return result; } @@ -288,7 +290,6 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_DISABLE_START); auto result = compDisable->Disable(networkId, dhId, find->second); - FinishTrace(DHFWK_HITRACE_LABEL); if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < DISABLE_RETRY_MAX_TIMES; retryCount++) { @@ -299,6 +300,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin if (compDisable->Disable(networkId, dhId, find->second) == DH_FWK_SUCCESS) { DHLOGE("disable success, retryCount = %d", retryCount); EnabledCompsDump::GetInstance().DumpDisabledComp(uuid, dhType, dhId); + FinishTrace(DHFWK_HITRACE_LABEL); return DH_FWK_SUCCESS; } DHLOGE("disable failed, retryCount = %d", retryCount); @@ -307,7 +309,9 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin } DHLOGI("disable result is %d, uuid = %s, dhId = %s", result, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str()); + EnabledCompsDump::GetInstance().DumpDisabledComp(uuid, dhType, dhId); + FinishTrace(DHFWK_HITRACE_LABEL); return result; } -- Gitee From dc77c6e804cb9865ed88dcd696efb0d302648e5f Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 30 May 2022 12:20:42 +0800 Subject: [PATCH 09/34] add hisysevent Signed-off-by: wanderer-dl122 --- .../src/componentmanager/component_manager.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index 90bdcad7..48e89d10 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -253,7 +253,6 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_ENABLE_START); auto result = compEnable->Enable(networkId, dhId, param, find->second); - if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < ENABLE_RETRY_MAX_TIMES; retryCount++) { if (!DHContext::GetInstance().IsDeviceOnline(uuid)) { @@ -290,7 +289,6 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_DISABLE_START); auto result = compDisable->Disable(networkId, dhId, find->second); - if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < DISABLE_RETRY_MAX_TIMES; retryCount++) { if (DHContext::GetInstance().IsDeviceOnline(uuid)) { -- Gitee From 448ec3768c3a4c03b9640ae87c5dcdb89fd9a110 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 1 Jun 2022 11:32:55 +0800 Subject: [PATCH 10/34] add hitrace Signed-off-by: wanderer-dl122 --- common/utils/include/device_type.h | 14 +++++ .../BUILD.gn | 1 - .../src/componentloader/component_loader.cpp | 8 +-- .../componentmanager/component_manager.cpp | 12 ++--- utils/BUILD.gn | 1 + .../include/dh_utils_hitrace.h | 9 ++-- utils/src/dh_utils_hitrace.cpp | 53 +++++++++++++++++++ 7 files changed, 83 insertions(+), 15 deletions(-) rename services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h => utils/include/dh_utils_hitrace.h (73%) create mode 100644 utils/src/dh_utils_hitrace.cpp diff --git a/common/utils/include/device_type.h b/common/utils/include/device_type.h index 03a4f819..563fcb2a 100644 --- a/common/utils/include/device_type.h +++ b/common/utils/include/device_type.h @@ -17,6 +17,7 @@ #define OHOS_DISTRIBUTED_HARDWARE_DEVICE_TYPE_H #include +#include namespace OHOS { namespace DistributedHardware { @@ -35,6 +36,19 @@ enum class DHType : uint32_t { MAX_DH = 0x80000000 }; +const std::unordered_map DHTypeStrMap = { + { DHType::CAMERA, "CAMERA" }, + { DHType::MIC, "MIC" }, + { DHType::SPEAKER, "SPEAKER" }, + { DHType::DISPLAY, "DISPLAY" }, + { DHType::GPS, "GPS" }, + { DHType::BUTTON, "BUTTON" }, + { DHType::HFP, "HFP" }, + { DHType::A2D, "A2D" }, + { DHType::VIRMODEM_MIC, "VIRMODEM_MIC" }, + { DHType::VIRMODEM_SPEAKER, "VIRMODEM_SPEAKER" }, +}; + struct DeviceInfo { std::string uuid; std::string deviceId; diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index 99a90650..6e3b3a20 100644 --- a/services/distributedhardwarefwkserviceimpl/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/BUILD.gn @@ -83,7 +83,6 @@ ohos_shared_library("distributedhardwarefwksvr_impl") { "bundle_framework:appexecfwk_core", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", - "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 07d4ab8a..baf48d65 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -66,9 +66,9 @@ std::map g_mapDhTypeName = { int32_t ComponentLoader::Init() { - StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_LOAD_START); + DHTraceStart("COMPONENT_LOAD_START"); int32_t ret = ParseConfig(); - FinishTrace(DHFWK_HITRACE_LABEL); + TraceEnd(); return ret; } @@ -275,7 +275,7 @@ int32_t ComponentLoader::ReleaseHandler(void *&handler) int32_t ComponentLoader::UnInit() { DHLOGI("release all handler"); - StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_RELEASE_START); + DHTraceStart("COMPONENT_RELEASE_START"); int32_t ret = DH_FWK_SUCCESS; for (std::map::iterator iter = compHandlerMap_.begin(); iter != compHandlerMap_.end(); iter++) { @@ -284,7 +284,7 @@ int32_t ComponentLoader::UnInit() ret += ReleaseSink(iter->first); } compHandlerMap_.clear(); - FinishTrace(DHFWK_HITRACE_LABEL); + TraceEnd(); return ret; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index 48e89d10..3e276cf8 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -251,7 +251,7 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string } auto compEnable = std::make_shared(); - StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_ENABLE_START); + CompEnableTraceStart(dhType); auto result = compEnable->Enable(networkId, dhId, param, find->second); if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < ENABLE_RETRY_MAX_TIMES; retryCount++) { @@ -261,8 +261,8 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string } if (compEnable->Enable(networkId, dhId, param, find->second) == DH_FWK_SUCCESS) { DHLOGE("enable success, retryCount = %d", retryCount); + TraceEnd(); EnabledCompsDump::GetInstance().DumpEnabledComp(uuid, dhType, dhId); - FinishTrace(DHFWK_HITRACE_LABEL); return DH_FWK_SUCCESS; } DHLOGE("enable failed, retryCount = %d", retryCount); @@ -272,7 +272,7 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string DHLOGI("enable result is %d, uuid = %s, dhId = %s", result, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str()); - FinishTrace(DHFWK_HITRACE_LABEL); + TraceEnd(); EnabledCompsDump::GetInstance().DumpEnabledComp(uuid, dhType, dhId); return result; } @@ -287,7 +287,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin } auto compDisable = std::make_shared(); - StartTrace(DHFWK_HITRACE_LABEL, DH_FWK_COMPONENT_DISABLE_START); + CompDisableTraceStart(dhType); auto result = compDisable->Disable(networkId, dhId, find->second); if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < DISABLE_RETRY_MAX_TIMES; retryCount++) { @@ -298,7 +298,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin if (compDisable->Disable(networkId, dhId, find->second) == DH_FWK_SUCCESS) { DHLOGE("disable success, retryCount = %d", retryCount); EnabledCompsDump::GetInstance().DumpDisabledComp(uuid, dhType, dhId); - FinishTrace(DHFWK_HITRACE_LABEL); + TraceEnd(); return DH_FWK_SUCCESS; } DHLOGE("disable failed, retryCount = %d", retryCount); @@ -309,7 +309,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin GetAnonyString(dhId).c_str()); EnabledCompsDump::GetInstance().DumpDisabledComp(uuid, dhType, dhId); - FinishTrace(DHFWK_HITRACE_LABEL); + TraceEnd(); return result; } diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 27018ede..1faa5db5 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -49,6 +49,7 @@ ohos_shared_library("distributedhardwareutils") { "bundle_framework:appexecfwk_core", "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", + "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", ] diff --git a/services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h b/utils/include/dh_utils_hitrace.h similarity index 73% rename from services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h rename to utils/include/dh_utils_hitrace.h index 3d5daeae..7a8d389f 100644 --- a/services/distributedhardwarefwkserviceimpl/include/utils/dh_hitrace.h +++ b/utils/include/dh_utils_hitrace.h @@ -18,16 +18,17 @@ #include +#include "device_type.h" #include "hitrace_meter.h" namespace OHOS { namespace DistributedHardware { constexpr uint64_t DHFWK_HITRACE_LABEL = HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK; -const std::string DH_FWK_COMPONENT_ENABLE_START = "DH_FWK_COMPONENT_ENABLE_START"; -const std::string DH_FWK_COMPONENT_DISABLE_START = "DH_FWK_COMPONENT_DISABLE_START"; -const std::string DH_FWK_COMPONENT_LOAD_START = "DH_FWK_COMPONENT_LOAD_START"; -const std::string DH_FWK_COMPONENT_RELEASE_START = "DH_FWK_COMPONENT_RELEASE_START"; +void CompEnableTraceStart(const DHType dhType); +void CompDisableTraceStart(const DHType dhType); +void DHTraceStart(const std::string &msg); +void TraceEnd(); } // namespace DistributedHardware } // namespace OHOS #endif \ No newline at end of file diff --git a/utils/src/dh_utils_hitrace.cpp b/utils/src/dh_utils_hitrace.cpp new file mode 100644 index 00000000..83cc6e7f --- /dev/null +++ b/utils/src/dh_utils_hitrace.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "dh_utils_hitrace.h" + +#include +#include + +namespace OHOS { +namespace DistributedHardware { + +void CompEnableTraceStart(const DHType dhType) +{ + std::string dhTypeStr = "UNKNOWN"; + auto it = DHTypeStrMap.find(dhType); + if (it != DHTypeStrMap.end()) { + dhTypeStr = it->second; + } + StartTrace(DHFWK_HITRACE_LABEL, + dhTypeStr + "_ENABLE_START"); +} + +void CompDisableTraceStart(const DHType dhType) +{ + std::string dhTypeStr = "UNKNOWN"; + auto it = DHTypeStrMap.find(dhType); + if (it != DHTypeStrMap.end()) { + dhTypeStr = it->second; + } + StartTrace(DHFWK_HITRACE_LABEL, dhTypeStr + "_DISABLE_START"); +} + +void DHTraceStart(const std::string &msg) +{ + StartTrace(DHFWK_HITRACE_LABEL, msg); +} + +void TraceEnd() +{ + FinishTrace(DHFWK_HITRACE_LABEL); +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file -- Gitee From 77b3ab05b4ccbfc7821311c38e2b64de7625c02a Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 1 Jun 2022 11:35:35 +0800 Subject: [PATCH 11/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/componentloader/component_loader.cpp | 2 +- .../src/componentmanager/component_manager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index baf48d65..858ca405 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -22,7 +22,7 @@ #include "nlohmann/json.hpp" #include "constants.h" -#include "dh_hitrace.h" +#include "dh_utils_hitrace.h" #include "distributed_hardware_log.h" #include "hidump_helper.h" diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index 3e276cf8..14a7894e 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -25,7 +25,7 @@ #include "component_loader.h" #include "constants.h" #include "dh_context.h" -#include "dh_hitrace.h" +#include "dh_utils_hitrace.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" -- Gitee From 2e7e17a6bcea88d4818a888945c56bf21b119d18 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 1 Jun 2022 14:28:54 +0800 Subject: [PATCH 12/34] add hitrace Signed-off-by: wanderer-dl122 --- services/distributedhardwarefwkserviceimpl/BUILD.gn | 1 + utils/BUILD.gn | 1 + utils/src/dh_utils_hitrace.cpp | 3 +-- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index 6e3b3a20..99a90650 100644 --- a/services/distributedhardwarefwkserviceimpl/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/BUILD.gn @@ -83,6 +83,7 @@ ohos_shared_library("distributedhardwarefwksvr_impl") { "bundle_framework:appexecfwk_core", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", + "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 1faa5db5..347dec70 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -29,6 +29,7 @@ ohos_shared_library("distributedhardwareutils") { sources = [ "src/anonymous_string.cpp", + "src/dh_utils_hitrace.cpp", "src/dh_utils_tool.cpp", "src/log/dh_log.cpp", ] diff --git a/utils/src/dh_utils_hitrace.cpp b/utils/src/dh_utils_hitrace.cpp index 83cc6e7f..293c259a 100644 --- a/utils/src/dh_utils_hitrace.cpp +++ b/utils/src/dh_utils_hitrace.cpp @@ -19,7 +19,6 @@ namespace OHOS { namespace DistributedHardware { - void CompEnableTraceStart(const DHType dhType) { std::string dhTypeStr = "UNKNOWN"; @@ -27,7 +26,7 @@ void CompEnableTraceStart(const DHType dhType) if (it != DHTypeStrMap.end()) { dhTypeStr = it->second; } - StartTrace(DHFWK_HITRACE_LABEL, + dhTypeStr + "_ENABLE_START"); + StartTrace(DHFWK_HITRACE_LABEL, dhTypeStr + "_ENABLE_START"); } void CompDisableTraceStart(const DHType dhType) -- Gitee From 76906ceaaed4bc47a92583fd8e4d2bbff23b8ec2 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 1 Jun 2022 14:38:48 +0800 Subject: [PATCH 13/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/hidumphelper/hidump_helper.cpp | 49 ++++++++++++------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp index 03ab7272..c879817c 100644 --- a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp @@ -41,20 +41,6 @@ const std::unordered_map MAP_ARGS = { { CAPABILITY_LIST, HidumpFlag::GET_CAPABILITY_LIST }, }; -std::unordered_map g_mapDhTypeName = { - { DHType::UNKNOWN, "UNKNOWN" }, - { DHType::CAMERA, "CAMERA" }, - { DHType::MIC, "MIC" }, - { DHType::SPEAKER, "SPEAKER" }, - { DHType::DISPLAY, "DISPLAY" }, - { DHType::GPS, "GPS" }, - { DHType::BUTTON, "BUTTON" }, - { DHType::HFP, "HFP" }, - { DHType::A2D, "A2D" }, - { DHType::VIRMODEM_MIC, "VIRMODEM_MIC" }, - { DHType::VIRMODEM_SPEAKER, "VIRMODEM_SPEAKER" }, -}; - std::unordered_map g_mapTaskType = { { TaskType::UNKNOWN, "UNKNOWN" }, { TaskType::ENABLE, "ENABLE" }, @@ -146,8 +132,13 @@ int32_t HidumpHelper::ShowAllLoadedComps(std::string &result) result.append("\n Source : ["); if (!loadedCompSource.empty()) { for (auto compSource : loadedCompSource) { + std::string dhTypeStr = "UNKNOWN"; + auto it = DHTypeStrMap.find(compSource); + if (it != DHTypeStrMap.end()) { + dhTypeStr = it->second; + } result.append(" "); - result.append(g_mapDhTypeName[compSource]); + result.append(dhTypeStr); result.append(","); } result.replace(result.size() - 1, 1, " "); @@ -157,8 +148,13 @@ int32_t HidumpHelper::ShowAllLoadedComps(std::string &result) result.append("\n Sink : ["); if (!loadedCompSink.empty()) { for (auto compSink : loadedCompSink) { + std::string dhTypeStr = "UNKNOWN"; + auto it = DHTypeStrMap.find(compSink); + if (it != DHTypeStrMap.end()) { + dhTypeStr = it->second; + } result.append(" "); - result.append(g_mapDhTypeName[compSink]); + result.append(dhTypeStr); result.append(","); } result.replace(result.size() - 1, 1, " "); @@ -180,11 +176,16 @@ int32_t HidumpHelper::ShowAllEnabledComps(std::string &result) } for (auto info : compInfoSet) { + std::string dhTypeStr = "UNKNOWN"; + auto it = DHTypeStrMap.find(info.dhType_); + if (it != DHTypeStrMap.end()) { + dhTypeStr = it->second; + } result.append("\n{"); result.append("\n DeviceId : "); result.append(GetAnonyString(info.deviceId_)); result.append("\n DHType : "); - result.append(g_mapDhTypeName[info.dhType_]); + result.append(dhTypeStr); result.append("\n DHId : "); result.append(GetAnonyString(info.dhId_)); result.append("\n},"); @@ -205,13 +206,18 @@ int32_t HidumpHelper::ShowAllTaskInfos(std::string &result) } for (auto taskInfo : taskInfos) { + std::string dhTypeStr = "UNKNOWN"; + auto it = DHTypeStrMap.find(taskInfo.taskParm.dhType); + if (it != DHTypeStrMap.end()) { + dhTypeStr = it->second; + } result.append("\n{"); result.append("\n TaskId : "); result.append(taskInfo.id); result.append("\n TaskType : "); result.append(g_mapTaskType[taskInfo.taskType]); result.append("\n DHType : "); - result.append(g_mapDhTypeName[taskInfo.taskParm.dhType]); + result.append(dhTypeStr); result.append("\n DHId : "); result.append(GetAnonyString(taskInfo.taskParm.dhId)); result.append("\n TaskState : "); @@ -241,6 +247,11 @@ int32_t HidumpHelper::ShowAllCapabilityInfos(std::string &result) } for (auto info : capInfos) { + std::string dhTypeStr = "UNKNOWN"; + auto it = DHTypeStrMap.find(info.GetDHType()); + if (it != DHTypeStrMap.end()) { + dhTypeStr = it->second; + } result.append("\n{"); result.append("\n DeviceName : "); result.append(GetAnonyString(info.GetDeviceName())); @@ -249,7 +260,7 @@ int32_t HidumpHelper::ShowAllCapabilityInfos(std::string &result) result.append("\n DeviceType : "); result.append(std::to_string(info.GetDeviceType())); result.append("\n DHType : "); - result.append(g_mapDhTypeName[info.GetDHType()]); + result.append(dhTypeStr); result.append("\n DHId : "); result.append(GetAnonyString(info.GetDHId())); result.append("\n DHAttrs :\n"); -- Gitee From 324e2578e9c60e514aa6abf2125e4aa7c61c8eb6 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 6 Jun 2022 16:30:00 +0800 Subject: [PATCH 14/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/componentloader/component_loader.cpp | 4 ++-- .../src/componentmanager/component_manager.cpp | 11 ++++++----- utils/include/dh_utils_hitrace.h | 2 +- utils/src/dh_utils_hitrace.cpp | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 858ca405..89050648 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -68,7 +68,7 @@ int32_t ComponentLoader::Init() { DHTraceStart("COMPONENT_LOAD_START"); int32_t ret = ParseConfig(); - TraceEnd(); + DHTraceEnd(); return ret; } @@ -284,7 +284,7 @@ int32_t ComponentLoader::UnInit() ret += ReleaseSink(iter->first); } compHandlerMap_.clear(); - TraceEnd(); + DHTraceEnd(); return ret; } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index 14a7894e..b1e67c29 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -56,6 +56,7 @@ ComponentManager::~ComponentManager() int32_t ComponentManager::Init() { DHLOGI("start."); + DHTraceStart("COMPONENT_INIT_START"); if (!InitCompSource()) { DHLOGE("InitCompSource failed."); return ERR_DH_FWK_COMPONENT_INIT_SOURCE_FAILED; @@ -77,7 +78,7 @@ int32_t ComponentManager::Init() } DHLOGI("Init component success"); - + DHTraceEnd(); return DH_FWK_SUCCESS; } @@ -261,7 +262,7 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string } if (compEnable->Enable(networkId, dhId, param, find->second) == DH_FWK_SUCCESS) { DHLOGE("enable success, retryCount = %d", retryCount); - TraceEnd(); + DHTraceEnd(); EnabledCompsDump::GetInstance().DumpEnabledComp(uuid, dhType, dhId); return DH_FWK_SUCCESS; } @@ -271,8 +272,8 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string } DHLOGI("enable result is %d, uuid = %s, dhId = %s", result, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str()); + DHTraceEnd(); - TraceEnd(); EnabledCompsDump::GetInstance().DumpEnabledComp(uuid, dhType, dhId); return result; } @@ -298,7 +299,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin if (compDisable->Disable(networkId, dhId, find->second) == DH_FWK_SUCCESS) { DHLOGE("disable success, retryCount = %d", retryCount); EnabledCompsDump::GetInstance().DumpDisabledComp(uuid, dhType, dhId); - TraceEnd(); + DHTraceEnd(); return DH_FWK_SUCCESS; } DHLOGE("disable failed, retryCount = %d", retryCount); @@ -309,7 +310,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin GetAnonyString(dhId).c_str()); EnabledCompsDump::GetInstance().DumpDisabledComp(uuid, dhType, dhId); - TraceEnd(); + DHTraceEnd(); return result; } diff --git a/utils/include/dh_utils_hitrace.h b/utils/include/dh_utils_hitrace.h index 7a8d389f..5e80205f 100644 --- a/utils/include/dh_utils_hitrace.h +++ b/utils/include/dh_utils_hitrace.h @@ -28,7 +28,7 @@ constexpr uint64_t DHFWK_HITRACE_LABEL = HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK; void CompEnableTraceStart(const DHType dhType); void CompDisableTraceStart(const DHType dhType); void DHTraceStart(const std::string &msg); -void TraceEnd(); +void DHTraceEnd(); } // namespace DistributedHardware } // namespace OHOS #endif \ No newline at end of file diff --git a/utils/src/dh_utils_hitrace.cpp b/utils/src/dh_utils_hitrace.cpp index 293c259a..841c85bc 100644 --- a/utils/src/dh_utils_hitrace.cpp +++ b/utils/src/dh_utils_hitrace.cpp @@ -44,7 +44,7 @@ void DHTraceStart(const std::string &msg) StartTrace(DHFWK_HITRACE_LABEL, msg); } -void TraceEnd() +void DHTraceEnd() { FinishTrace(DHFWK_HITRACE_LABEL); } -- Gitee From 97ad89319b8b5bf4e772edef78515b8936b6f7c5 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 8 Jun 2022 10:12:36 +0800 Subject: [PATCH 15/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/componentloader/component_loader.cpp | 4 ++-- .../src/componentmanager/component_manager.cpp | 4 ++-- .../localhardwaremanager/local_hardware_manager.cpp | 3 +++ utils/include/dh_utils_hitrace.h | 11 +++++++++-- utils/src/dh_utils_hitrace.cpp | 13 ++++--------- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp index 89050648..83774028 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentloader/component_loader.cpp @@ -66,7 +66,7 @@ std::map g_mapDhTypeName = { int32_t ComponentLoader::Init() { - DHTraceStart("COMPONENT_LOAD_START"); + DHTraceStart(COMPONENT_LOAD_START); int32_t ret = ParseConfig(); DHTraceEnd(); @@ -275,7 +275,7 @@ int32_t ComponentLoader::ReleaseHandler(void *&handler) int32_t ComponentLoader::UnInit() { DHLOGI("release all handler"); - DHTraceStart("COMPONENT_RELEASE_START"); + DHTraceStart(COMPONENT_RELEASE_START); int32_t ret = DH_FWK_SUCCESS; for (std::map::iterator iter = compHandlerMap_.begin(); iter != compHandlerMap_.end(); iter++) { diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index b1e67c29..37db0c77 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -252,7 +252,7 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string } auto compEnable = std::make_shared(); - CompEnableTraceStart(dhType); + DHCompMgrTraceStart(GetAnonyString(networkId), GetAnonyString(dhId), ENABLE_START); auto result = compEnable->Enable(networkId, dhId, param, find->second); if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < ENABLE_RETRY_MAX_TIMES; retryCount++) { @@ -288,7 +288,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin } auto compDisable = std::make_shared(); - CompDisableTraceStart(dhType); + DHCompMgrTraceStart(GetAnonyString(networkId), GetAnonyString(dhId), DISABLE_START); auto result = compDisable->Disable(networkId, dhId, find->second); if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < DISABLE_RETRY_MAX_TIMES; retryCount++) { diff --git a/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp index 42bc9bc0..2a1a721a 100644 --- a/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp @@ -48,7 +48,10 @@ void LocalHardwareManager::Init() DHLOGE("Initialize %#X failed", dhType); continue; } + + DHQeryTraceStart(dhType); QueryLocalHardware(dhType, hardwareHandler); + DHTraceEnd(); if (!hardwareHandler->IsSupportPlugin()) { DHLOGI("hardwareHandler is not support hot swap plugin, release!"); ComponentLoader::GetInstance().ReleaseHardwareHandler(dhType); diff --git a/utils/include/dh_utils_hitrace.h b/utils/include/dh_utils_hitrace.h index 5e80205f..cca8ac8b 100644 --- a/utils/include/dh_utils_hitrace.h +++ b/utils/include/dh_utils_hitrace.h @@ -25,8 +25,15 @@ namespace OHOS { namespace DistributedHardware { constexpr uint64_t DHFWK_HITRACE_LABEL = HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK; -void CompEnableTraceStart(const DHType dhType); -void CompDisableTraceStart(const DHType dhType); +const std::string COMPONENT_LOAD_START = "COMPONENT_LOAD_START"; +const std::string COMPONENT_RELEASE_START = "COMPONENT_RELEASE_START"; +const std::string COMPONENT_INIT_START = "COMPONENT_INIT_START"; +const std::string QUERY_START = "QUERY_START"; +const std::string ENABLE_START = "ENABLE_START"; +const std::string DISABLE_START = "DISABLE_START"; + +void DHCompMgrTraceStart(const std::string &anonyNetworkId, const std::string &anonyDHId, const std::string &msg); +void DHQeryTraceStart(const DHType dhType); void DHTraceStart(const std::string &msg); void DHTraceEnd(); } // namespace DistributedHardware diff --git a/utils/src/dh_utils_hitrace.cpp b/utils/src/dh_utils_hitrace.cpp index 841c85bc..b1f34cb4 100644 --- a/utils/src/dh_utils_hitrace.cpp +++ b/utils/src/dh_utils_hitrace.cpp @@ -19,24 +19,19 @@ namespace OHOS { namespace DistributedHardware { -void CompEnableTraceStart(const DHType dhType) +void DHCompMgrTraceStart(const std::string &anonyNetworkId, const std::string &anonyDHId, const std::string &msg) { - std::string dhTypeStr = "UNKNOWN"; - auto it = DHTypeStrMap.find(dhType); - if (it != DHTypeStrMap.end()) { - dhTypeStr = it->second; - } - StartTrace(DHFWK_HITRACE_LABEL, dhTypeStr + "_ENABLE_START"); + StartTrace(DHFWK_HITRACE_LABEL, anonyNetworkId + "_" + anonyDHId + "_" + msg); } -void CompDisableTraceStart(const DHType dhType) +void DHQeryTraceStart(const DHType dhType) { std::string dhTypeStr = "UNKNOWN"; auto it = DHTypeStrMap.find(dhType); if (it != DHTypeStrMap.end()) { dhTypeStr = it->second; } - StartTrace(DHFWK_HITRACE_LABEL, dhTypeStr + "_DISABLE_START"); + StartTrace(DHFWK_HITRACE_LABEL, dhTypeStr + "_" + QUERY_START); } void DHTraceStart(const std::string &msg) -- Gitee From 18b0459f264290a552592251742dabc5fddac6c4 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 8 Jun 2022 10:57:09 +0800 Subject: [PATCH 16/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/localhardwaremanager/local_hardware_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp index 2a1a721a..fa6e0800 100644 --- a/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp @@ -21,6 +21,7 @@ #include "component_loader.h" #include "device_type.h" #include "dh_context.h" +#include "dh_utils_hitrace.h" #include "distributed_hardware_errno.h" #include "plugin_listener_impl.h" -- Gitee From 4666f4038e99f0fd187bc265265d34fd878d7185 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 8 Jun 2022 15:11:18 +0800 Subject: [PATCH 17/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/componentmanager/component_manager.cpp | 8 ++------ .../src/localhardwaremanager/local_hardware_manager.cpp | 2 +- utils/include/dh_utils_hitrace.h | 2 +- utils/src/dh_utils_hitrace.cpp | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index b639c508..d6719518 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -268,7 +268,6 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string if (compEnable->Enable(networkId, dhId, param, find->second) == DH_FWK_SUCCESS) { DHLOGE("enable success, retryCount = %d", retryCount); DHTraceEnd(); - EnabledCompsDump::GetInstance().DumpEnabledComp(uuid, dhType, dhId); EnabledCompsDump::GetInstance().DumpEnabledComp(networkId, dhType, dhId); return DH_FWK_SUCCESS; } @@ -279,9 +278,8 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string DHLOGI("enable result is %d, uuid = %s, dhId = %s", result, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str()); DHTraceEnd(); - - EnabledCompsDump::GetInstance().DumpEnabledComp(uuid, dhType, dhId); EnabledCompsDump::GetInstance().DumpEnabledComp(networkId, dhType, dhId); + return result; } @@ -305,7 +303,6 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin } if (compDisable->Disable(networkId, dhId, find->second) == DH_FWK_SUCCESS) { DHLOGE("disable success, retryCount = %d", retryCount); - EnabledCompsDump::GetInstance().DumpDisabledComp(uuid, dhType, dhId); DHTraceEnd(); EnabledCompsDump::GetInstance().DumpDisabledComp(networkId, dhType, dhId); return DH_FWK_SUCCESS; @@ -316,10 +313,9 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin } DHLOGI("disable result is %d, uuid = %s, dhId = %s", result, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str()); - - EnabledCompsDump::GetInstance().DumpDisabledComp(uuid, dhType, dhId); DHTraceEnd(); EnabledCompsDump::GetInstance().DumpDisabledComp(networkId, dhType, dhId); + return result; } diff --git a/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp index fa6e0800..1eaec6e6 100644 --- a/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/localhardwaremanager/local_hardware_manager.cpp @@ -50,7 +50,7 @@ void LocalHardwareManager::Init() continue; } - DHQeryTraceStart(dhType); + DHQueryTraceStart(dhType); QueryLocalHardware(dhType, hardwareHandler); DHTraceEnd(); if (!hardwareHandler->IsSupportPlugin()) { diff --git a/utils/include/dh_utils_hitrace.h b/utils/include/dh_utils_hitrace.h index cca8ac8b..eef65e9c 100644 --- a/utils/include/dh_utils_hitrace.h +++ b/utils/include/dh_utils_hitrace.h @@ -33,7 +33,7 @@ const std::string ENABLE_START = "ENABLE_START"; const std::string DISABLE_START = "DISABLE_START"; void DHCompMgrTraceStart(const std::string &anonyNetworkId, const std::string &anonyDHId, const std::string &msg); -void DHQeryTraceStart(const DHType dhType); +void DHQueryTraceStart(const DHType dhType); void DHTraceStart(const std::string &msg); void DHTraceEnd(); } // namespace DistributedHardware diff --git a/utils/src/dh_utils_hitrace.cpp b/utils/src/dh_utils_hitrace.cpp index b1f34cb4..249db5d7 100644 --- a/utils/src/dh_utils_hitrace.cpp +++ b/utils/src/dh_utils_hitrace.cpp @@ -24,7 +24,7 @@ void DHCompMgrTraceStart(const std::string &anonyNetworkId, const std::string &a StartTrace(DHFWK_HITRACE_LABEL, anonyNetworkId + "_" + anonyDHId + "_" + msg); } -void DHQeryTraceStart(const DHType dhType) +void DHQueryTraceStart(const DHType dhType) { std::string dhTypeStr = "UNKNOWN"; auto it = DHTypeStrMap.find(dhType); -- Gitee From aee8ad8c34845c0fd5fcd9df4dca589ddbace1e4 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 8 Jun 2022 15:15:51 +0800 Subject: [PATCH 18/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/componentmanager/component_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index d6719518..66974df5 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -57,7 +57,7 @@ ComponentManager::~ComponentManager() int32_t ComponentManager::Init() { DHLOGI("start."); - DHTraceStart("COMPONENT_INIT_START"); + DHTraceStart(COMPONENT_INIT_START); if (!InitCompSource()) { DHLOGE("InitCompSource failed."); return ERR_DH_FWK_COMPONENT_INIT_SOURCE_FAILED; @@ -255,9 +255,9 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string usleep(ENABLE_PARAM_RETRY_TIME); } } - auto compEnable = std::make_shared(); DHCompMgrTraceStart(GetAnonyString(networkId), GetAnonyString(dhId), ENABLE_START); + auto compEnable = std::make_shared(); auto result = compEnable->Enable(networkId, dhId, param, find->second); if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < ENABLE_RETRY_MAX_TIMES; retryCount++) { @@ -291,9 +291,9 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin DHLOGE("can not find handler for dhId = %s.", dhId.c_str()); return ERR_DH_FWK_PARA_INVALID; } - auto compDisable = std::make_shared(); DHCompMgrTraceStart(GetAnonyString(networkId), GetAnonyString(dhId), DISABLE_START); + auto compDisable = std::make_shared(); auto result = compDisable->Disable(networkId, dhId, find->second); if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < DISABLE_RETRY_MAX_TIMES; retryCount++) { -- Gitee From 11eacb179387168738281e3b1749f6072d0590cb Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 8 Jun 2022 16:10:56 +0800 Subject: [PATCH 19/34] add hitrace Signed-off-by: wanderer-dl122 --- services/distributedhardwarefwkserviceimpl/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index fe019402..621b210b 100644 --- a/services/distributedhardwarefwkserviceimpl/BUILD.gn +++ b/services/distributedhardwarefwkserviceimpl/BUILD.gn @@ -83,8 +83,8 @@ ohos_shared_library("distributedhardwarefwksvr_impl") { "bundle_framework:appexecfwk_core", "distributeddatamgr:distributeddata_inner", "eventhandler:libeventhandler", - "hitrace_native:hitrace_meter", "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", -- Gitee From ec7c0f7794a9f96cffc9aeafc8b2ceb294f2de1f Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 8 Jun 2022 16:32:50 +0800 Subject: [PATCH 20/34] add hitrace Signed-off-by: wanderer-dl122 --- utils/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 3b9eadba..296ad89a 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -29,8 +29,8 @@ ohos_shared_library("distributedhardwareutils") { sources = [ "src/anonymous_string.cpp", - "src/dh_utils_hitrace.cpp", "src/dh_utils_hisysevent.cpp", + "src/dh_utils_hitrace.cpp", "src/dh_utils_tool.cpp", "src/log/dh_log.cpp", ] -- Gitee From 18e6b2e2ef907a6c1ae5c0cfc4b099b0366da791 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Wed, 8 Jun 2022 17:15:33 +0800 Subject: [PATCH 21/34] add hitrace Signed-off-by: wanderer-dl122 --- utils/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 296ad89a..02b32ab5 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -51,8 +51,8 @@ ohos_shared_library("distributedhardwareutils") { "bundle_framework:appexecfwk_core", "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", - "hitrace_native:hitrace_meter", "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", ] -- Gitee From 9796a99c8cb5524ec68942affdeebbd25196a60d Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 9 Jun 2022 10:32:47 +0800 Subject: [PATCH 22/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/distributed_hardware_manager_factory.cpp | 3 +++ utils/include/dh_utils_hitrace.h | 1 + 2 files changed, 4 insertions(+) diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index b50a6fe5..29018198 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -23,6 +23,7 @@ #include "constants.h" #include "device_manager.h" #include "dh_utils_hisysevent.h" +#include "dh_utils_hitrace.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -62,6 +63,7 @@ bool DistributedHardwareManagerFactory::Init() void DistributedHardwareManagerFactory::UnInit() { DHLOGI("start"); + DHTraceStart(UNLOAD_START) HiSysEventWriteMsg(DHFWK_EXIT_BEGIN, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa exit begin."); @@ -69,6 +71,7 @@ void DistributedHardwareManagerFactory::UnInit() distributedHardwareMgrPtr_->Release(); CloseLibrary(); + DHTraceEnd(); CheckExitSAOrNot(); } diff --git a/utils/include/dh_utils_hitrace.h b/utils/include/dh_utils_hitrace.h index eef65e9c..be52a356 100644 --- a/utils/include/dh_utils_hitrace.h +++ b/utils/include/dh_utils_hitrace.h @@ -28,6 +28,7 @@ constexpr uint64_t DHFWK_HITRACE_LABEL = HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK; const std::string COMPONENT_LOAD_START = "COMPONENT_LOAD_START"; const std::string COMPONENT_RELEASE_START = "COMPONENT_RELEASE_START"; const std::string COMPONENT_INIT_START = "COMPONENT_INIT_START"; +const std::string UNLOAD_START = "UNLOAD_START"; const std::string QUERY_START = "QUERY_START"; const std::string ENABLE_START = "ENABLE_START"; const std::string DISABLE_START = "DISABLE_START"; -- Gitee From 06d3efad9c3432e5031cffc514cf94e5c8be099d Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 9 Jun 2022 10:54:20 +0800 Subject: [PATCH 23/34] add hitrace Signed-off-by: wanderer-dl122 --- services/distributedhardwarefwkservice/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn index f9a205b8..7b6b0b52 100644 --- a/services/distributedhardwarefwkservice/BUILD.gn +++ b/services/distributedhardwarefwkservice/BUILD.gn @@ -58,6 +58,7 @@ ohos_shared_library("distributedhardwarefwksvr") { "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", -- Gitee From 09077847eb1f9c3042e7496f9500b3337318c4f0 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 9 Jun 2022 14:12:16 +0800 Subject: [PATCH 24/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/distributed_hardware_manager_factory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 29018198..6c08c141 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -63,7 +63,7 @@ bool DistributedHardwareManagerFactory::Init() void DistributedHardwareManagerFactory::UnInit() { DHLOGI("start"); - DHTraceStart(UNLOAD_START) + DHTraceStart(UNLOAD_START); HiSysEventWriteMsg(DHFWK_EXIT_BEGIN, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa exit begin."); -- Gitee From 5e92036845e7de9c893f36da13acc2e9a9105f02 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 9 Jun 2022 14:36:28 +0800 Subject: [PATCH 25/34] add hitrace Signed-off-by: wanderer-dl122 --- .../test/unittest/common/accessmanager/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn index be489786..64deadab 100644 --- a/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn +++ b/services/distributedhardwarefwkservice/test/unittest/common/accessmanager/BUILD.gn @@ -61,6 +61,7 @@ ohos_unittest("AccessManagerTest") { "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", -- Gitee From 63c5b3f6a67b72df009b09447d7c8e25110099c5 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 9 Jun 2022 19:24:33 +0800 Subject: [PATCH 26/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/distributed_hardware_manager_factory.cpp | 3 ++- .../src/componentmanager/component_manager.cpp | 6 ++++-- utils/include/dh_utils_hitrace.h | 12 +++++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp index 6c08c141..5afa2b0f 100644 --- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp +++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp @@ -63,7 +63,7 @@ bool DistributedHardwareManagerFactory::Init() void DistributedHardwareManagerFactory::UnInit() { DHLOGI("start"); - DHTraceStart(UNLOAD_START); + DHTraceStart(COMPONENT_UNLOAD_START); HiSysEventWriteMsg(DHFWK_EXIT_BEGIN, OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "dhfwk sa exit begin."); @@ -72,6 +72,7 @@ void DistributedHardwareManagerFactory::UnInit() CloseLibrary(); DHTraceEnd(); + CheckExitSAOrNot(); } diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index 66974df5..0e87932e 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -256,7 +256,7 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string } } - DHCompMgrTraceStart(GetAnonyString(networkId), GetAnonyString(dhId), ENABLE_START); + DHCompMgrTraceStart(GetAnonyString(networkId), GetAnonyString(dhId), DH_ENABLE_START); auto compEnable = std::make_shared(); auto result = compEnable->Enable(networkId, dhId, param, find->second); if (result != DH_FWK_SUCCESS) { @@ -273,6 +273,7 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string } DHLOGE("enable failed, retryCount = %d", retryCount); } + DHTraceEnd(); return result; } DHLOGI("enable result is %d, uuid = %s, dhId = %s", result, GetAnonyString(uuid).c_str(), @@ -292,7 +293,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin return ERR_DH_FWK_PARA_INVALID; } - DHCompMgrTraceStart(GetAnonyString(networkId), GetAnonyString(dhId), DISABLE_START); + DHCompMgrTraceStart(GetAnonyString(networkId), GetAnonyString(dhId), DH_DISABLE_START); auto compDisable = std::make_shared(); auto result = compDisable->Disable(networkId, dhId, find->second); if (result != DH_FWK_SUCCESS) { @@ -309,6 +310,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin } DHLOGE("disable failed, retryCount = %d", retryCount); } + DHTraceEnd(); return result; } DHLOGI("disable result is %d, uuid = %s, dhId = %s", result, GetAnonyString(uuid).c_str(), diff --git a/utils/include/dh_utils_hitrace.h b/utils/include/dh_utils_hitrace.h index be52a356..e3d03f36 100644 --- a/utils/include/dh_utils_hitrace.h +++ b/utils/include/dh_utils_hitrace.h @@ -26,13 +26,15 @@ namespace DistributedHardware { constexpr uint64_t DHFWK_HITRACE_LABEL = HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK; const std::string COMPONENT_LOAD_START = "COMPONENT_LOAD_START"; -const std::string COMPONENT_RELEASE_START = "COMPONENT_RELEASE_START"; +const std::string COMPONENT_UNLOAD_START = "COMPONENT_UNLOAD_START"; + const std::string COMPONENT_INIT_START = "COMPONENT_INIT_START"; -const std::string UNLOAD_START = "UNLOAD_START"; -const std::string QUERY_START = "QUERY_START"; -const std::string ENABLE_START = "ENABLE_START"; -const std::string DISABLE_START = "DISABLE_START"; +const std::string COMPONENT_RELEASE_START = "COMPONENT_RELEASE_START"; + +const std::string DH_QUERY_START = "DH_QUERY_START"; +const std::string DH_ENABLE_START = "DH_ENABLE_START"; +const std::string DH_DISABLE_START = "DH_DISABLE_START"; void DHCompMgrTraceStart(const std::string &anonyNetworkId, const std::string &anonyDHId, const std::string &msg); void DHQueryTraceStart(const DHType dhType); void DHTraceStart(const std::string &msg); -- Gitee From 6c1855968619ccd290925bd48b90ae799a3d0b99 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Thu, 9 Jun 2022 19:38:49 +0800 Subject: [PATCH 27/34] add hitrace Signed-off-by: wanderer-dl122 --- utils/src/dh_utils_hitrace.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/src/dh_utils_hitrace.cpp b/utils/src/dh_utils_hitrace.cpp index 249db5d7..0c0d8cbf 100644 --- a/utils/src/dh_utils_hitrace.cpp +++ b/utils/src/dh_utils_hitrace.cpp @@ -31,7 +31,7 @@ void DHQueryTraceStart(const DHType dhType) if (it != DHTypeStrMap.end()) { dhTypeStr = it->second; } - StartTrace(DHFWK_HITRACE_LABEL, dhTypeStr + "_" + QUERY_START); + StartTrace(DHFWK_HITRACE_LABEL, dhTypeStr + "_" + DH_QUERY_START); } void DHTraceStart(const std::string &msg) -- Gitee From 8fdb683366624c1e5d476b7fe72029d02759fc54 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Fri, 10 Jun 2022 09:51:11 +0800 Subject: [PATCH 28/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/componentmanager/component_manager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index 0e87932e..94d67a68 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -60,11 +60,13 @@ int32_t ComponentManager::Init() DHTraceStart(COMPONENT_INIT_START); if (!InitCompSource()) { DHLOGE("InitCompSource failed."); + DHTraceEnd(); return ERR_DH_FWK_COMPONENT_INIT_SOURCE_FAILED; } if (!InitCompSink()) { DHLOGE("InitCompSink failed."); compSource_.clear(); + DHTraceEnd(); return ERR_DH_FWK_COMPONENT_INIT_SINK_FAILED; } @@ -263,6 +265,7 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string 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()); + DHTraceEnd(); return result; } if (compEnable->Enable(networkId, dhId, param, find->second) == DH_FWK_SUCCESS) { @@ -300,6 +303,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin 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()); + DHTraceEnd(); return result; } if (compDisable->Disable(networkId, dhId, find->second) == DH_FWK_SUCCESS) { -- Gitee From 8afafb00bd76fbb71fc6bc0b4ae1af729a7f576e Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 13 Jun 2022 11:02:05 +0800 Subject: [PATCH 29/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/componentmanager/component_manager.cpp | 10 ---------- .../src/task/disable_task.cpp | 3 +++ .../src/task/enable_task.cpp | 3 +++ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index 94d67a68..fe4d9baf 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -25,7 +25,6 @@ #include "component_loader.h" #include "constants.h" #include "dh_context.h" -#include "dh_utils_hitrace.h" #include "dh_utils_hisysevent.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" @@ -258,14 +257,12 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string } } - DHCompMgrTraceStart(GetAnonyString(networkId), GetAnonyString(dhId), DH_ENABLE_START); auto compEnable = std::make_shared(); auto result = compEnable->Enable(networkId, dhId, param, find->second); 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()); - DHTraceEnd(); return result; } if (compEnable->Enable(networkId, dhId, param, find->second) == DH_FWK_SUCCESS) { @@ -276,12 +273,10 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string } DHLOGE("enable failed, retryCount = %d", retryCount); } - DHTraceEnd(); return result; } DHLOGI("enable result is %d, uuid = %s, dhId = %s", result, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str()); - DHTraceEnd(); EnabledCompsDump::GetInstance().DumpEnabledComp(networkId, dhType, dhId); return result; @@ -296,30 +291,25 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin return ERR_DH_FWK_PARA_INVALID; } - DHCompMgrTraceStart(GetAnonyString(networkId), GetAnonyString(dhId), DH_DISABLE_START); auto compDisable = std::make_shared(); auto result = compDisable->Disable(networkId, dhId, find->second); 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()); - DHTraceEnd(); return result; } if (compDisable->Disable(networkId, dhId, find->second) == DH_FWK_SUCCESS) { DHLOGE("disable success, retryCount = %d", retryCount); - DHTraceEnd(); EnabledCompsDump::GetInstance().DumpDisabledComp(networkId, dhType, dhId); return DH_FWK_SUCCESS; } DHLOGE("disable failed, retryCount = %d", retryCount); } - DHTraceEnd(); return result; } DHLOGI("disable result is %d, uuid = %s, dhId = %s", result, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str()); - DHTraceEnd(); EnabledCompsDump::GetInstance().DumpDisabledComp(networkId, dhType, dhId); return result; diff --git a/services/distributedhardwarefwkserviceimpl/src/task/disable_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/disable_task.cpp index ceb1d514..f8a10a8c 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/disable_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/disable_task.cpp @@ -17,6 +17,7 @@ #include "anonymous_string.h" #include "component_manager.h" +#include "dh_utils_hitrace.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" #include "offline_task.h" @@ -68,9 +69,11 @@ void DisableTask::DoTaskInner() 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()); + DHTraceEnd(); return result; } } // namespace DistributedHardware diff --git a/services/distributedhardwarefwkserviceimpl/src/task/enable_task.cpp b/services/distributedhardwarefwkserviceimpl/src/task/enable_task.cpp index d1e89f43..5f343cdf 100644 --- a/services/distributedhardwarefwkserviceimpl/src/task/enable_task.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/task/enable_task.cpp @@ -17,6 +17,7 @@ #include "anonymous_string.h" #include "component_manager.h" +#include "dh_utils_hitrace.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" #include "task_board.h" @@ -58,9 +59,11 @@ void EnableTask::DoTaskInner() 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()); + DHTraceEnd(); return result; } } // namespace DistributedHardware -- Gitee From a67c24aad0098a9924156ba9be4354325784918b Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 13 Jun 2022 12:22:55 +0800 Subject: [PATCH 30/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/componentmanager/component_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index fe4d9baf..f01a4ce1 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -25,6 +25,7 @@ #include "component_loader.h" #include "constants.h" #include "dh_context.h" +#include "dh_utils_hitrace.h" #include "dh_utils_hisysevent.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" -- Gitee From f4b53348d2ebfe968ebe0c9b0df01f5b0b93cab8 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 13 Jun 2022 15:02:51 +0800 Subject: [PATCH 31/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/hidumphelper/hidump_helper.cpp | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp index bc0a4aac..fa814617 100644 --- a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp @@ -18,6 +18,7 @@ #include #include "capability_info_manager.h" +#include "component_loader.h" #include "component_manager.h" #include "distributed_hardware_errno.h" #include "distributed_hardware_log.h" @@ -127,9 +128,11 @@ int32_t HidumpHelper::ShowAllLoadedComps(std::string &result) std::set loadedCompSource {}; std::set loadedCompSink {}; ComponentManager::GetInstance().DumpLoadedComps(loadedCompSource, loadedCompSink); + DHVersion dhVersion; + ComponentLoader::GetInstance().GetLocalDHVersion(dhVersion); - result.append("Local loaded components:\n{"); - result.append("\n Source : ["); + result.append("Local loaded components:"); + result.append("\nSource:\n"); if (!loadedCompSource.empty()) { for (auto compSource : loadedCompSource) { std::string dhTypeStr = "UNKNOWN"; @@ -137,15 +140,19 @@ int32_t HidumpHelper::ShowAllLoadedComps(std::string &result) if (it != DHTypeStrMap.end()) { dhTypeStr = it->second; } - result.append(" "); - result.append(dhTypeStr); - result.append(","); + std::string sourceVersion = ""; + auto iter = dhVersion.compVersions.find(compSource); + if (iter != dhVersion.compVersions.end()) { + sourceVersion = iter->second.sourceVersion; + } + result.append("{\n DHType : ").append(dhTypeStr); + result.append("\n Version : ").append(sourceVersion); + result.append("},"); } - result.replace(result.size() - 1, 1, " "); + result.replace(result.size() - 1, 1, "\n"); } - result.append("]"); - result.append("\n Sink : ["); + result.append("\nSink:"); if (!loadedCompSink.empty()) { for (auto compSink : loadedCompSink) { std::string dhTypeStr = "UNKNOWN"; @@ -153,14 +160,17 @@ int32_t HidumpHelper::ShowAllLoadedComps(std::string &result) if (it != DHTypeStrMap.end()) { dhTypeStr = it->second; } - result.append(" "); - result.append(dhTypeStr); - result.append(","); + std::string sinkVersion = ""; + auto iter = dhVersion.compVersions.find(compSink); + if (iter != dhVersion.compVersions.end()) { + sinkVersion = iter->second.sinkVersion; + } + result.append("{\n DHType : ").append(dhTypeStr); + result.append("\n Version : ").append(sinkVersion); + result.append("},"); } - result.replace(result.size() - 1, 1, " "); + result.replace(result.size() - 1, 1, "\n"); } - result.append("]"); - result.append("\n}\n"); return DH_FWK_SUCCESS; } -- Gitee From 1cc6f4af92d69c20fc39f786df3f7cfdf01d88b9 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 13 Jun 2022 16:10:16 +0800 Subject: [PATCH 32/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/hidumphelper/hidump_helper.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp index fa814617..88adf956 100644 --- a/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/hidumphelper/hidump_helper.cpp @@ -132,7 +132,7 @@ int32_t HidumpHelper::ShowAllLoadedComps(std::string &result) ComponentLoader::GetInstance().GetLocalDHVersion(dhVersion); result.append("Local loaded components:"); - result.append("\nSource:\n"); + result.append("\nSource:"); if (!loadedCompSource.empty()) { for (auto compSource : loadedCompSource) { std::string dhTypeStr = "UNKNOWN"; @@ -145,9 +145,9 @@ int32_t HidumpHelper::ShowAllLoadedComps(std::string &result) if (iter != dhVersion.compVersions.end()) { sourceVersion = iter->second.sourceVersion; } - result.append("{\n DHType : ").append(dhTypeStr); + result.append("\n{\n DHType : ").append(dhTypeStr); result.append("\n Version : ").append(sourceVersion); - result.append("},"); + result.append("\n},"); } result.replace(result.size() - 1, 1, "\n"); } @@ -165,9 +165,9 @@ int32_t HidumpHelper::ShowAllLoadedComps(std::string &result) if (iter != dhVersion.compVersions.end()) { sinkVersion = iter->second.sinkVersion; } - result.append("{\n DHType : ").append(dhTypeStr); + result.append("\n{\n DHType : ").append(dhTypeStr); result.append("\n Version : ").append(sinkVersion); - result.append("},"); + result.append("\n},"); } result.replace(result.size() - 1, 1, "\n"); } -- Gitee From 0937a859bea6188abc82c130c578d549d49b4941 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 13 Jun 2022 16:27:38 +0800 Subject: [PATCH 33/34] add hitrace Signed-off-by: wanderer-dl122 --- .../src/componentmanager/component_manager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index f01a4ce1..fa9d0939 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -268,7 +268,6 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string } if (compEnable->Enable(networkId, dhId, param, find->second) == DH_FWK_SUCCESS) { DHLOGE("enable success, retryCount = %d", retryCount); - DHTraceEnd(); EnabledCompsDump::GetInstance().DumpEnabledComp(networkId, dhType, dhId); return DH_FWK_SUCCESS; } -- Gitee From 11f05d20a1d22e40a880b462c6205efefaba91e1 Mon Sep 17 00:00:00 2001 From: wanderer-dl122 Date: Mon, 13 Jun 2022 16:39:34 +0800 Subject: [PATCH 34/34] add hitrace Signed-off-by: wanderer-dl122 --- utils/include/dh_utils_hitrace.h | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/include/dh_utils_hitrace.h b/utils/include/dh_utils_hitrace.h index e3d03f36..50221544 100644 --- a/utils/include/dh_utils_hitrace.h +++ b/utils/include/dh_utils_hitrace.h @@ -35,6 +35,7 @@ const std::string DH_QUERY_START = "DH_QUERY_START"; const std::string DH_ENABLE_START = "DH_ENABLE_START"; const std::string DH_DISABLE_START = "DH_DISABLE_START"; + void DHCompMgrTraceStart(const std::string &anonyNetworkId, const std::string &anonyDHId, const std::string &msg); void DHQueryTraceStart(const DHType dhType); void DHTraceStart(const std::string &msg); -- Gitee