android: Deduplicate GetJString
This commit is contained in:
parent
bf6e4a41d7
commit
e65ca8b907
|
@ -1,4 +1,6 @@
|
|||
add_library(citra-android SHARED
|
||||
android_common/android_common.cpp
|
||||
android_common/android_common.h
|
||||
applets/mii_selector.cpp
|
||||
applets/mii_selector.h
|
||||
applets/swkbd.cpp
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2022 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "jni/android_common/android_common.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
std::string GetJString(JNIEnv *env, jstring jstr) {
|
||||
if (!jstr) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const char *s = env->GetStringUTFChars(jstr, nullptr);
|
||||
std::string result = s;
|
||||
env->ReleaseStringUTFChars(jstr, s);
|
||||
return result;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright 2022 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
std::string GetJString(JNIEnv* env, jstring jstr);
|
|
@ -3,22 +3,14 @@
|
|||
// Refer to the license.txt file included.
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "core/core.h"
|
||||
#include "jni/android_common/android_common.h"
|
||||
#include "jni/applets/swkbd.h"
|
||||
#include "jni/id_cache.h"
|
||||
|
||||
static std::string GetJString(JNIEnv* env, jstring jstr) {
|
||||
if (!jstr) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const char* s = env->GetStringUTFChars(jstr, nullptr);
|
||||
std::string result = s;
|
||||
env->ReleaseStringUTFChars(jstr, s);
|
||||
return result;
|
||||
}
|
||||
|
||||
static jclass s_software_keyboard_class;
|
||||
static jclass s_keyboard_config_class;
|
||||
static jclass s_keyboard_data_class;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "core/hle/service/nfc/nfc.h"
|
||||
#include "core/savestate.h"
|
||||
#include "core/settings.h"
|
||||
#include "jni/android_common/android_common.h"
|
||||
#include "jni/applets/mii_selector.h"
|
||||
#include "jni/applets/swkbd.h"
|
||||
#include "jni/camera/ndk_camera.h"
|
||||
|
@ -58,17 +59,6 @@ std::condition_variable running_cv;
|
|||
|
||||
} // Anonymous namespace
|
||||
|
||||
static std::string GetJString(JNIEnv* env, jstring jstr) {
|
||||
if (!jstr) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const char* s = env->GetStringUTFChars(jstr, nullptr);
|
||||
std::string result = s;
|
||||
env->ReleaseStringUTFChars(jstr, s);
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool DisplayAlertMessage(const char* caption, const char* text, bool yes_no) {
|
||||
JNIEnv* env = IDCache::GetEnvForThread();
|
||||
|
||||
|
|
Reference in New Issue