diff --git a/ets_environment/frameworks/ets_environment/BUILD.gn b/ets_environment/frameworks/ets_environment/BUILD.gn index 8bc85903f65b5c3cb0adfbd0dce646ee989064d0..3b195ca02853ff32f4f71003158a93fb8763fbd7 100644 --- a/ets_environment/frameworks/ets_environment/BUILD.gn +++ b/ets_environment/frameworks/ets_environment/BUILD.gn @@ -62,6 +62,7 @@ ohos_shared_library("ets_environment") { "napi:ace_napi", "runtime_core:ani", "runtime_core:libarkruntime", + "runtime_core:ani_helpers", ] if (ability_runtime_graphics) { diff --git a/ets_environment/frameworks/ets_environment/src/ets_environment.cpp b/ets_environment/frameworks/ets_environment/src/ets_environment.cpp index 9b1a7982c799924f755a15af36db2f649d05118e..5032e6621e624d3a87b08b39d167d8c6cee674ea 100644 --- a/ets_environment/frameworks/ets_environment/src/ets_environment.cpp +++ b/ets_environment/frameworks/ets_environment/src/ets_environment.cpp @@ -44,6 +44,8 @@ #include "hilog_tag_wrapper.h" #include "unwinder.h" +#include + #ifdef SUPPORT_GRAPHICS #include "ui_content.h" #endif // SUPPORT_GRAPHICS @@ -69,6 +71,8 @@ constexpr const char* CLASSNAME_STRING = "Lstd/core/String;"; constexpr const char* CLASSNAME_LINKER = "Lstd/core/AbcRuntimeLinker;"; } // namespace +using namespace arkts::ani_signature; + ETSRuntimeAPI ETSEnvironment::lazyApis_ {}; std::unique_ptr instance_ = nullptr; @@ -338,9 +342,9 @@ EtsEnv::ETSErrorObject ETSEnvironment::GetETSErrorObject() TAG_LOGE(AAFwkTag::ETSRUNTIME, "ResetError failed, status : %{public}d", status); return EtsEnv::ETSErrorObject(); } - std::string errorMsg = GetErrorProperty(aniError, "message"); - std::string errorName = GetErrorProperty(aniError, "name"); - std::string errorStack = GetErrorProperty(aniError, "stack"); + std::string errorMsg = GetErrorProperty(aniError, Builder::BuildGetterName("message").c_str()); + std::string errorName = GetErrorProperty(aniError, Builder::BuildGetterName("name").c_str()); + std::string errorStack = GetErrorProperty(aniError, Builder::BuildGetterName("stack").c_str()); const EtsEnv::ETSErrorObject errorObj = { .name = errorName, .message = errorMsg, diff --git a/frameworks/ets/ani/ability_delegator/BUILD.gn b/frameworks/ets/ani/ability_delegator/BUILD.gn index c8385f189ed6bb44899fc4d1345940bc2ed7f728..c5a6e0e215e7702b4012e098a6bb0acdf64c76cd 100644 --- a/frameworks/ets/ani/ability_delegator/BUILD.gn +++ b/frameworks/ets/ani/ability_delegator/BUILD.gn @@ -76,6 +76,7 @@ ohos_shared_library("ability_delegator_registry_ani_kit") { "json:nlohmann_json_static", "napi:ace_napi", "runtime_core:ani", + "runtime_core:ani_helpers", ] innerapi_tags = [ "platformsdk" ] diff --git a/frameworks/ets/ani/ability_delegator/src/ets_ability_delegator_utils.cpp b/frameworks/ets/ani/ability_delegator/src/ets_ability_delegator_utils.cpp index e5ad56d26808529e9f2e01dde1972bef71d779e1..4a8af25df5cdd262389fc8578b5eb43d161f94aa 100644 --- a/frameworks/ets/ani/ability_delegator/src/ets_ability_delegator_utils.cpp +++ b/frameworks/ets/ani/ability_delegator/src/ets_ability_delegator_utils.cpp @@ -18,6 +18,7 @@ #include #include "ets_ability_delegator.h" #include "hilog_tag_wrapper.h" +#include namespace OHOS { namespace AbilityDelegatorEts { @@ -53,6 +54,8 @@ constexpr const char* RECORD_SET_NAME = "X{C{std.core.BaseEnum}C{std.core.Numeric}C{std.core.String}}C{std.core.Object}:"; } +using namespace arkts::ani_signature; + bool BindFunctions(ani_env *aniEnv, ani_class abilityDelegator) { if (aniEnv == nullptr) { @@ -164,7 +167,7 @@ void SetBundleName(ani_env *aniEnv, ani_class arguments, ani_object argumentObje // find the setter method ani_method nameSetter = nullptr; - status = aniEnv->Class_FindMethod(arguments, "bundleName", nullptr, &nameSetter); + status = aniEnv->Class_FindMethod(arguments, Builder::BuildSetterName("bundleName").c_str(), nullptr, &nameSetter); if (status != ANI_OK) { TAG_LOGE(AAFwkTag::DELEGATOR, "Class_FindMethod failed status: %{public}d", status); return; @@ -208,8 +211,8 @@ void SetParameters(ani_env *aniEnv, ani_class arguments, ani_object argumentObje return; } ani_ref parameterRef = nullptr; - status = aniEnv->Object_CallMethodByName_Ref(argumentObject, "parameters", ":Lescompat/Record;", - ¶meterRef); + status = aniEnv->Object_CallMethodByName_Ref(argumentObject, Builder::BuildGetterName("parameters").c_str(), + ":Lescompat/Record;", ¶meterRef); if (status != ANI_OK) { TAG_LOGE(AAFwkTag::DELEGATOR, "Object_CallMethodByName_Ref failed status: %{public}d", status); return; @@ -256,7 +259,8 @@ void SetTestCaseNames(ani_env *aniEnv, ani_class arguments, ani_object argumentO // find the setter method ani_method nameSetter = nullptr; - status = aniEnv->Class_FindMethod(arguments, "testCaseNames", nullptr, &nameSetter); + status = aniEnv->Class_FindMethod(arguments, Builder::BuildSetterName("testCaseNames").c_str(), + nullptr, &nameSetter); if (status != ANI_OK) { TAG_LOGE(AAFwkTag::DELEGATOR, "Class_FindMethod failed status: %{public}d", status); return; @@ -290,7 +294,8 @@ void SetTestRunnerClassName(ani_env *aniEnv, ani_class arguments, ani_object arg // find the setter method ani_method nameSetter = nullptr; - status = aniEnv->Class_FindMethod(arguments, "testRunnerClassName", nullptr, &nameSetter); + status = aniEnv->Class_FindMethod(arguments, Builder::BuildSetterName("testRunnerClassName").c_str(), + nullptr, &nameSetter); if (status != ANI_OK) { TAG_LOGE(AAFwkTag::DELEGATOR, "Class_FindMethod failed status: %{public}d", status); return; diff --git a/frameworks/ets/ani/ani_common/BUILD.gn b/frameworks/ets/ani/ani_common/BUILD.gn index aa4d97e986e2cfa66713c082d598e48c76d61e83..1f6cfbb94d650b1f261031bbfdc8cb54bf926001 100644 --- a/frameworks/ets/ani/ani_common/BUILD.gn +++ b/frameworks/ets/ani/ani_common/BUILD.gn @@ -106,6 +106,7 @@ ohos_shared_library("ani_common") { "resource_management:resmgr_napi_core", "resource_management:resourceManager_ani", "runtime_core:ani", + "runtime_core:ani_helpers", ] innerapi_tags = [ "platformsdk" ] diff --git a/frameworks/ets/ani/ani_common/src/ani_common_ability_result.cpp b/frameworks/ets/ani/ani_common/src/ani_common_ability_result.cpp index 6a9fd755dfe183d9fc830cac6c7eecbdd613fc03..392ffd0662d473a0c285e82bac46f10aa3466264 100644 --- a/frameworks/ets/ani/ani_common/src/ani_common_ability_result.cpp +++ b/frameworks/ets/ani/ani_common/src/ani_common_ability_result.cpp @@ -16,6 +16,7 @@ #include "ani_common_ability_result.h" #include "ani_common_want.h" +#include #include "hilog_tag_wrapper.h" namespace OHOS { @@ -24,6 +25,8 @@ namespace { constexpr const char *ABILITY_RESULT_CLASS_NAME = "Lability/abilityResult/AbilityResultInner;"; } // namespace +using namespace arkts::ani_signature; + ani_object WrapAbilityResult(ani_env *env, int32_t resultCode, const AAFwk::Want &want) { if (env == nullptr) { @@ -50,7 +53,8 @@ ani_object WrapAbilityResult(ani_env *env, int32_t resultCode, const AAFwk::Want } ani_method resultCodeSetter = nullptr; - if ((status = env->Class_FindMethod(cls, "resultCode", nullptr, &resultCodeSetter)) != ANI_OK) { + if ((status = env->Class_FindMethod(cls, Builder::BuildSetterName("resultCode").c_str(), + nullptr, &resultCodeSetter)) != ANI_OK) { TAG_LOGE(AAFwkTag::ANI, "Class_FindMethod status: %{public}d", status); return nullptr; } @@ -61,7 +65,8 @@ ani_object WrapAbilityResult(ani_env *env, int32_t resultCode, const AAFwk::Want } ani_method wantSetter = nullptr; - if ((status = env->Class_FindMethod(cls, "want", nullptr, &wantSetter)) != ANI_OK) { + if ((status = env->Class_FindMethod(cls, Builder::BuildSetterName("want").c_str(), + nullptr, &wantSetter)) != ANI_OK) { TAG_LOGE(AAFwkTag::ANI, "Class_FindMethod status: %{public}d", status); return nullptr; } diff --git a/frameworks/ets/ani/ani_common/src/ani_common_want.cpp b/frameworks/ets/ani/ani_common/src/ani_common_want.cpp index 9c638af8fb9f22d9289661001af94ef2cd370d0f..0f6bcc93fd018ff6ffcb4c69dd94d68019bcb1a9 100644 --- a/frameworks/ets/ani/ani_common/src/ani_common_want.cpp +++ b/frameworks/ets/ani/ani_common/src/ani_common_want.cpp @@ -33,10 +33,12 @@ #include "tokenid_kit.h" #include "want_params_wrapper.h" #include "zchar_wrapper.h" +#include namespace OHOS { namespace AppExecFwk { using namespace OHOS::AbilityRuntime; +using namespace arkts::ani_signature; namespace { constexpr const char *ABILITY_WANT_CLASS_NAME = "L@ohos/app/ability/Want/Want;"; constexpr const char *TOOL_CLASS_NAME = "L@ohos/app/ability/Want/RecordSerializeTool;"; @@ -1312,7 +1314,7 @@ bool GetAbilityResultClass(ani_env *env, ani_class &cls) bool GetResultCode(ani_env *env, ani_object param, ani_class cls, int &resultCode) { ani_method method = nullptr; - ani_status status = env->Class_FindMethod(cls, "resultCode", nullptr, &method); + ani_status status = env->Class_FindMethod(cls, Builder::BuildGetterName("resultCode").c_str(), nullptr, &method); if (status != ANI_OK) { TAG_LOGE(AAFwkTag::ANI, "status: %{public}d", status); return false; @@ -1330,7 +1332,7 @@ bool GetResultCode(ani_env *env, ani_object param, ani_class cls, int &resultCod bool GetWantReference(ani_env *env, ani_object param, ani_class cls, ani_ref &wantRef) { ani_method method {}; - ani_status status = env->Class_FindMethod(cls, "want", nullptr, &method); + ani_status status = env->Class_FindMethod(cls, Builder::BuildGetterName("want").c_str(), nullptr, &method); if (status != ANI_OK) { TAG_LOGE(AAFwkTag::ANI, "status: %{public}d", status); return false; diff --git a/frameworks/ets/ani/form_extension_ability/src/ets_form_extension.cpp b/frameworks/ets/ani/form_extension_ability/src/ets_form_extension.cpp index 2a71dc69e8c3fa83d1855246938e4ae4add7aa90..958b8c8ad767c0c79f60ca380175776cdd7c5b09 100644 --- a/frameworks/ets/ani/form_extension_ability/src/ets_form_extension.cpp +++ b/frameworks/ets/ani/form_extension_ability/src/ets_form_extension.cpp @@ -22,6 +22,7 @@ #include "ani_common_configuration.h" #include "ani_common_want.h" #include "ani_enum_convert.h" +#include #include "ets_runtime.h" #include "form_provider_data.h" #include "form_runtime/form_extension_provider_client.h" @@ -37,6 +38,8 @@ constexpr const char* FORM_BINDING_DATA_CLASS_NAME = constexpr const char* RECORD_CLASS_NAME = "escompat.Record"; } +using namespace arkts::ani_signature; + extern "C" __attribute__((visibility("default"))) FormExtension *OHOS_ABILITY_ETSFormExtension( const std::unique_ptr &runtime) { @@ -362,7 +365,7 @@ bool ETSFormExtension::ExtractFormData(ani_env *env, ani_ref nativeResult, AppEx } ani_method data{}; - status = env->Class_FindMethod(cls, "data", nullptr, &data); + status = env->Class_FindMethod(cls, Builder::BuildGetterName("data").c_str(), nullptr, &data); if (status != ANI_OK) { TAG_LOGE(AAFwkTag::FORM_EXT, "Class_FindMethod data status: %{public}d", status); return false; @@ -379,7 +382,7 @@ bool ETSFormExtension::ExtractFormData(ani_env *env, ani_ref nativeResult, AppEx formData = AppExecFwk::FormProviderData(dataStr); ani_method proxies; - status = env->Class_FindMethod(cls, "proxies", nullptr, &proxies); + status = env->Class_FindMethod(cls, Builder::BuildGetterName("proxies").c_str(), nullptr, &proxies); if (status != ANI_OK) { TAG_LOGE(AAFwkTag::FORM_EXT, "Class_FindMethod proxies status: %{public}d", status); return true; diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index 6f711db1d1f21b60144e634a3fe0e13ad73ce6e1..96a4819199663336242c9fdb372c7e4577fcb1af 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -1212,6 +1212,7 @@ ohos_shared_library("ets_form_extension") { "ipc:ipc_napi", "napi:ace_napi", "runtime_core:ani", + "runtime_core:ani_helpers", ] if (form_fwk_enable) { diff --git a/test/unittest/runtime_test/BUILD.gn b/test/unittest/runtime_test/BUILD.gn index 07f8a6615e3ebdde1b5e4874885a9a03fc98b834..526beeb13d5d532423d094291710323caf239b9e 100644 --- a/test/unittest/runtime_test/BUILD.gn +++ b/test/unittest/runtime_test/BUILD.gn @@ -304,6 +304,7 @@ ohos_unittest("ets_runtime_test") { "napi:ace_napi", "runtime_core:ani", "runtime_core:libarkruntime", + "runtime_core:ani_helpers", ] if (ability_runtime_graphics) {