Skip to content
Snippets Groups Projects
Commit 22eca89a authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Add logs to the Uri resolver

parent 3e3a5913
No related branches found
No related tags found
1 merge request!1630Add logs to the Uri resolver
Pipeline #285628 passed with stage
in 8 minutes and 37 seconds
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment