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

Commit 8862ad75 authored by Amanda Lin Dietz's avatar Amanda Lin Dietz
Browse files

[A11y][Keyboard shortcuts] Add flag for TalkBack key gesture

* This adds a flag to enable just the TalkBack key gesture shortcut
  individually.
* This separates out existing logic that tied together the key gestures
  for TalkBack and Magnification.
* To avoid rolling back existing work for Magnification, the
  enable_talkback_and_magnifier_key_gestures flag will be left named
  as-is.
* Due to the necessity of showing the permissions warning dialog when
  the TalkBack shortcut is added, the technical limitations on the
  existing dialog that shows when TalkBack settings are enabled, and the
  level of UI, behavior, and string change involved in enabling this
  scenario, it is safest to enable this TalkBack key gesture separately.

Bug: 331682600
Bug: 439624730
Flag: com.android.hardware.input.enable_talkback_and_magnifier_key_gestures
Flag: com.android.hardware.input.enable_talkback_key_gestures
Test: Tested manually locally, updated AccessibilityManagerServiceTest
and KeyGestureControllerTests

Change-Id: I7f78e3bffdab1da10a8b4226bc76824bdb4205c4
parent 980bd747
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -112,7 +112,14 @@ flag {
flag {
    name: "enable_talkback_and_magnifier_key_gestures"
    namespace: "input"
    description: "Adds key gestures for TalkBack and Magnification"
    description: "Adds key gestures for Magnification. TalkBack key gesture has been flagged separately under enable_talkback_key_gestures."
    bug: "375277034"
}

flag {
    name: "enable_talkback_key_gestures"
    namespace: "accessibility"
    description: "Adds key gesture for TalkBack"
    bug: "375277034"
}

+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ constructor(
        if (
            !Flags.enableTalkbackAndMagnifierKeyGestures() &&
                !Flags.enableSelectToSpeakKeyGestures() &&
                !Flags.enableTalkbackKeyGestures() &&
                !Flags.enableVoiceAccessKeyGestures()
        ) {
            return
+5 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ 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.enableTalkbackKeyGestures
import com.android.hardware.input.Flags.enableVoiceAccessKeyGestures
import com.android.hardware.input.Flags.keyboardA11yShortcutControl
import com.android.systemui.dagger.qualifiers.Main
@@ -94,7 +95,7 @@ class AccessibilityShortcutsSource @Inject constructor(@Main private val resourc
            )
        }

        if (enableTalkbackAndMagnifierKeyGestures()) {
        if (enableTalkbackKeyGestures()) {
            shortcuts.add(
                // Toggle talkback:
                //  - Meta + Alt + T
@@ -102,6 +103,9 @@ class AccessibilityShortcutsSource @Inject constructor(@Main private val resourc
                    command(META_META_ON or META_ALT_ON, KEYCODE_T)
                }
            )
        }

        if (enableTalkbackAndMagnifierKeyGestures()) {
            shortcuts.add(
                // Toggle magnification:
                //  - Meta + Alt + M
+15 −7
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import static android.view.accessibility.AccessibilityManager.FlashNotificationR

import static com.android.hardware.input.Flags.enableSelectToSpeakKeyGestures;
import static com.android.hardware.input.Flags.enableTalkbackAndMagnifierKeyGestures;
import static com.android.hardware.input.Flags.enableTalkbackKeyGestures;
import static com.android.hardware.input.Flags.enableVoiceAccessKeyGestures;
import static com.android.internal.accessibility.AccessibilityShortcutController.ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME;
import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_COMPONENT_NAME;
@@ -672,9 +673,11 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
            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 (enableTalkbackKeyGestures()) {
            supportedGestures.add(KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_SCREEN_READER);
        }
        if (enableVoiceAccessKeyGestures()) {
            supportedGestures.add(KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_VOICE_ACCESS);
        }
@@ -4484,13 +4487,11 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
                enable, shortcutType, shortcutTargets, userId));

        if (shortcutType == UserShortcutType.KEY_GESTURE) {
            if(!enableTalkbackAndMagnifierKeyGestures() &&
                    (shortcutTargets.contains(MAGNIFICATION_CONTROLLER_NAME) ||
                            shortcutTargets.contains(mContext.getString(
                                    R.string.config_defaultAccessibilityService)))) {
            if (!enableTalkbackAndMagnifierKeyGestures()
                    && shortcutTargets.contains(MAGNIFICATION_CONTROLLER_NAME)) {
                Slog.w(LOG_TAG,
                        "KEY_GESTURE type magnification and TalkBack shortcuts are disabled by "
                                + "feature flag");
                        "KEY_GESTURE type magnification shortcuts are disabled by feature "
                                + "flag");
                return;
            }
            if (!enableSelectToSpeakKeyGestures() && shortcutTargets.contains(mContext.getString(
@@ -4500,6 +4501,13 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
                                + "flag");
                return;
            }
            if (!enableTalkbackKeyGestures()
                    && shortcutTargets.contains(mContext.getString(
                                    R.string.config_defaultAccessibilityService))) {
                Slog.w(LOG_TAG,
                        "KEY_GESTURE type TalkBack shortcuts are disabled by feature flag");
                return;
            }
            if (!enableVoiceAccessKeyGestures() && shortcutTargets.contains(mContext.getString(
                    R.string.config_defaultVoiceAccessService))) {
                Slog.w(LOG_TAG,
+7 −4
Original line number Diff line number Diff line
@@ -21,6 +21,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.enableTalkbackKeyGestures;
import static com.android.hardware.input.Flags.enableVoiceAccessKeyGestures;
import static com.android.hardware.input.Flags.keyboardA11yShortcutControl;

@@ -221,15 +222,17 @@ final class InputGestureManager {
        }
        if (enableTalkbackAndMagnifierKeyGestures()) {
            systemShortcuts.add(
                    createKeyGesture(KeyEvent.KEYCODE_T,
                    createKeyGesture(KeyEvent.KEYCODE_M,
                            KeyEvent.META_META_ON | KeyEvent.META_ALT_ON,
                            KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_SCREEN_READER,
                            KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION,
                            /* allowCaptureByFocusedWindow = */true
                    ));
        }
        if (enableTalkbackKeyGestures()) {
            systemShortcuts.add(
                    createKeyGesture(KeyEvent.KEYCODE_M,
                    createKeyGesture(KeyEvent.KEYCODE_T,
                            KeyEvent.META_META_ON | KeyEvent.META_ALT_ON,
                            KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION,
                            KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_SCREEN_READER,
                            /* allowCaptureByFocusedWindow = */true
                    ));
        }
Loading