diff --git a/adapter/uhdf2/hdi.gni b/adapter/uhdf2/hdi.gni index 882ba74141cfab7b7cad5c12aeb82565d4bfff0c..dbfaa404fc4768db02a90c7cd9aade2f9a7319d6 100644 --- a/adapter/uhdf2/hdi.gni +++ b/adapter/uhdf2/hdi.gni @@ -12,7 +12,6 @@ # limitations under the License.. import("//build/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") hdf_fwk_path = "//drivers/hdf_core/framework" idl_tool_path = "//foundation/ability/idl_tool/idl_tool_2" diff --git a/adapter/uhdf2/ipc/BUILD.gn b/adapter/uhdf2/ipc/BUILD.gn index 1bef89f422aa7ee2896fc8afdacc4fcf1b94b30e..4481e0a9ddf10e457c2bd0e24737c275f1fbc6bb 100644 --- a/adapter/uhdf2/ipc/BUILD.gn +++ b/adapter/uhdf2/ipc/BUILD.gn @@ -56,6 +56,10 @@ if (defined(ohos_lite)) { "ipc:ipc_single", "samgr:samgr_proxy", ] + + if (hicollie_enabled) { + external_deps += [ "hicollie:libhicollie" ] + } } else { external_deps = [ "hilog:libhilog", diff --git a/adapter/uhdf2/ipc/src/hdf_remote_adapter.cpp b/adapter/uhdf2/ipc/src/hdf_remote_adapter.cpp index f6d3db3cd317e9e6df9446c7d70dbbba439a43bd..9966c1bd0750ad6daabe6fa209458eb9b3965c52 100644 --- a/adapter/uhdf2/ipc/src/hdf_remote_adapter.cpp +++ b/adapter/uhdf2/ipc/src/hdf_remote_adapter.cpp @@ -311,6 +311,9 @@ int HdfRemoteAdapterAddSa(int32_t saId, struct HdfRemoteService *service) const int32_t sleepInterval = 20000; OHOS::sptr saManager; { + OHOS::HdfXCollie hdfXCollie("HdfRemoteAdapterAddSa_" + OHOS::ToString(saId) + "_get_samgr", + OHOS::DEFAULT_TIMEOUT_SECONDS, nullptr, nullptr, OHOS::HDF_XCOLLIE_FLAG_RECOVERY); + for (uint32_t cnt = 0; cnt < waitTimes; ++cnt) { HDF_LOGI("waiting for samgr... %{public}d", cnt); saManager = OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); @@ -329,6 +332,8 @@ int HdfRemoteAdapterAddSa(int32_t saId, struct HdfRemoteService *service) } } { + OHOS::HdfXCollie hdfXCollie("HdfRemoteAdapterAddSa_" + OHOS::ToString(saId) + "_add_sa", + OHOS::DEFAULT_TIMEOUT_SECONDS, nullptr, nullptr, OHOS::HDF_XCOLLIE_FLAG_RECOVERY); struct HdfRemoteServiceHolder *holder = reinterpret_cast(service); #ifdef WITH_SELINUX OHOS::sptr remote = holder->remote_; diff --git a/adapter/uhdf2/pub_utils/BUILD.gn b/adapter/uhdf2/pub_utils/BUILD.gn index 173d86786aa4f54685dae55d779df7965f7f4e45..a8a2a679d16d55f00787719f3d62343383b3287c 100644 --- a/adapter/uhdf2/pub_utils/BUILD.gn +++ b/adapter/uhdf2/pub_utils/BUILD.gn @@ -54,7 +54,7 @@ if (defined(ohos_lite)) { ] defines = [] if (hicollie_enabled) { - public_external_deps = [ "hicollie:libhicollie" ] + external_deps += [ "hicollie:libhicollie" ] defines += [ "HDFHICOLLIE_ENABLE" ] } diff --git a/adapter/uhdf2/uhdf.gni b/adapter/uhdf2/uhdf.gni index 3a7b5f64e10f1990a91510b351bc887c6a0a0549..9de2161f44a1fef9aa480f1ce0f8a2e7e67d9bc3 100644 --- a/adapter/uhdf2/uhdf.gni +++ b/adapter/uhdf2/uhdf.gni @@ -14,11 +14,16 @@ hdf_framework_path = "//drivers/hdf_core/framework" hdf_uhdf_path = "//drivers/hdf_core/adapter/uhdf2" declare_args() { - hicollie_enabled = true - if (defined(global_parts_info) && - !defined(global_parts_info.hiviewdfx_hicollie)) { - hicollie_enabled = false + hdf_core_default_hicollie_config = false +} + +declare_args() { + hicollie_enabled = false + + if (hdf_core_default_hicollie_config) { + hicollie_enabled = hdf_core_default_hicollie_config } + with_sample = false hdf_core_default_peripheral_config = true } diff --git a/adapter/uhdf2/utils/include/hdf_xcollie.h b/adapter/uhdf2/utils/include/hdf_xcollie.h index 32511b961ac139be1ee5e8776a688dbbd91845c7..7a0068942b27486d6f91d1bc15d64e6305b2efd7 100644 --- a/adapter/uhdf2/utils/include/hdf_xcollie.h +++ b/adapter/uhdf2/utils/include/hdf_xcollie.h @@ -24,24 +24,29 @@ #endif namespace OHOS { +constexpr uint32_t HDF_XCOLLIE_FLAG_LOG = 1; // generate log file +constexpr uint32_t HDF_XCOLLIE_FLAG_RECOVERY = 2; // die when timeout +constexpr uint32_t DEFAULT_TIMEOUT_SECONDS = 10; #ifdef HDFHICOLLIE_ENABLE -using HdfXCollie = ::OHOS::HiviewDFX::XCollie; -#else -class HdfXCollie : public Singleton { - DECLARE_SINGLETON(HdfXCollie); -public: - // NULL impl - int SetTimer(const std::string &name, unsigned int timeout, - std::function func, void *arg, unsigned int flag); +class HdfXCollie { + HdfXCollie(const std::string& tag, uint32_t timeoutSeconds = DEFAULT_TIMEOUT_SECONDS, + std::function func = nullptr, void* arg = nullptr, uint32_t flag = HDF_XCOLLIE_FLAG_LOG); + ~HdfXCollie(); - // NULL impl - void CancelTimer(int id); + void CancelHdfXCollie(); - // NULL impl - int SetTimerCount(const std::string &name, unsigned int timeLimit, int countLimit); +private: + int32_t id_; + std::string tag_; + bool isCanceled_; +}; - // NULL impl - void TriggerTimerCount(const std::string &name, bool bTrigger, const std::string &message); +#else +class HdfXCollie { +public: + HdfXCollie(const std::string& tag, uint32_t timeoutSeconds = DEFAULT_TIMEOUT_SECONDS, + std::function func = nullptr, void* arg = nullptr, uint32_t flag = HDF_XCOLLIE_FLAG_LOG); + ~HdfXCollie(); }; #endif } diff --git a/adapter/uhdf2/utils/src/hdf_xcollie.cpp b/adapter/uhdf2/utils/src/hdf_xcollie.cpp index 0b3f9224736ab114de1779fe9c2178da97d41eda..88f5e1ed965d1fdc5934589be347d25d19f01dbd 100644 --- a/adapter/uhdf2/utils/src/hdf_xcollie.cpp +++ b/adapter/uhdf2/utils/src/hdf_xcollie.cpp @@ -18,35 +18,38 @@ namespace OHOS { #ifdef HDFHICOLLIE_ENABLE -#else -#define HDFXCOLLIE_SUCCESS 0 -HdfXCollie::HdfXCollie() +HdfXCollie::HdfXCollie(const std::string& tag, uint32_t timeoutSeconds, + std::function func, void* arg, uint32_t flag) { + tag_ = tag; + id_ = HiviewDFX::XCollie::GetInstance().SetTimer(tag_, timeoutSeconds, func, arg, flag); + isCanceled_ = false; + HDF_LOGD("start HdfXCollie, tag:%{public}s,timeout:%{public}u,flag:%{public}u,id:%{public}d", + tag_.c_str(), timeoutSeconds, flag, id_); } + HdfXCollie::~HdfXCollie() { -} -// NULL impl -int HdfXCollie::SetTimer(const std::string &name, unsigned int timeout, - std::function func, void *arg, unsigned int flag) -{ - return HDFXCOLLIE_SUCCESS; + CancelHdfXCollie(); } -// NULL impl -void HdfXCollie::CancelTimer(int id) +void HdfXCollie::CancelHdfXCollie() { + if (!isCanceled_) { + HiviewDFX::XCollie::GetInstance().CancelTimer(id_); + isCanceled_ = true; + HDF_LOGD("cancel HdfXCollie, tag:%{public}s,id:%{public}d", tag_.c_str(), id_); + } } +#else -// NULL impl -int HdfXCollie::SetTimerCount(const std::string &name, unsigned int timeLimit, int countLimit) +HdfXCollie::HdfXCollie(const std::string& tag, uint32_t timeoutSeconds, + std::function func, void* arg, uint32_t flag) { - return HDFXCOLLIE_SUCCESS; } -// NULL impl -void HdfXCollie::TriggerTimerCount(const std::string &name, bool bTrigger, const std::string &message) +HdfXCollie::~HdfXCollie() { } #endif -} \ No newline at end of file +} diff --git a/bundle.json b/bundle.json index 5465573090d63f4b2bf98fb7e4e200a345aff7d6..7b2f6d0ce1cabcaf013c57a0a3ac8dbbbc6e492e 100644 --- a/bundle.json +++ b/bundle.json @@ -16,7 +16,8 @@ "hdf_core_khdf_test_support", "hdf_core_platform_test_support", "hdf_core_platform_rtc_test_support", - "hdf_core_default_peripheral_config" + "hdf_core_default_peripheral_config", + "hdf_core_default_hicollie_config" ], "adapted_system_type": ["standard", "small", "mini"], "rom": "735KB",