summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Brown <dab@google.com>2011-11-17 16:31:10 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-11-17 16:31:10 -0800
commit3f51f954948caf1fe5b3f175f7e8523f2ba58f58 (patch)
tree54a6d08a6481d1020e8b394e00b776a9601c8e23
parenta37a78e2efe54892a744adfc6330c2d2179dee21 (diff)
parent158f116eb7fdc23a12d6822d34a549f33605bc8c (diff)
downloadframeworks_base-3f51f954948caf1fe5b3f175f7e8523f2ba58f58.zip
frameworks_base-3f51f954948caf1fe5b3f175f7e8523f2ba58f58.tar.gz
frameworks_base-3f51f954948caf1fe5b3f175f7e8523f2ba58f58.tar.bz2
Merge "Fix a crash caused by SIP addresses containing "%40" instead of "@"" into ics-mr1
-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,