Fix a crash caused by SIP addresses containing "%40" instead of "@"
ContactInfoHelper.lookupNumber() was assuming that SIP addresses would
always contain the character '@', but that's not always true since the
username/domainname delimiter can actually be "%40" (the URI-escaped
equivalent.)
This would cause Dialtacts to crash upon launch if you somehow managed to
get a SIP address like "123%40foo" in your call log.
TESTED:
(1) Make an outgoing call to the (malformed) SIP address "123%40foo"
(2) Launch Dialtacts ("Phone")
==> No longer crashes
This change should be submitted after change I62d15a in frameworks/base,
which adds the PhoneNumberUtils.getUsernameFromUriNumber() method.
Bug: 5637074
Change-Id: I06f333cf993ca5e33b88c0c8b9006116b6fd5cf7
diff --git a/src/com/android/contacts/calllog/ContactInfoHelper.java b/src/com/android/contacts/calllog/ContactInfoHelper.java
index b4e4cf7..90d5e8b 100644
--- a/src/com/android/contacts/calllog/ContactInfoHelper.java
+++ b/src/com/android/contacts/calllog/ContactInfoHelper.java
@@ -57,8 +57,9 @@
// This "number" is really a SIP address.
ContactInfo sipInfo = queryContactInfoForSipAddress(number);
if (sipInfo == null || sipInfo == ContactInfo.EMPTY) {
- // Check whether the username is actually a phone number of contact.
- String username = number.substring(0, number.indexOf('@'));
+ // Check whether the "username" part of the SIP address is
+ // actually the phone number of a contact.
+ String username = PhoneNumberUtils.getUsernameFromUriNumber(number);
if (PhoneNumberUtils.isGlobalPhoneNumber(username)) {
sipInfo = queryContactInfoForPhoneNumber(username, countryIso);
}