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

Commit 0cebf69d authored by Yuhan Yang's avatar Yuhan Yang
Browse files

Plumb mouse keys use_primary_keys setting

Bug: 418844181
Test: manual verified on test Device
Flag: com.android.server.accessibility.enable_mouse_key_enhancement
Change-Id: If4ef4f4256aeb10df610ac3263a28bb236ec713b
parent d0dba9b0
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
@@ -1192,6 +1192,53 @@ public class InputSettings {
                maxSpeed, UserHandle.USER_CURRENT);
    }

     /**
     * Returns true if the primary keys are selected to control the mouse key. Returns false if
     * numpad keys are the only way to control the mouse key.
     *
     * <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>
     * @param context The application context.
     * @return Whether user can use primary keys to control the Mouse Key.
     * @hide
     */
    @FlaggedApi(FLAG_KEYBOARD_A11Y_MOUSE_KEYS)
    public static boolean isPrimaryKeysForMouseKeysEnabled(@NonNull Context context) {
        if (!isAccessibilityMouseKeysFeatureFlagEnabled()) {
            return false;
        }

        return Settings.Secure.getIntForUser(context.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_USE_PRIMARY_KEYS,
                1, UserHandle.USER_CURRENT) != 0;
    }

    /**
     * Whether primary keys are selected to control the Mouse Key.
     *
     * <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 void setPrimaryKeysForMouseKeysEnabled(
            @NonNull Context context, boolean enabled) {
        if (!isAccessibilityMouseKeysFeatureFlagEnabled()) {
            return;
        }

        Settings.Secure.putIntForUser(context.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_USE_PRIMARY_KEYS,
                enabled ? 1 : 0, UserHandle.USER_CURRENT);
    }

    /**
     * Whether "Repeat keys" feature flag is enabled.
     *
+8 −0
Original line number Diff line number Diff line
@@ -13128,6 +13128,14 @@ public final class Settings {
        public static final String ACCESSIBILITY_MOUSE_KEYS_MAX_SPEED =
                "accessibility_mouse_keys_max_speed";
        /**
         * Whether the primary keys are selected to control the mouse keys.
         *
         * @hide
         */
        public static final String ACCESSIBILITY_MOUSE_KEYS_USE_PRIMARY_KEYS =
                "accessibility_mouse_keys_use_primary_keys";
        /**
         * Whether the Adaptive connectivity option is enabled.
         *
+1 −0
Original line number Diff line number Diff line
@@ -245,6 +245,7 @@ public class SecureSettings {
        Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_ENABLED,
        Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_ACCELERATION,
        Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_MAX_SPEED,
        Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_USE_PRIMARY_KEYS,
        Settings.Secure.ACCESSIBILITY_PINCH_TO_ZOOM_ANYWHERE_ENABLED,
        Settings.Secure.ACCESSIBILITY_SINGLE_FINGER_PANNING_ENABLED,
        Settings.Secure.ACTION_CORNER_TOP_LEFT_ACTION,
+1 −0
Original line number Diff line number Diff line
@@ -492,6 +492,7 @@ public class SecureSettingsValidators {
                new InclusiveFloatRangeValidator(0, 1.0f));
        VALIDATORS.put(Secure.ACCESSIBILITY_MOUSE_KEYS_MAX_SPEED,
                new InclusiveIntegerRangeValidator(1, 10));
        VALIDATORS.put(Secure.ACCESSIBILITY_MOUSE_KEYS_USE_PRIMARY_KEYS, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.MANDATORY_BIOMETRICS, new InclusiveIntegerRangeValidator(0, 1));
        VALIDATORS.put(Secure.MANDATORY_BIOMETRICS_REQUIREMENTS_SATISFIED,
                new InclusiveIntegerRangeValidator(0, 1));