[Android] Proper crash fix for the file provider IOException

Nicolas Pomepuy git at videolan.org
Thu Sep 12 12:44:04 UTC 2024


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Sep 12 07:28:12 2024 +0200| [d470d65be38b9570ac7a6970b575fbd9e49ae1a0] | committer: Nicolas Pomepuy

Proper crash fix for the file provider IOException

> https://code.videolan.org/videolan/vlc-android/commit/d470d65be38b9570ac7a6970b575fbd9e49ae1a0
---

 application/vlc-android/src/org/videolan/vlc/FileProvider.kt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/FileProvider.kt b/application/vlc-android/src/org/videolan/vlc/FileProvider.kt
index e6da05b92c..e76ffd540d 100644
--- a/application/vlc-android/src/org/videolan/vlc/FileProvider.kt
+++ b/application/vlc-android/src/org/videolan/vlc/FileProvider.kt
@@ -60,12 +60,12 @@ fun getUpdateUri() = Uri.Builder()
         .build()!!
 
 fun isPathValid(path: String): Boolean {
-    val file = try {
-        File(path)
+    try {
+        val file = File(path)
+        return AndroidDevices.mountBL.any { file.canonicalPath.startsWith(it) } && file.canRead()
     } catch (e: IOException) {
         Log.e(TAG, "Failed to parse path: $path")
         Log.e(TAG, e.message, e)
         return false
     }
-    return AndroidDevices.mountBL.any { file.canonicalPath.startsWith(it) } && file.canRead()
 }
\ No newline at end of file



More information about the Android mailing list