diff options
Diffstat (limited to 'java/com/android/incallui/answer/impl/hint')
-rw-r--r-- | java/com/android/incallui/answer/impl/hint/AnswerHintFactory.java | 15 | ||||
-rw-r--r-- | java/com/android/incallui/answer/impl/hint/PawImageLoaderImpl.java | 5 |
2 files changed, 7 insertions, 13 deletions
diff --git a/java/com/android/incallui/answer/impl/hint/AnswerHintFactory.java b/java/com/android/incallui/answer/impl/hint/AnswerHintFactory.java index eaf5b74e5..77b45ec71 100644 --- a/java/com/android/incallui/answer/impl/hint/AnswerHintFactory.java +++ b/java/com/android/incallui/answer/impl/hint/AnswerHintFactory.java @@ -20,13 +20,13 @@ import android.content.Context; import android.content.SharedPreferences; import android.graphics.drawable.Drawable; import android.os.Build; -import android.preference.PreferenceManager; 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.util.DialerUtils; import com.android.incallui.util.AccessibilityUtil; /** @@ -62,7 +62,7 @@ public class AnswerHintFactory { if (shouldShowAnswerHint( context, ConfigProviderBindings.get(context), - getDeviceProtectedPreferences(context), + DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(context), Build.PRODUCT)) { return new DotAnswerHint(context, puckUpDuration, puckUpDelay); } @@ -77,7 +77,8 @@ public class AnswerHintFactory { } public static void increaseAnsweredCount(Context context) { - SharedPreferences sharedPreferences = getDeviceProtectedPreferences(context); + SharedPreferences sharedPreferences = + DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(context); int answeredCount = sharedPreferences.getInt(ANSWERED_COUNT_PREFERENCE_KEY, 0); sharedPreferences.edit().putInt(ANSWERED_COUNT_PREFERENCE_KEY, answeredCount + 1).apply(); } @@ -119,12 +120,4 @@ public class AnswerHintFactory { .getString(CONFIG_ANSWER_HINT_WHITELISTED_DEVICES_KEY, DEFAULT_WHITELISTED_DEVICES_CSV) .contains("/" + device + "/"); } - - private static SharedPreferences getDeviceProtectedPreferences(Context context) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { - return PreferenceManager.getDefaultSharedPreferences(context); - } - return PreferenceManager.getDefaultSharedPreferences( - context.createDeviceProtectedStorageContext()); - } } diff --git a/java/com/android/incallui/answer/impl/hint/PawImageLoaderImpl.java b/java/com/android/incallui/answer/impl/hint/PawImageLoaderImpl.java index 485a9ae37..21154cade 100644 --- a/java/com/android/incallui/answer/impl/hint/PawImageLoaderImpl.java +++ b/java/com/android/incallui/answer/impl/hint/PawImageLoaderImpl.java @@ -21,10 +21,10 @@ import android.content.Context; import android.content.SharedPreferences; import android.graphics.drawable.Drawable; import android.os.Build.VERSION_CODES; -import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.android.dialer.common.Assert; +import com.android.dialer.util.DialerUtils; /** Decrypt the event payload to be shown if in a specific time range and the key is received. */ @TargetApi(VERSION_CODES.M) @@ -35,7 +35,8 @@ public final class PawImageLoaderImpl implements PawImageLoader { public Drawable loadPayload(@NonNull Context context) { Assert.isNotNull(context); - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); + SharedPreferences preferences = + DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(context); if (!preferences.getBoolean(PawSecretCodeListener.PAW_ENABLED_WITH_SECRET_CODE_KEY, false)) { return null; } |