diff --git a/framework/js/ani/BUILD.gn b/framework/js/ani/BUILD.gn index ba2c5ce452b83085861b00e5490a434d6da81c25..a9335f0b0728a08c004379ba60280993f21c5119 100644 --- a/framework/js/ani/BUILD.gn +++ b/framework/js/ani/BUILD.gn @@ -26,6 +26,7 @@ ohos_shared_library("systemdatetime_ani") { "hilog:libhilog", "init:libbegetutil", "runtime_core:ani", + "runtime_core:ani_helpers", "samgr:samgr_proxy", ] diff --git a/framework/js/ani/src/system_date_time_ani.cpp b/framework/js/ani/src/system_date_time_ani.cpp index ac178cd6e454a764270e935448652f159e606104..c72a92ac548c686003b09ef4b767ad43ddae8093 100644 --- a/framework/js/ani/src/system_date_time_ani.cpp +++ b/framework/js/ani/src/system_date_time_ani.cpp @@ -14,6 +14,7 @@ */ #include +#include #include #include #include @@ -50,6 +51,7 @@ static ani_double GetTime([[maybe_unused]] ani_env *env, ani_object booleanObjec return GetRealTime(false); } ani_boolean isNano; + // Pls replace manually if (ANI_OK !=env->Object_CallMethodByName_Boolean(booleanObject, "unboxed", nullptr, &isNano)) { TIME_HILOGE(TIME_MODULE_JS_ANI, "Object_CallMethodByName_Boolean Fail"); } @@ -78,14 +80,17 @@ ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) static const char *namespaceName = "L@ohos/systemDateTime/systemDateTime;"; ani_namespace ns; + // Pls replace manually if (ANI_OK != env->FindNamespace(namespaceName, &ns)) { TIME_HILOGE(TIME_MODULE_JS_ANI, "Not found '%{public}s'", namespaceName); return ANI_ERROR; } + arkts::ani_signature::SignatureBuilder GetTimeZoneSigBuilder; + GetTimeZoneSigBuilder.SetReturnClass("std.core.String"); + auto GetTimeZoneSignature = GetTimeZoneSigBuilder.BuildSignatureDescriptor(); std::array methods = { - ani_native_function {"getTime", nullptr, reinterpret_cast(GetTime)}, - ani_native_function {"getTimezoneSync", ":Lstd/core/String;", reinterpret_cast(GetTimeZone)}, + ani_native_function{ "getTimezoneSync", GetTimeZoneSignature.c_str(), reinterpret_cast(GetTimeZone) }, }; if (ANI_OK != env->Namespace_BindNativeFunctions(ns, methods.data(), methods.size())) {