diff --git a/frameworks/js/napi/inner/napi_common/napi_common_want.cpp b/frameworks/js/napi/inner/napi_common/napi_common_want.cpp index 6e3521fb90..04d814b2d3 100644 --- a/frameworks/js/napi/inner/napi_common/napi_common_want.cpp +++ b/frameworks/js/napi/inner/napi_common/napi_common_want.cpp @@ -1382,5 +1382,43 @@ bool WrapJsWantParamsArray(napi_env env, napi_value object, const std::string &k return false; } } + +template +bool InnerWrapWantParamsArray(napi_env env, napi_value object, const std::string &key, sptr &ao) +{ + if (ao == nullptr) { + return false; + } + long size = 0; + if (ao->GetLength(size) != ERR_OK) { + return false; + } + std::vector natArray; + for (long i = 0; i < size; i++) { + sptr iface = nullptr; + if (ao->Get(i, iface) == ERR_OK) { + TBase *iValue = TBase::Query(iface); + if (iValue != nullptr) { + natArray.push_back(T::Unbox(iValue)); + } + } + } + napi_set_named_property(env, object, key.c_str(), OHOS::AbilityRuntime::CreateNativeArray(env, natArray)); + return true; +} + +template +bool InnerWrapJsWantParams(napi_env env, napi_value object, const std::string &key, const AAFwk::WantParams &wantParams) +{ + auto value = wantParams.GetParam(key); + TBase *ao = TBase::Query(value); + if (ao != nullptr) { + NativeT natValue = T::Unbox(ao); + napi_value propertyValue = OHOS::AbilityRuntime::CreateJsValue(env, natValue); + napi_set_named_property(env, object, key.c_str(), propertyValue); + return true; + } + return false; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/frameworks/js/napi/inner/napi_common/napi_common_want.h b/frameworks/js/napi/inner/napi_common/napi_common_want.h index dfc87ead29..846abf2ca9 100644 --- a/frameworks/js/napi/inner/napi_common/napi_common_want.h +++ b/frameworks/js/napi/inner/napi_common/napi_common_want.h @@ -20,7 +20,6 @@ #include #include -#include "js_runtime_utils.h" #include "native_engine/native_engine.h" #include "want.h" #include "want_params.h" @@ -57,18 +56,8 @@ napi_value CreateJsWant(napi_env env, const AAFwk::Want &want); napi_value CreateJsWantParams(napi_env env, const AAFwk::WantParams &wantParams); template -bool InnerWrapJsWantParams(napi_env env, napi_value object, const std::string &key, const AAFwk::WantParams &wantParams) -{ - auto value = wantParams.GetParam(key); - TBase *ao = TBase::Query(value); - if (ao != nullptr) { - NativeT natValue = T::Unbox(ao); - napi_value propertyValue = OHOS::AbilityRuntime::CreateJsValue(env, natValue); - napi_set_named_property(env, object, key.c_str(), propertyValue); - return true; - } - return false; -} +bool InnerWrapJsWantParams( + napi_env env, napi_value object, const std::string &key, const AAFwk::WantParams &wantParams); bool InnerWrapJsWantParamsWantParams( napi_env env, napi_value object, const std::string &key, const AAFwk::WantParams &wantParams); @@ -77,25 +66,7 @@ bool WrapJsWantParamsArray( napi_env env, napi_value object, const std::string &key, sptr &ao); template -bool InnerWrapWantParamsArray(napi_env env, napi_value object, const std::string &key, sptr &ao) -{ - long size = 0; - if (ao->GetLength(size) != ERR_OK) { - return false; - } - std::vector natArray; - for (long i = 0; i < size; i++) { - sptr iface = nullptr; - if (ao->Get(i, iface) == ERR_OK) { - TBase *iValue = TBase::Query(iface); - if (iValue != nullptr) { - natArray.push_back(T::Unbox(iValue)); - } - } - } - napi_set_named_property(env, object, key.c_str(), OHOS::AbilityRuntime::CreateNativeArray(env, natArray)); - return true; -} +bool InnerWrapWantParamsArray(napi_env env, napi_value object, const std::string &key, sptr &ao); } // namespace AppExecFwk } // namespace OHOS #endif // OHOS_ABILITY_RUNTIME_NAPI_COMMON_WANT_H diff --git a/frameworks/js/napi/mission_manager/distributed_mission_manager.h b/frameworks/js/napi/mission_manager/distributed_mission_manager.h index a2195a3ae7..0db0335a89 100644 --- a/frameworks/js/napi/mission_manager/distributed_mission_manager.h +++ b/frameworks/js/napi/mission_manager/distributed_mission_manager.h @@ -23,7 +23,6 @@ #include "mission_continue_stub.h" #include "napi/native_api.h" #include "napi/native_node_api.h" -#include "js_runtime_utils.h" #include "securec.h" #include "want.h" #include "remote_mission_listener_stub.h" diff --git a/frameworks/native/child_process/BUILD.gn b/frameworks/native/child_process/BUILD.gn index 172c2ad700..85682f3873 100644 --- a/frameworks/native/child_process/BUILD.gn +++ b/frameworks/native/child_process/BUILD.gn @@ -44,6 +44,7 @@ ohos_shared_library("child_process") { deps = [ "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_native_path}/ability/native:ability_business_error", ] diff --git a/interfaces/inner_api/error_utils/include/ability_runtime_error_util.h b/interfaces/inner_api/error_utils/include/ability_runtime_error_util.h index aaf07eb4fe..d7cd19ae3b 100644 --- a/interfaces/inner_api/error_utils/include/ability_runtime_error_util.h +++ b/interfaces/inner_api/error_utils/include/ability_runtime_error_util.h @@ -17,7 +17,7 @@ #define OHOS_ABILITY_RUNTIME_ABILITY_RUNTIME_ERROR_UTIL_H #include -#include "js_runtime_utils.h" +#include "napi/native_api.h" namespace OHOS { namespace AbilityRuntime { diff --git a/interfaces/inner_api/error_utils/src/ability_runtime_error_util.cpp b/interfaces/inner_api/error_utils/src/ability_runtime_error_util.cpp index 7175234307..8fd1198bd7 100644 --- a/interfaces/inner_api/error_utils/src/ability_runtime_error_util.cpp +++ b/interfaces/inner_api/error_utils/src/ability_runtime_error_util.cpp @@ -18,6 +18,7 @@ #include #include "errors.h" #include "hilog_tag_wrapper.h" +#include "js_runtime_utils.h" #include "napi/native_api.h" #include "runtime.h" diff --git a/test/fuzztest/napicommonwant_fuzzer/napicommonwant_fuzzer.cpp b/test/fuzztest/napicommonwant_fuzzer/napicommonwant_fuzzer.cpp index be67589877..4de8979820 100755 --- a/test/fuzztest/napicommonwant_fuzzer/napicommonwant_fuzzer.cpp +++ b/test/fuzztest/napicommonwant_fuzzer/napicommonwant_fuzzer.cpp @@ -31,13 +31,15 @@ #include "double_wrapper.h" #include "float_wrapper.h" #include "int_wrapper.h" +#include "js_environment.h" +#include "js_runtime.h" +#include "js_runtime_lite.h" #include "long_wrapper.h" +#include "remote_object_wrapper.h" +#include "runtime.h" #include "short_wrapper.h" #include "string_wrapper.h" #include "zchar_wrapper.h" -#include "remote_object_wrapper.h" -#include "js_runtime_lite.h" -#include "js_environment.h" using namespace OHOS::AAFwk; using namespace OHOS::AppExecFwk; @@ -145,7 +147,7 @@ void NapiCommonWantFuzztest2(bool boolParam, std::string &stringParam, int32_t i void NapiCommonWantFuzztest3(bool boolParam, std::string &stringParam, int32_t int32Param) { std::shared_ptr jsEnv = nullptr; - AbilityRuntime::JsRuntime::Options options; + AbilityRuntime::Runtime::Options options; auto err = JsRuntimeLite::GetInstance().CreateJsEnv(options, jsEnv); napi_env env = reinterpret_cast(jsEnv->GetNativeEngine()); ElementName elementName1; @@ -189,7 +191,7 @@ void NapiCommonWantFuzztest4(bool boolParam, std::string &stringParam, int32_t i { napi_value param = nullptr; std::shared_ptr jsEnv = nullptr; - AbilityRuntime::JsRuntime::Options options; + AbilityRuntime::Runtime::Options options; auto err = JsRuntimeLite::GetInstance().CreateJsEnv(options, jsEnv); napi_env env = reinterpret_cast(jsEnv->GetNativeEngine()); Want want; @@ -236,7 +238,7 @@ void NapiCommonWantFuzztest5(bool boolParam, std::string &stringParam, int32_t i { napi_value param = nullptr; std::shared_ptr jsEnv = nullptr; - AbilityRuntime::JsRuntime::Options options; + AbilityRuntime::Runtime::Options options; auto err = JsRuntimeLite::GetInstance().CreateJsEnv(options, jsEnv); napi_env env = reinterpret_cast(jsEnv->GetNativeEngine()); napi_value nullObject = nullptr; @@ -290,7 +292,7 @@ void NapiCommonWantFuzztest6(bool boolParam, std::string &stringParam, int32_t i { napi_value param = nullptr; std::shared_ptr jsEnv = nullptr; - AbilityRuntime::JsRuntime::Options options; + AbilityRuntime::Runtime::Options options; auto err = JsRuntimeLite::GetInstance().CreateJsEnv(options, jsEnv); napi_env env = reinterpret_cast(jsEnv->GetNativeEngine()); napi_value nullObject = nullptr; diff --git a/test/unittest/frameworks_kits_appkit_native_test/dump_runtime_helper_second_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/dump_runtime_helper_second_test.cpp index 76e9da1084..7be5fffd66 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/dump_runtime_helper_second_test.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/dump_runtime_helper_second_test.cpp @@ -19,6 +19,8 @@ #undef private #include "app_loader.h" +#include "js_runtime.h" +#include "js_runtime_utils.h" #include "ohos_application.h" using namespace testing::ext;