From 2d5167b475d64b4bad0f0cde2508bca55c4b7643 Mon Sep 17 00:00:00 2001 From: linyuh Date: Thu, 14 Dec 2017 12:34:31 -0800 Subject: Take into consideration special characters when we do contact match. Bug: 30225112 Test: CallLogGroupBuilderTest, PhoneNumberHelperTest, CallerInfoTest, and Manual (see demo) PiperOrigin-RevId: 179080046 Change-Id: I8e451a6c197a6c3df4260e58d0276a5dc5b9515a --- .../android/dialer/phonenumbercache/ContactInfoHelper.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'java/com/android/dialer/phonenumbercache') diff --git a/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java b/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java index 39e3866cf..1fd2bffd9 100644 --- a/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java +++ b/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java @@ -355,6 +355,17 @@ public class ContactInfoHelper { return ContactInfo.EMPTY; } + // The Contacts provider ignores special characters in phone numbers when searching for a + // contact. For example, number "123" is considered a match with a contact with number "#123". + // We need to check whether the result contains a number that truly matches the query and move + // the cursor to that position before building a ContactInfo. + boolean hasNumberMatch = + PhoneNumberHelper.updateCursorToMatchContactLookupUri( + phoneLookupCursor, PhoneQuery.MATCHED_NUMBER, uri); + if (!hasNumberMatch) { + return ContactInfo.EMPTY; + } + String lookupKey = phoneLookupCursor.getString(PhoneQuery.LOOKUP_KEY); ContactInfo contactInfo = createPhoneLookupContactInfo(phoneLookupCursor, lookupKey); fillAdditionalContactInfo(mContext, contactInfo); -- cgit v1.2.3