Fix a crash caused by SIP addresses containing "%40" instead of "@"
CallerInfo.doSecondaryLookupIfNecessary() 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 the in-call UI to crash if you ever called a SIP address
like "xyz%40example.com".
TESTED:
- Make an outgoing call to the SIP address "xyz%40example.com"
==> The call ultimately fails, but the in-call UI no longer crashes when
it first comes up.
Bug: 5637074
Change-Id: I62d15a7ccd509924d38b780b92e657b9efa26125
This commit is contained in:
@@ -2117,6 +2117,31 @@ public class PhoneNumberUtils
|
||||
return number != null && (number.contains("@") || number.contains("%40"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the "username" part of the specified SIP address,
|
||||
* i.e. the part before the "@" character (or "%40").
|
||||
*
|
||||
* @param number SIP address of the form "username@domainname"
|
||||
* (or the URI-escaped equivalent "username%40domainname")
|
||||
* @see isUriNumber
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static String getUsernameFromUriNumber(String number) {
|
||||
// The delimiter between username and domain name can be
|
||||
// either "@" or "%40" (the URI-escaped equivalent.)
|
||||
int delimiterIndex = number.indexOf('@');
|
||||
if (delimiterIndex < 0) {
|
||||
delimiterIndex = number.indexOf("%40");
|
||||
}
|
||||
if (delimiterIndex < 0) {
|
||||
Log.w(LOG_TAG,
|
||||
"getUsernameFromUriNumber: no delimiter found in SIP addr '" + number + "'");
|
||||
delimiterIndex = number.length();
|
||||
}
|
||||
return number.substring(0, delimiterIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function handles the plus code conversion within NANP CDMA network
|
||||
* If the number format is
|
||||
|
||||
@@ -288,7 +288,7 @@ public class CallerInfo {
|
||||
String number, CallerInfo previousResult) {
|
||||
if (!previousResult.contactExists
|
||||
&& PhoneNumberUtils.isUriNumber(number)) {
|
||||
String username = number.substring(0, number.indexOf('@'));
|
||||
String username = PhoneNumberUtils.getUsernameFromUriNumber(number);
|
||||
if (PhoneNumberUtils.isGlobalPhoneNumber(username)) {
|
||||
previousResult = getCallerInfo(context,
|
||||
Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
|
||||
|
||||
Reference in New Issue
Block a user