summaryrefslogtreecommitdiff
path: root/InCallUI/src/com/android/incallui/CallerInfo.java
diff options
context:
space:
mode:
Diffstat (limited to 'InCallUI/src/com/android/incallui/CallerInfo.java')
-rw-r--r--InCallUI/src/com/android/incallui/CallerInfo.java112
1 files changed, 27 insertions, 85 deletions
diff --git a/InCallUI/src/com/android/incallui/CallerInfo.java b/InCallUI/src/com/android/incallui/CallerInfo.java
index 1650fbb05..a5ab07c64 100644
--- a/InCallUI/src/com/android/incallui/CallerInfo.java
+++ b/InCallUI/src/com/android/incallui/CallerInfo.java
@@ -90,11 +90,19 @@ public class CallerInfo {
public String numberLabel;
public int photoResource;
- public long person_id;
- public String lookupKey;
+
+ // Contact ID, which will be 0 if a contact comes from the corp CP2.
+ public long contactIdOrZero;
+ public String lookupKeyOrNull;
public boolean needUpdate;
public Uri contactRefUri;
+ /**
+ * Contact display photo URI. If a contact has no display photo but a thumbnail, it'll be
+ * the thumbnail URI instead.
+ */
+ public Uri contactDisplayPhotoUri;
+
// fields to hold individual contact preference data,
// including the send to voicemail flag and the ringtone
// uri reference.
@@ -204,15 +212,13 @@ public class CallerInfo {
// Look for the person_id.
columnIndex = getColumnIndexForPersonId(contactRef, cursor);
if (columnIndex != -1) {
- info.person_id = cursor.getLong(columnIndex);
- Log.v(TAG, "==> got info.person_id: " + info.person_id);
+ info.contactIdOrZero = cursor.getLong(columnIndex);
+ Log.v(TAG, "==> got info.contactIdOrZero: " + info.contactIdOrZero);
// cache the lookup key for later use with person_id to create lookup URIs
columnIndex = cursor.getColumnIndex(PhoneLookup.LOOKUP_KEY);
- if ((columnIndex != -1) && (cursor.getString(columnIndex) != null)) {
- info.lookupKey = cursor.getString(columnIndex);
- } else {
- info.lookupKey = null;
+ if (columnIndex != -1) {
+ info.lookupKeyOrNull = cursor.getString(columnIndex);
}
} else {
// No valid columnIndex, so we can't look up person_id.
@@ -222,6 +228,14 @@ public class CallerInfo {
// the in-call UI, for example.)
}
+ // Display photo URI.
+ columnIndex = cursor.getColumnIndex(PhoneLookup.PHOTO_URI);
+ if ((columnIndex != -1) && (cursor.getString(columnIndex) != null)) {
+ info.contactDisplayPhotoUri = Uri.parse(cursor.getString(columnIndex));
+ } else {
+ info.contactDisplayPhotoUri = null;
+ }
+
// look for the custom ringtone, create from the string stored
// in the database.
columnIndex = cursor.getColumnIndex(PhoneLookup.CUSTOM_RINGTONE);
@@ -256,53 +270,13 @@ public class CallerInfo {
* @return the CallerInfo which contains the caller id for the given
* number. The returned CallerInfo is null if no number is supplied.
*/
- public static CallerInfo getCallerInfo(Context context, Uri contactRef) {
+ private static CallerInfo getCallerInfo(Context context, Uri contactRef) {
return getCallerInfo(context, contactRef,
context.getContentResolver().query(contactRef, null, null, null, null));
}
/**
- * getCallerInfo given a phone number, look up in the call-log database
- * for the matching caller id info.
- * @param context the context used to get the ContentResolver
- * @param number the phone number used to lookup caller id
- * @return the CallerInfo which contains the caller id for the given
- * number. The returned CallerInfo is null if no number is supplied. If
- * a matching number is not found, then a generic caller info is returned,
- * with all relevant fields empty or null.
- */
- public static CallerInfo getCallerInfo(Context context, String number) {
- Log.v(TAG, "getCallerInfo() based on number...");
-
- if (TextUtils.isEmpty(number)) {
- return null;
- }
-
- // Change the callerInfo number ONLY if it is an emergency number
- // or if it is the voicemail number. If it is either, take a
- // shortcut and skip the query.
- if (PhoneNumberHelper.isLocalEmergencyNumber(number, context)) {
- return new CallerInfo().markAsEmergency(context);
- } else if (PhoneNumberUtils.isVoiceMailNumber(number)) {
- return new CallerInfo().markAsVoiceMail(context);
- }
-
- 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.
- if (TextUtils.isEmpty(info.phoneNumber)) {
- info.phoneNumber = number;
- }
-
- return info;
- }
-
- /**
* 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.
@@ -319,46 +293,13 @@ public class CallerInfo {
String username = PhoneNumberHelper.getUsernameFromUriNumber(number);
if (PhoneNumberUtils.isGlobalPhoneNumber(username)) {
previousResult = getCallerInfo(context,
- Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
+ Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI,
Uri.encode(username)));
}
}
return previousResult;
}
- /**
- * getCallerId: a convenience method to get the caller id for a given
- * number.
- *
- * @param context the context used to get the ContentResolver.
- * @param number a phone number.
- * @return if the number belongs to a contact, the contact's name is
- * returned; otherwise, the number itself is returned.
- *
- * TODO NOTE: This MAY need to refer to the Asynchronous Query API
- * [startQuery()], instead of getCallerInfo, but since it looks like
- * it is only being used by the provider calls in the messaging app:
- * 1. android.provider.Telephony.Mms.getDisplayAddress()
- * 2. android.provider.Telephony.Sms.getDisplayAddress()
- * We may not need to make the change.
- */
- public static String getCallerId(Context context, String number) {
- CallerInfo info = getCallerInfo(context, number);
- String callerID = null;
-
- if (info != null) {
- String name = info.name;
-
- if (!TextUtils.isEmpty(name)) {
- callerID = name;
- } else {
- callerID = number;
- }
- }
-
- return callerID;
- }
-
// Accessors
/**
@@ -589,10 +530,11 @@ public class CallerInfo {
.append("\nnumberType: " + numberType)
.append("\nnumberLabel: " + numberLabel)
.append("\nphotoResource: " + photoResource)
- .append("\nperson_id: " + person_id)
+ .append("\ncontactIdOrZero: " + contactIdOrZero)
.append("\nneedUpdate: " + needUpdate)
.append("\ncontactRefUri: " + contactRefUri)
- .append("\ncontactRingtoneUri: " + contactRefUri)
+ .append("\ncontactRingtoneUri: " + contactRingtoneUri)
+ .append("\ncontactDisplayPhotoUri: " + contactDisplayPhotoUri)
.append("\nshouldSendToVoicemail: " + shouldSendToVoicemail)
.append("\ncachedPhoto: " + cachedPhoto)
.append("\nisCachedPhotoCurrent: " + isCachedPhotoCurrent)