From 5326ea63e5eb31c5b701d50b961d17bce3423f5d Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Tue, 26 Sep 2023 00:25:20 -0400 Subject: android: Fix case bug for installing game content The C++ side never made the filename lowercase when checking the extension. This just passes the pre-prepared extension to have it checked. --- .../app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt | 7 ++++++- .../src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt | 7 ++++++- src/android/app/src/main/jni/native.cpp | 12 +++++++----- 3 files changed, 19 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt index 21f67f32a..7745c9fc7 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt @@ -247,7 +247,12 @@ object NativeLibrary { external fun setAppDirectory(directory: String) - external fun installFileToNand(filename: String): Int + /** + * Installs a nsp or xci file to nand + * @param filename String representation of file uri + * @param extension Lowercase string representation of file extension without "." + */ + external fun installFileToNand(filename: String, extension: String): Int external fun initializeGpuDriver( hookLibDir: String?, diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt index 6fa847631..7ca95fc23 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt @@ -523,7 +523,12 @@ class MainActivity : AppCompatActivity(), ThemeProvider { var errorExtension = 0 var errorOther = 0 documents.forEach { - when (NativeLibrary.installFileToNand(it.toString())) { + when ( + NativeLibrary.installFileToNand( + it.toString(), + FileUtil.getExtension(it) + ) + ) { NativeLibrary.InstallFileToNandResult.Success -> { installSuccess += 1 } diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index f31fe054b..71ef2833d 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -102,7 +102,7 @@ public: m_native_window = native_window; } - int InstallFileToNand(std::string filename) { + int InstallFileToNand(std::string filename, std::string file_extension) { jconst copy_func = [](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest, std::size_t block_size) { if (src == nullptr || dest == nullptr) { @@ -134,12 +134,12 @@ public: m_system.GetFileSystemController().CreateFactories(*m_vfs); [[maybe_unused]] std::shared_ptr nsp; - if (filename.ends_with("nsp")) { + if (file_extension == "nsp") { nsp = std::make_shared(m_vfs->OpenFile(filename, FileSys::Mode::Read)); if (nsp->IsExtractedType()) { return InstallError; } - } else if (filename.ends_with("xci")) { + } else if (file_extension == "xci") { jconst xci = std::make_shared(m_vfs->OpenFile(filename, FileSys::Mode::Read)); nsp = xci->GetSecurePartitionNSP(); @@ -607,8 +607,10 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_setAppDirectory(JNIEnv* env, jobject } int Java_org_yuzu_yuzu_1emu_NativeLibrary_installFileToNand(JNIEnv* env, jobject instance, - [[maybe_unused]] jstring j_file) { - return EmulationSession::GetInstance().InstallFileToNand(GetJString(env, j_file)); + jstring j_file, + jstring j_file_extension) { + return EmulationSession::GetInstance().InstallFileToNand(GetJString(env, j_file), + GetJString(env, j_file_extension)); } void JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_initializeGpuDriver(JNIEnv* env, jclass clazz, -- cgit v1.2.3 From 3491ba4a06d6f9f72766971393e0cb96971347d6 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Tue, 26 Sep 2023 00:26:46 -0400 Subject: android: Use a different string for the content install dialog --- src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt | 2 +- src/android/app/src/main/res/values/strings.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt index 7ca95fc23..ee490abc0 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt @@ -515,7 +515,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider { if (documents.isNotEmpty()) { IndeterminateProgressDialogFragment.newInstance( this@MainActivity, - R.string.install_game_content + R.string.installing_game_content ) { var installSuccess = 0 var installOverwrite = 0 diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 0730143bd..574290479 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -107,6 +107,7 @@ No log file found Install game content Install game updates or DLC + Installing content… Error installing file(s) to NAND Please ensure content(s) are valid and that the prod.keys file is installed. Installation of base games isn\'t permitted in order to avoid possible conflicts. -- cgit v1.2.3