android: Fixed native path intent URIs not launching apps correctly

This commit is contained in:
OpenSauce04 2026-03-21 20:50:10 +00:00
parent 7f9f1e90ca
commit 7c0331da25
3 changed files with 13 additions and 9 deletions

View File

@ -143,14 +143,17 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
}
if (intentUri != null) {
if (!BuildUtil.isGooglePlayBuild) {
val intentUriString = intentUri.toString()
// We need to build a special path as the incoming URI may be SAF exclusive
Log.warning("[EmulationFragment] Cannot determine native path of URI \"" +
intentUri.toString() + "\", using file descriptor instead.")
gameFd = requireContext().contentResolver.openFileDescriptor(intentUri, "r")?.detachFd()
intentUri = if (gameFd != null) {
Uri.parse("fd://" + gameFd.toString())
} else {
null
intentUriString + "\", using file descriptor instead.")
if (!intentUriString.startsWith("!")) {
gameFd = requireContext().contentResolver.openFileDescriptor(intentUri, "r")?.detachFd()
intentUri = if (gameFd != null) {
Uri.parse("fd://" + gameFd.toString())
} else {
null
}
}
}
intentGame =

View File

@ -547,7 +547,7 @@ object FileUtil {
}
@JvmStatic
fun isNativePath(path: String): Boolean =
fun isNativePath(path: String): Boolean = // FIXME: This function name is bullshit -OS
try {
path[0] == '/'
} catch (e: StringIndexOutOfBoundsException) {

View File

@ -72,7 +72,7 @@ object GameHelper {
val filePath = uri.toString()
var nativePath: String? = null
var gameInfo: GameInfo?
if (BuildUtil.isGooglePlayBuild || FileUtil.isNativePath(filePath)) {
if (BuildUtil.isGooglePlayBuild || FileUtil.isNativePath(filePath) || filePath.startsWith("!")) {
gameInfo = GameInfo(filePath)
} else {
nativePath = if (uri.scheme == "fd") {
@ -94,7 +94,8 @@ object GameHelper {
valid,
(gameInfo?.getTitle() ?: FileUtil.getFilename(uri)).replace("[\\t\\n\\r]+".toRegex(), " "),
filePath.replace("\n", " "),
if (BuildUtil.isGooglePlayBuild || FileUtil.isNativePath(filePath)) {
// TODO: This next line can be deduplicated but I don't want to right now -OS
if (BuildUtil.isGooglePlayBuild || FileUtil.isNativePath(filePath) || filePath.startsWith("!")) {
filePath
} else {
nativePath!!