diff options
author | Victor Chang <vichang@google.com> | 2016-02-11 11:34:08 +0000 |
---|---|---|
committer | Victor Chang <vichang@google.com> | 2016-02-11 11:37:10 +0000 |
commit | 5aa626cfe520ad9c38c8e38d78d6140b60cbc26b (patch) | |
tree | ade0b45b8ae835b1a6cb3bcc220e9ec4c477ead1 /InCallUI | |
parent | 08c6b1521eb4d4cda4066dd72d2f8b7ea1b864b8 (diff) |
Cache directory photo in app storage through CachedNumberLookupService
[cherry-pick from ag/861979]
Photo of directory contact in call log should not require internet access.
It's now cached locally.
BUG=26111304
Change-Id: I9848e6fe9487c09899fd77f21804bcb4537799a8
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); + } + + } } } |