summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorHung-ying Tyan <tyanh@google.com>2010-10-20 13:57:20 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-10-20 13:57:20 -0700
commitd691b36cdea314585b6aa17556ed4c35bb65a69e (patch)
tree36089b5b75df0fb721f58341ee787bbd83ba584a /telephony
parentfd0ba81c02c0881f7534333afc8c53e241158a3d (diff)
parent6fe795ecd35c4d49822d349424fc71b660577dfc (diff)
downloadframeworks_base-d691b36cdea314585b6aa17556ed4c35bb65a69e.zip
frameworks_base-d691b36cdea314585b6aa17556ed4c35bb65a69e.tar.gz
frameworks_base-d691b36cdea314585b6aa17556ed4c35bb65a69e.tar.bz2
am 6fe795ec: Do another contact lookup if the first one fails and...
Merge commit '6fe795ecd35c4d49822d349424fc71b660577dfc' into gingerbread-plus-aosp * commit '6fe795ecd35c4d49822d349424fc71b660577dfc': Do another contact lookup if the first one fails and...
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/com/android/internal/telephony/CallerInfo.java26
-rw-r--r--telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java8
2 files changed, 34 insertions, 0 deletions
diff --git a/telephony/java/com/android/internal/telephony/CallerInfo.java b/telephony/java/com/android/internal/telephony/CallerInfo.java
index 1e9b930..f7506c6 100644
--- a/telephony/java/com/android/internal/telephony/CallerInfo.java
+++ b/telephony/java/com/android/internal/telephony/CallerInfo.java
@@ -260,6 +260,7 @@ public class CallerInfo {
Uri contactUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
CallerInfo info = getCallerInfo(context, contactUri);
+ info = doSecondaryLookupIfNecessary(context, number, info);
// if no query results were returned with a viable number,
// fill in the original number value we used to query with.
@@ -271,6 +272,30 @@ public class CallerInfo {
}
/**
+ * Performs another lookup if previous lookup fails and it's a SIP call
+ * and the peer's username is all numeric. Look up the username as it
+ * could be a PSTN number in the contact database.
+ *
+ * @param context the query context
+ * @param number the original phone number, could be a SIP URI
+ * @param previousResult the result of previous lookup
+ * @return previousResult if it's not the case
+ */
+ static CallerInfo doSecondaryLookupIfNecessary(Context context,
+ String number, CallerInfo previousResult) {
+ if (!previousResult.contactExists
+ && PhoneNumberUtils.isUriNumber(number)) {
+ String username = number.substring(0, number.indexOf('@'));
+ if (PhoneNumberUtils.isGlobalPhoneNumber(username)) {
+ previousResult = getCallerInfo(context,
+ Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
+ Uri.encode(username)));
+ }
+ }
+ return previousResult;
+ }
+
+ /**
* getCallerId: a convenience method to get the caller id for a given
* number.
*
@@ -402,6 +427,7 @@ public class CallerInfo {
.append("\nisCachedPhotoCurrent: " + isCachedPhotoCurrent)
.append("\nemergency: " + mIsEmergency)
.append("\nvoicemail " + mIsVoiceMail)
+ .append("\ncontactExists " + contactExists)
.toString();
}
}
diff --git a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java
index 9561c6e..c6b5861 100644
--- a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java
+++ b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java
@@ -230,6 +230,14 @@ public class CallerInfoAsyncQuery {
mCallerInfo = CallerInfo.getCallerInfo(mQueryContext, mQueryUri, cursor);
if (DBG) Log.d(LOG_TAG, "==> Got mCallerInfo: " + mCallerInfo);
+ CallerInfo newCallerInfo = CallerInfo.doSecondaryLookupIfNecessary(
+ mQueryContext, cw.number, mCallerInfo);
+ if (newCallerInfo != mCallerInfo) {
+ mCallerInfo = newCallerInfo;
+ if (DBG) log("#####async contact look up with numeric username"
+ + mCallerInfo);
+ }
+
// Use the number entered by the user for display.
if (!TextUtils.isEmpty(cw.number)) {
mCallerInfo.phoneNumber = PhoneNumberUtils.formatNumber(cw.number);