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

Commit 189ddfff authored by Danny Wang's avatar Danny Wang
Browse files

Plumb mouse keys acceleration settings

Bug: 393566398
Test: manual verified on test Device
Flag: com.android.server.accessibility.enable_mouse_key_enhancement
Change-Id: Ic1e78f0f6bc5e8ab2609f603ae9120f02812bdb8
parent 39813386
Loading
Loading
Loading
Loading
+54 −0
Original line number Diff line number Diff line
@@ -100,6 +100,13 @@ public class InputSettings {
     */
    public static final int DEFAULT_SLOW_KEYS_THRESHOLD_MILLIS = 500;

    /**
     * The default acceleration value for mouse keys movement.
     *
     * @hide
     */
    public static final float DEFAULT_MOUSE_KEYS_ACCELERATION = .2f;

    /**
     * The maximum allowed obscuring opacity by UID to propagate touches (0 <= x <= 1).
     * @hide
@@ -1086,6 +1093,53 @@ public class InputSettings {
                UserHandle.USER_CURRENT);
    }


    /**
     * Get Accessibility mouse keys acceleration.
     *
     *  <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 float getAccessibilityMouseKeysAcceleration(@NonNull Context context) {
        if (!isAccessibilityMouseKeysFeatureFlagEnabled()) {
            return 0;
        }
        return Settings.Secure.getFloatForUser(context.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_ACCELERATION,
                DEFAULT_MOUSE_KEYS_ACCELERATION,
                UserHandle.USER_CURRENT);
    }

    /**
     * Set Accessibility mouse keys acceleration.
     *
     *  <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_SECURE_SETTINGS)
    public static void setAccessibilityMouseKeysAcceleration(@NonNull Context context,
            int acceleration) {
        if (!isAccessibilityMouseKeysFeatureFlagEnabled()) {
            return;
        }
        Settings.Secure.putFloatForUser(context.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_ACCELERATION,
                acceleration, UserHandle.USER_CURRENT);
    }


    /**
     * Whether "Repeat keys" feature flag is enabled.
     *
+8 −0
Original line number Diff line number Diff line
@@ -12866,6 +12866,14 @@ public final class Settings {
        public static final String ACCESSIBILITY_MOUSE_KEYS_ENABLED =
                "accessibility_mouse_keys_enabled";
        /**
         * The current acceleration for mouse keys movement.
         *
         * @hide
         */
        public static final String ACCESSIBILITY_MOUSE_KEYS_ACCELERATION =
                "accessibility_mouse_keys_acceleration";
        /**
         * Whether the Adaptive connectivity option is enabled.
         *
+1 −0
Original line number Diff line number Diff line
@@ -238,6 +238,7 @@ public class SecureSettings {
        Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
        Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MAGNIFY_NAV_AND_IME,
        Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_ENABLED,
        Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_ACCELERATION,
        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
@@ -463,6 +463,8 @@ public class SecureSettingsValidators {
        VALIDATORS.put(Secure.ON_DEVICE_INTELLIGENCE_UNBIND_TIMEOUT_MS, ANY_LONG_VALIDATOR);
        VALIDATORS.put(Secure.ON_DEVICE_INTELLIGENCE_IDLE_TIMEOUT_MS, NONE_NEGATIVE_LONG_VALIDATOR);
        VALIDATORS.put(Secure.ACCESSIBILITY_MOUSE_KEYS_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.ACCESSIBILITY_MOUSE_KEYS_ACCELERATION,
                new InclusiveIntegerRangeValidator(0, 10));
        VALIDATORS.put(Secure.MANDATORY_BIOMETRICS, new InclusiveIntegerRangeValidator(0, 1));
        VALIDATORS.put(Secure.MANDATORY_BIOMETRICS_REQUIREMENTS_SATISFIED,
                new InclusiveIntegerRangeValidator(0, 1));