diff options
author | Victor Chang <vichang@google.com> | 2016-02-11 23:12:31 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-02-11 23:12:31 +0000 |
commit | e694c7ba72954f007c9ec3f1efd5bafd9cc5e86f (patch) | |
tree | 1c9402ff08d13acf72a882fb6acefcdd4a9367ed /InCallUI | |
parent | faa3cf481db67c9f7c789c65d64116883444d1ce (diff) | |
parent | 49df92e2f4ab4e86cfcec9e58851755b26d10b50 (diff) |
Cache directory photo in app storage through CachedNumberLookupService
am: 49df92e2f4
* commit '49df92e2f4ab4e86cfcec9e58851755b26d10b50':
Cache directory photo in app storage through CachedNumberLookupService
Diffstat (limited to 'InCallUI')
-rw-r--r-- | InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java b/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java index 4714af492..bf5e1a311 100644 --- a/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java +++ b/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java @@ -41,6 +41,8 @@ import com.android.dialer.service.CachedNumberLookupService; import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo; import com.android.dialerbind.ObjectFactory; +import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Locale; @@ -520,11 +522,25 @@ public class CallerInfoAsyncQuery { private void addCallerInfoIntoCache(CallerInfo ci, long directoryId) { if (ci.contactExists && mCachedNumberLookupService != null) { + // 1. Cache caller info CachedContactInfo cachedContactInfo = CallerInfoUtils .buildCachedContactInfo(mCachedNumberLookupService, ci); String directoryLabel = mContext.getString(R.string.directory_search_label); cachedContactInfo.setDirectorySource(directoryLabel, directoryId); mCachedNumberLookupService.addContact(mContext, cachedContactInfo); + + // 2. Cache photo + if (ci.contactDisplayPhotoUri != null && ci.normalizedNumber != null) { + try (InputStream in = mContext.getContentResolver() + .openInputStream(ci.contactDisplayPhotoUri)) { + if (in != null) { + mCachedNumberLookupService.addPhoto(mContext, ci.normalizedNumber, in); + } + } catch (IOException e) { + Log.e(LOG_TAG, "failed to fetch directory contact photo", e); + } + + } } } |