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

Commit 311d8371 authored by Vaibhav Devmurari's avatar Vaibhav Devmurari Committed by Android (Google) Code Review
Browse files

Merge "Add Sticky keys A11Y feature flag and Setting" into main

parents f1cb2e98 9807d772
Loading
Loading
Loading
Loading
+46 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.hardware.input;

import static com.android.hardware.input.Flags.keyboardA11yBounceKeysFlag;
import static com.android.hardware.input.Flags.keyboardA11yStickyKeysFlag;

import android.Manifest;
import android.annotation.FloatRange;
@@ -401,4 +402,49 @@ public class InputSettings {
                UserHandle.USER_CURRENT);
    }

    /**
     * Whether Accessibility sticky keys is enabled.
     *
     * <p>
     * 'Sticky keys' is an accessibility feature that assists users who have physical
     * disabilities or help users reduce repetitive strain injury. It serializes keystrokes
     * instead of pressing multiple keys at a time, allowing the user to press and release a
     * modifier key, such as Shift, Ctrl, Alt, or any other modifier key, and have it remain
     * active until any other key is pressed.
     * </p>
     *
     * @hide
     */
    public static boolean isAccessibilityStickyKeysEnabled(@NonNull Context context) {
        if (!keyboardA11yStickyKeysFlag()) {
            return false;
        }
        return Settings.System.getIntForUser(context.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_STICKY_KEYS, 0, UserHandle.USER_CURRENT) != 0;
    }

    /**
     * Set Accessibility sticky keys feature enabled/disabled.
     *
     *  <p>
     * 'Sticky keys' is an accessibility feature that assists users who have physical
     * disabilities or help users reduce repetitive strain injury. It serializes keystrokes
     * instead of pressing multiple keys at a time, allowing the user to press and release a
     * modifier key, such as Shift, Ctrl, Alt, or any other modifier key, and have it remain
     * active until any other key is pressed.
     * </p>
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.WRITE_SETTINGS)
    public static void setAccessibilityStickyKeysEnabled(@NonNull Context context,
            boolean enabled) {
        if (!keyboardA11yStickyKeysFlag()) {
            return;
        }
        Settings.System.putIntForUser(context.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_STICKY_KEYS, enabled ? 1 : 0,
                UserHandle.USER_CURRENT);
    }

}
+9 −0
Original line number Diff line number Diff line
@@ -7800,6 +7800,15 @@ public final class Settings {
         */
        public static final String ACCESSIBILITY_BOUNCE_KEYS = "accessibility_bounce_keys";
        /**
         * Whether to enable sticky keys for Physical Keyboard accessibility.
         *
         * This is a boolean value that determines if Sticky keys feature is enabled.
         *
         * @hide
         */
        public static final String ACCESSIBILITY_STICKY_KEYS = "accessibility_sticky_keys";
        /**
         * Whether stylus button presses are disabled. This is a boolean that
         * determines if stylus buttons are ignored.
+1 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public class SecureSettings {
        Settings.Secure.TTS_DEFAULT_LOCALE,
        Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD,
        Settings.Secure.ACCESSIBILITY_BOUNCE_KEYS,
        Settings.Secure.ACCESSIBILITY_STICKY_KEYS,
        Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,            // moved to global
        Settings.Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY,               // moved to global
        Settings.Secure.WIFI_NUM_OPEN_NETWORKS_KEPT,                        // moved to global
+1 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ public class SecureSettingsValidators {
        VALIDATORS.put(Secure.TTS_DEFAULT_LOCALE, TTS_LIST_VALIDATOR);
        VALIDATORS.put(Secure.SHOW_IME_WITH_HARD_KEYBOARD, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.ACCESSIBILITY_BOUNCE_KEYS, ANY_INTEGER_VALIDATOR);
        VALIDATORS.put(Secure.ACCESSIBILITY_STICKY_KEYS, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, NON_NEGATIVE_INTEGER_VALIDATOR);
        VALIDATORS.put(Secure.WIFI_NUM_OPEN_NETWORKS_KEPT, NON_NEGATIVE_INTEGER_VALIDATOR);
+7 −0
Original line number Diff line number Diff line
@@ -3511,6 +3511,13 @@ public class InputManagerService extends IInputManager.Stub
        mNative.setAccessibilityBounceKeysThreshold(thresholdTimeMs);
    }

    /**
     * Sets whether Accessibility sticky keys is enabled.
     */
    public void setAccessibilityStickyKeysEnabled(boolean enabled) {
        mNative.setAccessibilityStickyKeysEnabled(enabled);
    }

    interface KeyboardBacklightControllerInterface {
        default void incrementKeyboardBacklight(int deviceId) {}
        default void decrementKeyboardBacklight(int deviceId) {}
Loading