Android: Make the handling of SAF open modes more robust

This commit is contained in:
JosJuice 2020-11-04 20:59:39 +01:00
commit 70df5446d3
4 changed files with 43 additions and 25 deletions

View file

@ -17,7 +17,9 @@ public class ContentHandler
return DolphinApplication.getAppContext().getContentResolver()
.openFileDescriptor(Uri.parse(uri), mode).detachFd();
}
catch (FileNotFoundException | NullPointerException e)
// Some content providers throw IllegalArgumentException for invalid modes,
// despite the documentation saying that invalid modes result in a FileNotFoundException
catch (FileNotFoundException | IllegalArgumentException | NullPointerException e)
{
return -1;
}