Merge pull request #9555 from JosJuice/android-jni-cleanup

Android: Some JNI cleanup
This commit is contained in:
Léo Lam 2021-03-05 00:47:36 +01:00 committed by GitHub
commit 5efd563b03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 22 deletions

View File

@ -1,6 +1,9 @@
package org.dolphinemu.dolphinemu.utils;
import androidx.annotation.Keep;
public interface BooleanSupplier
{
@Keep
boolean get();
}

View File

@ -271,11 +271,9 @@ jmethodID GetBooleanSupplierGet()
} // namespace IDCache
#ifdef __cplusplus
extern "C" {
#endif
jint JNI_OnLoad(JavaVM* vm, void* reserved)
JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
s_java_vm = vm;
@ -336,11 +334,13 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
s_linked_hash_map_init = env->GetMethodID(s_linked_hash_map_class, "<init>", "(I)V");
s_linked_hash_map_put = env->GetMethodID(
s_linked_hash_map_class, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
env->DeleteLocalRef(map_class);
const jclass compress_cb_class =
env->FindClass("org/dolphinemu/dolphinemu/utils/CompressCallback");
s_compress_cb_class = reinterpret_cast<jclass>(env->NewGlobalRef(compress_cb_class));
s_compress_cb_run = env->GetMethodID(s_compress_cb_class, "run", "(Ljava/lang/String;F)Z");
env->DeleteLocalRef(compress_cb_class);
const jclass content_handler_class =
env->FindClass("org/dolphinemu/dolphinemu/utils/ContentHandler");
@ -358,6 +358,7 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
s_content_handler_do_file_search =
env->GetStaticMethodID(s_content_handler_class, "doFileSearch",
"(Ljava/lang/String;[Ljava/lang/String;Z)[Ljava/lang/String;");
env->DeleteLocalRef(content_handler_class);
const jclass network_helper_class =
env->FindClass("org/dolphinemu/dolphinemu/utils/NetworkHelper");
@ -368,16 +369,18 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
env->GetStaticMethodID(s_network_helper_class, "GetNetworkPrefixLength", "()I");
s_network_helper_get_network_gateway =
env->GetStaticMethodID(s_network_helper_class, "GetNetworkGateway", "()I");
env->DeleteLocalRef(network_helper_class);
const jclass boolean_supplier_class =
env->FindClass("org/dolphinemu/dolphinemu/utils/BooleanSupplier");
s_boolean_supplier_class = reinterpret_cast<jclass>(env->NewGlobalRef(boolean_supplier_class));
s_boolean_supplier_get = env->GetMethodID(s_boolean_supplier_class, "get", "()Z");
env->DeleteLocalRef(boolean_supplier_class);
return JNI_VERSION;
}
void JNI_OnUnload(JavaVM* vm, void* reserved)
JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved)
{
JNIEnv* env;
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION) != JNI_OK)
@ -393,8 +396,6 @@ void JNI_OnUnload(JavaVM* vm, void* reserved)
env->DeleteGlobalRef(s_compress_cb_class);
env->DeleteGlobalRef(s_content_handler_class);
env->DeleteGlobalRef(s_network_helper_class);
env->DeleteGlobalRef(s_boolean_supplier_class);
}
#ifdef __cplusplus
}
#endif

View File

@ -60,9 +60,7 @@ static void Set(JNIEnv* env, jobject obj, jstring section_name, jstring key, T n
->Set(GetJString(env, key), new_value);
}
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_exists(
JNIEnv* env, jobject obj, jstring key)
@ -243,7 +241,4 @@ JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_copyIniFile
{
return reinterpret_cast<jlong>(new IniFile(*GetIniFilePointer(env, other)));
}
#ifdef __cplusplus
}
#endif

View File

@ -196,9 +196,7 @@ static std::string GetAnalyticValue(const std::string& key)
return stdvalue;
}
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv*,
jclass)
@ -703,7 +701,4 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCurrentTitleDescriptionUnchecked
return ToJString(env, description);
}
#ifdef __cplusplus
}
#endif

View File

@ -94,9 +94,7 @@ static void Set(jint layer, const Config::Location& location, T value)
Config::OnConfigChanged();
}
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jboolean JNICALL
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_isSettingSaveable(
@ -210,7 +208,4 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_settings_model_Na
{
return Set(layer, GetLocation(env, file, section, key), value);
}
#ifdef __cplusplus
}
#endif