[Settings] Make scribe setting default_on and secure

1. Migrate scribe pref to Settings.Secure
2. Consider enabled when not set.

Bug: 272376168
Test: atest StylusDevicesControllerTest StylusHandwritingPreferenceControllerTest.java


Change-Id: I4973a93c2cfe8c44f461b68fbda1a853e49340a2
This commit is contained in:
Taran Singh
2023-03-01 20:02:03 +00:00
parent 0f90688ede
commit 1ec8dff6d6
4 changed files with 35 additions and 43 deletions

View File

@@ -63,8 +63,8 @@ public class StylusHandwritingPreferenceControllerTest {
public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOn() {
mController.onPreferenceChange(mPreference, true /* new value */);
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
assertThat(mode).isEqualTo(SETTING_VALUE_ON);
}
@@ -73,16 +73,16 @@ public class StylusHandwritingPreferenceControllerTest {
public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOff() {
mController.onPreferenceChange(mPreference, false /* new value */);
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
}
@Test
public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
mController.updateState(mPreference);
verify(mPreference).setChecked(false);
@@ -90,22 +90,11 @@ public class StylusHandwritingPreferenceControllerTest {
@Test
public void updateState_settingEnabled_preferenceShouldBeChecked() {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_ON);
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_ON);
mController.updateState(mPreference);
verify(mPreference).setChecked(true);
}
@Test
public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
mController.onDeveloperOptionsSwitchDisabled();
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
verify(mPreference).setChecked(false);
verify(mPreference).setEnabled(false);
}
}