[Android] Add logs to the Uri resolver
Nicolas Pomepuy
git at videolan.org
Tue Nov 22 14:51:00 UTC 2022
vlc-android | branch: 3.5.x | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Nov 22 08:13:28 2022 +0100| [3437c7c960ca51f5fd0d258d41b4d5ede1189a24] | committer: Duncan McNamara
Add logs to the Uri resolver
> https://code.videolan.org/videolan/vlc-android/commit/3437c7c960ca51f5fd0d258d41b4d5ede1189a24
---
.../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 0330f1046c..4e0647f71c 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