summaryrefslogtreecommitdiff
path: root/Source/Android/jni
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2026-11-04 19:46:41 +0100
committerGitHub <noreply@github.com>2026-11-04 19:46:41 +0100
commit584366cb6859f5e371b1314bf0d92bb59d4d1b80 (patch)
treeeacc9d6f545183321717955ed5c4f0589d125564 /Source/Android/jni
parent112e1a436ae8c81ccd6d002460094172e72a600f (diff)
parent49ebb1cfea589e66134039d4ecca911e0e14af43 (diff)
Merge pull request #14794 from JosJuice/android-title-databaseHEADmaster
Android: Use TitleDatabase for game list
Diffstat (limited to 'Source/Android/jni')
-rw-r--r--Source/Android/jni/AndroidCommon/IDCache.cpp26
-rw-r--r--Source/Android/jni/AndroidCommon/IDCache.h4
-rw-r--r--Source/Android/jni/CMakeLists.txt2
-rw-r--r--Source/Android/jni/GameList/GameFile.cpp17
-rw-r--r--Source/Android/jni/GameList/TitleDatabase.cpp37
-rw-r--r--Source/Android/jni/GameList/TitleDatabase.h13
6 files changed, 95 insertions, 4 deletions
diff --git a/Source/Android/jni/AndroidCommon/IDCache.cpp b/Source/Android/jni/AndroidCommon/IDCache.cpp
index 58cec02308..8d774dbbd9 100644
--- a/Source/Android/jni/AndroidCommon/IDCache.cpp
+++ b/Source/Android/jni/AndroidCommon/IDCache.cpp
@@ -151,6 +151,10 @@ static jclass s_audio_utils_class;
static jmethodID s_audio_utils_get_sample_rate;
static jmethodID s_audio_utils_get_frames_per_buffer;
+static jclass s_title_database_class;
+static jfieldID s_title_database_pointer;
+static jmethodID s_title_database_constructor;
+
namespace IDCache
{
JNIEnv* GetEnvForThread()
@@ -721,6 +725,21 @@ jmethodID GetAudioUtilsGetFramesPerBuffer()
return s_audio_utils_get_frames_per_buffer;
}
+jclass GetTitleDatabaseClass()
+{
+ return s_title_database_class;
+}
+
+jfieldID GetTitleDatabasePointer()
+{
+ return s_title_database_pointer;
+}
+
+jmethodID GetTitleDatabaseConstructor()
+{
+ return s_title_database_constructor;
+}
+
} // namespace IDCache
extern "C" {
@@ -1015,6 +1034,13 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
env->GetStaticMethodID(audio_utils_class, "getFramesPerBuffer", "()I");
env->DeleteLocalRef(audio_utils_class);
+ const jclass title_database_class =
+ env->FindClass("org/dolphinemu/dolphinemu/model/TitleDatabase");
+ s_title_database_class = reinterpret_cast<jclass>(env->NewGlobalRef(title_database_class));
+ s_title_database_pointer = env->GetFieldID(title_database_class, "pointer", "J");
+ s_title_database_constructor = env->GetMethodID(title_database_class, "<init>", "(J)V");
+ env->DeleteLocalRef(title_database_class);
+
return JNI_VERSION;
}
diff --git a/Source/Android/jni/AndroidCommon/IDCache.h b/Source/Android/jni/AndroidCommon/IDCache.h
index 43c4f43585..1483b3bbd3 100644
--- a/Source/Android/jni/AndroidCommon/IDCache.h
+++ b/Source/Android/jni/AndroidCommon/IDCache.h
@@ -150,4 +150,8 @@ jclass GetAudioUtilsClass();
jmethodID GetAudioUtilsGetSampleRate();
jmethodID GetAudioUtilsGetFramesPerBuffer();
+jclass GetTitleDatabaseClass();
+jfieldID GetTitleDatabasePointer();
+jmethodID GetTitleDatabaseConstructor();
+
} // namespace IDCache
diff --git a/Source/Android/jni/CMakeLists.txt b/Source/Android/jni/CMakeLists.txt
index a7ee0b6b3a..59e1e1138e 100644
--- a/Source/Android/jni/CMakeLists.txt
+++ b/Source/Android/jni/CMakeLists.txt
@@ -13,6 +13,8 @@ add_library(main SHARED
GameList/GameFile.cpp
GameList/GameFile.h
GameList/GameFileCache.cpp
+ GameList/TitleDatabase.cpp
+ GameList/TitleDatabase.h
GpuDriver.cpp
HotkeyScheduler.cpp
HotkeyScheduler.h
diff --git a/Source/Android/jni/GameList/GameFile.cpp b/Source/Android/jni/GameList/GameFile.cpp
index dc922d701c..e13f5c810a 100644
--- a/Source/Android/jni/GameList/GameFile.cpp
+++ b/Source/Android/jni/GameList/GameFile.cpp
@@ -16,6 +16,7 @@
#include "UICommon/GameFile.h"
#include "jni/AndroidCommon/AndroidCommon.h"
#include "jni/AndroidCommon/IDCache.h"
+#include "jni/GameList/TitleDatabase.h"
static std::shared_ptr<const UICommon::GameFile>* GetPointer(JNIEnv* env, jobject obj)
{
@@ -52,11 +53,19 @@ JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getPlatform
return static_cast<jint>(GetRef(env, obj)->GetPlatform());
}
-JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getTitle(JNIEnv* env,
- jobject obj)
+JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getTitle(
+ JNIEnv* env, jobject obj, jobject j_title_database)
{
- return ToJString(env,
- GetRef(env, obj)->GetName(UICommon::GameFile::Variant::LongAndPossiblyCustom));
+ const Core::TitleDatabase* title_database = TitleDatabaseFromJava(env, j_title_database);
+ if (title_database)
+ {
+ return ToJString(env, GetRef(env, obj)->GetName(*title_database));
+ }
+ else
+ {
+ return ToJString(env,
+ GetRef(env, obj)->GetName(UICommon::GameFile::Variant::LongAndPossiblyCustom));
+ }
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_model_GameFile_getDescription(JNIEnv* env,
diff --git a/Source/Android/jni/GameList/TitleDatabase.cpp b/Source/Android/jni/GameList/TitleDatabase.cpp
new file mode 100644
index 0000000000..c4aca48a25
--- /dev/null
+++ b/Source/Android/jni/GameList/TitleDatabase.cpp
@@ -0,0 +1,37 @@
+// Copyright 2026 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "jni/GameList/TitleDatabase.h"
+
+#include <jni.h>
+
+#include "Core/TitleDatabase.h"
+#include "jni/AndroidCommon/IDCache.h"
+
+Core::TitleDatabase* TitleDatabaseFromJava(JNIEnv* env, jobject obj)
+{
+ return reinterpret_cast<Core::TitleDatabase*>(
+ env->GetLongField(obj, IDCache::GetTitleDatabasePointer()));
+}
+extern "C" {
+
+JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_model_TitleDatabase_finalize(JNIEnv* env,
+ jobject obj)
+{
+ delete TitleDatabaseFromJava(env, obj);
+}
+
+JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_model_TitleDatabase_userTitleMapEquals(
+ JNIEnv* env, jobject obj, jobject other)
+{
+ return other != nullptr && TitleDatabaseFromJava(env, obj)->GetUserTitleMap() ==
+ TitleDatabaseFromJava(env, other)->GetUserTitleMap();
+}
+
+JNIEXPORT jobject JNICALL Java_org_dolphinemu_dolphinemu_model_TitleDatabase_load(JNIEnv* env,
+ jclass)
+{
+ return env->NewObject(IDCache::GetTitleDatabaseClass(), IDCache::GetTitleDatabaseConstructor(),
+ reinterpret_cast<jlong>(new Core::TitleDatabase));
+}
+}
diff --git a/Source/Android/jni/GameList/TitleDatabase.h b/Source/Android/jni/GameList/TitleDatabase.h
new file mode 100644
index 0000000000..fcf8f9bf32
--- /dev/null
+++ b/Source/Android/jni/GameList/TitleDatabase.h
@@ -0,0 +1,13 @@
+// Copyright 2026 Dolphin Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <jni.h>
+
+namespace Core
+{
+class TitleDatabase;
+}
+
+Core::TitleDatabase* TitleDatabaseFromJava(JNIEnv* env, jobject obj);