From 7c414093c8c66a69cfea77a0ac10c1354f96cb7c Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Mon, 9 Mar 2015 13:44:02 -0700 Subject: Show corp contacts in call-log... as wells as the missed-call notification. Just PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI instead of PhoneLookup.CONTENT_FILTER_URI. This CL requires the new column in calllog provider. Change-Id: I61a2f63bcad102cb8a7e8021483b7dfe254abd95 --- src/com/android/dialer/calllog/CallLogAdapter.java | 9 +++++++-- src/com/android/dialer/calllog/CallLogQuery.java | 4 +++- src/com/android/dialer/calllog/ContactInfo.java | 5 +++++ src/com/android/dialer/calllog/ContactInfoHelper.java | 5 +++-- .../dialer/interactions/UndemoteOutgoingCallReceiver.java | 2 ++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 8bfe0dec5..914520e84 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -1169,6 +1169,10 @@ public class CallLogAdapter extends GroupingListAdapter values.put(Calls.CACHED_PHOTO_ID, updatedInfo.photoId); needsUpdate = true; } + if (!UriUtils.areEqual(updatedInfo.photoUri, callLogInfo.photoUri)) { + values.put(Calls.CACHED_PHOTO_URI, UriUtils.uriToString(updatedInfo.photoUri)); + needsUpdate = true; + } if (!TextUtils.equals(updatedInfo.formattedNumber, callLogInfo.formattedNumber)) { values.put(Calls.CACHED_FORMATTED_NUMBER, updatedInfo.formattedNumber); needsUpdate = true; @@ -1182,6 +1186,7 @@ public class CallLogAdapter extends GroupingListAdapter values.put(Calls.CACHED_MATCHED_NUMBER, updatedInfo.number); values.put(Calls.CACHED_NORMALIZED_NUMBER, updatedInfo.normalizedNumber); values.put(Calls.CACHED_PHOTO_ID, updatedInfo.photoId); + values.put(Calls.CACHED_PHOTO_URI, UriUtils.uriToString(updatedInfo.photoUri)); values.put(Calls.CACHED_FORMATTED_NUMBER, updatedInfo.formattedNumber); needsUpdate = true; } @@ -1214,7 +1219,7 @@ public class CallLogAdapter extends GroupingListAdapter info.number = matchedNumber == null ? c.getString(CallLogQuery.NUMBER) : matchedNumber; info.normalizedNumber = c.getString(CallLogQuery.CACHED_NORMALIZED_NUMBER); info.photoId = c.getLong(CallLogQuery.CACHED_PHOTO_ID); - info.photoUri = null; // We do not cache the photo URI. + info.photoUri = UriUtils.parseUriOrNull(c.getString(CallLogQuery.CACHED_PHOTO_URI)); info.formattedNumber = c.getString(CallLogQuery.CACHED_FORMATTED_NUMBER); return info; } @@ -1352,7 +1357,7 @@ public class CallLogAdapter extends GroupingListAdapter } else { try { Cursor phonesCursor = mContext.getContentResolver().query( - Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, number), + Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, number), PhoneQuery._PROJECTION, null, null, null); if (phonesCursor != null) { try { diff --git a/src/com/android/dialer/calllog/CallLogQuery.java b/src/com/android/dialer/calllog/CallLogQuery.java index 0ae4cda33..2b43c2857 100644 --- a/src/com/android/dialer/calllog/CallLogQuery.java +++ b/src/com/android/dialer/calllog/CallLogQuery.java @@ -45,7 +45,8 @@ public final class CallLogQuery { Calls.PHONE_ACCOUNT_ID, // 19 Calls.FEATURES, // 20 Calls.DATA_USAGE, // 21 - Calls.TRANSCRIPTION // 22 + Calls.TRANSCRIPTION, // 22 + Calls.CACHED_PHOTO_URI // 23 }; public static final int ID = 0; @@ -71,4 +72,5 @@ public final class CallLogQuery { public static final int FEATURES = 20; public static final int DATA_USAGE = 21; public static final int TRANSCRIPTION = 22; + public static final int CACHED_PHOTO_URI = 23; } diff --git a/src/com/android/dialer/calllog/ContactInfo.java b/src/com/android/dialer/calllog/ContactInfo.java index 7b6014dd1..effe14270 100644 --- a/src/com/android/dialer/calllog/ContactInfo.java +++ b/src/com/android/dialer/calllog/ContactInfo.java @@ -27,6 +27,11 @@ import com.google.common.base.Objects; */ public class ContactInfo { public Uri lookupUri; + + /** + * Contact lookup key. Note this may be a lookup key for a corp contact, in which case + * "lookup by lookup key" doesn't work on the personal profile. + */ public String lookupKey; public String name; public int type; diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java index 3a1144f25..da03b072f 100644 --- a/src/com/android/dialer/calllog/ContactInfoHelper.java +++ b/src/com/android/dialer/calllog/ContactInfoHelper.java @@ -205,7 +205,7 @@ public class ContactInfoHelper { final ContactInfo info; // "contactNumber" is a SIP address, so use the PhoneLookup table with the SIP parameter. - Uri.Builder uriBuilder = PhoneLookup.CONTENT_FILTER_URI.buildUpon(); + Uri.Builder uriBuilder = PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI.buildUpon(); uriBuilder.appendPath(Uri.encode(sipAddress)); uriBuilder.appendQueryParameter(PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, "1"); return lookupContactFromUri(uriBuilder.build()); @@ -236,7 +236,8 @@ public class ContactInfoHelper { } // The "contactNumber" is a regular phone number, so use the PhoneLookup table. - Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(contactNumber)); + Uri uri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, + Uri.encode(contactNumber)); ContactInfo info = lookupContactFromUri(uri); if (info != null && info != ContactInfo.EMPTY) { info.formattedNumber = formatPhoneNumber(number, null, countryIso); diff --git a/src/com/android/dialer/interactions/UndemoteOutgoingCallReceiver.java b/src/com/android/dialer/interactions/UndemoteOutgoingCallReceiver.java index 6d74cd0f7..960a31bc3 100644 --- a/src/com/android/dialer/interactions/UndemoteOutgoingCallReceiver.java +++ b/src/com/android/dialer/interactions/UndemoteOutgoingCallReceiver.java @@ -30,6 +30,8 @@ import android.text.TextUtils; /** * This broadcast receiver is used to listen to outgoing calls and undemote formerly demoted * contacts if a phone call is made to a phone number belonging to that contact. + * + * NOTE This doesn't work for corp contacts. */ public class UndemoteOutgoingCallReceiver extends BroadcastReceiver { -- cgit v1.2.3