app/internal/window: [Android] remove JNI_OnLoad JNI callback

There can only be one JNI_OnLoad callback per JNI library, and the
Gio program may need it for its own purposes.

Gio only used JNI_OnLoad for explicitly registering native methods. Switch
to implicit name based registration and get rid of JNI_OnLoad.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-05-05 19:01:12 +02:00
parent 0c0a22bee7
commit cde651db60
2 changed files with 30 additions and 125 deletions
-95
View File
@@ -4,101 +4,6 @@
#include "os_android.h"
#include "_cgo_export.h"
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
JNIEnv *env;
if ((*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_6) != JNI_OK) {
return -1;
}
jclass viewClass = (*env)->FindClass(env, "org/gioui/GioView");
if (viewClass == NULL) {
return -1;
}
static const JNINativeMethod methods[] = {
{
.name = "runGoMain",
.signature = "([BLandroid/content/Context;)V",
.fnPtr = runGoMain
},
{
.name = "onCreateView",
.signature = "(Lorg/gioui/GioView;)J",
.fnPtr = onCreateView
},
{
.name = "onDestroyView",
.signature = "(J)V",
.fnPtr = onDestroyView
},
{
.name = "onStartView",
.signature = "(J)V",
.fnPtr = onStartView
},
{
.name = "onStopView",
.signature = "(J)V",
.fnPtr = onStopView
},
{
.name = "onSurfaceDestroyed",
.signature = "(J)V",
.fnPtr = onSurfaceDestroyed
},
{
.name = "onSurfaceChanged",
.signature = "(JLandroid/view/Surface;)V",
.fnPtr = onSurfaceChanged
},
{
.name = "onConfigurationChanged",
.signature = "(J)V",
.fnPtr = onConfigurationChanged
},
{
.name = "onWindowInsets",
.signature = "(JIIII)V",
.fnPtr = onWindowInsets
},
{
.name = "onLowMemory",
.signature = "()V",
.fnPtr = onLowMemory
},
{
.name = "onTouchEvent",
.signature = "(JIIIFFIJ)V",
.fnPtr = onTouchEvent
},
{
.name = "onKeyEvent",
.signature = "(JIIJ)V",
.fnPtr = onKeyEvent
},
{
.name = "onFrameCallback",
.signature = "(JJ)V",
.fnPtr = onFrameCallback
},
{
.name = "onBack",
.signature = "(J)Z",
.fnPtr = onBack
},
{
.name = "onFocusChange",
.signature = "(JZ)V",
.fnPtr = onFocusChange
}
};
if ((*env)->RegisterNatives(env, viewClass, methods, sizeof(methods)/sizeof(methods[0])) != 0) {
return -1;
}
return JNI_VERSION_1_6;
}
jint gio_jni_GetEnv(JavaVM *vm, JNIEnv **env, jint version) {
return (*vm)->GetEnv(vm, (void **)env, version);
}