diff --git a/frameworks/js/ani/BUILD.gn b/frameworks/js/ani/BUILD.gn index b38cfea8cd338c0110c6195d56981690657d4779..35d01811949da395f7a8e388bd7a05c126f406ed 100644 --- a/frameworks/js/ani/BUILD.gn +++ b/frameworks/js/ani/BUILD.gn @@ -48,6 +48,7 @@ ohos_shared_library("crypto_framework_ani") { "hilog:libhilog", "openssl:libcrypto_shared", "runtime_core:ani", + "runtime_core:ani_helpers", ] } diff --git a/frameworks/js/ani/src/cryptoframework_ani.cpp b/frameworks/js/ani/src/cryptoframework_ani.cpp index 59cc6a9ec2f860357b28d5b24541579bc99662a3..006a96542cf74cbb499774739bef4f492ffc107f 100644 --- a/frameworks/js/ani/src/cryptoframework_ani.cpp +++ b/frameworks/js/ani/src/cryptoframework_ani.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "log.h" #include "mac.h" @@ -74,13 +75,15 @@ template ani_object CreateAniObject(ani_env *env, std::string name, const char *signature, Args... args) { ani_class cls; + // Pls replace manually if (env->FindClass(name.c_str(), &cls) != ANI_OK) { LOGE("not found '%s'", name.c_str()); return {}; } ani_method ctor; - if (env->Class_FindMethod(cls, "", signature, &ctor) != ANI_OK) { + auto methodCtor = arkts::ani_signature::Builder::BuildConstructorName(); + if (env->Class_FindMethod(cls, methodCtor.c_str(), signature, &ctor) != ANI_OK) { LOGE("get ctor failed '%s'", name.c_str()); return {}; } @@ -123,7 +126,8 @@ static ani_object CreateSymKeyGenerator([[maybe_unused]] ani_env *env, [[maybe_u static ani_object ConvertKeySync([[maybe_unused]] ani_env *env, [[maybe_unused]] ani_object object, ani_object data) { ani_ref dataRef; - if (env->Object_CallMethodByName_Ref(data, "data", nullptr, &dataRef) != ANI_OK) { + auto methodGetData = arkts::ani_signature::Builder::BuildGetterName("data"); + if (env->Object_CallMethodByName_Ref(data, methodGetData.c_str(), nullptr, &dataRef) != ANI_OK) { LOGE("get datablob failed"); return {}; } @@ -177,7 +181,8 @@ static void InitSync([[maybe_unused]] ani_env *env, [[maybe_unused]] ani_object static void UpdateSync([[maybe_unused]] ani_env *env, [[maybe_unused]] ani_object object, ani_object input) { ani_ref inputRef; - if (env->Object_CallMethodByName_Ref(input, "data", nullptr, &inputRef) != ANI_OK) { + auto methodGetData = arkts::ani_signature::Builder::BuildGetterName("data"); + if (env->Object_CallMethodByName_Ref(input, methodGetData.c_str(), nullptr, &inputRef) != ANI_OK) { LOGE("get datablob failed"); return; } @@ -263,6 +268,7 @@ ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) const char *className = entry.first.c_str(); std::vector methods = entry.second; ani_class cls; + // Pls replace manually if (env->FindClass(className, &cls) != ANI_OK) { LOGE("not found '%s'", className); return ANI_ERROR;