Catch content resolver security exception

pull/162/head
M66B 6 years ago
parent 984c1430bf
commit 264cfc375d

@ -1840,16 +1840,19 @@ public class FragmentCompose extends FragmentBase {
String name = uri.getLastPathSegment(); String name = uri.getLastPathSegment();
String s = null; String s = null;
try (Cursor cursor = context.getContentResolver().query(uri, null, null, null, null, null)) { try {
if (cursor != null && cursor.moveToFirst()) { try (Cursor cursor = context.getContentResolver().query(uri, null, null, null, null, null)) {
int colName = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME); if (cursor != null && cursor.moveToFirst()) {
int colSize = cursor.getColumnIndex(OpenableColumns.SIZE); int colName = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
if (colName >= 0) int colSize = cursor.getColumnIndex(OpenableColumns.SIZE);
name = cursor.getString(colName); if (colName >= 0)
if (colSize >= 0) name = cursor.getString(colName);
s = cursor.getString(colSize); if (colSize >= 0)
s = cursor.getString(colSize);
}
} }
} catch (SecurityException ex) {
Log.w(ex);
} }
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
@ -1935,7 +1938,7 @@ public class FragmentCompose extends FragmentBase {
resizeAttachment(context, attachment); resizeAttachment(context, attachment);
} catch (IOException ex) { } catch (Throwable ex) {
// Reset progress on failure // Reset progress on failure
Log.e(ex); Log.e(ex);
db.attachment().setError(attachment.id, Helper.formatThrowable(ex, false)); db.attachment().setError(attachment.id, Helper.formatThrowable(ex, false));

Loading…
Cancel
Save