From ac03b699be2664a1abdbe64073b48fbf21efa39d Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Thu, 26 Nov 2015 17:02:08 +0000 Subject: Show Enterprise directory contacts name in IncallUI and notification known issue:b/25859809 BUG=25899500 Change-Id: Ia61250707981b49efebb6e2c2e4910f58a1233dd --- .../android/dialer/calllog/ContactInfoHelper.java | 32 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'src/com/android/dialer/calllog/ContactInfoHelper.java') diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java index 52d143784..a68d8f253 100644 --- a/src/com/android/dialer/calllog/ContactInfoHelper.java +++ b/src/com/android/dialer/calllog/ContactInfoHelper.java @@ -19,6 +19,7 @@ import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteFullException; import android.net.Uri; +import android.os.Build; import android.provider.CallLog.Calls; import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Phone; @@ -47,6 +48,11 @@ import org.json.JSONObject; public class ContactInfoHelper { private static final String TAG = ContactInfoHelper.class.getSimpleName(); + private static final boolean FLAG_PRE_N_FEATURE = + true // Enforce Pre-N (M) behavior in release build + || Build.VERSION.SDK_INT <= Build.VERSION_CODES.M + || !Build.VERSION.CODENAME.startsWith("N"); + private final Context mContext; private final String mCurrentCountryIso; @@ -379,13 +385,31 @@ public class ContactInfoHelper { } public static Uri getContactInfoLookupUri(String number) { + return getContactInfoLookupUri(number, -1); + } + + public static Uri getContactInfoLookupUri(String number, long directoryId) { // Get URI for the number in the PhoneLookup table, with a parameter to indicate whether // the number is a SIP number. - return PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI.buildUpon() - .appendPath(Uri.encode(number)) + Uri uri = PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI; + if (FLAG_PRE_N_FEATURE) { + if (directoryId != -1) { + // ENTERPRISE_CONTENT_FILTER_URI in M doesn't support directory lookup + uri = PhoneLookup.CONTENT_FILTER_URI; + } else { + // b/25900607 in M. PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, encodes twice. + number = Uri.encode(number); + } + } + Uri.Builder builder = uri.buildUpon() + .appendPath(number) .appendQueryParameter(PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, - String.valueOf(PhoneNumberHelper.isUriNumber(number))) - .build(); + String.valueOf(PhoneNumberHelper.isUriNumber(number))); + if (directoryId != -1) { + builder.appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY, + String.valueOf(directoryId)); + } + return builder.build(); } /** -- cgit v1.2.3