From 852d978af6ddcfe0b309eaa17a3a46c121fe9e5c Mon Sep 17 00:00:00 2001 From: zhuhan Date: Thu, 22 Aug 2024 17:25:46 +0800 Subject: [PATCH] env dfx Signed-off-by: zhuhan Change-Id: I6e6f545b6e2ae549bb54cc23345368b0eef6b3cf --- frameworks/native/appkit/BUILD.gn | 6 +++++- .../context/application_context_manager.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/frameworks/native/appkit/BUILD.gn b/frameworks/native/appkit/BUILD.gn index 56cf4b7ce3..5dc0c79ddb 100644 --- a/frameworks/native/appkit/BUILD.gn +++ b/frameworks/native/appkit/BUILD.gn @@ -472,7 +472,10 @@ ohos_shared_library("appkit_delegator") { } config("application_context_manager_config") { - include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context" ] + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context", + "${ability_runtime_services_path}/common/include", + ] } ohos_shared_library("appkit_manager_helper") { @@ -529,6 +532,7 @@ ohos_shared_library("application_context_manager") { external_deps = [ "ets_runtime:libark_jsruntime", + "hilog:libhilog", "napi:ace_napi", ] diff --git a/frameworks/native/appkit/ability_runtime/context/application_context_manager.cpp b/frameworks/native/appkit/ability_runtime/context/application_context_manager.cpp index b71a9eb1cc..b90ea0279c 100644 --- a/frameworks/native/appkit/ability_runtime/context/application_context_manager.cpp +++ b/frameworks/native/appkit/ability_runtime/context/application_context_manager.cpp @@ -15,6 +15,8 @@ #include "application_context_manager.h" +#include "hilog_tag_wrapper.h" + namespace OHOS { namespace AbilityRuntime { namespace { @@ -52,7 +54,10 @@ void ApplicationContextManager::AddGlobalObject(napi_env env, if (envData == nullptr) { return; } - napi_add_env_cleanup_hook(env, HandleClean, static_cast(envData)); + auto ret = napi_add_env_cleanup_hook(env, HandleClean, static_cast(envData)); + if (ret != napi_status::napi_ok) { + TAG_LOGE(AAFwkTag::APPKIT, "add hook err"); + } std::lock_guard lock(applicationContextMutex_); auto iter = applicationContextMap_.find(env); if (iter == applicationContextMap_.end()) {