From 04a75fb9a7db522281732414b9059e7d66e35b12 Mon Sep 17 00:00:00 2001 From: Alex Mang Date: Wed, 29 Jul 2020 17:49:34 -0700 Subject: [PATCH] Updating feedback setting to be global Test: atest AssistantFeedbackPreferenceControllerTest Change-Id: I9dc79a8418a00db319f7f289b20724d00bd50b9e --- .../AssistantFeedbackPreferenceController.java | 8 ++++---- ...istantFeedbackPreferenceControllerTest.java | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/com/android/settings/notification/AssistantFeedbackPreferenceController.java b/src/com/android/settings/notification/AssistantFeedbackPreferenceController.java index 66a9caa0222..1566ae913f4 100644 --- a/src/com/android/settings/notification/AssistantFeedbackPreferenceController.java +++ b/src/com/android/settings/notification/AssistantFeedbackPreferenceController.java @@ -16,7 +16,7 @@ package com.android.settings.notification; -import static android.provider.Settings.Secure.NOTIFICATION_FEEDBACK_ENABLED; +import static android.provider.Settings.Global.NOTIFICATION_FEEDBACK_ENABLED; import android.content.ContentResolver; import android.content.Context; @@ -82,20 +82,20 @@ public class AssistantFeedbackPreferenceController extends TogglePreferenceContr @Override public boolean isChecked() { - return Settings.Secure.getInt(mContext.getContentResolver(), + return Settings.Global.getInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, OFF) == ON; } @Override public boolean setChecked(boolean isChecked) { - return Settings.Secure.putInt(mContext.getContentResolver(), + return Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, isChecked ? ON : OFF); } class SettingObserver extends ContentObserver { private final Uri NOTIFICATION_URI = - Settings.Secure.getUriFor(NOTIFICATION_FEEDBACK_ENABLED); + Settings.Global.getUriFor(NOTIFICATION_FEEDBACK_ENABLED); private final Preference mPreference; diff --git a/tests/robotests/src/com/android/settings/notification/AssistantFeedbackPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/AssistantFeedbackPreferenceControllerTest.java index 135c364fb5f..8cfb0e0d111 100644 --- a/tests/robotests/src/com/android/settings/notification/AssistantFeedbackPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/AssistantFeedbackPreferenceControllerTest.java @@ -16,7 +16,7 @@ package com.android.settings.notification; -import static android.provider.Settings.Secure.NOTIFICATION_FEEDBACK_ENABLED; +import static android.provider.Settings.Global.NOTIFICATION_FEEDBACK_ENABLED; import static com.android.settings.notification.AssistantFeedbackPreferenceController.OFF; import static com.android.settings.notification.AssistantFeedbackPreferenceController.ON; @@ -76,7 +76,7 @@ public class AssistantFeedbackPreferenceControllerTest { public void updateState_preferenceSetCheckedWhenSettingIsOn() { final TwoStatePreference preference = mock(TwoStatePreference.class); final Context context = RuntimeEnvironment.application; - Settings.Secure.putInt(context.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, ON); + Settings.Global.putInt(context.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, ON); mController = new AssistantFeedbackPreferenceController(context, KEY); mController.updateState(preference); @@ -88,7 +88,7 @@ public class AssistantFeedbackPreferenceControllerTest { public void updateState_preferenceSetUncheckedWhenSettingIsOff() { final TwoStatePreference preference = mock(TwoStatePreference.class); final Context context = RuntimeEnvironment.application; - Settings.Secure.putInt(context.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, OFF); + Settings.Global.putInt(context.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, OFF); mController = new AssistantFeedbackPreferenceController(context, KEY); mController.updateState(preference); @@ -98,24 +98,24 @@ public class AssistantFeedbackPreferenceControllerTest { @Test public void isChecked_settingIsOff_shouldReturnFalse() { - Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, OFF); + Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, OFF); assertThat(mController.isChecked()).isFalse(); } @Test public void isChecked_settingIsOn_shouldReturnTrue() { - Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, ON); + Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, ON); assertThat(mController.isChecked()).isTrue(); } @Test public void setChecked_setFalse_disablesSetting() { - Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, ON); + Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, ON); mController.setChecked(false); - int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(), + int updatedValue = Settings.Global.getInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, -1); assertThat(updatedValue).isEqualTo(OFF); @@ -123,10 +123,10 @@ public class AssistantFeedbackPreferenceControllerTest { @Test public void setChecked_setTrue_enablesSetting() { - Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, OFF); + Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, OFF); mController.setChecked(true); - int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(), + int updatedValue = Settings.Global.getInt(mContext.getContentResolver(), NOTIFICATION_FEEDBACK_ENABLED, -1); assertThat(updatedValue).isEqualTo(ON);