Camera lift preference now saves correctly
Bug: 37751057 Test: manual + make RunSettingsRoboTests Fixed issue where camera lift preference was saving the opposite value of what it was supposed to. Added test to cover saving of value on preference change. Change-Id: I2d2c454eb478afb7f73519f9f05c9a9a1933938b
This commit is contained in:
@@ -57,7 +57,7 @@ public class CameraLiftTriggerPreferenceController extends GesturePreferenceCont
|
|||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
boolean enabled = (boolean) newValue;
|
boolean enabled = (boolean) newValue;
|
||||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.CAMERA_LIFT_TRIGGER_ENABLED, enabled ? 0 : 1);
|
Settings.Secure.CAMERA_LIFT_TRIGGER_ENABLED, enabled ? 1 : 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -100,4 +100,26 @@ public class CameraLiftTriggerPreferenceControllerTest {
|
|||||||
|
|
||||||
assertThat(mController.isSwitchPrefEnabled()).isTrue();
|
assertThat(mController.isSwitchPrefEnabled()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEnablePreference_shouldSetSetting() {
|
||||||
|
final Context context = RuntimeEnvironment.application;
|
||||||
|
mController = new CameraLiftTriggerPreferenceController(context, null,
|
||||||
|
KEY_CAMERA_LIFT_TRIGGER);
|
||||||
|
mController.onPreferenceChange(null, true);
|
||||||
|
|
||||||
|
assertThat(Settings.Secure.getInt(context.getContentResolver(),
|
||||||
|
CAMERA_LIFT_TRIGGER_ENABLED, 0)).isEqualTo(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDisablePreference_shouldClearSetting() {
|
||||||
|
final Context context = RuntimeEnvironment.application;
|
||||||
|
mController = new CameraLiftTriggerPreferenceController(context, null,
|
||||||
|
KEY_CAMERA_LIFT_TRIGGER);
|
||||||
|
mController.onPreferenceChange(null, false);
|
||||||
|
|
||||||
|
assertThat(Settings.Secure.getInt(context.getContentResolver(),
|
||||||
|
CAMERA_LIFT_TRIGGER_ENABLED, 1)).isEqualTo(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user