diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-08-31 16:17:04 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-08-31 16:17:04 +0000 |
commit | c39ea3c55fac807c0b98aabdf56c70dc8a49036c (patch) | |
tree | e282668a9587cf6c1ec7b604dea860400c75c6c7 /java/com/android/incallui/answer/impl/hint/AnswerHintFactory.java | |
parent | 68038172793ee0e2ab3e2e56ddfbeb82879d1f58 (diff) | |
parent | 2ca4318cc1ee57dda907ba2069bd61d162b1baef (diff) |
Merge "Update Dialer source to latest internal Google revision."
Diffstat (limited to 'java/com/android/incallui/answer/impl/hint/AnswerHintFactory.java')
-rw-r--r-- | java/com/android/incallui/answer/impl/hint/AnswerHintFactory.java | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/java/com/android/incallui/answer/impl/hint/AnswerHintFactory.java b/java/com/android/incallui/answer/impl/hint/AnswerHintFactory.java index 77b45ec71..94cf893f0 100644 --- a/java/com/android/incallui/answer/impl/hint/AnswerHintFactory.java +++ b/java/com/android/incallui/answer/impl/hint/AnswerHintFactory.java @@ -23,9 +23,8 @@ import android.os.Build; import android.support.annotation.NonNull; import android.support.annotation.VisibleForTesting; import com.android.dialer.common.Assert; -import com.android.dialer.common.ConfigProvider; -import com.android.dialer.common.ConfigProviderBindings; import com.android.dialer.common.LogUtil; +import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.util.DialerUtils; import com.android.incallui.util.AccessibilityUtil; @@ -35,8 +34,9 @@ import com.android.incallui.util.AccessibilityUtil; */ public class AnswerHintFactory { - private static final String CONFIG_ANSWER_HINT_ANSWERED_THRESHOLD_KEY = - "answer_hint_answered_threshold"; + @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) + static final String CONFIG_ANSWER_HINT_ANSWERED_THRESHOLD_KEY = "answer_hint_answered_threshold"; + @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) static final String CONFIG_ANSWER_HINT_WHITELISTED_DEVICES_KEY = "answer_hint_whitelisted_devices"; @@ -58,12 +58,7 @@ public class AnswerHintFactory { @NonNull public AnswerHint create(Context context, long puckUpDuration, long puckUpDelay) { - - if (shouldShowAnswerHint( - context, - ConfigProviderBindings.get(context), - DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(context), - Build.PRODUCT)) { + if (shouldShowAnswerHint(context, Build.PRODUCT)) { return new DotAnswerHint(context, puckUpDuration, puckUpDelay); } @@ -84,24 +79,23 @@ public class AnswerHintFactory { } @VisibleForTesting - static boolean shouldShowAnswerHint( - Context context, - ConfigProvider configProvider, - SharedPreferences sharedPreferences, - String device) { + static boolean shouldShowAnswerHint(Context context, String device) { if (AccessibilityUtil.isTouchExplorationEnabled(context)) { return false; } // Devices that has the legacy dialer installed are whitelisted as they are likely to go through // a UX change during updates. - if (!isDeviceWhitelisted(device, configProvider)) { + if (!isDeviceWhitelisted(context, device)) { return false; } // If the user has gone through the process a few times we can assume they have learnt the // method. - int answeredCount = sharedPreferences.getInt(ANSWERED_COUNT_PREFERENCE_KEY, 0); - long threshold = configProvider.getLong(CONFIG_ANSWER_HINT_ANSWERED_THRESHOLD_KEY, 3); + int answeredCount = + DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(context) + .getInt(ANSWERED_COUNT_PREFERENCE_KEY, 0); + long threshold = + ConfigProviderBindings.get(context).getLong(CONFIG_ANSWER_HINT_ANSWERED_THRESHOLD_KEY, 3); LogUtil.i( "AnswerHintFactory.shouldShowAnswerHint", "answerCount: %d, threshold: %d", @@ -115,8 +109,8 @@ public class AnswerHintFactory { * @param configProvider should provide a list of devices quoted with '/' concatenated to a * string. */ - private static boolean isDeviceWhitelisted(String device, ConfigProvider configProvider) { - return configProvider + private static boolean isDeviceWhitelisted(Context context, String device) { + return ConfigProviderBindings.get(context) .getString(CONFIG_ANSWER_HINT_WHITELISTED_DEVICES_KEY, DEFAULT_WHITELISTED_DEVICES_CSV) .contains("/" + device + "/"); } |