From e878174df8c17a6422e54d9ea48d534a740dc994 Mon Sep 17 00:00:00 2001 From: OpenSauce04 Date: Sat, 7 Mar 2026 23:09:34 +0000 Subject: [PATCH] android: Fixed games located in an application directory not being accessible --- .../java/org/citra/citra_emu/NativeLibrary.kt | 5 +++++ .../java/org/citra/citra_emu/utils/GameHelper.kt | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/android/app/src/main/java/org/citra/citra_emu/NativeLibrary.kt b/src/android/app/src/main/java/org/citra/citra_emu/NativeLibrary.kt index 3e82567f1..d20f13d19 100644 --- a/src/android/app/src/main/java/org/citra/citra_emu/NativeLibrary.kt +++ b/src/android/app/src/main/java/org/citra/citra_emu/NativeLibrary.kt @@ -698,6 +698,11 @@ object NativeLibrary { val dirSep = "/" + val uriString = uri.toString() + if (!uriString.contains(":")) { // These raw URIs happen when generating the game list. Why? + return uriString + } + val pathSegment = uri.lastPathSegment ?: return "" val virtualPath = pathSegment.substringAfter(":") diff --git a/src/android/app/src/main/java/org/citra/citra_emu/utils/GameHelper.kt b/src/android/app/src/main/java/org/citra/citra_emu/utils/GameHelper.kt index 90b011114..032947c1d 100644 --- a/src/android/app/src/main/java/org/citra/citra_emu/utils/GameHelper.kt +++ b/src/android/app/src/main/java/org/citra/citra_emu/utils/GameHelper.kt @@ -70,7 +70,15 @@ object GameHelper { fun getGame(uri: Uri, isInstalled: Boolean, addedToLibrary: Boolean): Game { val filePath = uri.toString() - var gameInfo: GameInfo? = GameInfo(filePath) + var nativePath: String? = null + var gameInfo: GameInfo? + if (BuildUtil.isGooglePlayBuild || FileUtil.isNativePath(filePath)) { + gameInfo = GameInfo(filePath) + } else { + nativePath = "!" + NativeLibrary.getNativePath(uri); + gameInfo = GameInfo(nativePath) + } + if (gameInfo?.isValid() == false) { gameInfo = null @@ -81,7 +89,11 @@ object GameHelper { val newGame = Game( (gameInfo?.getTitle() ?: FileUtil.getFilename(uri)).replace("[\\t\\n\\r]+".toRegex(), " "), filePath.replace("\n", " "), - filePath, + if (BuildUtil.isGooglePlayBuild || FileUtil.isNativePath(filePath)) { + filePath + } else { + nativePath!! + }, gameInfo?.getTitleID() ?: 0, gameInfo?.getCompany() ?: "", if (isEncrypted) { CitraApplication.appContext.getString(R.string.unsupported_encrypted) } else { gameInfo?.getRegions() ?: "" },