Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2dccd842 authored by Yuhan Yang's avatar Yuhan Yang
Browse files

Plumb mouse keys max speed settings

Bug: 393565528
Test: manual verified on test Device
Flag: com.android.server.accessibility.enable_mouse_key_enhancement
Change-Id: Ib6635376b82a3f9877157f2f1b19f72a75514d3c
parent 9a04fbfe
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
@@ -107,6 +107,13 @@ public class InputSettings {
     */
    public static final float DEFAULT_MOUSE_KEYS_ACCELERATION = .2f;

    /**
     * The default max speed as a factor of the minimum speed for mouse keys movement.
     *
     * @hide
     */
    public static final int DEFAULT_MOUSE_KEYS_MAX_SPEED = 5;

    /**
     * The maximum allowed obscuring opacity by UID to propagate touches (0 <= x <= 1).
     * @hide
@@ -1140,6 +1147,51 @@ public class InputSettings {
    }


    /**
     * Get Accessibility mouse keys max speed.
     *
     *  <p>
     * ‘Mouse keys’ is an accessibility feature to aid users who have physical disabilities,
     * that allows the user to use the keys on the keyboard to control the mouse pointer and
     * other perform other mouse functionality.
     * </p>
     *
     * @hide
     */
    @FlaggedApi(FLAG_KEYBOARD_A11Y_MOUSE_KEYS)
    public static int getAccessibilityMouseKeysMaxSpeed(@NonNull Context context) {
        if (!isAccessibilityMouseKeysFeatureFlagEnabled()) {
            return 0;
        }
        return Settings.Secure.getIntForUser(context.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_MAX_SPEED,
                DEFAULT_MOUSE_KEYS_MAX_SPEED,
                UserHandle.USER_CURRENT);
    }

    /**
     * Set Accessibility mouse keys max speed.
     *
     *  <p>
     * ‘Mouse keys’ is an accessibility feature to aid users who have physical disabilities,
     * that allows the user to use the keys on the keyboard to control the mouse pointer and
     * other perform other mouse functionality.
     * </p>
     *
     * @hide
     */
    @FlaggedApi(FLAG_KEYBOARD_A11Y_MOUSE_KEYS)
    @RequiresPermission(Manifest.permission.WRITE_SETTINGS)
    public static void setAccessibilityMouseKeysMaxSpeed(@NonNull Context context,
            int maxSpeed) {
        if (!isAccessibilityMouseKeysFeatureFlagEnabled()) {
            return;
        }
        Settings.Secure.putIntForUser(context.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_MAX_SPEED,
                maxSpeed, UserHandle.USER_CURRENT);
    }

    /**
     * Whether "Repeat keys" feature flag is enabled.
     *
+8 −0
Original line number Diff line number Diff line
@@ -12968,6 +12968,14 @@ public final class Settings {
        public static final String ACCESSIBILITY_MOUSE_KEYS_ACCELERATION =
                "accessibility_mouse_keys_acceleration";
        /**
         * The max speed as a factor of the minimum speed for mouse keys movement.
         *
         * @hide
         */
        public static final String ACCESSIBILITY_MOUSE_KEYS_MAX_SPEED =
                "accessibility_mouse_keys_max_speed";
        /**
         * Whether the Adaptive connectivity option is enabled.
         *
+1 −0
Original line number Diff line number Diff line
@@ -241,6 +241,7 @@ public class SecureSettings {
        Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MAGNIFY_NAV_AND_IME,
        Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_ENABLED,
        Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_ACCELERATION,
        Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_MAX_SPEED,
        Settings.Secure.ACCESSIBILITY_PINCH_TO_ZOOM_ANYWHERE_ENABLED,
        Settings.Secure.ACCESSIBILITY_SINGLE_FINGER_PANNING_ENABLED,
        Settings.Secure.ODI_CAPTIONS_VOLUME_UI_ENABLED,
+2 −0
Original line number Diff line number Diff line
@@ -469,6 +469,8 @@ public class SecureSettingsValidators {
        VALIDATORS.put(Secure.ACCESSIBILITY_MOUSE_KEYS_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.ACCESSIBILITY_MOUSE_KEYS_ACCELERATION,
                new InclusiveIntegerRangeValidator(0, 10));
        VALIDATORS.put(Secure.ACCESSIBILITY_MOUSE_KEYS_MAX_SPEED,
                new InclusiveIntegerRangeValidator(1, 10));
        VALIDATORS.put(Secure.MANDATORY_BIOMETRICS, new InclusiveIntegerRangeValidator(0, 1));
        VALIDATORS.put(Secure.MANDATORY_BIOMETRICS_REQUIREMENTS_SATISFIED,
                new InclusiveIntegerRangeValidator(0, 1));