1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Revert "Enable the ability to use Godot as a subview within an Android app"

This reverts commit 920639511d.

The changes are good, this revert is only done for release management reasons
as we want this feature to get more testing before making it in a stable build,
but a 3.2.3 release is imminent to handle some regressions in 3.2.2.

This will be re-committed in a 3.2-based feature branch, and we'll merge it
again once we're confident about it (probably for 3.2.4).
This commit is contained in:
Rémi Verschelde
2020-07-10 08:25:01 +02:00
parent 5854bf4696
commit 0246a1a276
16 changed files with 226 additions and 340 deletions

View File

@@ -37,47 +37,36 @@
// TODO we could probably create a base class for this...
GodotJavaWrapper::GodotJavaWrapper(JNIEnv *p_env, jobject p_activity, jobject p_godot_instance) {
GodotJavaWrapper::GodotJavaWrapper(JNIEnv *p_env, jobject p_godot_instance) {
godot_instance = p_env->NewGlobalRef(p_godot_instance);
activity = p_env->NewGlobalRef(p_activity);
// get info about our Godot class so we can get pointers and stuff...
godot_class = p_env->FindClass("org/godotengine/godot/Godot");
if (godot_class) {
godot_class = (jclass)p_env->NewGlobalRef(godot_class);
} else {
// this is a pretty serious fail.. bail... pointers will stay 0
return;
}
activity_class = p_env->FindClass("android/app/Activity");
if (activity_class) {
activity_class = (jclass)p_env->NewGlobalRef(activity_class);
cls = p_env->FindClass("org/godotengine/godot/Godot");
if (cls) {
cls = (jclass)p_env->NewGlobalRef(cls);
} else {
// this is a pretty serious fail.. bail... pointers will stay 0
return;
}
// get some Godot method pointers...
_on_video_init = p_env->GetMethodID(godot_class, "onVideoInit", "()V");
_restart = p_env->GetMethodID(godot_class, "restart", "()V");
_finish = p_env->GetMethodID(godot_class, "forceQuit", "()V");
_set_keep_screen_on = p_env->GetMethodID(godot_class, "setKeepScreenOn", "(Z)V");
_alert = p_env->GetMethodID(godot_class, "alert", "(Ljava/lang/String;Ljava/lang/String;)V");
_get_GLES_version_code = p_env->GetMethodID(godot_class, "getGLESVersionCode", "()I");
_get_clipboard = p_env->GetMethodID(godot_class, "getClipboard", "()Ljava/lang/String;");
_set_clipboard = p_env->GetMethodID(godot_class, "setClipboard", "(Ljava/lang/String;)V");
_request_permission = p_env->GetMethodID(godot_class, "requestPermission", "(Ljava/lang/String;)Z");
_request_permissions = p_env->GetMethodID(godot_class, "requestPermissions", "()Z");
_get_granted_permissions = p_env->GetMethodID(godot_class, "getGrantedPermissions", "()[Ljava/lang/String;");
_init_input_devices = p_env->GetMethodID(godot_class, "initInputDevices", "()V");
_get_surface = p_env->GetMethodID(godot_class, "getSurface", "()Landroid/view/Surface;");
_is_activity_resumed = p_env->GetMethodID(godot_class, "isActivityResumed", "()Z");
_vibrate = p_env->GetMethodID(godot_class, "vibrate", "(I)V");
_get_input_fallback_mapping = p_env->GetMethodID(godot_class, "getInputFallbackMapping", "()Ljava/lang/String;");
_on_godot_main_loop_started = p_env->GetMethodID(godot_class, "onGodotMainLoopStarted", "()V");
// get some Activity method pointers...
_get_class_loader = p_env->GetMethodID(activity_class, "getClassLoader", "()Ljava/lang/ClassLoader;");
// get some method pointers...
_on_video_init = p_env->GetMethodID(cls, "onVideoInit", "()V");
_restart = p_env->GetMethodID(cls, "restart", "()V");
_finish = p_env->GetMethodID(cls, "forceQuit", "()V");
_set_keep_screen_on = p_env->GetMethodID(cls, "setKeepScreenOn", "(Z)V");
_alert = p_env->GetMethodID(cls, "alert", "(Ljava/lang/String;Ljava/lang/String;)V");
_get_GLES_version_code = p_env->GetMethodID(cls, "getGLESVersionCode", "()I");
_get_clipboard = p_env->GetMethodID(cls, "getClipboard", "()Ljava/lang/String;");
_set_clipboard = p_env->GetMethodID(cls, "setClipboard", "(Ljava/lang/String;)V");
_request_permission = p_env->GetMethodID(cls, "requestPermission", "(Ljava/lang/String;)Z");
_request_permissions = p_env->GetMethodID(cls, "requestPermissions", "()Z");
_get_granted_permissions = p_env->GetMethodID(cls, "getGrantedPermissions", "()[Ljava/lang/String;");
_init_input_devices = p_env->GetMethodID(cls, "initInputDevices", "()V");
_get_surface = p_env->GetMethodID(cls, "getSurface", "()Landroid/view/Surface;");
_is_activity_resumed = p_env->GetMethodID(cls, "isActivityResumed", "()Z");
_vibrate = p_env->GetMethodID(cls, "vibrate", "(I)V");
_get_input_fallback_mapping = p_env->GetMethodID(cls, "getInputFallbackMapping", "()Ljava/lang/String;");
_on_godot_main_loop_started = p_env->GetMethodID(cls, "onGodotMainLoopStarted", "()V");
}
GodotJavaWrapper::~GodotJavaWrapper() {
@@ -85,25 +74,27 @@ GodotJavaWrapper::~GodotJavaWrapper() {
}
jobject GodotJavaWrapper::get_activity() {
return activity;
// our godot instance is our activity
return godot_instance;
}
jobject GodotJavaWrapper::get_member_object(const char *p_name, const char *p_class, JNIEnv *p_env) {
if (godot_class) {
if (cls) {
if (p_env == NULL)
p_env = ThreadAndroid::get_env();
jfieldID fid = p_env->GetStaticFieldID(godot_class, p_name, p_class);
return p_env->GetStaticObjectField(godot_class, fid);
jfieldID fid = p_env->GetStaticFieldID(cls, p_name, p_class);
return p_env->GetStaticObjectField(cls, fid);
} else {
return NULL;
}
}
jobject GodotJavaWrapper::get_class_loader() {
if (_get_class_loader) {
if (cls) {
JNIEnv *env = ThreadAndroid::get_env();
return env->CallObjectMethod(godot_instance, _get_class_loader);
jmethodID getClassLoader = env->GetMethodID(cls, "getClassLoader", "()Ljava/lang/ClassLoader;");
return env->CallObjectMethod(godot_instance, getClassLoader);
} else {
return NULL;
}