|
@@ -91,7 +91,7 @@ jobject GodotJavaWrapper::get_activity() {
|
|
jobject GodotJavaWrapper::get_member_object(const char *p_name, const char *p_class, JNIEnv *p_env) {
|
|
jobject GodotJavaWrapper::get_member_object(const char *p_name, const char *p_class, JNIEnv *p_env) {
|
|
if (godot_class) {
|
|
if (godot_class) {
|
|
if (p_env == NULL)
|
|
if (p_env == NULL)
|
|
- p_env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ p_env = get_jni_env();
|
|
|
|
|
|
jfieldID fid = p_env->GetStaticFieldID(godot_class, p_name, p_class);
|
|
jfieldID fid = p_env->GetStaticFieldID(godot_class, p_name, p_class);
|
|
return p_env->GetStaticObjectField(godot_class, fid);
|
|
return p_env->GetStaticObjectField(godot_class, fid);
|
|
@@ -102,7 +102,7 @@ jobject GodotJavaWrapper::get_member_object(const char *p_name, const char *p_cl
|
|
|
|
|
|
jobject GodotJavaWrapper::get_class_loader() {
|
|
jobject GodotJavaWrapper::get_class_loader() {
|
|
if (_get_class_loader) {
|
|
if (_get_class_loader) {
|
|
- JNIEnv *env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
return env->CallObjectMethod(activity, _get_class_loader);
|
|
return env->CallObjectMethod(activity, _get_class_loader);
|
|
} else {
|
|
} else {
|
|
return NULL;
|
|
return NULL;
|
|
@@ -119,7 +119,7 @@ void GodotJavaWrapper::gfx_init(bool gl2) {
|
|
void GodotJavaWrapper::on_video_init(JNIEnv *p_env) {
|
|
void GodotJavaWrapper::on_video_init(JNIEnv *p_env) {
|
|
if (_on_video_init)
|
|
if (_on_video_init)
|
|
if (p_env == NULL)
|
|
if (p_env == NULL)
|
|
- p_env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ p_env = get_jni_env();
|
|
|
|
|
|
p_env->CallVoidMethod(godot_instance, _on_video_init);
|
|
p_env->CallVoidMethod(godot_instance, _on_video_init);
|
|
}
|
|
}
|
|
@@ -127,7 +127,7 @@ void GodotJavaWrapper::on_video_init(JNIEnv *p_env) {
|
|
void GodotJavaWrapper::on_godot_main_loop_started(JNIEnv *p_env) {
|
|
void GodotJavaWrapper::on_godot_main_loop_started(JNIEnv *p_env) {
|
|
if (_on_godot_main_loop_started) {
|
|
if (_on_godot_main_loop_started) {
|
|
if (p_env == NULL) {
|
|
if (p_env == NULL) {
|
|
- p_env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ p_env = get_jni_env();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
p_env->CallVoidMethod(godot_instance, _on_godot_main_loop_started);
|
|
p_env->CallVoidMethod(godot_instance, _on_godot_main_loop_started);
|
|
@@ -136,7 +136,7 @@ void GodotJavaWrapper::on_godot_main_loop_started(JNIEnv *p_env) {
|
|
void GodotJavaWrapper::restart(JNIEnv *p_env) {
|
|
void GodotJavaWrapper::restart(JNIEnv *p_env) {
|
|
if (_restart)
|
|
if (_restart)
|
|
if (p_env == NULL)
|
|
if (p_env == NULL)
|
|
- p_env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ p_env = get_jni_env();
|
|
|
|
|
|
p_env->CallVoidMethod(godot_instance, _restart);
|
|
p_env->CallVoidMethod(godot_instance, _restart);
|
|
}
|
|
}
|
|
@@ -144,21 +144,21 @@ void GodotJavaWrapper::restart(JNIEnv *p_env) {
|
|
void GodotJavaWrapper::force_quit(JNIEnv *p_env) {
|
|
void GodotJavaWrapper::force_quit(JNIEnv *p_env) {
|
|
if (_finish)
|
|
if (_finish)
|
|
if (p_env == NULL)
|
|
if (p_env == NULL)
|
|
- p_env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ p_env = get_jni_env();
|
|
|
|
|
|
p_env->CallVoidMethod(godot_instance, _finish);
|
|
p_env->CallVoidMethod(godot_instance, _finish);
|
|
}
|
|
}
|
|
|
|
|
|
void GodotJavaWrapper::set_keep_screen_on(bool p_enabled) {
|
|
void GodotJavaWrapper::set_keep_screen_on(bool p_enabled) {
|
|
if (_set_keep_screen_on) {
|
|
if (_set_keep_screen_on) {
|
|
- JNIEnv *env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
env->CallVoidMethod(godot_instance, _set_keep_screen_on, p_enabled);
|
|
env->CallVoidMethod(godot_instance, _set_keep_screen_on, p_enabled);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void GodotJavaWrapper::alert(const String &p_message, const String &p_title) {
|
|
void GodotJavaWrapper::alert(const String &p_message, const String &p_title) {
|
|
if (_alert) {
|
|
if (_alert) {
|
|
- JNIEnv *env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
jstring jStrMessage = env->NewStringUTF(p_message.utf8().get_data());
|
|
jstring jStrMessage = env->NewStringUTF(p_message.utf8().get_data());
|
|
jstring jStrTitle = env->NewStringUTF(p_title.utf8().get_data());
|
|
jstring jStrTitle = env->NewStringUTF(p_title.utf8().get_data());
|
|
env->CallVoidMethod(godot_instance, _alert, jStrMessage, jStrTitle);
|
|
env->CallVoidMethod(godot_instance, _alert, jStrMessage, jStrTitle);
|
|
@@ -166,7 +166,7 @@ void GodotJavaWrapper::alert(const String &p_message, const String &p_title) {
|
|
}
|
|
}
|
|
|
|
|
|
int GodotJavaWrapper::get_gles_version_code() {
|
|
int GodotJavaWrapper::get_gles_version_code() {
|
|
- JNIEnv *env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
if (_get_GLES_version_code) {
|
|
if (_get_GLES_version_code) {
|
|
return env->CallIntMethod(godot_instance, _get_GLES_version_code);
|
|
return env->CallIntMethod(godot_instance, _get_GLES_version_code);
|
|
}
|
|
}
|
|
@@ -180,7 +180,7 @@ bool GodotJavaWrapper::has_get_clipboard() {
|
|
|
|
|
|
String GodotJavaWrapper::get_clipboard() {
|
|
String GodotJavaWrapper::get_clipboard() {
|
|
if (_get_clipboard) {
|
|
if (_get_clipboard) {
|
|
- JNIEnv *env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
jstring s = (jstring)env->CallObjectMethod(godot_instance, _get_clipboard);
|
|
jstring s = (jstring)env->CallObjectMethod(godot_instance, _get_clipboard);
|
|
return jstring_to_string(s, env);
|
|
return jstring_to_string(s, env);
|
|
} else {
|
|
} else {
|
|
@@ -190,7 +190,7 @@ String GodotJavaWrapper::get_clipboard() {
|
|
|
|
|
|
String GodotJavaWrapper::get_input_fallback_mapping() {
|
|
String GodotJavaWrapper::get_input_fallback_mapping() {
|
|
if (_get_input_fallback_mapping) {
|
|
if (_get_input_fallback_mapping) {
|
|
- JNIEnv *env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
jstring fallback_mapping = (jstring)env->CallObjectMethod(godot_instance, _get_input_fallback_mapping);
|
|
jstring fallback_mapping = (jstring)env->CallObjectMethod(godot_instance, _get_input_fallback_mapping);
|
|
return jstring_to_string(fallback_mapping, env);
|
|
return jstring_to_string(fallback_mapping, env);
|
|
} else {
|
|
} else {
|
|
@@ -204,7 +204,7 @@ bool GodotJavaWrapper::has_set_clipboard() {
|
|
|
|
|
|
void GodotJavaWrapper::set_clipboard(const String &p_text) {
|
|
void GodotJavaWrapper::set_clipboard(const String &p_text) {
|
|
if (_set_clipboard) {
|
|
if (_set_clipboard) {
|
|
- JNIEnv *env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
jstring jStr = env->NewStringUTF(p_text.utf8().get_data());
|
|
jstring jStr = env->NewStringUTF(p_text.utf8().get_data());
|
|
env->CallVoidMethod(godot_instance, _set_clipboard, jStr);
|
|
env->CallVoidMethod(godot_instance, _set_clipboard, jStr);
|
|
}
|
|
}
|
|
@@ -212,7 +212,7 @@ void GodotJavaWrapper::set_clipboard(const String &p_text) {
|
|
|
|
|
|
bool GodotJavaWrapper::request_permission(const String &p_name) {
|
|
bool GodotJavaWrapper::request_permission(const String &p_name) {
|
|
if (_request_permission) {
|
|
if (_request_permission) {
|
|
- JNIEnv *env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
jstring jStrName = env->NewStringUTF(p_name.utf8().get_data());
|
|
jstring jStrName = env->NewStringUTF(p_name.utf8().get_data());
|
|
return env->CallBooleanMethod(godot_instance, _request_permission, jStrName);
|
|
return env->CallBooleanMethod(godot_instance, _request_permission, jStrName);
|
|
} else {
|
|
} else {
|
|
@@ -222,7 +222,7 @@ bool GodotJavaWrapper::request_permission(const String &p_name) {
|
|
|
|
|
|
bool GodotJavaWrapper::request_permissions() {
|
|
bool GodotJavaWrapper::request_permissions() {
|
|
if (_request_permissions) {
|
|
if (_request_permissions) {
|
|
- JNIEnv *env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
return env->CallBooleanMethod(godot_instance, _request_permissions);
|
|
return env->CallBooleanMethod(godot_instance, _request_permissions);
|
|
} else {
|
|
} else {
|
|
return false;
|
|
return false;
|
|
@@ -232,7 +232,7 @@ bool GodotJavaWrapper::request_permissions() {
|
|
Vector<String> GodotJavaWrapper::get_granted_permissions() const {
|
|
Vector<String> GodotJavaWrapper::get_granted_permissions() const {
|
|
Vector<String> permissions_list;
|
|
Vector<String> permissions_list;
|
|
if (_get_granted_permissions) {
|
|
if (_get_granted_permissions) {
|
|
- JNIEnv *env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
jobject permissions_object = env->CallObjectMethod(godot_instance, _get_granted_permissions);
|
|
jobject permissions_object = env->CallObjectMethod(godot_instance, _get_granted_permissions);
|
|
jobjectArray *arr = reinterpret_cast<jobjectArray *>(&permissions_object);
|
|
jobjectArray *arr = reinterpret_cast<jobjectArray *>(&permissions_object);
|
|
|
|
|
|
@@ -250,14 +250,14 @@ Vector<String> GodotJavaWrapper::get_granted_permissions() const {
|
|
|
|
|
|
void GodotJavaWrapper::init_input_devices() {
|
|
void GodotJavaWrapper::init_input_devices() {
|
|
if (_init_input_devices) {
|
|
if (_init_input_devices) {
|
|
- JNIEnv *env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
env->CallVoidMethod(godot_instance, _init_input_devices);
|
|
env->CallVoidMethod(godot_instance, _init_input_devices);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
jobject GodotJavaWrapper::get_surface() {
|
|
jobject GodotJavaWrapper::get_surface() {
|
|
if (_get_surface) {
|
|
if (_get_surface) {
|
|
- JNIEnv *env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
return env->CallObjectMethod(godot_instance, _get_surface);
|
|
return env->CallObjectMethod(godot_instance, _get_surface);
|
|
} else {
|
|
} else {
|
|
return NULL;
|
|
return NULL;
|
|
@@ -266,7 +266,7 @@ jobject GodotJavaWrapper::get_surface() {
|
|
|
|
|
|
bool GodotJavaWrapper::is_activity_resumed() {
|
|
bool GodotJavaWrapper::is_activity_resumed() {
|
|
if (_is_activity_resumed) {
|
|
if (_is_activity_resumed) {
|
|
- JNIEnv *env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
return env->CallBooleanMethod(godot_instance, _is_activity_resumed);
|
|
return env->CallBooleanMethod(godot_instance, _is_activity_resumed);
|
|
} else {
|
|
} else {
|
|
return false;
|
|
return false;
|
|
@@ -275,7 +275,7 @@ bool GodotJavaWrapper::is_activity_resumed() {
|
|
|
|
|
|
void GodotJavaWrapper::vibrate(int p_duration_ms) {
|
|
void GodotJavaWrapper::vibrate(int p_duration_ms) {
|
|
if (_vibrate) {
|
|
if (_vibrate) {
|
|
- JNIEnv *env = ThreadAndroid::get_env();
|
|
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
env->CallVoidMethod(godot_instance, _vibrate, p_duration_ms);
|
|
env->CallVoidMethod(godot_instance, _vibrate, p_duration_ms);
|
|
}
|
|
}
|
|
}
|
|
}
|