summaryrefslogtreecommitdiff
path: root/java/com/android/incallui
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/incallui')
-rw-r--r--java/com/android/incallui/CallerInfo.java22
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