diff --git a/adapter/ohos/osal/thp_extra_manager_impl.cpp b/adapter/ohos/osal/thp_extra_manager_impl.cpp index 96838eb8bdb..68233de2f02 100644 --- a/adapter/ohos/osal/thp_extra_manager_impl.cpp +++ b/adapter/ohos/osal/thp_extra_manager_impl.cpp @@ -22,12 +22,16 @@ #include "base/json/json_util.h" namespace OHOS::Ace::NG { +void* THPExtraManagerImpl::lib_ = nullptr; + bool THPExtraManagerImpl::Init() { ThpExtraRunCommand_ = [](const char* command, const char* parameters) -> const char* { return "ok"; }; - lib_ = dlopen("/system/lib64/libthp_extra_innerapi.z.so", RTLD_LAZY); + if (lib_ == nullptr) { + lib_ = dlopen("/system/lib64/libthp_extra_innerapi.z.so", RTLD_LAZY); + } if (lib_ == nullptr) { LOGI("Failed to open libthp_extra_innerapi.z.so, reason: %{public}s", dlerror()); return false; diff --git a/adapter/ohos/osal/thp_extra_manager_impl.h b/adapter/ohos/osal/thp_extra_manager_impl.h index 9076632bb57..32cf77190a5 100644 --- a/adapter/ohos/osal/thp_extra_manager_impl.h +++ b/adapter/ohos/osal/thp_extra_manager_impl.h @@ -31,7 +31,7 @@ public: int32_t GetHeight(void) const override; int32_t GetWidth(void) const override; private: - void* lib_ = nullptr; + static void* lib_; bool enable_ = false; int32_t height_ = 0; int32_t width_ = 0;