diff options
Diffstat (limited to 'src/android')
-rw-r--r-- | src/android/app/build.gradle.kts | 2 | ||||
-rw-r--r-- | src/android/app/src/main/AndroidManifest.xml | 1 | ||||
-rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt | 35 | ||||
-rw-r--r-- | src/android/app/src/main/jni/native.cpp | 44 |
4 files changed, 73 insertions, 9 deletions
diff --git a/src/android/app/build.gradle.kts b/src/android/app/build.gradle.kts index a8db70511..fe79a701c 100644 --- a/src/android/app/build.gradle.kts +++ b/src/android/app/build.gradle.kts @@ -95,6 +95,7 @@ android { // builds a release build that doesn't need signing // Attaches 'debug' suffix to version and package name, allowing installation alongside the release build. register("relWithDebInfo") { + isDefault = true resValue("string", "app_name_suffixed", "yuzu Debug Release") signingConfig = signingConfigs.getByName("debug") isMinifyEnabled = true @@ -122,6 +123,7 @@ android { flavorDimensions.add("version") productFlavors { create("mainline") { + isDefault = true dimension = "version" buildConfigField("Boolean", "PREMIUM", "false") } diff --git a/src/android/app/src/main/AndroidManifest.xml b/src/android/app/src/main/AndroidManifest.xml index 6184f3eb6..36e2dac98 100644 --- a/src/android/app/src/main/AndroidManifest.xml +++ b/src/android/app/src/main/AndroidManifest.xml @@ -25,6 +25,7 @@ SPDX-License-Identifier: GPL-3.0-or-later android:hasFragileUserData="false" android:supportsRtl="true" android:isGame="true" + android:appCategory="game" android:localeConfig="@xml/locales_config" android:banner="@drawable/tv_banner" android:extractNativeLibs="true" diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt index f8e7eeca7..f71d0a098 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt @@ -11,6 +11,7 @@ import kotlinx.serialization.json.Json import org.yuzu.yuzu_emu.NativeLibrary import org.yuzu.yuzu_emu.YuzuApplication import org.yuzu.yuzu_emu.model.Game +import org.yuzu.yuzu_emu.model.MinimalDocumentFile object GameHelper { const val KEY_GAME_PATH = "game_path" @@ -29,15 +30,7 @@ object GameHelper { // Ensure keys are loaded so that ROM metadata can be decrypted. NativeLibrary.reloadKeys() - val children = FileUtil.listFiles(context, gamesUri) - for (file in children) { - if (!file.isDirectory) { - // Check that the file has an extension we care about before trying to read out of it. - if (Game.extensions.contains(FileUtil.getExtension(file.uri))) { - games.add(getGame(file.uri)) - } - } - } + addGamesRecursive(games, FileUtil.listFiles(context, gamesUri), 3) // Cache list of games found on disk val serializedGames = mutableSetOf<String>() @@ -52,6 +45,30 @@ object GameHelper { return games.toList() } + private fun addGamesRecursive( + games: MutableList<Game>, + files: Array<MinimalDocumentFile>, + depth: Int + ) { + if (depth <= 0) { + return + } + + files.forEach { + if (it.isDirectory) { + addGamesRecursive( + games, + FileUtil.listFiles(YuzuApplication.appContext, it.uri), + depth - 1 + ) + } else { + if (Game.extensions.contains(FileUtil.getExtension(it.uri))) { + games.add(getGame(it.uri)) + } + } + } + } + private fun getGame(uri: Uri): Game { val filePath = uri.toString() var name = NativeLibrary.getTitle(filePath) diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index c23b2f19e..8b99d1d6e 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -30,6 +30,7 @@ #include "core/cpu_manager.h" #include "core/crypto/key_manager.h" #include "core/file_sys/card_image.h" +#include "core/file_sys/content_archive.h" #include "core/file_sys/registered_cache.h" #include "core/file_sys/submission_package.h" #include "core/file_sys/vfs.h" @@ -224,6 +225,42 @@ public: m_system.Renderer().NotifySurfaceChanged(); } + void ConfigureFilesystemProvider(const std::string& filepath) { + const auto file = m_system.GetFilesystem()->OpenFile(filepath, FileSys::Mode::Read); + if (!file) { + return; + } + + auto loader = Loader::GetLoader(m_system, file); + if (!loader) { + return; + } + + const auto file_type = loader->GetFileType(); + if (file_type == Loader::FileType::Unknown || file_type == Loader::FileType::Error) { + return; + } + + u64 program_id = 0; + const auto res2 = loader->ReadProgramId(program_id); + if (res2 == Loader::ResultStatus::Success && file_type == Loader::FileType::NCA) { + m_manual_provider->AddEntry(FileSys::TitleType::Application, + FileSys::GetCRTypeFromNCAType(FileSys::NCA{file}.GetType()), + program_id, file); + } else if (res2 == Loader::ResultStatus::Success && + (file_type == Loader::FileType::XCI || file_type == Loader::FileType::NSP)) { + const auto nsp = file_type == Loader::FileType::NSP + ? std::make_shared<FileSys::NSP>(file) + : FileSys::XCI{file}.GetSecurePartitionNSP(); + for (const auto& title : nsp->GetNCAs()) { + for (const auto& entry : title.second) { + m_manual_provider->AddEntry(entry.first.first, entry.first.second, title.first, + entry.second->GetBaseFile()); + } + } + } + } + Core::SystemResultStatus InitializeEmulation(const std::string& filepath) { std::scoped_lock lock(m_mutex); @@ -254,8 +291,14 @@ public: std::move(android_keyboard), // Software Keyboard nullptr, // Web Browser }); + + // Initialize filesystem. + m_manual_provider = std::make_unique<FileSys::ManualContentProvider>(); m_system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>()); + m_system.RegisterContentProvider(FileSys::ContentProviderUnionSlot::FrontendManual, + m_manual_provider.get()); m_system.GetFileSystemController().CreateFactories(*m_vfs); + ConfigureFilesystemProvider(filepath); // Initialize account manager m_profile_manager = std::make_unique<Service::Account::ProfileManager>(); @@ -489,6 +532,7 @@ private: bool m_is_paused{}; SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{}; std::unique_ptr<Service::Account::ProfileManager> m_profile_manager; + std::unique_ptr<FileSys::ManualContentProvider> m_manual_provider; // GPU driver parameters std::shared_ptr<Common::DynamicLibrary> m_vulkan_library; |