summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Liam2023-08-22 22:47:25 -0400
committerGravatar Liam2023-08-22 22:47:25 -0400
commit2c4ebeb51d1e5b68d37c9eadfdef47e91524fe27 (patch)
treeff3cfa763ceb48f775a6e377ef68399d2194bb9d /src
parentMerge pull request #11302 from vonchenplus/vulkan_macos (diff)
downloadyuzu-2c4ebeb51d1e5b68d37c9eadfdef47e91524fe27.tar.gz
yuzu-2c4ebeb51d1e5b68d37c9eadfdef47e91524fe27.tar.xz
yuzu-2c4ebeb51d1e5b68d37c9eadfdef47e91524fe27.zip
android: jni: ensure NCAs from loaded filepath are registered in manual content provider
Diffstat (limited to '')
-rw-r--r--src/android/app/src/main/jni/native.cpp44
1 files changed, 44 insertions, 0 deletions
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 @@
30#include "core/cpu_manager.h" 30#include "core/cpu_manager.h"
31#include "core/crypto/key_manager.h" 31#include "core/crypto/key_manager.h"
32#include "core/file_sys/card_image.h" 32#include "core/file_sys/card_image.h"
33#include "core/file_sys/content_archive.h"
33#include "core/file_sys/registered_cache.h" 34#include "core/file_sys/registered_cache.h"
34#include "core/file_sys/submission_package.h" 35#include "core/file_sys/submission_package.h"
35#include "core/file_sys/vfs.h" 36#include "core/file_sys/vfs.h"
@@ -224,6 +225,42 @@ public:
224 m_system.Renderer().NotifySurfaceChanged(); 225 m_system.Renderer().NotifySurfaceChanged();
225 } 226 }
226 227
228 void ConfigureFilesystemProvider(const std::string& filepath) {
229 const auto file = m_system.GetFilesystem()->OpenFile(filepath, FileSys::Mode::Read);
230 if (!file) {
231 return;
232 }
233
234 auto loader = Loader::GetLoader(m_system, file);
235 if (!loader) {
236 return;
237 }
238
239 const auto file_type = loader->GetFileType();
240 if (file_type == Loader::FileType::Unknown || file_type == Loader::FileType::Error) {
241 return;
242 }
243
244 u64 program_id = 0;
245 const auto res2 = loader->ReadProgramId(program_id);
246 if (res2 == Loader::ResultStatus::Success && file_type == Loader::FileType::NCA) {
247 m_manual_provider->AddEntry(FileSys::TitleType::Application,
248 FileSys::GetCRTypeFromNCAType(FileSys::NCA{file}.GetType()),
249 program_id, file);
250 } else if (res2 == Loader::ResultStatus::Success &&
251 (file_type == Loader::FileType::XCI || file_type == Loader::FileType::NSP)) {
252 const auto nsp = file_type == Loader::FileType::NSP
253 ? std::make_shared<FileSys::NSP>(file)
254 : FileSys::XCI{file}.GetSecurePartitionNSP();
255 for (const auto& title : nsp->GetNCAs()) {
256 for (const auto& entry : title.second) {
257 m_manual_provider->AddEntry(entry.first.first, entry.first.second, title.first,
258 entry.second->GetBaseFile());
259 }
260 }
261 }
262 }
263
227 Core::SystemResultStatus InitializeEmulation(const std::string& filepath) { 264 Core::SystemResultStatus InitializeEmulation(const std::string& filepath) {
228 std::scoped_lock lock(m_mutex); 265 std::scoped_lock lock(m_mutex);
229 266
@@ -254,8 +291,14 @@ public:
254 std::move(android_keyboard), // Software Keyboard 291 std::move(android_keyboard), // Software Keyboard
255 nullptr, // Web Browser 292 nullptr, // Web Browser
256 }); 293 });
294
295 // Initialize filesystem.
296 m_manual_provider = std::make_unique<FileSys::ManualContentProvider>();
257 m_system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>()); 297 m_system.SetContentProvider(std::make_unique<FileSys::ContentProviderUnion>());
298 m_system.RegisterContentProvider(FileSys::ContentProviderUnionSlot::FrontendManual,
299 m_manual_provider.get());
258 m_system.GetFileSystemController().CreateFactories(*m_vfs); 300 m_system.GetFileSystemController().CreateFactories(*m_vfs);
301 ConfigureFilesystemProvider(filepath);
259 302
260 // Initialize account manager 303 // Initialize account manager
261 m_profile_manager = std::make_unique<Service::Account::ProfileManager>(); 304 m_profile_manager = std::make_unique<Service::Account::ProfileManager>();
@@ -489,6 +532,7 @@ private:
489 bool m_is_paused{}; 532 bool m_is_paused{};
490 SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{}; 533 SoftwareKeyboard::AndroidKeyboard* m_software_keyboard{};
491 std::unique_ptr<Service::Account::ProfileManager> m_profile_manager; 534 std::unique_ptr<Service::Account::ProfileManager> m_profile_manager;
535 std::unique_ptr<FileSys::ManualContentProvider> m_manual_provider;
492 536
493 // GPU driver parameters 537 // GPU driver parameters
494 std::shared_ptr<Common::DynamicLibrary> m_vulkan_library; 538 std::shared_ptr<Common::DynamicLibrary> m_vulkan_library;