diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-10-18 02:50:55 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-10-18 02:50:55 +0000 |
commit | ef7a7eb0f103d41df55385267ac52dc3dcf603cb (patch) | |
tree | 8bb6b163a88cf321073913c2b0b7dad5ecbd854e /java/com/android/dialer/phonenumbercache/ContactInfoHelper.java | |
parent | c2590357cf857e714f875f2a7c222d1bd128c2c5 (diff) | |
parent | 6f78d935ff64f178e9fe8891082c18578d4e4b74 (diff) |
Merge changes Ida554313,Ie7187b02,I7a7c23b4
* changes:
Stop showing partially matched numbers that are not global phone numbers.
Display Voicemail Contact Name and Photo in Voicemail Fragment.
Add temporary assisted dialing setting to Dialer.
Diffstat (limited to 'java/com/android/dialer/phonenumbercache/ContactInfoHelper.java')
-rw-r--r-- | java/com/android/dialer/phonenumbercache/ContactInfoHelper.java | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java b/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java index b680bd57d..f501792f9 100644 --- a/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java +++ b/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java @@ -337,30 +337,30 @@ 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, null, null)) { + 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); + + Cursor matchedCursor = + PhoneNumberHelper.getCursorMatchForContactLookupUri( + phoneLookupCursor, PhoneQuery.MATCHED_NUMBER, uri); + if (matchedCursor == null) { + return ContactInfo.EMPTY; + } + + String lookupKey = matchedCursor.getString(PhoneQuery.LOOKUP_KEY); + ContactInfo contactInfo = createPhoneLookupContactInfo(matchedCursor, lookupKey); fillAdditionalContactInfo(mContext, contactInfo); return contactInfo; - } finally { - phoneLookupCursor.close(); } } |