Skip to content

Commit

Permalink
Fix #3324 (crash in getMimeType)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomas2 committed Oct 3, 2024
1 parent 17fb150 commit c789771
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,15 @@ class InstallZip : ActivityBase() {

private fun getDisplayName(uri: Uri): String? =
contentResolver.query(uri, null, null, null, null)?.use {
if (it.isLast) return null;
it.moveToFirst()
val displayNameIdx = it.getColumnIndex(OpenableColumns.DISPLAY_NAME)
if(displayNameIdx < 0) null else it.getString(displayNameIdx)
}

private fun getMimeType(uri: Uri): String? =
contentResolver.query(uri, null, null, null, null)?.use {
if (it.isLast) return null;
it.moveToFirst()
val mimeTypeIdx = it.getColumnIndex("mime_type")
if(mimeTypeIdx < 0) null else it.getString(mimeTypeIdx)
Expand Down

0 comments on commit c789771

Please sign in to comment.