mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-04-07 09:01:29 -06:00
android: Fixed native path intent URIs not launching apps correctly
This commit is contained in:
parent
7f9f1e90ca
commit
7c0331da25
@ -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 =
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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!!
|
||||
|
||||
Loading…
Reference in New Issue
Block a user