InputSettings: fix touchpad tap-to-click default

This was inconsistent with the default in
InputSettingsObserver#updateTouchpadTapToClickEnabled, leading to the
settings UI showing the setting being off on a fresh install, when
actually it was on.

Since the source of this bug was having the default in two different
places that could be inconsistent, also refactor InputSettingsObserver
to use the InputSettings methods where applicable.

Bug: 283135635
Test: wipe the device, check Settings > System > Touchpad > Tap to click
      toggle is shown as on
Change-Id: I8418c35c674a04e6849bd05de9e3f37a793e3aa9
This commit is contained in:
Harry Cutts
2023-05-24 12:00:22 +00:00
parent 961b2c2924
commit 85dd8de763
2 changed files with 10 additions and 11 deletions

View File

@@ -266,7 +266,7 @@ public class InputSettings {
*/
public static boolean useTouchpadTapToClick(@NonNull Context context) {
return Settings.System.getIntForUser(context.getContentResolver(),
Settings.System.TOUCHPAD_TAP_TO_CLICK, 0, UserHandle.USER_CURRENT) == 1;
Settings.System.TOUCHPAD_TAP_TO_CLICK, 1, UserHandle.USER_CURRENT) == 1;
}
/**

View File

@@ -115,35 +115,34 @@ class InputSettingsObserver extends ContentObserver {
return setting != 0;
}
private int getPointerSpeedValue(String settingName) {
int speed = Settings.System.getIntForUser(mContext.getContentResolver(),
settingName, InputSettings.DEFAULT_POINTER_SPEED, UserHandle.USER_CURRENT);
private int constrainPointerSpeedValue(int speed) {
return Math.min(Math.max(speed, InputSettings.MIN_POINTER_SPEED),
InputSettings.MAX_POINTER_SPEED);
}
private void updateMousePointerSpeed() {
mNative.setPointerSpeed(getPointerSpeedValue(Settings.System.POINTER_SPEED));
int speed = Settings.System.getIntForUser(mContext.getContentResolver(),
Settings.System.POINTER_SPEED, InputSettings.DEFAULT_POINTER_SPEED,
UserHandle.USER_CURRENT);
mNative.setPointerSpeed(constrainPointerSpeedValue(speed));
}
private void updateTouchpadPointerSpeed() {
mNative.setTouchpadPointerSpeed(
getPointerSpeedValue(Settings.System.TOUCHPAD_POINTER_SPEED));
constrainPointerSpeedValue(InputSettings.getTouchpadPointerSpeed(mContext)));
}
private void updateTouchpadNaturalScrollingEnabled() {
mNative.setTouchpadNaturalScrollingEnabled(
getBoolean(Settings.System.TOUCHPAD_NATURAL_SCROLLING, true));
InputSettings.useTouchpadNaturalScrolling(mContext));
}
private void updateTouchpadTapToClickEnabled() {
mNative.setTouchpadTapToClickEnabled(
getBoolean(Settings.System.TOUCHPAD_TAP_TO_CLICK, true));
mNative.setTouchpadTapToClickEnabled(InputSettings.useTouchpadTapToClick(mContext));
}
private void updateTouchpadRightClickZoneEnabled() {
mNative.setTouchpadRightClickZoneEnabled(
getBoolean(Settings.System.TOUCHPAD_RIGHT_CLICK_ZONE, false));
mNative.setTouchpadRightClickZoneEnabled(InputSettings.useTouchpadRightClickZone(mContext));
}
private void updateShowTouches() {