From 7584bbc015539baeb6901e3c081b02eb3526ce97 Mon Sep 17 00:00:00 2001 From: Vania Januar Date: Thu, 2 Feb 2023 12:13:39 +0000 Subject: [PATCH] Invert STYLUS_BUTTONS_DISABLED to avoid double negatives. Test: StylusDevicesControllerTest Bug: 267595764 Change-Id: I9f74aaf064eb08d4abb6800d59ee3c224f9793b8 --- .../connecteddevice/stylus/StylusDevicesController.java | 6 +++--- .../stylus/StylusDevicesControllerTest.java | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java b/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java index a7e94e91ff1..ac895df60ac 100644 --- a/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java +++ b/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java @@ -140,7 +140,7 @@ public class StylusDevicesController extends AbstractPreferenceController implem pref.setIcon(R.drawable.ic_block); pref.setOnPreferenceClickListener(this); pref.setChecked(Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.STYLUS_BUTTONS_DISABLED, 0) == 1); + Settings.Secure.STYLUS_BUTTONS_ENABLED, 1) == 0); return pref; } @@ -175,8 +175,8 @@ public class StylusDevicesController extends AbstractPreferenceController implem break; case KEY_IGNORE_BUTTON: Settings.Secure.putInt(mContext.getContentResolver(), - Secure.STYLUS_BUTTONS_DISABLED, - ((SwitchPreference) preference).isChecked() ? 1 : 0); + Secure.STYLUS_BUTTONS_ENABLED, + ((SwitchPreference) preference).isChecked() ? 0 : 1); break; } return true; diff --git a/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java index cd6b4bd1260..56a83733ca4 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java @@ -364,7 +364,7 @@ public class StylusDevicesControllerTest { @Test public void buttonsPreference_checkedWhenFlagTrue() { Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.STYLUS_BUTTONS_DISABLED, 1); + Settings.Secure.STYLUS_BUTTONS_ENABLED, 0); showScreen(mController); SwitchPreference buttonsPref = (SwitchPreference) mPreferenceContainer.getPreference(2); @@ -375,7 +375,7 @@ public class StylusDevicesControllerTest { @Test public void buttonsPreference_uncheckedWhenFlagFalse() { Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.STYLUS_BUTTONS_DISABLED, 0); + Settings.Secure.STYLUS_BUTTONS_ENABLED, 1); showScreen(mController); SwitchPreference buttonsPref = (SwitchPreference) mPreferenceContainer.getPreference(2); @@ -386,7 +386,7 @@ public class StylusDevicesControllerTest { @Test public void buttonsPreference_updatesFlagOnClick() { Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.STYLUS_BUTTONS_DISABLED, 1); + Settings.Secure.STYLUS_BUTTONS_ENABLED, 0); showScreen(mController); SwitchPreference buttonsPref = (SwitchPreference) mPreferenceContainer.getPreference(2); @@ -394,7 +394,7 @@ public class StylusDevicesControllerTest { assertThat(buttonsPref.isChecked()).isEqualTo(false); assertThat(Settings.Secure.getInt(mContext.getContentResolver(), - Secure.STYLUS_BUTTONS_DISABLED, -1)).isEqualTo(0); + Secure.STYLUS_BUTTONS_ENABLED, -1)).isEqualTo(0); } private void showScreen(StylusDevicesController controller) {