Merge pull request #12866 from JosJuice/android-log-types-sorting

Android: Replace log type names map with array
This commit is contained in:
JosJuice
2025-03-15 16:01:33 +01:00
committed by GitHub
7 changed files with 49 additions and 57 deletions

View File

@ -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*,