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