summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorDavid Brown <dab@google.com>2011-11-16 22:10:56 -0800
committerDavid Brown <dab@google.com>2011-11-17 15:39:21 -0800
commit158f116eb7fdc23a12d6822d34a549f33605bc8c (patch)
treeccb2cd0c484f7ace83a98505140440ee7a5c68c1 /telephony
parent1733a3de8c4f98ba4df08ab79d1fef6d2684d2c2 (diff)
downloadframeworks_base-158f116eb7fdc23a12d6822d34a549f33605bc8c.zip
frameworks_base-158f116eb7fdc23a12d6822d34a549f33605bc8c.tar.gz
frameworks_base-158f116eb7fdc23a12d6822d34a549f33605bc8c.tar.bz2
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
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/android/telephony/PhoneNumberUtils.java25
-rw-r--r--telephony/java/com/android/internal/telephony/CallerInfo.java2
2 files changed, 26 insertions, 1 deletions
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java
index 56a0a2c..07afe30 100644
--- a/telephony/java/android/telephony/PhoneNumberUtils.java
+++ b/telephony/java/android/telephony/PhoneNumberUtils.java
@@ -2118,6 +2118,31 @@ public class PhoneNumberUtils
}
/**
+ * @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
* 1)+1NANP,remove +,
diff --git a/telephony/java/com/android/internal/telephony/CallerInfo.java b/telephony/java/com/android/internal/telephony/CallerInfo.java
index 6324550..5d1f758 100644
--- a/telephony/java/com/android/internal/telephony/CallerInfo.java
+++ b/telephony/java/com/android/internal/telephony/CallerInfo.java
@@ -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,