android: Fix resolving android URIs in native code
This commit is contained in:
parent
a9e29a3972
commit
585b6e9d46
7 changed files with 117 additions and 11 deletions
|
@ -5,6 +5,7 @@ package org.yuzu.yuzu_emu
|
|||
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.Html
|
||||
import android.text.method.LinkMovementMethod
|
||||
|
@ -16,7 +17,7 @@ import androidx.fragment.app.DialogFragment
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import java.lang.ref.WeakReference
|
||||
import org.yuzu.yuzu_emu.activities.EmulationActivity
|
||||
import org.yuzu.yuzu_emu.utils.DocumentsTree.Companion.isNativePath
|
||||
import org.yuzu.yuzu_emu.utils.DocumentsTree
|
||||
import org.yuzu.yuzu_emu.utils.FileUtil
|
||||
import org.yuzu.yuzu_emu.utils.Log
|
||||
import org.yuzu.yuzu_emu.utils.SerializableHelper.serializable
|
||||
|
@ -68,7 +69,7 @@ object NativeLibrary {
|
|||
@Keep
|
||||
@JvmStatic
|
||||
fun openContentUri(path: String?, openmode: String?): Int {
|
||||
return if (isNativePath(path!!)) {
|
||||
return if (DocumentsTree.isNativePath(path!!)) {
|
||||
YuzuApplication.documentsTree!!.openContentUri(path, openmode)
|
||||
} else {
|
||||
FileUtil.openContentUri(path, openmode)
|
||||
|
@ -78,7 +79,7 @@ object NativeLibrary {
|
|||
@Keep
|
||||
@JvmStatic
|
||||
fun getSize(path: String?): Long {
|
||||
return if (isNativePath(path!!)) {
|
||||
return if (DocumentsTree.isNativePath(path!!)) {
|
||||
YuzuApplication.documentsTree!!.getFileSize(path)
|
||||
} else {
|
||||
FileUtil.getFileSize(path)
|
||||
|
@ -88,7 +89,7 @@ object NativeLibrary {
|
|||
@Keep
|
||||
@JvmStatic
|
||||
fun exists(path: String?): Boolean {
|
||||
return if (isNativePath(path!!)) {
|
||||
return if (DocumentsTree.isNativePath(path!!)) {
|
||||
YuzuApplication.documentsTree!!.exists(path)
|
||||
} else {
|
||||
FileUtil.exists(path)
|
||||
|
@ -98,13 +99,31 @@ object NativeLibrary {
|
|||
@Keep
|
||||
@JvmStatic
|
||||
fun isDirectory(path: String?): Boolean {
|
||||
return if (isNativePath(path!!)) {
|
||||
return if (DocumentsTree.isNativePath(path!!)) {
|
||||
YuzuApplication.documentsTree!!.isDirectory(path)
|
||||
} else {
|
||||
FileUtil.isDirectory(path)
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
@JvmStatic
|
||||
fun getParentDirectory(path: String): String =
|
||||
if (DocumentsTree.isNativePath(path)) {
|
||||
YuzuApplication.documentsTree!!.getParentDirectory(path)
|
||||
} else {
|
||||
path
|
||||
}
|
||||
|
||||
@Keep
|
||||
@JvmStatic
|
||||
fun getFilename(path: String): String =
|
||||
if (DocumentsTree.isNativePath(path)) {
|
||||
YuzuApplication.documentsTree!!.getFilename(path)
|
||||
} else {
|
||||
FileUtil.getFilename(Uri.parse(path))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if pro controller isn't available and handheld is
|
||||
*/
|
||||
|
|
|
@ -42,6 +42,23 @@ class DocumentsTree {
|
|||
return node != null && node.isDirectory
|
||||
}
|
||||
|
||||
fun getParentDirectory(filepath: String): String {
|
||||
val node = resolvePath(filepath)!!
|
||||
val parentNode = node.parent
|
||||
if (parentNode != null && parentNode.isDirectory) {
|
||||
return parentNode.uri!!.toString()
|
||||
}
|
||||
return node.uri!!.toString()
|
||||
}
|
||||
|
||||
fun getFilename(filepath: String): String {
|
||||
val node = resolvePath(filepath)
|
||||
if (node != null) {
|
||||
return node.name!!
|
||||
}
|
||||
return filepath
|
||||
}
|
||||
|
||||
private fun resolvePath(filepath: String): DocumentsNode? {
|
||||
val tokens = StringTokenizer(filepath, File.separator, false)
|
||||
var iterator = root
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <android/native_window_jni.h>
|
||||
#include "core/core.h"
|
||||
#include "core/perf_stats.h"
|
||||
#include "jni/emu_window/emu_window.h"
|
||||
#include "jni/applets/software_keyboard.h"
|
||||
#include "video_core/rasterizer_interface.h"
|
||||
#include "common/detached_tasks.h"
|
||||
#include "core/hle/service/acc/profile_manager.h"
|
||||
#include "core/core.h"
|
||||
#include "core/file_sys/registered_cache.h"
|
||||
#include "core/hle/service/acc/profile_manager.h"
|
||||
#include "core/perf_stats.h"
|
||||
#include "jni/applets/software_keyboard.h"
|
||||
#include "jni/emu_window/emu_window.h"
|
||||
#include "video_core/rasterizer_interface.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue