diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index daaa910ce3..b21889813f 100644 --- a/frameworks/native/runtime/js_runtime.cpp +++ b/frameworks/native/runtime/js_runtime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -60,6 +60,7 @@ #include "system_ability_definition.h" #include "source_map.h" #include "source_map_operator.h" +#include "worker_info.h" #ifdef SUPPORT_SCREEN #include "hot_reloader.h" diff --git a/frameworks/native/runtime/js_runtime_lite.cpp b/frameworks/native/runtime/js_runtime_lite.cpp index 785b607c4d..0242988a8d 100644 --- a/frameworks/native/runtime/js_runtime_lite.cpp +++ b/frameworks/native/runtime/js_runtime_lite.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -28,6 +28,7 @@ #include "parameters.h" #include "system_ability_definition.h" #include "native_engine/native_create_env.h" +#include "worker_info.h" using Extractor = OHOS::AbilityBase::Extractor; using ExtractorUtil = OHOS::AbilityBase::ExtractorUtil; diff --git a/frameworks/native/runtime/js_worker.cpp b/frameworks/native/runtime/js_worker.cpp index ca49ec39bf..a4ba72e16e 100644 --- a/frameworks/native/runtime/js_worker.cpp +++ b/frameworks/native/runtime/js_worker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 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 @@ -43,6 +43,8 @@ #include "singleton.h" #include "syscap_ts.h" #include "system_ability_definition.h" +#include "js_environment_impl.h" +#include "worker_info.h" #ifdef SUPPORT_SCREEN using OHOS::Ace::ContainerScope; #endif @@ -169,6 +171,14 @@ std::string AssetHelper::NormalizedFileName(const std::string& fileName) const return normalizedFilePath; } +AssetHelper::AssetHelper(std::shared_ptr workerInfo) : workerInfo_(workerInfo) +{ + panda::panda_file::StringPacProtect codePath = panda::panda_file::StringPacProtect(workerInfo_->codePath); + if (!(codePath.GetOriginString()).empty() && (codePath.GetOriginString()).back() != '/') { + (workerInfo_->codePath).Append('/'); + } +} + AssetHelper::~AssetHelper() { TAG_LOGD(AAFwkTag::JSRUNTIME, "destroyed"); diff --git a/frameworks/native/runtime/js_worker.h b/frameworks/native/runtime/js_worker.h index 0832956083..a5d67f8ef5 100644 --- a/frameworks/native/runtime/js_worker.h +++ b/frameworks/native/runtime/js_worker.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 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 @@ -34,13 +34,7 @@ void SetJsFramework(); class AssetHelper final { public: - explicit AssetHelper(std::shared_ptr workerInfo) : workerInfo_(workerInfo) - { - panda::panda_file::StringPacProtect codePath = panda::panda_file::StringPacProtect(workerInfo_->codePath); - if (!(codePath.GetOriginString()).empty() && (codePath.GetOriginString()).back() != '/') { - (workerInfo_->codePath).Append('/'); - } - } + explicit AssetHelper(std::shared_ptr workerInfo); virtual ~AssetHelper(); diff --git a/frameworks/native/runtime/ohos_js_environment_impl.cpp b/frameworks/native/runtime/ohos_js_environment_impl.cpp index ee6cf1ecc0..6f77792c82 100644 --- a/frameworks/native/runtime/ohos_js_environment_impl.cpp +++ b/frameworks/native/runtime/ohos_js_environment_impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -21,6 +21,7 @@ #include "js_worker.h" #include "ohos_loop_handler.h" #include "sys_timer.h" +#include "worker_info.h" namespace OHOS { namespace AbilityRuntime { diff --git a/interfaces/kits/native/ability/native/continuation/distributed/continuation_manager.h b/interfaces/kits/native/ability/native/continuation/distributed/continuation_manager.h index 801696e430..e9db4d2cb7 100644 --- a/interfaces/kits/native/ability/native/continuation/distributed/continuation_manager.h +++ b/interfaces/kits/native/ability/native/continuation/distributed/continuation_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -20,13 +20,13 @@ #include #include "continuation_state.h" #include "ability_info.h" -#include "event_handler.h" #include "iremote_object.h" #include "want.h" using OHOS::AAFwk::WantParams; namespace OHOS { namespace AppExecFwk { +class EventHandler; class Ability; class ContinuationHandler; class IAbilityContinuation; diff --git a/js_environment/frameworks/js_environment/src/js_environment.cpp b/js_environment/frameworks/js_environment/src/js_environment.cpp index 6ff8846763..e81c53a596 100644 --- a/js_environment/frameworks/js_environment/src/js_environment.cpp +++ b/js_environment/frameworks/js_environment/src/js_environment.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -23,6 +23,7 @@ #include "js_environment_impl.h" #include "native_engine/impl/ark/ark_native_engine.h" #include "uncaught_exception_callback.h" +#include "worker_info.h" namespace OHOS { namespace JsEnv { diff --git a/js_environment/interfaces/inner_api/js_environment.h b/js_environment/interfaces/inner_api/js_environment.h index b66520164b..91b9248641 100644 --- a/js_environment/interfaces/inner_api/js_environment.h +++ b/js_environment/interfaces/inner_api/js_environment.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -26,6 +26,7 @@ namespace OHOS { namespace JsEnv { +struct WorkerInfo; class JsEnvironmentImpl; using DebuggerPostTask = std::function&&)>; using RequestAotCallback = diff --git a/js_environment/interfaces/inner_api/js_environment_impl.h b/js_environment/interfaces/inner_api/js_environment_impl.h index 7143eb4717..d8e1bde605 100644 --- a/js_environment/interfaces/inner_api/js_environment_impl.h +++ b/js_environment/interfaces/inner_api/js_environment_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -20,24 +20,9 @@ #include "event_handler.h" #include "native_engine/native_engine.h" -#include "native_engine/native_engine.h" - -#include "data_protect.h" - namespace OHOS { namespace JsEnv { -struct WorkerInfo { - panda::panda_file::StringPacProtect codePath; - bool isDebugVersion = false; - bool isBundle = true; - std::string packagePathStr; - std::vector assetBasePathStr; - panda::panda_file::StringPacProtect hapPath; - panda::panda_file::BoolPacProtect isStageModel = panda::panda_file::BoolPacProtect(true); - std::string moduleName; - panda::panda_file::DataProtect apiTargetVersion = panda::panda_file::DataProtect(); -}; - +struct WorkerInfo; class JsEnvironmentImpl { public: JsEnvironmentImpl() {} diff --git a/js_environment/interfaces/inner_api/worker_info.h b/js_environment/interfaces/inner_api/worker_info.h new file mode 100644 index 0000000000..22b01d14b9 --- /dev/null +++ b/js_environment/interfaces/inner_api/worker_info.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 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_ABILITY_JS_ENVIRONMENT_WORKER_INFO_H +#define OHOS_ABILITY_JS_ENVIRONMENT_WORKER_INFO_H + +#include + +#include "data_protect.h" + +namespace OHOS { +namespace JsEnv { +struct WorkerInfo { + panda::panda_file::StringPacProtect codePath; + bool isDebugVersion = false; + bool isBundle = true; + std::string packagePathStr; + std::vector assetBasePathStr; + panda::panda_file::StringPacProtect hapPath; + panda::panda_file::BoolPacProtect isStageModel = panda::panda_file::BoolPacProtect(true); + std::string moduleName; + panda::panda_file::DataProtect apiTargetVersion = panda::panda_file::DataProtect(); +}; +} // namespace JsEnv +} // namespace OHOS +#endif // OHOS_ABILITY_JS_ENVIRONMENT_WORKER_INFO_H diff --git a/js_environment/test/unittest/js_environment_test/js_environment_test.cpp b/js_environment/test/unittest/js_environment_test/js_environment_test.cpp index 178c62f6a5..aad0becba6 100644 --- a/js_environment/test/unittest/js_environment_test/js_environment_test.cpp +++ b/js_environment/test/unittest/js_environment_test/js_environment_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -25,6 +25,7 @@ #include "ecmascript/napi/include/jsnapi.h" #include "ohos_js_env_logger.h" #include "ohos_js_environment_impl.h" +#include "worker_info.h" using namespace testing; using namespace testing::ext; diff --git a/test/fuzztest/abilityframeworksnativejsworker_fuzzer/abilityframeworksnativejsworker_fuzzer.cpp b/test/fuzztest/abilityframeworksnativejsworker_fuzzer/abilityframeworksnativejsworker_fuzzer.cpp index 142d9d9144..8ce729f894 100644 --- a/test/fuzztest/abilityframeworksnativejsworker_fuzzer/abilityframeworksnativejsworker_fuzzer.cpp +++ b/test/fuzztest/abilityframeworksnativejsworker_fuzzer/abilityframeworksnativejsworker_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -26,6 +26,7 @@ #include "ability_record.h" #include "securec.h" +#include "worker_info.h" using namespace OHOS::AAFwk; using namespace OHOS::AppExecFwk; diff --git a/test/unittest/runtime_test/js_worker_test.cpp b/test/unittest/runtime_test/js_worker_test.cpp index 6a4e04642d..f58311735e 100644 --- a/test/unittest/runtime_test/js_worker_test.cpp +++ b/test/unittest/runtime_test/js_worker_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -26,6 +26,7 @@ #undef private #undef protected #include "native_engine.h" +#include "worker_info.h" using namespace testing; using namespace testing::ext; diff --git a/test/unittest/runtime_test/ohos_js_environment_test.cpp b/test/unittest/runtime_test/ohos_js_environment_test.cpp index 398839b54f..9939c045b7 100644 --- a/test/unittest/runtime_test/ohos_js_environment_test.cpp +++ b/test/unittest/runtime_test/ohos_js_environment_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -21,6 +21,7 @@ #include "hilog_tag_wrapper.h" #include "js_runtime.h" +#include "worker_info.h" using namespace testing; using namespace testing::ext;