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

Commit 3b926f13 authored by Chun-Ku Lin's avatar Chun-Ku Lin
Browse files

Add the default a11y service to the target shortcut service when turns

on the default shortcut.

Bug: 294575237
Test: atest AccessibilityShortcutControllerTest
Test: manual
- Test steps:
    - In SUW landing page, use the volume keys to trigger an accessibility shortcut
    - Given the default accessibility service is TalkBack
    - Click Turn on when seeing Turn on TalkBack shortcut? warning dialog
    - [Expected] TalkBack component name is added to
      Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE by running the
      adb command `adb shell settings get secure accessibility_shortcut_target_service`
      and verify the output contains Talkback component name.
    - Go to Vision Settings
    - Click Select to Speak
    - Set up volume keys as the shortcut to trigger Select to Speak
    - Use the volume keys to trigger the accessibility service
    - [Expected] See the dialog letting the user to choose whether to
      turn on Select to Speak or TalkBack.

Change-Id: I1482240e8fbd778ad760a0a0c07a3c05bb2ed817
parent 7748d9bf
Loading
Loading
Loading
Loading
+27 −4
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ public class AccessibilityShortcutController {
            DialogStatus.SHOWN,
    })
    /** Denotes the user shortcut type. */
    private @interface DialogStatus {
    @interface DialogStatus {
        int NOT_SHOWN = 0;
        int SHOWN  = 1;
    }
@@ -338,7 +338,30 @@ public class AccessibilityShortcutController {
                .setTitle(getShortcutWarningTitle(targets))
                .setMessage(getShortcutWarningMessage(targets))
                .setCancelable(false)
                .setNegativeButton(R.string.accessibility_shortcut_on, null)
                .setNegativeButton(R.string.accessibility_shortcut_on,
                        (DialogInterface d, int which) -> {
                            String targetServices = Settings.Secure.getStringForUser(
                                    mContext.getContentResolver(),
                                    Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE, userId);
                            String defaultService = mContext.getString(
                                    R.string.config_defaultAccessibilityService);
                            // If the targetServices is null, means the user enables a
                            // shortcut for the default service by triggering the volume keys
                            // shortcut in the SUW instead of intentionally configuring the
                            // shortcut on UI.
                            if (targetServices == null && !TextUtils.isEmpty(defaultService)) {
                                // The defaultService in the string resource could be a shorten
                                // form like com.google.android.marvin.talkback/.TalkBackService.
                                // Converts it to the componentName for consistency before saving
                                // to the Settings.
                                final ComponentName configDefaultService =
                                        ComponentName.unflattenFromString(defaultService);
                                Settings.Secure.putStringForUser(mContext.getContentResolver(),
                                        Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE,
                                        configDefaultService.flattenToString(),
                                        userId);
                            }
                        })
                .setPositiveButton(R.string.accessibility_shortcut_off,
                        (DialogInterface d, int which) -> {
                            Settings.Secure.putStringForUser(mContext.getContentResolver(),
+138 −57

File changed.

Preview size limit exceeded, changes collapsed.