mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Merge pull request #12866 from JosJuice/android-log-types-sorting
Android: Replace log type names map with array
This commit is contained in:
@ -29,9 +29,8 @@ static jclass s_analytics_class;
|
||||
static jmethodID s_send_analytics_report;
|
||||
static jmethodID s_get_analytics_value;
|
||||
|
||||
static jclass s_linked_hash_map_class;
|
||||
static jmethodID s_linked_hash_map_init;
|
||||
static jmethodID s_linked_hash_map_put;
|
||||
static jclass s_pair_class;
|
||||
static jmethodID s_pair_constructor;
|
||||
|
||||
static jclass s_hash_map_class;
|
||||
static jmethodID s_hash_map_init;
|
||||
@ -212,19 +211,14 @@ jfieldID GetGameFileCachePointer()
|
||||
return s_game_file_cache_pointer;
|
||||
}
|
||||
|
||||
jclass GetLinkedHashMapClass()
|
||||
jclass GetPairClass()
|
||||
{
|
||||
return s_linked_hash_map_class;
|
||||
return s_pair_class;
|
||||
}
|
||||
|
||||
jmethodID GetLinkedHashMapInit()
|
||||
jmethodID GetPairConstructor()
|
||||
{
|
||||
return s_linked_hash_map_init;
|
||||
}
|
||||
|
||||
jmethodID GetLinkedHashMapPut()
|
||||
{
|
||||
return s_linked_hash_map_put;
|
||||
return s_pair_constructor;
|
||||
}
|
||||
|
||||
jclass GetHashMapClass()
|
||||
@ -565,12 +559,11 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||
"(Ljava/lang/String;)Ljava/lang/String;");
|
||||
env->DeleteLocalRef(analytics_class);
|
||||
|
||||
const jclass linked_hash_map_class = env->FindClass("java/util/LinkedHashMap");
|
||||
s_linked_hash_map_class = reinterpret_cast<jclass>(env->NewGlobalRef(linked_hash_map_class));
|
||||
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(linked_hash_map_class);
|
||||
const jclass pair_class = env->FindClass("androidx/core/util/Pair");
|
||||
s_pair_class = reinterpret_cast<jclass>(env->NewGlobalRef(pair_class));
|
||||
s_pair_constructor =
|
||||
env->GetMethodID(s_pair_class, "<init>", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||
env->DeleteLocalRef(pair_class);
|
||||
|
||||
const jclass hash_map_class = env->FindClass("java/util/HashMap");
|
||||
s_hash_map_class = reinterpret_cast<jclass>(env->NewGlobalRef(hash_map_class));
|
||||
@ -741,7 +734,7 @@ JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved)
|
||||
env->DeleteGlobalRef(s_game_file_class);
|
||||
env->DeleteGlobalRef(s_game_file_cache_class);
|
||||
env->DeleteGlobalRef(s_analytics_class);
|
||||
env->DeleteGlobalRef(s_linked_hash_map_class);
|
||||
env->DeleteGlobalRef(s_pair_class);
|
||||
env->DeleteGlobalRef(s_hash_map_class);
|
||||
env->DeleteGlobalRef(s_compress_cb_class);
|
||||
env->DeleteGlobalRef(s_content_handler_class);
|
||||
|
@ -29,9 +29,8 @@ jmethodID GetGameFileConstructor();
|
||||
jclass GetGameFileCacheClass();
|
||||
jfieldID GetGameFileCachePointer();
|
||||
|
||||
jclass GetLinkedHashMapClass();
|
||||
jmethodID GetLinkedHashMapInit();
|
||||
jmethodID GetLinkedHashMapPut();
|
||||
jclass GetPairClass();
|
||||
jmethodID GetPairConstructor();
|
||||
|
||||
jclass GetHashMapClass();
|
||||
jmethodID GetHashMapInit();
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <android/log.h>
|
||||
@ -691,27 +692,25 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ChangeDisc(J
|
||||
system.GetDVDInterface().ChangeDisc(Core::CPUThreadGuard{system}, path);
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetLogTypeNames(JNIEnv* env,
|
||||
jclass)
|
||||
JNIEXPORT jobjectArray JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetLogTypeNames(JNIEnv* env, jclass)
|
||||
{
|
||||
std::map<std::string, std::string> map = Common::Log::LogManager::GetInstance()->GetLogTypes();
|
||||
using LogManager = Common::Log::LogManager;
|
||||
|
||||
auto map_size = static_cast<jsize>(map.size());
|
||||
jobject linked_hash_map =
|
||||
env->NewObject(IDCache::GetLinkedHashMapClass(), IDCache::GetLinkedHashMapInit(), map_size);
|
||||
for (const auto& entry : map)
|
||||
{
|
||||
jstring key = ToJString(env, entry.first);
|
||||
jstring value = ToJString(env, entry.second);
|
||||
return VectorToJObjectArray(
|
||||
env, LogManager::GetInstance()->GetLogTypes(), IDCache::GetPairClass(),
|
||||
[](JNIEnv* env_, const LogManager::LogContainer& log_container) {
|
||||
jstring short_name = ToJString(env_, log_container.m_short_name);
|
||||
jstring full_name = ToJString(env_, log_container.m_full_name);
|
||||
|
||||
jobject result =
|
||||
env->CallObjectMethod(linked_hash_map, IDCache::GetLinkedHashMapPut(), key, value);
|
||||
jobject pair = env_->NewObject(IDCache::GetPairClass(), IDCache::GetPairConstructor(),
|
||||
short_name, full_name);
|
||||
|
||||
env->DeleteLocalRef(key);
|
||||
env->DeleteLocalRef(value);
|
||||
env->DeleteLocalRef(result);
|
||||
}
|
||||
return linked_hash_map;
|
||||
env_->DeleteLocalRef(short_name);
|
||||
env_->DeleteLocalRef(full_name);
|
||||
|
||||
return pair;
|
||||
});
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ReloadLoggerConfig(JNIEnv*,
|
||||
|
Reference in New Issue
Block a user