diff options
author | Tony Mak <tonymak@google.com> | 2016-02-22 20:29:11 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-02-22 20:29:11 +0000 |
commit | 639ed3451d911c9a282d1351b87595f3e1d8aaa4 (patch) | |
tree | be84dc56e5df832b2f2ca46de939b67dcb4c00c4 /src/com/android/dialer/calllog | |
parent | 4acb573794b2da2870b6ccfffca65570fb1bc564 (diff) | |
parent | 83583b735686aa02119f5754f77eb9f0d318fe44 (diff) |
Merge "Show Briefcase icon not displayed in in-call UI for work SIP calls" into nyc-dev
Diffstat (limited to 'src/com/android/dialer/calllog')
-rw-r--r-- | src/com/android/dialer/calllog/ContactInfoHelper.java | 3 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/PhoneQuery.java | 53 |
2 files changed, 36 insertions, 20 deletions
diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java index 75e7ab746..a9c7651d9 100644 --- a/src/com/android/dialer/calllog/ContactInfoHelper.java +++ b/src/com/android/dialer/calllog/ContactInfoHelper.java @@ -164,8 +164,7 @@ public class ContactInfoHelper { Cursor phoneLookupCursor = null; try { - String[] projection = (isSip) ? PhoneQuery.SIP_PHONE_LOOKUP_PROJECTION - : PhoneQuery.PHONE_LOOKUP_PROJECTION; + String[] projection = PhoneQuery.getPhoneLookupProjection(uri); phoneLookupCursor = mContext.getContentResolver().query(uri, projection, null, null, null); } catch (NullPointerException e) { diff --git a/src/com/android/dialer/calllog/PhoneQuery.java b/src/com/android/dialer/calllog/PhoneQuery.java index 5261874c8..f1f14c66e 100644 --- a/src/com/android/dialer/calllog/PhoneQuery.java +++ b/src/com/android/dialer/calllog/PhoneQuery.java @@ -16,10 +16,15 @@ package com.android.dialer.calllog; +import android.net.Uri; +import android.provider.ContactsContract; import android.provider.ContactsContract.Contacts; -import android.provider.ContactsContract.Data; import android.provider.ContactsContract.PhoneLookup; +import com.android.contacts.common.compat.CompatUtils; +import com.android.contacts.common.compat.PhoneLookupSdkCompat; +import com.android.contacts.common.ContactsUtils; + /** * The queries to look up the {@link ContactInfo} for a given number in the Call Log. */ @@ -27,10 +32,11 @@ final class PhoneQuery { /** * Projection to look up the ContactInfo. Does not include DISPLAY_NAME_ALTERNATIVE as that - * column isn't available in ContactsCommon.PhoneLookup + * column isn't available in ContactsCommon.PhoneLookup. + * We should always use this projection starting from NYC onward. */ - public static final String[] PHONE_LOOKUP_PROJECTION = new String[] { - PhoneLookup._ID, + private static final String[] PHONE_LOOKUP_PROJECTION = new String[] { + PhoneLookupSdkCompat.CONTACT_ID, PhoneLookup.DISPLAY_NAME, PhoneLookup.TYPE, PhoneLookup.LABEL, @@ -42,21 +48,32 @@ final class PhoneQuery { }; /** - * Similar to {@link PHONE_LOOKUP_PROJECTION}. Due to a bug in framework, the column name of - * contact id in normal phonelookup query is _id, but that in sip phonelookup query is - * contact_id. + * Similar to {@link PHONE_LOOKUP_PROJECTION}. In pre-N, contact id is stored in + * {@link PhoneLookup#_ID} in non-sip query. */ - public static final String[] SIP_PHONE_LOOKUP_PROJECTION = new String[] { - Data.CONTACT_ID, - PhoneLookup.DISPLAY_NAME, - PhoneLookup.TYPE, - PhoneLookup.LABEL, - PhoneLookup.NUMBER, - PhoneLookup.NORMALIZED_NUMBER, - PhoneLookup.PHOTO_ID, - PhoneLookup.LOOKUP_KEY, - PhoneLookup.PHOTO_URI - }; + private static final String[] BACKWARD_COMPATIBLE_NON_SIP_PHONE_LOOKUP_PROJECTION = + new String[] { + PhoneLookup._ID, + PhoneLookup.DISPLAY_NAME, + PhoneLookup.TYPE, + PhoneLookup.LABEL, + PhoneLookup.NUMBER, + PhoneLookup.NORMALIZED_NUMBER, + PhoneLookup.PHOTO_ID, + PhoneLookup.LOOKUP_KEY, + PhoneLookup.PHOTO_URI + }; + + public static String[] getPhoneLookupProjection(Uri phoneLookupUri) { + if (CompatUtils.isNCompatible()) { + return PHONE_LOOKUP_PROJECTION; + } + // Pre-N + boolean isSip = phoneLookupUri.getBooleanQueryParameter( + ContactsContract.PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, false); + return (isSip) ? PHONE_LOOKUP_PROJECTION + : BACKWARD_COMPATIBLE_NON_SIP_PHONE_LOOKUP_PROJECTION; + } public static final int PERSON_ID = 0; public static final int NAME = 1; |