[Android] Add logs to the Uri resolver

Nicolas Pomepuy git at videolan.org
Tue Nov 22 13:28:27 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Nov 22 08:13:28 2022 +0100| [22eca89af633ad63e3761f1a3316a847efb9d27b] | committer: Nicolas Pomepuy

Add logs to the Uri resolver

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

 .../vlc-android/src/org/videolan/vlc/util/FileUtils.kt      | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/util/FileUtils.kt b/application/vlc-android/src/org/videolan/vlc/util/FileUtils.kt
index 6d99164f1e..70154abeb0 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/FileUtils.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/FileUtils.kt
@@ -352,7 +352,10 @@ object FileUtils {
                         val filename = cursor.getString(cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME)).replace("/", "")
                         if (BuildConfig.DEBUG) Log.i(TAG, "Getting file $filename from content:// URI")
                         inputStream = ctx.contentResolver.openInputStream(data)
-                        if (inputStream == null) return data
+                        if (inputStream == null) {
+                            Log.i("FileUtils", "Expanding uri: $data to $data")
+                            return data
+                        }
                         os = FileOutputStream(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY + "/Download/" + filename)
                         val buffer = ByteArray(1024)
                         var bytesRead = inputStream.read(buffer)
@@ -363,7 +366,7 @@ object FileUtils {
                         uri = AndroidUtil.PathToUri(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY + "/Download/" + filename)
                     }
                 } catch (e: Exception) {
-                    Log.e(TAG, "Couldn't download file from mail URI")
+                    Log.e(TAG, "Couldn't download file from mail URI: $data")
                     return null
                 } finally {
                     CloseableUtils.close(inputStream)
@@ -380,7 +383,10 @@ object FileUtils {
                 val inputPFD: ParcelFileDescriptor?
                 try {
                     inputPFD = ctx.contentResolver.openFileDescriptor(data, "r")
-                    if (inputPFD == null) return data
+                    if (inputPFD == null) {
+                        Log.i("FileUtils", "Expanding uri: $data to $data")
+                        return data
+                    }
                     uri = AndroidUtil.LocationToUri("fd://" + inputPFD.fd)
                     //                    Cursor returnCursor =
                     //                            getContentResolver().query(data, null, null, null, null);
@@ -412,6 +418,7 @@ object FileUtils {
                 }
             }// Media or MMS URI
         }
+        Log.i("FileUtils", "Expanding uri: $data to $uri")
         return uri
     }
 



More information about the Android mailing list