summaryrefslogtreecommitdiff
path: root/InCallUI
diff options
context:
space:
mode:
Diffstat (limited to 'InCallUI')
-rw-r--r--InCallUI/src/com/android/incallui/CallerInfo.java36
-rw-r--r--InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java14
2 files changed, 41 insertions, 9 deletions
diff --git a/InCallUI/src/com/android/incallui/CallerInfo.java b/InCallUI/src/com/android/incallui/CallerInfo.java
index 670c3fd66..55a4be6fd 100644
--- a/InCallUI/src/com/android/incallui/CallerInfo.java
+++ b/InCallUI/src/com/android/incallui/CallerInfo.java
@@ -16,6 +16,7 @@
package com.android.incallui;
+import com.android.dialer.util.PhoneLookupUtil;
import com.google.common.primitives.Longs;
import android.content.Context;
@@ -32,6 +33,8 @@ import android.provider.ContactsContract.RawContacts;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
+import com.android.contacts.common.compat.CompatUtils;
+import com.android.contacts.common.compat.PhoneLookupSdkCompat;
import com.android.contacts.common.ContactsUtils;
import com.android.contacts.common.ContactsUtils.UserType;
import com.android.contacts.common.util.PhoneNumberHelper;
@@ -44,8 +47,9 @@ import com.android.dialer.calllog.ContactInfoHelper;
public class CallerInfo {
private static final String TAG = "CallerInfo";
- public static final String[] DEFAULT_PHONELOOKUP_PROJECTION = new String[] {
- PhoneLookup._ID,
+ // We should always use this projection starting from NYC onward.
+ private static final String[] DEFAULT_PHONELOOKUP_PROJECTION = new String[] {
+ PhoneLookupSdkCompat.CONTACT_ID,
PhoneLookup.DISPLAY_NAME,
PhoneLookup.LOOKUP_KEY,
PhoneLookup.NUMBER,
@@ -57,6 +61,32 @@ public class CallerInfo {
PhoneLookup.SEND_TO_VOICEMAIL
};
+ // In pre-N, contact id is stored in {@link PhoneLookup._ID} in non-sip query.
+ private static final String[] BACKWARD_COMPATIBLE_NON_SIP_DEFAULT_PHONELOOKUP_PROJECTION =
+ new String[] {
+ PhoneLookup._ID,
+ PhoneLookup.DISPLAY_NAME,
+ PhoneLookup.LOOKUP_KEY,
+ PhoneLookup.NUMBER,
+ PhoneLookup.NORMALIZED_NUMBER,
+ PhoneLookup.LABEL,
+ PhoneLookup.TYPE,
+ PhoneLookup.PHOTO_URI,
+ PhoneLookup.CUSTOM_RINGTONE,
+ PhoneLookup.SEND_TO_VOICEMAIL
+ };
+
+ public static String[] getDefaultPhoneLookupProjection(Uri phoneLookupUri) {
+ if (CompatUtils.isNCompatible()) {
+ return DEFAULT_PHONELOOKUP_PROJECTION;
+ }
+ // Pre-N
+ boolean isSip = phoneLookupUri.getBooleanQueryParameter(
+ ContactsContract.PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, false);
+ return (isSip) ? DEFAULT_PHONELOOKUP_PROJECTION
+ : BACKWARD_COMPATIBLE_NON_SIP_DEFAULT_PHONELOOKUP_PROJECTION;
+ }
+
/**
* Please note that, any one of these member variables can be null,
* and any accesses to them should be prepared to handle such a case.
@@ -480,7 +510,7 @@ public class CallerInfo {
// for phone numbers.
// MIME type: PhoneLookup.CONTENT_TYPE (= "vnd.android.cursor.dir/phone_lookup")
Log.v(TAG, "'phone_lookup' URI; using PhoneLookup._ID");
- columnName = PhoneLookup._ID;
+ columnName = PhoneLookupUtil.getContactIdColumnNameForUri(contactRef);
} else {
Log.v(TAG, "Unexpected prefix for contactRef '" + url + "'");
}
diff --git a/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java b/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java
index bf5e1a311..5188323c9 100644
--- a/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java
+++ b/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java
@@ -400,13 +400,15 @@ public class CallerInfoAsyncQuery {
cw.event = EVENT_NEW_QUERY;
}
+
+ String[] proejection = CallerInfo.getDefaultPhoneLookupProjection(contactRef);
c.mHandler.startQuery(token,
- cw, // cookie
- contactRef, // uri
- CallerInfo.DEFAULT_PHONELOOKUP_PROJECTION, // projection
- null, // selection
- null, // selectionArgs
- null); // orderBy
+ cw, // cookie
+ contactRef, // uri
+ proejection, // projection
+ null, // selection
+ null, // selectionArgs
+ null); // orderBy
return c;
}