From 76855c20de037a38b02716642cd27be674772f2d Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Tue, 8 Jul 2014 17:56:03 -0700 Subject: Use enterprise caller-id in incall. - Use PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI for caller-id. - Removed a bunch of unused code. - Renamed fields that will have different semantics. e.g. contactId now will be 0 and lookupUri null for corp contacts. - Simplify the sip caller-id lookup. The regular caller-id lookup can also do SIP. The original code (http://ag/70555) was written before CP2 supported it (http://ag/147367). This needs QAing. - Instead of passing around a contact-id to later load a contact picture, use the picture URI returned from the API. Bug 15779911 Change-Id: Ia755b9079d03d9236f824c2f1102a6fa902b2097 --- .../src/com/android/incallui/ContactInfoCache.java | 39 +++++++++------------- 1 file changed, 16 insertions(+), 23 deletions(-) (limited to 'InCallUI/src/com/android/incallui/ContactInfoCache.java') diff --git a/InCallUI/src/com/android/incallui/ContactInfoCache.java b/InCallUI/src/com/android/incallui/ContactInfoCache.java index 7015d2bd3..22ca88e4e 100644 --- a/InCallUI/src/com/android/incallui/ContactInfoCache.java +++ b/InCallUI/src/com/android/incallui/ContactInfoCache.java @@ -16,7 +16,6 @@ package com.android.incallui; -import android.content.ContentUris; import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; @@ -32,14 +31,12 @@ import com.android.contacts.common.util.PhoneNumberHelper; import com.android.incallui.service.PhoneNumberService; import com.android.incalluibind.ServiceFactory; import com.android.services.telephony.common.MoreStrings; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.common.base.Objects; import com.google.common.base.Preconditions; import java.util.HashMap; -import java.util.List; import java.util.Set; /** @@ -173,12 +170,12 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete final PhoneNumberServiceListener listener = new PhoneNumberServiceListener(callId); mPhoneNumberService.getPhoneNumberInfo(cacheEntry.number, listener, listener, isIncoming); - } else if (cacheEntry.personUri != null) { + } else if (cacheEntry.displayPhotoUri != null) { Log.d(TAG, "Contact lookup. Local contact found, starting image load"); // Load the image with a callback to update the image state. // When the load is finished, onImageLoadComplete() will be called. ContactsAsyncHelper.startObtainPhotoAsync(TOKEN_UPDATE_PHOTO_FOR_CALL_STATE, - mContext, cacheEntry.personUri, ContactInfoCache.this, callId); + mContext, cacheEntry.displayPhotoUri, ContactInfoCache.this, callId); } else { if (callerInfo.contactExists) { Log.d(TAG, "Contact lookup done. Local contact found, no image."); @@ -317,26 +314,17 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete } else { photo = context.getResources().getDrawable(R.drawable.picture_unknown); } - } else if (info.person_id == 0) { + } else if (info.contactDisplayPhotoUri == null) { photo = context.getResources().getDrawable(R.drawable.picture_unknown); } else { - Uri personUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, info.person_id); - Log.d(TAG, "- got personUri: '" + personUri + "', based on info.person_id: " + - info.person_id); - - if (personUri == null) { - Log.v(TAG, "personUri is null. Just use unknown picture."); - photo = context.getResources().getDrawable(R.drawable.picture_unknown); - } else { - cce.personUri = personUri; - } + cce.displayPhotoUri = info.contactDisplayPhotoUri; + } - if (info.lookupKey == null) { - Log.v(TAG, "lookup key is null. Don't create a lookup uri."); - cce.lookupUri = null; - } else { - cce.lookupUri = Contacts.getLookupUri(info.person_id, info.lookupKey); - } + if (info.lookupKeyOrNull == null || info.contactIdOrZero == 0) { + Log.v(TAG, "lookup key is null or contact ID is 0. Don't create a lookup uri."); + cce.lookupUri = null; + } else { + cce.lookupUri = Contacts.getLookupUri(info.contactIdOrZero, info.lookupKeyOrNull); } cce.photo = photo; @@ -511,7 +499,10 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete public String label; public Drawable photo; public boolean isSipCall; - public Uri personUri; // Used for local photo load + /** This will be used for the "view" notification. */ + public Uri contactUri; + /** Either a display photo or a thumbnail URI. */ + public Uri displayPhotoUri; public Uri lookupUri; // Sent to NotificationMananger @Override @@ -523,6 +514,8 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete .add("label", label) .add("photo", photo) .add("isSipCall", isSipCall) + .add("contactUri", contactUri) + .add("displayPhotoUri", displayPhotoUri) .toString(); } } -- cgit v1.2.3