diff --git a/services/distributedhardwarefwkserviceimpl/BUILD.gn b/services/distributedhardwarefwkserviceimpl/BUILD.gn index 6e3b3a2..99a9065 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 0000000..89a7139 --- /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 9cb2c82..009fa3b 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 ebbf1cb..c53cbdc 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; }