android: Fixed games located in an application directory not being accessible

This commit is contained in:
OpenSauce04 2026-03-07 23:09:34 +00:00 committed by OpenSauce
parent 7ad6621f91
commit e878174df8
2 changed files with 19 additions and 2 deletions

View file

@ -698,6 +698,11 @@ object NativeLibrary {
val dirSep = "/" 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 pathSegment = uri.lastPathSegment ?: return ""
val virtualPath = pathSegment.substringAfter(":") val virtualPath = pathSegment.substringAfter(":")

View file

@ -70,7 +70,15 @@ object GameHelper {
fun getGame(uri: Uri, isInstalled: Boolean, addedToLibrary: Boolean): Game { fun getGame(uri: Uri, isInstalled: Boolean, addedToLibrary: Boolean): Game {
val filePath = uri.toString() 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) { if (gameInfo?.isValid() == false) {
gameInfo = null gameInfo = null
@ -81,7 +89,11 @@ object GameHelper {
val newGame = Game( val newGame = Game(
(gameInfo?.getTitle() ?: FileUtil.getFilename(uri)).replace("[\\t\\n\\r]+".toRegex(), " "), (gameInfo?.getTitle() ?: FileUtil.getFilename(uri)).replace("[\\t\\n\\r]+".toRegex(), " "),
filePath.replace("\n", " "), filePath.replace("\n", " "),
filePath, if (BuildUtil.isGooglePlayBuild || FileUtil.isNativePath(filePath)) {
filePath
} else {
nativePath!!
},
gameInfo?.getTitleID() ?: 0, gameInfo?.getTitleID() ?: 0,
gameInfo?.getCompany() ?: "", gameInfo?.getCompany() ?: "",
if (isEncrypted) { CitraApplication.appContext.getString(R.string.unsupported_encrypted) } else { gameInfo?.getRegions() ?: "" }, if (isEncrypted) { CitraApplication.appContext.getString(R.string.unsupported_encrypted) } else { gameInfo?.getRegions() ?: "" },