summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt22
-rw-r--r--src/android/app/src/main/res/values/strings.xml1
2 files changed, 23 insertions, 0 deletions
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 b455b7d35..c03c28aa1 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
@@ -180,6 +180,10 @@ class MainActivity : AppCompatActivity() {
windowInsets
}
+ private fun hasExtension(path: String, extension: String): Boolean {
+ return path.substring(path.lastIndexOf(".") + 1).contains(extension)
+ }
+
val getGamesDirectory =
registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { result ->
if (result == null)
@@ -212,6 +216,15 @@ class MainActivity : AppCompatActivity() {
if (result == null)
return@registerForActivityResult
+ if (!hasExtension(result.toString(), "keys")) {
+ Toast.makeText(
+ applicationContext,
+ R.string.invalid_keys_file,
+ Toast.LENGTH_SHORT
+ ).show()
+ return@registerForActivityResult
+ }
+
val takeFlags =
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION
contentResolver.takePersistableUriPermission(
@@ -243,6 +256,15 @@ class MainActivity : AppCompatActivity() {
if (result == null)
return@registerForActivityResult
+ if (!hasExtension(result.toString(), "bin")) {
+ Toast.makeText(
+ applicationContext,
+ R.string.invalid_keys_file,
+ Toast.LENGTH_SHORT
+ ).show()
+ return@registerForActivityResult
+ }
+
val takeFlags =
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION
contentResolver.takePersistableUriPermission(
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml
index 916f516c0..92fe67bf0 100644
--- a/src/android/app/src/main/res/values/strings.xml
+++ b/src/android/app/src/main/res/values/strings.xml
@@ -35,6 +35,7 @@
<string name="install_prod_keys_description">Required to decrypt retail games</string>
<string name="install_amiibo_keys">Install Amiibo Keys</string>
<string name="install_amiibo_keys_description">Required to use Amiibo in game</string>
+ <string name="invalid_keys_file">Invalid keys file selected</string>
<string name="install_keys_success">Keys successfully installed</string>
<string name="install_keys_failure">Keys file (prod.keys) is invalid</string>
<string name="install_amiibo_keys_failure">Keys file (key_retail.bin) is invalid</string>