summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/app/calllog/calllogcache
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-07-27 10:45:54 -0700
committerEric Erfanian <erfanian@google.com>2017-07-27 11:16:14 -0700
commitff2ad7ffdba7c74077eae3016b32174f0f2dad30 (patch)
tree978e817617700854b5e2ed6f166f883c3bf6ffe9 /java/com/android/dialer/app/calllog/calllogcache
parent0602dd0831eb782890f74861b20075c76f503571 (diff)
Update oc-dr1-dev to v11 RC17
This change updates the oc-dr1-dev branch to v11 RC17, from the previous state synced @160679286. This contains: - A ROLLUP from 161342943 - Fixes for the following bugs: Bug: 33490149 36608790 37846172 62294499 62338925 63013427 63089358 63104326 63112642 63143138 63161630 63405063 63415147 63450835 63494010 63522618 63523694 63523776 63524435 63575857 63594129 63634700 63642638 63643370 63709810 63710739 63716219 63757003 64009408 64025042 64060628 64073371 Test: make Merged-In: I69ba6cbadbd1a02f05405ca0f5273b0a5ea0e5e9 Change-Id: Iaad73fa51796f62f4947571ddb744bbdadcca64e
Diffstat (limited to 'java/com/android/dialer/app/calllog/calllogcache')
-rw-r--r--java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java62
1 files changed, 50 insertions, 12 deletions
diff --git a/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java b/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java
index 2e7c9339a..15de14318 100644
--- a/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java
+++ b/java/com/android/dialer/app/calllog/calllogcache/CallLogCache.java
@@ -19,8 +19,14 @@ package com.android.dialer.app.calllog.calllogcache;
import android.content.Context;
import android.support.annotation.Nullable;
import android.telecom.PhoneAccountHandle;
+import android.text.TextUtils;
+import android.util.ArrayMap;
import com.android.dialer.app.calllog.CallLogAdapter;
+import com.android.dialer.calllogutils.PhoneAccountUtils;
+import com.android.dialer.telecom.TelecomUtil;
import com.android.dialer.util.CallUtil;
+import java.util.Map;
+import javax.annotation.concurrent.ThreadSafe;
/**
* This is the base class for the CallLogCaches.
@@ -31,7 +37,8 @@ import com.android.dialer.util.CallUtil;
*
* <p>This is designed with the specific use case of the {@link CallLogAdapter} in mind.
*/
-public abstract class CallLogCache {
+@ThreadSafe
+public class CallLogCache {
// TODO: Dialer should be fixed so as not to check isVoicemail() so often but at the time of
// this writing, that was a much larger undertaking than creating this cache.
@@ -39,17 +46,18 @@ public abstract class CallLogCache {
private boolean mHasCheckedForVideoAvailability;
private int mVideoAvailability;
+ private final Map<PhoneAccountHandle, String> mPhoneAccountLabelCache = new ArrayMap<>();
+ private final Map<PhoneAccountHandle, Integer> mPhoneAccountColorCache = new ArrayMap<>();
+ private final Map<PhoneAccountHandle, Boolean> mPhoneAccountCallWithNoteCache = new ArrayMap<>();
public CallLogCache(Context context) {
mContext = context;
}
- /** Return the most compatible version of the TelecomCallLogCache. */
- public static CallLogCache getCallLogCache(Context context) {
- return new CallLogCacheLollipopMr1(context);
- }
-
- public void reset() {
+ public synchronized void reset() {
+ mPhoneAccountLabelCache.clear();
+ mPhoneAccountColorCache.clear();
+ mPhoneAccountCallWithNoteCache.clear();
mHasCheckedForVideoAvailability = false;
mVideoAvailability = 0;
}
@@ -58,8 +66,13 @@ public abstract class CallLogCache {
* Returns true if the given number is the number of the configured voicemail. To be able to
* mock-out this, it is not a static method.
*/
- public abstract boolean isVoicemailNumber(
- PhoneAccountHandle accountHandle, @Nullable CharSequence number);
+ public synchronized boolean isVoicemailNumber(
+ PhoneAccountHandle accountHandle, @Nullable CharSequence number) {
+ if (TextUtils.isEmpty(number)) {
+ return false;
+ }
+ return TelecomUtil.isVoicemailNumber(mContext, accountHandle, number.toString());
+ }
/**
* Returns {@code true} when the current sim supports checking video calling capabilities via the
@@ -74,10 +87,26 @@ public abstract class CallLogCache {
}
/** Extract account label from PhoneAccount object. */
- public abstract String getAccountLabel(PhoneAccountHandle accountHandle);
+ public synchronized String getAccountLabel(PhoneAccountHandle accountHandle) {
+ if (mPhoneAccountLabelCache.containsKey(accountHandle)) {
+ return mPhoneAccountLabelCache.get(accountHandle);
+ } else {
+ String label = PhoneAccountUtils.getAccountLabel(mContext, accountHandle);
+ mPhoneAccountLabelCache.put(accountHandle, label);
+ return label;
+ }
+ }
/** Extract account color from PhoneAccount object. */
- public abstract int getAccountColor(PhoneAccountHandle accountHandle);
+ public synchronized int getAccountColor(PhoneAccountHandle accountHandle) {
+ if (mPhoneAccountColorCache.containsKey(accountHandle)) {
+ return mPhoneAccountColorCache.get(accountHandle);
+ } else {
+ Integer color = PhoneAccountUtils.getAccountColor(mContext, accountHandle);
+ mPhoneAccountColorCache.put(accountHandle, color);
+ return color;
+ }
+ }
/**
* Determines if the PhoneAccount supports specifying a call subject (i.e. calling with a note)
@@ -86,5 +115,14 @@ public abstract class CallLogCache {
* @param accountHandle The PhoneAccount handle.
* @return {@code true} if calling with a note is supported, {@code false} otherwise.
*/
- public abstract boolean doesAccountSupportCallSubject(PhoneAccountHandle accountHandle);
+ public synchronized boolean doesAccountSupportCallSubject(PhoneAccountHandle accountHandle) {
+ if (mPhoneAccountCallWithNoteCache.containsKey(accountHandle)) {
+ return mPhoneAccountCallWithNoteCache.get(accountHandle);
+ } else {
+ Boolean supportsCallWithNote =
+ PhoneAccountUtils.getAccountSupportsCallSubject(mContext, accountHandle);
+ mPhoneAccountCallWithNoteCache.put(accountHandle, supportsCallWithNote);
+ return supportsCallWithNote;
+ }
+ }
}