23 #include <winpr/winpr.h>
24 #include <winpr/assert.h>
28 #define TAG WINPR_TAG("android")
32 WINPR_API jint JNI_OnLoad(JavaVM* vm,
void* reserved)
34 WLog_INFO(TAG,
"Setting up JNI environement...");
37 return JNI_VERSION_1_6;
40 WINPR_API
void JNICALL JNI_OnUnload(JavaVM* vm,
void* reserved)
43 WLog_INFO(TAG,
"Tearing down JNI environement...");
45 if ((*jniVm)->GetEnv(vm, (
void**)&env, JNI_VERSION_1_6) != JNI_OK)
47 WLog_FATAL(TAG,
"Failed to get the environment");
52 jboolean winpr_jni_attach_thread(JNIEnv** env)
56 if ((*jniVm)->GetEnv(jniVm, (
void**)env, JNI_VERSION_1_4) != JNI_OK)
58 WLog_INFO(TAG,
"android_java_callback: attaching current thread");
59 (*jniVm)->AttachCurrentThread(jniVm, env, NULL);
61 if ((*jniVm)->GetEnv(jniVm, (
void**)env, JNI_VERSION_1_4) != JNI_OK)
63 WLog_ERR(TAG,
"android_java_callback: failed to obtain current JNI environment");
73 void winpr_jni_detach_thread(
void)
76 (*jniVm)->DetachCurrentThread(jniVm);