2018-06-01 07:36:29 +00:00
|
|
|
// Copyright 2018 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "jni/AndroidCommon/IDCache.h"
|
|
|
|
|
|
|
|
#include <jni.h>
|
|
|
|
|
|
|
|
static constexpr jint JNI_VERSION = JNI_VERSION_1_6;
|
|
|
|
|
|
|
|
static JavaVM* s_java_vm;
|
|
|
|
|
|
|
|
static jclass s_native_library_class;
|
|
|
|
static jmethodID s_display_alert_msg;
|
2019-01-20 03:49:04 +00:00
|
|
|
static jmethodID s_get_update_touch_pointer;
|
2018-06-01 07:36:29 +00:00
|
|
|
|
|
|
|
static jclass s_game_file_class;
|
|
|
|
static jfieldID s_game_file_pointer;
|
|
|
|
static jmethodID s_game_file_constructor;
|
|
|
|
|
|
|
|
static jclass s_game_file_cache_class;
|
|
|
|
static jfieldID s_game_file_cache_pointer;
|
|
|
|
|
2018-08-19 21:38:29 +00:00
|
|
|
static jclass s_analytics_class;
|
|
|
|
static jmethodID s_send_analytics_report;
|
|
|
|
static jmethodID s_get_analytics_value;
|
|
|
|
|
2018-06-01 07:36:29 +00:00
|
|
|
namespace IDCache
|
|
|
|
{
|
|
|
|
JavaVM* GetJavaVM()
|
|
|
|
{
|
|
|
|
return s_java_vm;
|
|
|
|
}
|
|
|
|
|
|
|
|
jclass GetNativeLibraryClass()
|
|
|
|
{
|
|
|
|
return s_native_library_class;
|
|
|
|
}
|
|
|
|
|
|
|
|
jmethodID GetDisplayAlertMsg()
|
|
|
|
{
|
|
|
|
return s_display_alert_msg;
|
|
|
|
}
|
|
|
|
|
2019-01-20 03:49:04 +00:00
|
|
|
jmethodID GetUpdateTouchPointer()
|
|
|
|
{
|
|
|
|
return s_get_update_touch_pointer;
|
|
|
|
}
|
|
|
|
|
2018-08-19 21:38:29 +00:00
|
|
|
jclass GetAnalyticsClass()
|
|
|
|
{
|
|
|
|
return s_analytics_class;
|
|
|
|
}
|
|
|
|
|
|
|
|
jmethodID GetSendAnalyticsReport()
|
|
|
|
{
|
|
|
|
return s_send_analytics_report;
|
|
|
|
}
|
|
|
|
|
|
|
|
jmethodID GetAnalyticsValue()
|
|
|
|
{
|
|
|
|
return s_get_analytics_value;
|
|
|
|
}
|
2018-06-01 07:36:29 +00:00
|
|
|
jclass GetGameFileClass()
|
|
|
|
{
|
|
|
|
return s_game_file_class;
|
|
|
|
}
|
|
|
|
|
|
|
|
jfieldID GetGameFilePointer()
|
|
|
|
{
|
|
|
|
return s_game_file_pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
jmethodID GetGameFileConstructor()
|
|
|
|
{
|
|
|
|
return s_game_file_constructor;
|
|
|
|
}
|
|
|
|
|
|
|
|
jclass GetGameFileCacheClass()
|
|
|
|
{
|
|
|
|
return s_game_file_cache_class;
|
|
|
|
}
|
|
|
|
|
|
|
|
jfieldID GetGameFileCachePointer()
|
|
|
|
{
|
|
|
|
return s_game_file_cache_pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace IDCache
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
|
|
|
{
|
|
|
|
s_java_vm = vm;
|
|
|
|
|
|
|
|
JNIEnv* env;
|
|
|
|
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION) != JNI_OK)
|
|
|
|
return JNI_ERR;
|
|
|
|
|
|
|
|
const jclass native_library_class = env->FindClass("org/dolphinemu/dolphinemu/NativeLibrary");
|
|
|
|
s_native_library_class = reinterpret_cast<jclass>(env->NewGlobalRef(native_library_class));
|
|
|
|
s_display_alert_msg = env->GetStaticMethodID(s_native_library_class, "displayAlertMsg",
|
|
|
|
"(Ljava/lang/String;Ljava/lang/String;Z)Z");
|
2019-01-20 03:49:04 +00:00
|
|
|
s_get_update_touch_pointer =
|
|
|
|
env->GetStaticMethodID(IDCache::GetNativeLibraryClass(), "updateTouchPointer", "()V");
|
2018-06-01 07:36:29 +00:00
|
|
|
|
|
|
|
const jclass game_file_class = env->FindClass("org/dolphinemu/dolphinemu/model/GameFile");
|
|
|
|
s_game_file_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_file_class));
|
|
|
|
s_game_file_pointer = env->GetFieldID(game_file_class, "mPointer", "J");
|
|
|
|
s_game_file_constructor = env->GetMethodID(game_file_class, "<init>", "(J)V");
|
|
|
|
|
|
|
|
const jclass game_file_cache_class =
|
|
|
|
env->FindClass("org/dolphinemu/dolphinemu/model/GameFileCache");
|
|
|
|
s_game_file_cache_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_file_cache_class));
|
|
|
|
s_game_file_cache_pointer = env->GetFieldID(game_file_cache_class, "mPointer", "J");
|
|
|
|
|
2018-08-19 21:38:29 +00:00
|
|
|
const jclass analytics_class = env->FindClass("org/dolphinemu/dolphinemu/utils/Analytics");
|
|
|
|
s_analytics_class = reinterpret_cast<jclass>(env->NewGlobalRef(analytics_class));
|
|
|
|
s_send_analytics_report =
|
|
|
|
env->GetStaticMethodID(s_analytics_class, "sendReport", "(Ljava/lang/String;[B)V");
|
|
|
|
s_get_analytics_value = env->GetStaticMethodID(s_analytics_class, "getValue",
|
|
|
|
"(Ljava/lang/String;)Ljava/lang/String;");
|
|
|
|
|
2018-06-01 07:36:29 +00:00
|
|
|
return JNI_VERSION;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JNI_OnUnload(JavaVM* vm, void* reserved)
|
|
|
|
{
|
|
|
|
JNIEnv* env;
|
|
|
|
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION) != JNI_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
env->DeleteGlobalRef(s_native_library_class);
|
|
|
|
env->DeleteGlobalRef(s_game_file_class);
|
|
|
|
env->DeleteGlobalRef(s_game_file_cache_class);
|
2018-08-19 21:38:29 +00:00
|
|
|
env->DeleteGlobalRef(s_analytics_class);
|
2018-06-01 07:36:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|