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

Commit 6a82a5f1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[A11y][Keyboard shortcuts] Add flag for Select to Speak key gesture" into main

parents 999ec522 f36245dc
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -92,10 +92,17 @@ flag {
    bug: "383730505"
}

flag {
    name: "enable_select_to_speak_key_gestures"
    namespace: "accessibility"
    description: "Adds key gestures for select to speak"
    bug: "375277034"
}

flag {
    name: "enable_talkback_and_magnifier_key_gestures"
    namespace: "input"
    description: "Adds key gestures for talkback and magnifier"
    description: "Adds key gestures for TalkBack and Magnification"
    bug: "375277034"
}

+3 −1
Original line number Diff line number Diff line
@@ -64,7 +64,9 @@ constructor(

    override fun start() {
        if (
            !Flags.enableTalkbackAndMagnifierKeyGestures() && !Flags.enableVoiceAccessKeyGestures()
            !Flags.enableTalkbackAndMagnifierKeyGestures() &&
                !Flags.enableSelectToSpeakKeyGestures() &&
                !Flags.enableVoiceAccessKeyGestures()
        ) {
            return
        }
+4 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.view.KeyEvent.META_ALT_ON
import android.view.KeyEvent.META_META_ON
import android.view.KeyboardShortcutGroup
import android.view.KeyboardShortcutInfo
import com.android.hardware.input.Flags.enableSelectToSpeakKeyGestures
import com.android.hardware.input.Flags.enableTalkbackAndMagnifierKeyGestures
import com.android.hardware.input.Flags.enableVoiceAccessKeyGestures
import com.android.hardware.input.Flags.keyboardA11yShortcutControl
@@ -110,6 +111,9 @@ class AccessibilityShortcutsSource @Inject constructor(@Main private val resourc
                    command(META_META_ON or META_ALT_ON, KEYCODE_M)
                }
            )
        }

        if (enableSelectToSpeakKeyGestures()) {
            shortcuts.add(
                // Activate Select to Speak:
                //  - Meta + Alt + S
+14 −6
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import static android.view.Display.INVALID_DISPLAY;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
import static android.view.accessibility.AccessibilityManager.FlashNotificationReason;

import static com.android.hardware.input.Flags.enableSelectToSpeakKeyGestures;
import static com.android.hardware.input.Flags.enableTalkbackAndMagnifierKeyGestures;
import static com.android.hardware.input.Flags.enableVoiceAccessKeyGestures;
import static com.android.internal.accessibility.AccessibilityShortcutController.ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME;
@@ -667,10 +668,12 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        mAccessibilityContentObserver.register(mContext.getContentResolver());

        List<Integer> supportedGestures = new ArrayList<>();
        if (enableTalkbackAndMagnifierKeyGestures()) {
            supportedGestures.add(KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION);
        if (enableSelectToSpeakKeyGestures()) {
            supportedGestures.add(KeyGestureEvent.KEY_GESTURE_TYPE_ACTIVATE_SELECT_TO_SPEAK);
        }
        if (enableTalkbackAndMagnifierKeyGestures()) {
            supportedGestures.add(KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_SCREEN_READER);
            supportedGestures.add(KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION);
        }
        if (enableVoiceAccessKeyGestures()) {
            supportedGestures.add(KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_VOICE_ACCESS);
@@ -4483,13 +4486,18 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
        if (shortcutType == UserShortcutType.KEY_GESTURE) {
            if(!enableTalkbackAndMagnifierKeyGestures() &&
                    (shortcutTargets.contains(MAGNIFICATION_CONTROLLER_NAME) ||
                            shortcutTargets.contains(mContext.getString(
                                    R.string.config_defaultSelectToSpeakService)) ||
                            shortcutTargets.contains(mContext.getString(
                                    R.string.config_defaultAccessibilityService)))) {
                Slog.w(LOG_TAG,
                        "KEY_GESTURE type magnification, select to speak and TalkBack shortcuts"
                                + "are disabled by feature flag");
                        "KEY_GESTURE type magnification and TalkBack shortcuts are disabled by "
                                + "feature flag");
                return;
            }
            if (!enableSelectToSpeakKeyGestures() && shortcutTargets.contains(mContext.getString(
                    R.string.config_defaultSelectToSpeakService))) {
                Slog.w(LOG_TAG,
                        "KEY_GESTURE type select to speak shortcuts are disabled by feature "
                                + "flag");
                return;
            }
            if (!enableVoiceAccessKeyGestures() && shortcutTargets.contains(mContext.getString(
+9 −6
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.hardware.input.InputGestureData.createKeyTrigger;

import static com.android.hardware.input.Flags.enableQuickSettingsPanelShortcut;
import static com.android.hardware.input.Flags.enableTalkbackAndMagnifierKeyGestures;
import static com.android.hardware.input.Flags.enableSelectToSpeakKeyGestures;
import static com.android.hardware.input.Flags.enableVoiceAccessKeyGestures;
import static com.android.hardware.input.Flags.keyboardA11yShortcutControl;

@@ -210,6 +211,14 @@ final class InputGestureManager {
                            /* allowCaptureByFocusedWindow = */false
                    ));
        }
        if (enableSelectToSpeakKeyGestures()) {
            systemShortcuts.add(
                    createKeyGesture(KeyEvent.KEYCODE_S,
                            KeyEvent.META_META_ON | KeyEvent.META_ALT_ON,
                            KeyGestureEvent.KEY_GESTURE_TYPE_ACTIVATE_SELECT_TO_SPEAK,
                            /* allowCaptureByFocusedWindow = */true
                    ));
        }
        if (enableTalkbackAndMagnifierKeyGestures()) {
            systemShortcuts.add(
                    createKeyGesture(KeyEvent.KEYCODE_T,
@@ -223,12 +232,6 @@ final class InputGestureManager {
                            KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION,
                            /* allowCaptureByFocusedWindow = */true
                    ));
            systemShortcuts.add(
                    createKeyGesture(KeyEvent.KEYCODE_S,
                            KeyEvent.META_META_ON | KeyEvent.META_ALT_ON,
                            KeyGestureEvent.KEY_GESTURE_TYPE_ACTIVATE_SELECT_TO_SPEAK,
                            /* allowCaptureByFocusedWindow = */true
                    ));
        }
        if (enableVoiceAccessKeyGestures()) {
            systemShortcuts.add(
Loading