1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-26 01:36:55 +00:00

Prevent NPE

This commit is contained in:
M66B 2024-09-15 08:04:47 +02:00
parent 117cb38511
commit 1bdfac3f72

View file

@ -1146,9 +1146,11 @@ public class FragmentRule extends FragmentBase {
private void onSelectSound(Uri uri) {
try {
Log.i("Selected sound uri=" + uri);
getContext().getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
if (!Helper.isPersisted(getContext(), uri, true, false))
throw new IllegalStateException("No permission granted to access selected image " + uri);
if (uri != null) {
getContext().getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
if (!Helper.isPersisted(getContext(), uri, true, false))
throw new IllegalStateException("No permission granted to access selected image " + uri);
}
} catch (Throwable ex) {
Log.w(ex);
}