Improve exception handling logic a bit

This commit is contained in:
cpfeiffer 2016-03-08 21:32:35 +01:00
parent 87023ebdb3
commit 7e8281e8d4
1 changed files with 2 additions and 5 deletions

View File

@ -479,15 +479,12 @@ public class DeviceCommunicationService extends Service {
Cursor contactLookup = null; Cursor contactLookup = null;
try { try {
contactLookup = contentResolver.query(uri, null, null, null, null); contactLookup = contentResolver.query(uri, null, null, null, null);
} catch (SecurityException e) {
return name;
}
try {
if (contactLookup != null && contactLookup.getCount() > 0) { if (contactLookup != null && contactLookup.getCount() > 0) {
contactLookup.moveToNext(); contactLookup.moveToNext();
name = contactLookup.getString(contactLookup.getColumnIndex(ContactsContract.Data.DISPLAY_NAME)); name = contactLookup.getString(contactLookup.getColumnIndex(ContactsContract.Data.DISPLAY_NAME));
} }
} catch (SecurityException e) {
// ignore, just return name below
} finally { } finally {
if (contactLookup != null) { if (contactLookup != null) {
contactLookup.close(); contactLookup.close();