diff options
8 files changed, 34 insertions, 41 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt index 6e39e542b..115f72710 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt | |||
| @@ -15,13 +15,9 @@ import androidx.annotation.Keep | |||
| 15 | import androidx.fragment.app.DialogFragment | 15 | import androidx.fragment.app.DialogFragment |
| 16 | import com.google.android.material.dialog.MaterialAlertDialogBuilder | 16 | import com.google.android.material.dialog.MaterialAlertDialogBuilder |
| 17 | import java.lang.ref.WeakReference | 17 | import java.lang.ref.WeakReference |
| 18 | import org.yuzu.yuzu_emu.YuzuApplication.Companion.appContext | ||
| 19 | import org.yuzu.yuzu_emu.activities.EmulationActivity | 18 | import org.yuzu.yuzu_emu.activities.EmulationActivity |
| 20 | import org.yuzu.yuzu_emu.utils.DocumentsTree.Companion.isNativePath | 19 | import org.yuzu.yuzu_emu.utils.DocumentsTree.Companion.isNativePath |
| 21 | import org.yuzu.yuzu_emu.utils.FileUtil.exists | 20 | import org.yuzu.yuzu_emu.utils.FileUtil |
| 22 | import org.yuzu.yuzu_emu.utils.FileUtil.getFileSize | ||
| 23 | import org.yuzu.yuzu_emu.utils.FileUtil.isDirectory | ||
| 24 | import org.yuzu.yuzu_emu.utils.FileUtil.openContentUri | ||
| 25 | import org.yuzu.yuzu_emu.utils.Log | 21 | import org.yuzu.yuzu_emu.utils.Log |
| 26 | import org.yuzu.yuzu_emu.utils.SerializableHelper.serializable | 22 | import org.yuzu.yuzu_emu.utils.SerializableHelper.serializable |
| 27 | 23 | ||
| @@ -75,7 +71,7 @@ object NativeLibrary { | |||
| 75 | return if (isNativePath(path!!)) { | 71 | return if (isNativePath(path!!)) { |
| 76 | YuzuApplication.documentsTree!!.openContentUri(path, openmode) | 72 | YuzuApplication.documentsTree!!.openContentUri(path, openmode) |
| 77 | } else { | 73 | } else { |
| 78 | openContentUri(appContext, path, openmode) | 74 | FileUtil.openContentUri(path, openmode) |
| 79 | } | 75 | } |
| 80 | } | 76 | } |
| 81 | 77 | ||
| @@ -85,7 +81,7 @@ object NativeLibrary { | |||
| 85 | return if (isNativePath(path!!)) { | 81 | return if (isNativePath(path!!)) { |
| 86 | YuzuApplication.documentsTree!!.getFileSize(path) | 82 | YuzuApplication.documentsTree!!.getFileSize(path) |
| 87 | } else { | 83 | } else { |
| 88 | getFileSize(appContext, path) | 84 | FileUtil.getFileSize(path) |
| 89 | } | 85 | } |
| 90 | } | 86 | } |
| 91 | 87 | ||
| @@ -95,7 +91,7 @@ object NativeLibrary { | |||
| 95 | return if (isNativePath(path!!)) { | 91 | return if (isNativePath(path!!)) { |
| 96 | YuzuApplication.documentsTree!!.exists(path) | 92 | YuzuApplication.documentsTree!!.exists(path) |
| 97 | } else { | 93 | } else { |
| 98 | exists(appContext, path) | 94 | FileUtil.exists(path) |
| 99 | } | 95 | } |
| 100 | } | 96 | } |
| 101 | 97 | ||
| @@ -105,7 +101,7 @@ object NativeLibrary { | |||
| 105 | return if (isNativePath(path!!)) { | 101 | return if (isNativePath(path!!)) { |
| 106 | YuzuApplication.documentsTree!!.isDirectory(path) | 102 | YuzuApplication.documentsTree!!.isDirectory(path) |
| 107 | } else { | 103 | } else { |
| 108 | isDirectory(appContext, path) | 104 | FileUtil.isDirectory(path) |
| 109 | } | 105 | } |
| 110 | } | 106 | } |
| 111 | 107 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt index 9561748cb..8c053670c 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt | |||
| @@ -47,7 +47,7 @@ class YuzuApplication : Application() { | |||
| 47 | application = this | 47 | application = this |
| 48 | documentsTree = DocumentsTree() | 48 | documentsTree = DocumentsTree() |
| 49 | DirectoryInitialization.start() | 49 | DirectoryInitialization.start() |
| 50 | GpuDriverHelper.initializeDriverParameters(applicationContext) | 50 | GpuDriverHelper.initializeDriverParameters() |
| 51 | NativeLibrary.logDeviceInfo() | 51 | NativeLibrary.logDeviceInfo() |
| 52 | 52 | ||
| 53 | createNotificationChannels() | 53 | createNotificationChannels() |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt index 8923c0ea2..18857db2d 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/HomeSettingsFragment.kt | |||
| @@ -304,7 +304,7 @@ class HomeSettingsFragment : Fragment() { | |||
| 304 | .setMessage(driverName) | 304 | .setMessage(driverName) |
| 305 | .setNegativeButton(android.R.string.cancel, null) | 305 | .setNegativeButton(android.R.string.cancel, null) |
| 306 | .setNeutralButton(R.string.select_gpu_driver_default) { _: DialogInterface?, _: Int -> | 306 | .setNeutralButton(R.string.select_gpu_driver_default) { _: DialogInterface?, _: Int -> |
| 307 | GpuDriverHelper.installDefaultDriver(requireContext()) | 307 | GpuDriverHelper.installDefaultDriver() |
| 308 | Toast.makeText( | 308 | Toast.makeText( |
| 309 | requireContext(), | 309 | requireContext(), |
| 310 | R.string.select_gpu_driver_use_default, | 310 | R.string.select_gpu_driver_use_default, |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt index 0fa5df5e5..ac96c8207 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt | |||
| @@ -343,7 +343,6 @@ class MainActivity : AppCompatActivity(), ThemeProvider { | |||
| 343 | 343 | ||
| 344 | val dstPath = DirectoryInitialization.userDirectory + "/keys/" | 344 | val dstPath = DirectoryInitialization.userDirectory + "/keys/" |
| 345 | if (FileUtil.copyUriToInternalStorage( | 345 | if (FileUtil.copyUriToInternalStorage( |
| 346 | applicationContext, | ||
| 347 | result, | 346 | result, |
| 348 | dstPath, | 347 | dstPath, |
| 349 | "prod.keys" | 348 | "prod.keys" |
| @@ -446,7 +445,6 @@ class MainActivity : AppCompatActivity(), ThemeProvider { | |||
| 446 | 445 | ||
| 447 | val dstPath = DirectoryInitialization.userDirectory + "/keys/" | 446 | val dstPath = DirectoryInitialization.userDirectory + "/keys/" |
| 448 | if (FileUtil.copyUriToInternalStorage( | 447 | if (FileUtil.copyUriToInternalStorage( |
| 449 | applicationContext, | ||
| 450 | result, | 448 | result, |
| 451 | dstPath, | 449 | dstPath, |
| 452 | "key_retail.bin" | 450 | "key_retail.bin" |
| @@ -493,20 +491,20 @@ class MainActivity : AppCompatActivity(), ThemeProvider { | |||
| 493 | withContext(Dispatchers.IO) { | 491 | withContext(Dispatchers.IO) { |
| 494 | // Ignore file exceptions when a user selects an invalid zip | 492 | // Ignore file exceptions when a user selects an invalid zip |
| 495 | try { | 493 | try { |
| 496 | GpuDriverHelper.installCustomDriver(applicationContext, result) | 494 | GpuDriverHelper.installCustomDriver(result) |
| 497 | } catch (_: IOException) { | 495 | } catch (_: IOException) { |
| 498 | } | 496 | } |
| 499 | 497 | ||
| 500 | withContext(Dispatchers.Main) { | 498 | withContext(Dispatchers.Main) { |
| 501 | installationDialog.dismiss() | 499 | installationDialog.dismiss() |
| 502 | 500 | ||
| 503 | val driverName = GpuDriverHelper.customDriverName | 501 | val driverData = GpuDriverHelper.customDriverData |
| 504 | if (driverName != null) { | 502 | if (driverData.name != null) { |
| 505 | Toast.makeText( | 503 | Toast.makeText( |
| 506 | applicationContext, | 504 | applicationContext, |
| 507 | getString( | 505 | getString( |
| 508 | R.string.select_gpu_driver_install_success, | 506 | R.string.select_gpu_driver_install_success, |
| 509 | driverName | 507 | driverData.name |
| 510 | ), | 508 | ), |
| 511 | Toast.LENGTH_SHORT | 509 | Toast.LENGTH_SHORT |
| 512 | ).show() | 510 | ).show() |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt index cf226ad94..eafcf9e42 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt | |||
| @@ -7,7 +7,6 @@ import android.net.Uri | |||
| 7 | import androidx.documentfile.provider.DocumentFile | 7 | import androidx.documentfile.provider.DocumentFile |
| 8 | import java.io.File | 8 | import java.io.File |
| 9 | import java.util.* | 9 | import java.util.* |
| 10 | import org.yuzu.yuzu_emu.YuzuApplication | ||
| 11 | import org.yuzu.yuzu_emu.model.MinimalDocumentFile | 10 | import org.yuzu.yuzu_emu.model.MinimalDocumentFile |
| 12 | 11 | ||
| 13 | class DocumentsTree { | 12 | class DocumentsTree { |
| @@ -22,7 +21,7 @@ class DocumentsTree { | |||
| 22 | 21 | ||
| 23 | fun openContentUri(filepath: String, openMode: String?): Int { | 22 | fun openContentUri(filepath: String, openMode: String?): Int { |
| 24 | val node = resolvePath(filepath) ?: return -1 | 23 | val node = resolvePath(filepath) ?: return -1 |
| 25 | return FileUtil.openContentUri(YuzuApplication.appContext, node.uri.toString(), openMode) | 24 | return FileUtil.openContentUri(node.uri.toString(), openMode) |
| 26 | } | 25 | } |
| 27 | 26 | ||
| 28 | fun getFileSize(filepath: String): Long { | 27 | fun getFileSize(filepath: String): Long { |
| @@ -30,7 +29,7 @@ class DocumentsTree { | |||
| 30 | return if (node == null || node.isDirectory) { | 29 | return if (node == null || node.isDirectory) { |
| 31 | 0 | 30 | 0 |
| 32 | } else { | 31 | } else { |
| 33 | FileUtil.getFileSize(YuzuApplication.appContext, node.uri.toString()) | 32 | FileUtil.getFileSize(node.uri.toString()) |
| 34 | } | 33 | } |
| 35 | } | 34 | } |
| 36 | 35 | ||
| @@ -67,7 +66,7 @@ class DocumentsTree { | |||
| 67 | * @param parent parent node of this level | 66 | * @param parent parent node of this level |
| 68 | */ | 67 | */ |
| 69 | private fun structTree(parent: DocumentsNode) { | 68 | private fun structTree(parent: DocumentsNode) { |
| 70 | val documents = FileUtil.listFiles(YuzuApplication.appContext, parent.uri!!) | 69 | val documents = FileUtil.listFiles(parent.uri!!) |
| 71 | for (document in documents) { | 70 | for (document in documents) { |
| 72 | val node = DocumentsNode(document) | 71 | val node = DocumentsNode(document) |
| 73 | node.parent = parent | 72 | node.parent = parent |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt index c3f53f1c5..a5f89bba6 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/FileUtil.kt | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | 3 | ||
| 4 | package org.yuzu.yuzu_emu.utils | 4 | package org.yuzu.yuzu_emu.utils |
| 5 | 5 | ||
| 6 | import android.content.Context | ||
| 7 | import android.database.Cursor | 6 | import android.database.Cursor |
| 8 | import android.net.Uri | 7 | import android.net.Uri |
| 9 | import android.provider.DocumentsContract | 8 | import android.provider.DocumentsContract |
| @@ -29,6 +28,8 @@ object FileUtil { | |||
| 29 | const val APPLICATION_OCTET_STREAM = "application/octet-stream" | 28 | const val APPLICATION_OCTET_STREAM = "application/octet-stream" |
| 30 | const val TEXT_PLAIN = "text/plain" | 29 | const val TEXT_PLAIN = "text/plain" |
| 31 | 30 | ||
| 31 | private val context get() = YuzuApplication.appContext | ||
| 32 | |||
| 32 | /** | 33 | /** |
| 33 | * Create a file from directory with filename. | 34 | * Create a file from directory with filename. |
| 34 | * @param context Application context | 35 | * @param context Application context |
| @@ -36,11 +37,11 @@ object FileUtil { | |||
| 36 | * @param filename file display name. | 37 | * @param filename file display name. |
| 37 | * @return boolean | 38 | * @return boolean |
| 38 | */ | 39 | */ |
| 39 | fun createFile(context: Context?, directory: String?, filename: String): DocumentFile? { | 40 | fun createFile(directory: String?, filename: String): DocumentFile? { |
| 40 | var decodedFilename = filename | 41 | var decodedFilename = filename |
| 41 | try { | 42 | try { |
| 42 | val directoryUri = Uri.parse(directory) | 43 | val directoryUri = Uri.parse(directory) |
| 43 | val parent = DocumentFile.fromTreeUri(context!!, directoryUri) ?: return null | 44 | val parent = DocumentFile.fromTreeUri(context, directoryUri) ?: return null |
| 44 | decodedFilename = URLDecoder.decode(decodedFilename, DECODE_METHOD) | 45 | decodedFilename = URLDecoder.decode(decodedFilename, DECODE_METHOD) |
| 45 | var mimeType = APPLICATION_OCTET_STREAM | 46 | var mimeType = APPLICATION_OCTET_STREAM |
| 46 | if (decodedFilename.endsWith(".txt")) { | 47 | if (decodedFilename.endsWith(".txt")) { |
| @@ -56,16 +57,15 @@ object FileUtil { | |||
| 56 | 57 | ||
| 57 | /** | 58 | /** |
| 58 | * Create a directory from directory with filename. | 59 | * Create a directory from directory with filename. |
| 59 | * @param context Application context | ||
| 60 | * @param directory parent path for directory. | 60 | * @param directory parent path for directory. |
| 61 | * @param directoryName directory display name. | 61 | * @param directoryName directory display name. |
| 62 | * @return boolean | 62 | * @return boolean |
| 63 | */ | 63 | */ |
| 64 | fun createDir(context: Context?, directory: String?, directoryName: String?): DocumentFile? { | 64 | fun createDir(directory: String?, directoryName: String?): DocumentFile? { |
| 65 | var decodedDirectoryName = directoryName | 65 | var decodedDirectoryName = directoryName |
| 66 | try { | 66 | try { |
| 67 | val directoryUri = Uri.parse(directory) | 67 | val directoryUri = Uri.parse(directory) |
| 68 | val parent = DocumentFile.fromTreeUri(context!!, directoryUri) ?: return null | 68 | val parent = DocumentFile.fromTreeUri(context, directoryUri) ?: return null |
| 69 | decodedDirectoryName = URLDecoder.decode(decodedDirectoryName, DECODE_METHOD) | 69 | decodedDirectoryName = URLDecoder.decode(decodedDirectoryName, DECODE_METHOD) |
| 70 | val isExist = parent.findFile(decodedDirectoryName) | 70 | val isExist = parent.findFile(decodedDirectoryName) |
| 71 | return isExist ?: parent.createDirectory(decodedDirectoryName) | 71 | return isExist ?: parent.createDirectory(decodedDirectoryName) |
| @@ -77,13 +77,12 @@ object FileUtil { | |||
| 77 | 77 | ||
| 78 | /** | 78 | /** |
| 79 | * Open content uri and return file descriptor to JNI. | 79 | * Open content uri and return file descriptor to JNI. |
| 80 | * @param context Application context | ||
| 81 | * @param path Native content uri path | 80 | * @param path Native content uri path |
| 82 | * @param openMode will be one of "r", "r", "rw", "wa", "rwa" | 81 | * @param openMode will be one of "r", "r", "rw", "wa", "rwa" |
| 83 | * @return file descriptor | 82 | * @return file descriptor |
| 84 | */ | 83 | */ |
| 85 | @JvmStatic | 84 | @JvmStatic |
| 86 | fun openContentUri(context: Context, path: String, openMode: String?): Int { | 85 | fun openContentUri(path: String, openMode: String?): Int { |
| 87 | try { | 86 | try { |
| 88 | val uri = Uri.parse(path) | 87 | val uri = Uri.parse(path) |
| 89 | val parcelFileDescriptor = context.contentResolver.openFileDescriptor(uri, openMode!!) | 88 | val parcelFileDescriptor = context.contentResolver.openFileDescriptor(uri, openMode!!) |
| @@ -103,11 +102,10 @@ object FileUtil { | |||
| 103 | /** | 102 | /** |
| 104 | * Reference: https://stackoverflow.com/questions/42186820/documentfile-is-very-slow | 103 | * Reference: https://stackoverflow.com/questions/42186820/documentfile-is-very-slow |
| 105 | * This function will be faster than DoucmentFile.listFiles | 104 | * This function will be faster than DoucmentFile.listFiles |
| 106 | * @param context Application context | ||
| 107 | * @param uri Directory uri. | 105 | * @param uri Directory uri. |
| 108 | * @return CheapDocument lists. | 106 | * @return CheapDocument lists. |
| 109 | */ | 107 | */ |
| 110 | fun listFiles(context: Context, uri: Uri): Array<MinimalDocumentFile> { | 108 | fun listFiles(uri: Uri): Array<MinimalDocumentFile> { |
| 111 | val resolver = context.contentResolver | 109 | val resolver = context.contentResolver |
| 112 | val columns = arrayOf( | 110 | val columns = arrayOf( |
| 113 | DocumentsContract.Document.COLUMN_DOCUMENT_ID, | 111 | DocumentsContract.Document.COLUMN_DOCUMENT_ID, |
| @@ -145,7 +143,7 @@ object FileUtil { | |||
| 145 | * @param path Native content uri path | 143 | * @param path Native content uri path |
| 146 | * @return bool | 144 | * @return bool |
| 147 | */ | 145 | */ |
| 148 | fun exists(context: Context, path: String?): Boolean { | 146 | fun exists(path: String?): Boolean { |
| 149 | var c: Cursor? = null | 147 | var c: Cursor? = null |
| 150 | try { | 148 | try { |
| 151 | val mUri = Uri.parse(path) | 149 | val mUri = Uri.parse(path) |
| @@ -165,7 +163,7 @@ object FileUtil { | |||
| 165 | * @param path content uri path | 163 | * @param path content uri path |
| 166 | * @return bool | 164 | * @return bool |
| 167 | */ | 165 | */ |
| 168 | fun isDirectory(context: Context, path: String): Boolean { | 166 | fun isDirectory(path: String): Boolean { |
| 169 | val resolver = context.contentResolver | 167 | val resolver = context.contentResolver |
| 170 | val columns = arrayOf( | 168 | val columns = arrayOf( |
| 171 | DocumentsContract.Document.COLUMN_MIME_TYPE | 169 | DocumentsContract.Document.COLUMN_MIME_TYPE |
| @@ -210,10 +208,10 @@ object FileUtil { | |||
| 210 | return filename | 208 | return filename |
| 211 | } | 209 | } |
| 212 | 210 | ||
| 213 | fun getFilesName(context: Context, path: String): Array<String> { | 211 | fun getFilesName(path: String): Array<String> { |
| 214 | val uri = Uri.parse(path) | 212 | val uri = Uri.parse(path) |
| 215 | val files: MutableList<String> = ArrayList() | 213 | val files: MutableList<String> = ArrayList() |
| 216 | for (file in listFiles(context, uri)) { | 214 | for (file in listFiles(uri)) { |
| 217 | files.add(file.filename) | 215 | files.add(file.filename) |
| 218 | } | 216 | } |
| 219 | return files.toTypedArray() | 217 | return files.toTypedArray() |
| @@ -225,7 +223,7 @@ object FileUtil { | |||
| 225 | * @return long file size | 223 | * @return long file size |
| 226 | */ | 224 | */ |
| 227 | @JvmStatic | 225 | @JvmStatic |
| 228 | fun getFileSize(context: Context, path: String): Long { | 226 | fun getFileSize(path: String): Long { |
| 229 | val resolver = context.contentResolver | 227 | val resolver = context.contentResolver |
| 230 | val columns = arrayOf( | 228 | val columns = arrayOf( |
| 231 | DocumentsContract.Document.COLUMN_SIZE | 229 | DocumentsContract.Document.COLUMN_SIZE |
| @@ -246,7 +244,6 @@ object FileUtil { | |||
| 246 | } | 244 | } |
| 247 | 245 | ||
| 248 | fun copyUriToInternalStorage( | 246 | fun copyUriToInternalStorage( |
| 249 | context: Context, | ||
| 250 | sourceUri: Uri?, | 247 | sourceUri: Uri?, |
| 251 | destinationParentPath: String, | 248 | destinationParentPath: String, |
| 252 | destinationFilename: String | 249 | destinationFilename: String |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt index e0ee29c9b..9001ca9ab 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt | |||
| @@ -30,7 +30,7 @@ object GameHelper { | |||
| 30 | // Ensure keys are loaded so that ROM metadata can be decrypted. | 30 | // Ensure keys are loaded so that ROM metadata can be decrypted. |
| 31 | NativeLibrary.reloadKeys() | 31 | NativeLibrary.reloadKeys() |
| 32 | 32 | ||
| 33 | addGamesRecursive(games, FileUtil.listFiles(context, gamesUri), 3) | 33 | addGamesRecursive(games, FileUtil.listFiles(gamesUri), 3) |
| 34 | 34 | ||
| 35 | // Cache list of games found on disk | 35 | // Cache list of games found on disk |
| 36 | val serializedGames = mutableSetOf<String>() | 36 | val serializedGames = mutableSetOf<String>() |
| @@ -58,7 +58,7 @@ object GameHelper { | |||
| 58 | if (it.isDirectory) { | 58 | if (it.isDirectory) { |
| 59 | addGamesRecursive( | 59 | addGamesRecursive( |
| 60 | games, | 60 | games, |
| 61 | FileUtil.listFiles(YuzuApplication.appContext, it.uri), | 61 | FileUtil.listFiles(it.uri), |
| 62 | depth - 1 | 62 | depth - 1 |
| 63 | ) | 63 | ) |
| 64 | } else { | 64 | } else { |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverHelper.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverHelper.kt index 1d4695a2a..296a8f1cf 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverHelper.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverHelper.kt | |||
| @@ -13,6 +13,7 @@ import java.io.IOException | |||
| 13 | import java.util.zip.ZipInputStream | 13 | import java.util.zip.ZipInputStream |
| 14 | import org.yuzu.yuzu_emu.NativeLibrary | 14 | import org.yuzu.yuzu_emu.NativeLibrary |
| 15 | import org.yuzu.yuzu_emu.utils.FileUtil.copyUriToInternalStorage | 15 | import org.yuzu.yuzu_emu.utils.FileUtil.copyUriToInternalStorage |
| 16 | import org.yuzu.yuzu_emu.YuzuApplication | ||
| 16 | 17 | ||
| 17 | object GpuDriverHelper { | 18 | object GpuDriverHelper { |
| 18 | private const val META_JSON_FILENAME = "meta.json" | 19 | private const val META_JSON_FILENAME = "meta.json" |
| @@ -61,6 +62,7 @@ object GpuDriverHelper { | |||
| 61 | 62 | ||
| 62 | // Initialize the driver installation directory. | 63 | // Initialize the driver installation directory. |
| 63 | driverInstallationPath = context.filesDir.canonicalPath + "/gpu_driver/" | 64 | driverInstallationPath = context.filesDir.canonicalPath + "/gpu_driver/" |
| 65 | .filesDir.canonicalPath + "/gpu_driver/" | ||
| 64 | } catch (e: IOException) { | 66 | } catch (e: IOException) { |
| 65 | throw RuntimeException(e) | 67 | throw RuntimeException(e) |
| 66 | } | 68 | } |
| @@ -70,6 +72,7 @@ object GpuDriverHelper { | |||
| 70 | 72 | ||
| 71 | // Initialize hook libraries directory. | 73 | // Initialize hook libraries directory. |
| 72 | hookLibPath = context.applicationInfo.nativeLibraryDir + "/" | 74 | hookLibPath = context.applicationInfo.nativeLibraryDir + "/" |
| 75 | hookLibPath = YuzuApplication.appContext.applicationInfo.nativeLibraryDir + "/" | ||
| 73 | 76 | ||
| 74 | // Initialize GPU driver. | 77 | // Initialize GPU driver. |
| 75 | NativeLibrary.initializeGpuDriver( | 78 | NativeLibrary.initializeGpuDriver( |
| @@ -81,15 +84,15 @@ object GpuDriverHelper { | |||
| 81 | } | 84 | } |
| 82 | 85 | ||
| 83 | fun installDefaultDriver(context: Context) { | 86 | fun installDefaultDriver(context: Context) { |
| 87 | fun installDefaultDriver() { | ||
| 84 | // Removing the installed driver will result in the backend using the default system driver. | 88 | // Removing the installed driver will result in the backend using the default system driver. |
| 85 | val driverInstallationDir = File(driverInstallationPath!!) | 89 | val driverInstallationDir = File(driverInstallationPath!!) |
| 86 | deleteRecursive(driverInstallationDir) | 90 | deleteRecursive(driverInstallationDir) |
| 87 | initializeDriverParameters(context) | ||
| 88 | } | 91 | } |
| 89 | 92 | ||
| 90 | fun installCustomDriver(context: Context, driverPathUri: Uri?) { | 93 | fun installCustomDriver(context: Context, driverPathUri: Uri?) { |
| 91 | // Revert to system default in the event the specified driver is bad. | 94 | // Revert to system default in the event the specified driver is bad. |
| 92 | installDefaultDriver(context) | 95 | installDefaultDriver() |
| 93 | 96 | ||
| 94 | // Ensure we have directories. | 97 | // Ensure we have directories. |
| 95 | initializeDirectories() | 98 | initializeDirectories() |