From 83583b735686aa02119f5754f77eb9f0d318fe44 Mon Sep 17 00:00:00 2001 From: Tony Mak Date: Mon, 22 Feb 2016 19:58:42 +0000 Subject: Show Briefcase icon not displayed in in-call UI for work SIP calls Current dialer always queries PhoneLookup._ID and uses this as a contact ID. In pre-N, contact id of non-sip query is stored in PhoneLookup._ID and it is actually a mistake. This problem does not exist in sip query, and contact id of sip query is stored in Data.CONTACT_ID. So it is a "bug" in dialer that we use PhoneLooup._ID for sip query as it is not really a contacat id. The bug of missing work badge may not be the only issue introduced by this. In N, the issue is get fixed in framework, PhoneLookup.CONTACT_ID is introduced. We should access PhoneLookup.CONTACT_ID no matter what phone lookup query we are having. The ideal case is we always use PhoneLookup.CONTACT_ID for retrieving contact id, but given that we need to support in pre-N, we need to query PhoneLookup._ID for contact id in non-sip query in pre-N. BUG:27242975 Change-Id: Id14378e3dce5b07629ffe0c6e83c3d107fbb468e --- InCallUI/src/com/android/incallui/CallerInfo.java | 36 ++++++++++++++++++++-- .../com/android/incallui/CallerInfoAsyncQuery.java | 14 +++++---- 2 files changed, 41 insertions(+), 9 deletions(-) (limited to 'InCallUI/src/com/android') 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; } -- cgit v1.2.3