diff --git a/js_concurrent_module/taskpool/worker.cpp b/js_concurrent_module/taskpool/worker.cpp index 19a781c886abdcb83753f246754ce1f45743e95c..9aa14b309657bc78172ba5e8b8f4744a3682b7cd 100644 --- a/js_concurrent_module/taskpool/worker.cpp +++ b/js_concurrent_module/taskpool/worker.cpp @@ -28,6 +28,7 @@ #include "native_engine.h" namespace Commonlibrary::Concurrent::TaskPoolModule { +using RegisterIntl = bool (*)(napi_env); using namespace OHOS::JsSysModule; using namespace Commonlibrary::Platform; static constexpr uint32_t TASKPOOL_TYPE = 2; @@ -264,6 +265,28 @@ void Worker::ExecuteInThread(const void* data) worker = nullptr; } +void RegisterIntlModule(napi_env env) +{ + HILOG_ERROR("ReplaceBuildInAPI: taskpool OHOSJsEnvironmentImpl::InitIntlModule"); + void *intlUtilHandle = dlopen("libintl.z.so", RTLD_NOW); + if (intlUtilHandle == nullptr) { + HILOG_ERROR("ReplaceBuildInAPI: taskpool load libintl.z.so failed"); + return; + } + RegisterIntl registerIntl = (RegisterIntl)dlsym(intlUtilHandle, "RegisterIntl"); + + bool ret = false; + if (registerIntl) { + ret = registerIntl(env); + } else { + HILOG_ERROR("ReplaceBuildInAPI: taskpool registerIntl is null"); + } + // dlclose(intlUtilHandle); + if (!ret) { + HILOG_ERROR("ReplaceBuildInAPI: taskpool Register intl failed"); + } +} + bool Worker::PrepareForWorkerInstance() { HITRACE_HELPER_METER_NAME(__PRETTY_FUNCTION__); @@ -311,6 +334,9 @@ bool Worker::PrepareForWorkerInstance() // register timer interface Timer::RegisterTime(workerEnv_); + // register timer interface + RegisterIntlModule(workerEnv_); + // Check exception after worker construction if (NapiHelper::IsExceptionPending(workerEnv_)) { HILOG_ERROR("taskpool:: Worker construction occur exception"); diff --git a/js_concurrent_module/worker/worker.cpp b/js_concurrent_module/worker/worker.cpp index 5a70a71aa9f0d4b7c8262448f71e05a35eb9da10..0a567a3210539976154c8038ad7c06234db3e220 100644 --- a/js_concurrent_module/worker/worker.cpp +++ b/js_concurrent_module/worker/worker.cpp @@ -31,6 +31,7 @@ #include "native_engine.h" namespace Commonlibrary::Concurrent::WorkerModule { +using RegisterIntl = bool (*)(napi_env); using namespace OHOS::JsSysModule; static constexpr int8_t NUM_WORKER_ARGS = 2; static constexpr uint8_t NUM_GLOBAL_CALL_ARGS = 3; @@ -1506,6 +1507,28 @@ void Worker::ExecuteInThread(const void* data) } } +void RegisterIntlModule(napi_env env) +{ + HILOG_ERROR("ReplaceBuildInAPI: taskpool OHOSJsEnvironmentImpl::InitIntlModule"); + void *intlUtilHandle = dlopen("libintl_util.z.so", RTLD_NOW); + if (intlUtilHandle == nullptr) { + HILOG_ERROR("ReplaceBuildInAPI: taskpool load libintl_util.z.so failed"); + return; + } + RegisterIntl registerIntl = (RegisterIntl)dlsym(intlUtilHandle, "RegisterIntl"); + + bool ret = false; + if (registerIntl) { + ret = registerIntl(env); + } else { + HILOG_ERROR("ReplaceBuildInAPI: taskpool registerIntl is null"); + } + // dlclose(intlUtilHandle); + if (!ret) { + HILOG_ERROR("ReplaceBuildInAPI: taskpool Register intl failed"); + } +} + bool Worker::PrepareForWorkerInstance() { std::string rawFileName = script_; @@ -1534,6 +1557,10 @@ bool Worker::PrepareForWorkerInstance() } // add timer interface Timer::RegisterTime(workerEnv_); + + // register timer interface + RegisterIntlModule(workerEnv_); + napi_value execScriptResult = nullptr; napi_status status = napi_run_actor(workerEnv_, const_cast(rawFileName.c_str()), const_cast(script_.c_str()), &execScriptResult);