diff --git a/src/xenia/base/main_android.cc b/src/xenia/base/main_android.cc index e1ef53c72..a44ca7d3b 100644 --- a/src/xenia/base/main_android.cc +++ b/src/xenia/base/main_android.cc @@ -145,7 +145,7 @@ void ShutdownAndroidAppFromMainThread() { int32_t GetAndroidApiLevel() { return android_api_level_; } -JNIEnv* GetAndroidThreadJNIEnv() { +JNIEnv* GetAndroidThreadJniEnv() { if (!android_java_vm_) { return nullptr; } diff --git a/src/xenia/base/main_android.h b/src/xenia/base/main_android.h index 7fe35e038..e74a82ffe 100644 --- a/src/xenia/base/main_android.h +++ b/src/xenia/base/main_android.h @@ -38,9 +38,18 @@ void ShutdownAndroidAppFromMainThread(); // configuration. int32_t GetAndroidApiLevel(); +// Useful notes about JNI usage on Android within Xenia: +// - All static libraries defining JNI native functions must be linked to shared +// libraries via LOCAL_WHOLE_STATIC_LIBRARIES. +// - If method or field IDs are cached, a global reference to the class needs to +// be held - it prevents the class from being unloaded by the class loaders +// (in a way that would make the IDs invalid when it's reloaded). +// - GetStringUTFChars (UTF-8) returns null-terminated strings, GetStringChars +// (UTF-16) does not. + // May return null if not in a Java VM process, or in case of a failure to // attach on a non-main thread. -JNIEnv* GetAndroidThreadJNIEnv(); +JNIEnv* GetAndroidThreadJniEnv(); // Returns the global reference if in an application context, or null otherwise. // This is the application context, not the activity one, because multiple // activities may be running in one process. diff --git a/src/xenia/base/system_android.cc b/src/xenia/base/system_android.cc index bc1f34b35..25c14a7bc 100644 --- a/src/xenia/base/system_android.cc +++ b/src/xenia/base/system_android.cc @@ -39,7 +39,7 @@ static bool android_system_initialized_ = false; bool InitializeAndroidSystemForApplicationContext() { assert_false(android_system_initialized_); - JNIEnv* jni_env = GetAndroidThreadJNIEnv(); + JNIEnv* jni_env = GetAndroidThreadJniEnv(); if (!jni_env) { return false; } @@ -209,7 +209,7 @@ void ShutdownAndroidSystem() { android_system_intent_init_action_uri_ = nullptr; android_system_uri_parse_ = nullptr; android_system_application_context_start_activity_ = nullptr; - JNIEnv* jni_env = GetAndroidThreadJNIEnv(); + JNIEnv* jni_env = GetAndroidThreadJniEnv(); if (jni_env) { if (android_system_intent_action_view_) { jni_env->DeleteGlobalRef(android_system_intent_action_view_); @@ -234,7 +234,7 @@ void LaunchWebBrowser(const std::string_view url) { if (!android_system_initialized_) { return; } - JNIEnv* jni_env = GetAndroidThreadJNIEnv(); + JNIEnv* jni_env = GetAndroidThreadJniEnv(); if (!jni_env) { return; } diff --git a/src/xenia/ui/windowed_app_context_android.h b/src/xenia/ui/windowed_app_context_android.h index d3947938b..d12d25766 100644 --- a/src/xenia/ui/windowed_app_context_android.h +++ b/src/xenia/ui/windowed_app_context_android.h @@ -78,14 +78,6 @@ class AndroidWindowedAppContext final : public WindowedAppContext { bool InitializeApp(std::unique_ptr (*app_creator)( WindowedAppContext& app_context)); - // Useful notes about JNI usage on Android within Xenia: - // - All static libraries defining JNI native functions must be linked to - // shared libraries via LOCAL_WHOLE_STATIC_LIBRARIES. - // - If method or field IDs are cached, a global reference to the class needs - // to be held - it prevents the class from being unloaded by the class - // loaders (in a way that would make the IDs invalid when it's reloaded). - // - GetStringUTFChars (UTF-8) returns null-terminated strings, GetStringChars - // (UTF-16) does not. JNIEnv* ui_thread_jni_env_ = nullptr; // The object reference must be held by the app according to