diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-12-13 08:33:50 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-12-13 08:33:50 +0000 |
commit | ecfba0c3588bdbd77c5bda509b66bc621837986b (patch) | |
tree | 5d6c024860bd04bd36a226d6a72aa75acdb146d8 /java/com/android/dialer/phonenumbercache/ContactInfoHelper.java | |
parent | 19be6707405171fdecb86c04f49a7006e2d64057 (diff) | |
parent | e7ea93d5235c097151e40f8922a1efb000734904 (diff) |
Merge changes I2dd58db1,I6cf55ad4
* changes:
Refactor CallerInfo and ContactInfoHelper to improve readability.
Move TelecomCallUtil to com.android.dialer
Diffstat (limited to 'java/com/android/dialer/phonenumbercache/ContactInfoHelper.java')
-rw-r--r-- | java/com/android/dialer/phonenumbercache/ContactInfoHelper.java | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java b/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java index c3f5b692f..39e3866cf 100644 --- a/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java +++ b/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java @@ -337,30 +337,28 @@ public class ContactInfoHelper { return ContactInfo.EMPTY; } - Cursor phoneLookupCursor = null; - try { - String[] projection = PhoneQuery.getPhoneLookupProjection(uri); - phoneLookupCursor = mContext.getContentResolver().query(uri, projection, null, null, null); - } catch (NullPointerException e) { - LogUtil.e("ContactInfoHelper.lookupContactFromUri", "phone lookup", e); - // Trap NPE from pre-N CP2 - return null; - } - if (phoneLookupCursor == null) { - LogUtil.d("ContactInfoHelper.lookupContactFromUri", "phoneLookupCursor is null"); - return null; - } + try (Cursor phoneLookupCursor = + mContext + .getContentResolver() + .query( + uri, + PhoneQuery.getPhoneLookupProjection(uri), + null /* selection */, + null /* selectionArgs */, + null /* sortOrder */)) { + if (phoneLookupCursor == null) { + LogUtil.d("ContactInfoHelper.lookupContactFromUri", "phoneLookupCursor is null"); + return null; + } - try { if (!phoneLookupCursor.moveToFirst()) { return ContactInfo.EMPTY; } + String lookupKey = phoneLookupCursor.getString(PhoneQuery.LOOKUP_KEY); ContactInfo contactInfo = createPhoneLookupContactInfo(phoneLookupCursor, lookupKey); fillAdditionalContactInfo(mContext, contactInfo); return contactInfo; - } finally { - phoneLookupCursor.close(); } } |