diff options
author | linyuh <linyuh@google.com> | 2017-12-14 12:34:31 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2017-12-14 13:16:13 -0800 |
commit | 2d5167b475d64b4bad0f0cde2508bca55c4b7643 (patch) | |
tree | e8ac965f799aa1be24268c241280223b86157ec0 /java/com/android/incallui | |
parent | 35363b349d9542a0dd124307a498a3daa0e73390 (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/incallui')
-rw-r--r-- | java/com/android/incallui/CallerInfo.java | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/java/com/android/incallui/CallerInfo.java b/java/com/android/incallui/CallerInfo.java index 5c43b4f39..d3b12c158 100644 --- a/java/com/android/incallui/CallerInfo.java +++ b/java/com/android/incallui/CallerInfo.java @@ -223,16 +223,26 @@ public class CallerInfo { long contactId = 0L; int columnIndex; - // Look for the name - columnIndex = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME); + // Look for the number + columnIndex = cursor.getColumnIndex(PhoneLookup.NUMBER); if (columnIndex != -1) { - info.name = normalize(cursor.getString(columnIndex)); + // 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 filling in the fields in CallerInfo. + boolean hasNumberMatch = + PhoneNumberHelper.updateCursorToMatchContactLookupUri(cursor, columnIndex, contactRef); + if (hasNumberMatch) { + info.phoneNumber = cursor.getString(columnIndex); + } else { + return info; + } } - // Look for the number - columnIndex = cursor.getColumnIndex(PhoneLookup.NUMBER); + // Look for the name + columnIndex = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME); if (columnIndex != -1) { - info.phoneNumber = cursor.getString(columnIndex); + info.name = normalize(cursor.getString(columnIndex)); } // Look for the normalized number |