From 28632341e39579a4c49dbb9f2fd619489fe1a196 Mon Sep 17 00:00:00 2001 From: LeechyLiang Date: Sun, 6 Apr 2025 21:51:20 +0800 Subject: [PATCH] Modify signature rawString2Builder Signed-off-by: LeechyLiang Change-Id: I476c5585cb5985015622a34b81915800fbaac420 --- frameworks/js/ani/BUILD.gn | 1 + frameworks/js/ani/src/cryptoframework_ani.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/frameworks/js/ani/BUILD.gn b/frameworks/js/ani/BUILD.gn index b38cfea..35d0181 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 59cc6a9..006a965 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; -- Gitee