summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/phonenumbercache
diff options
context:
space:
mode:
authorlinyuh <linyuh@google.com>2017-12-14 12:34:31 -0800
committerCopybara-Service <copybara-piper@google.com>2017-12-14 13:16:13 -0800
commit2d5167b475d64b4bad0f0cde2508bca55c4b7643 (patch)
treee8ac965f799aa1be24268c241280223b86157ec0 /java/com/android/dialer/phonenumbercache
parent35363b349d9542a0dd124307a498a3daa0e73390 (diff)
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
Diffstat (limited to 'java/com/android/dialer/phonenumbercache')
-rw-r--r--java/com/android/dialer/phonenumbercache/ContactInfoHelper.java11
1 files changed, 11 insertions, 0 deletions
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);