From 9cc266b0e71a73ed772301272b55ccf45526d7c9 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 7 Sep 2023 17:36:20 -0700 Subject: [PATCH] Android: Fix developer tools -> run tests. --- Common/System/Request.cpp | 2 +- Core/PSPLoaders.cpp | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Common/System/Request.cpp b/Common/System/Request.cpp index 3dc290af1a..1635152a24 100644 --- a/Common/System/Request.cpp +++ b/Common/System/Request.cpp @@ -40,7 +40,7 @@ bool RequestManager::MakeSystemRequest(SystemRequestType type, RequestCallback c callbackMap_[requestId] = { callback, failedCallback }; } - DEBUG_LOG(SYSTEM, "Making system request %s: id %d", RequestTypeAsString(type), requestId); + VERBOSE_LOG(SYSTEM, "Making system request %s: id %d", RequestTypeAsString(type), requestId); if (!System_MakeRequest(type, requestId, param1, param2, param3)) { if (callback || failedCallback) { std::lock_guard guard(callbackMutex_); diff --git a/Core/PSPLoaders.cpp b/Core/PSPLoaders.cpp index 5fc79c28d3..9516ab60bd 100644 --- a/Core/PSPLoaders.cpp +++ b/Core/PSPLoaders.cpp @@ -21,6 +21,7 @@ #include "Common/Thread/ThreadUtil.h" #include "Common/System/Request.h" +#include "Common/File/AndroidContentURI.h" #include "Common/File/FileUtil.h" #include "Common/StringUtils.h" #ifdef _WIN32 @@ -380,6 +381,10 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) { std::string path = full_path.GetDirectory(); std::string file = full_path.GetFilename(); + if (full_path.Type() == PathType::CONTENT_URI) { + path = AndroidContentURI(full_path.c_str()).FilePath(); + } + size_t pos = path.find("PSP/GAME/"); std::string ms_path; if (pos != std::string::npos) { @@ -393,7 +398,11 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) { if (!PSP_CoreParameter().mountRoot.empty()) { // We don't want to worry about .. and cwd and such. const Path rootNorm = NormalizePath(PSP_CoreParameter().mountRoot); - const Path pathNorm = NormalizePath(Path(path)); + Path pathNorm = NormalizePath(Path(path)); + + if (full_path.Type() == PathType::CONTENT_URI) { + pathNorm = full_path.NavigateUp(); + } // If root is not a subpath of path, we can't boot the game. if (!pathNorm.StartsWith(rootNorm)) { @@ -402,10 +411,17 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) { return false; } - // TODO(scoped): This won't work! - const std::string filepath = ReplaceAll(pathNorm.ToString().substr(rootNorm.ToString().size()), "\\", "/"); + std::string filepath; + if (full_path.Type() == PathType::CONTENT_URI) { + std::string rootFilePath = AndroidContentURI(rootNorm.c_str()).FilePath(); + std::string pathFilePath = AndroidContentURI(pathNorm.c_str()).FilePath(); + filepath = pathFilePath.substr(rootFilePath.size()); + } else { + filepath = ReplaceAll(pathNorm.ToString().substr(rootNorm.ToString().size()), "\\", "/"); + } + file = filepath + "/" + file; - path = rootNorm.ToString() + "/"; + path = rootNorm.ToString(); pspFileSystem.SetStartingDirectory(filepath); } else { pspFileSystem.SetStartingDirectory(ms_path);