MCPcopy Create free account
hub / github.com/AGenUI/AGenUI / AndroidPlatformFunction

Method AndroidPlatformFunction

core/src/jni/jni_android_platform_function.cpp:62–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60} // namespace
61
62AndroidPlatformFunction::AndroidPlatformFunction(JNIEnv* env, jobject javaFunction)
63 : _jvm(nullptr), _javaFunction(nullptr),
64 _callSyncMethod(nullptr), _contextClass(nullptr), _contextConstructor(nullptr) {
65
66 env->GetJavaVM(&_jvm);
67
68 _javaFunction = env->NewGlobalRef(javaFunction);
69
70 ScopedLocalRef<jclass> functionClass(env, env->GetObjectClass(javaFunction));
71 if (functionClass.get() == nullptr) {
72 AGENUI_LOG("[AndroidPlatformFunction] constructor: failed to get function class");
73 return;
74 }
75
76 // Cache FunctionCallContext class and constructor
77 ScopedLocalRef<jclass> ctxClass(env,
78 env->FindClass("com/amap/agenui/function/FunctionCallContext"));
79 if (ctxClass.get() == nullptr) {
80 AGENUI_LOG("[AndroidPlatformFunction] constructor: failed to find FunctionCallContext class");
81 return;
82 }
83 _contextClass = (jclass)env->NewGlobalRef(ctxClass.get());
84 _contextConstructor = env->GetMethodID(_contextClass, "<init>", "(ILjava/lang/String;)V");
85 if (_contextConstructor == nullptr) {
86 AGENUI_LOG("[AndroidPlatformFunction] constructor: failed to get FunctionCallContext constructor");
87 return;
88 }
89
90 // Cache callSync method ID
91 _callSyncMethod = env->GetMethodID(functionClass.get(), "callSync",
92 "(Lcom/amap/agenui/function/FunctionCallContext;Ljava/lang/String;)Ljava/lang/String;");
93
94 if (_callSyncMethod == nullptr) {
95 AGENUI_LOG("[AndroidPlatformFunction] constructor: failed to get method IDs");
96 }
97}
98
99AndroidPlatformFunction::~AndroidPlatformFunction() {
100 if (_jvm != nullptr) {

Callers

nothing calls this directly

Calls 1

getMethod · 0.65

Tested by

no test coverage detected