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

Commit 73369ee1 authored by Sally Yuen's avatar Sally Yuen Committed by Automerger Merge Worker
Browse files

Merge "Add triggering the accessibility shortcut as a system action" into rvc-dev am: a2172bb2

Change-Id: I3ac0eef0b1a309ada745d4e8cb2e4ce450323351
parents 445f86fa a2172bb2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -513,6 +513,13 @@ public abstract class AccessibilityService extends Service {
     */
    public static final int GLOBAL_ACTION_ACCESSIBILITY_BUTTON_CHOOSER = 12;

    /**
     * Action to trigger the Accessibility Shortcut. This shortcut has a hardware trigger and can
     * be activated by holding down the two volume keys.
     * @hide
     */
    public static final int GLOBAL_ACTION_ACCESSIBILITY_SHORTCUT = 13;

    private static final String LOG_TAG = "AccessibilityService";

    /**
+6 −4
Original line number Diff line number Diff line
@@ -5441,10 +5441,12 @@
    <string name="accessibility_system_action_lock_screen_label">Lock Screen</string>
    <!-- Label for taking screenshot action [CHAR LIMIT=NONE] -->
    <string name="accessibility_system_action_screenshot_label">Screenshot</string>
    <!-- Label for showing accessibility shortcut action [CHAR LIMIT=NONE] -->
    <string name="accessibility_system_action_accessibility_button_label">On-screen Accessibility Shortcut</string>
    <!-- Label for showing accessibility shortcut menu action [CHAR LIMIT=NONE] -->
    <string name="accessibility_system_action_accessibility_button_chooser_label">On-screen Accessibility Shortcut Chooser</string>
    <!-- Label for triggering on-screen accessibility shortcut action [CHAR LIMIT=NONE] -->
    <string name="accessibility_system_action_on_screen_a11y_shortcut_label">On-screen Accessibility Shortcut</string>
    <!-- Label for showing on-screen accessibility shortcut chooser action [CHAR LIMIT=NONE] -->
    <string name="accessibility_system_action_on_screen_a11y_shortcut_chooser_label">On-screen Accessibility Shortcut Chooser</string>
    <!-- Label for triggering hardware accessibility shortcut action [CHAR LIMIT=NONE] -->
    <string name="accessibility_system_action_hardware_a11y_shortcut_label">Accessibility Shortcut</string>
    <!-- Accessibility description of caption view -->
    <string name="accessibility_freeform_caption">Caption bar of <xliff:g id="app_name">%1$s</xliff:g>.</string>

+3 −2
Original line number Diff line number Diff line
@@ -3844,8 +3844,9 @@
  <java-symbol type="string" name="accessibility_system_action_quick_settings_label" />
  <java-symbol type="string" name="accessibility_system_action_recents_label" />
  <java-symbol type="string" name="accessibility_system_action_screenshot_label" />
  <java-symbol type="string" name="accessibility_system_action_accessibility_button_label" />
  <java-symbol type="string" name="accessibility_system_action_accessibility_button_chooser_label" />
  <java-symbol type="string" name="accessibility_system_action_on_screen_a11y_shortcut_label" />
  <java-symbol type="string" name="accessibility_system_action_on_screen_a11y_shortcut_chooser_label" />
  <java-symbol type="string" name="accessibility_system_action_hardware_a11y_shortcut_label" />

  <java-symbol type="string" name="accessibility_freeform_caption" />

+29 −3
Original line number Diff line number Diff line
@@ -125,6 +125,9 @@ public class SystemActions extends SystemUI {
    public static final int SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON_CHOOSER =
            AccessibilityService.GLOBAL_ACTION_ACCESSIBILITY_BUTTON_CHOOSER; // 12

    public static final int SYSTEM_ACTION_ID_ACCESSIBILITY_SHORTCUT =
            AccessibilityService.GLOBAL_ACTION_ACCESSIBILITY_SHORTCUT; // 13

    private Recents mRecents;
    private StatusBar mStatusBar;
    private SystemActionsBroadcastReceiver mReceiver;
@@ -191,6 +194,10 @@ public class SystemActions extends SystemUI {
                R.string.accessibility_system_action_screenshot_label,
                SystemActionsBroadcastReceiver.INTENT_ACTION_TAKE_SCREENSHOT);

        RemoteAction actionAccessibilityShortcut = createRemoteAction(
                R.string.accessibility_system_action_hardware_a11y_shortcut_label,
                SystemActionsBroadcastReceiver.INTENT_ACTION_ACCESSIBILITY_SHORTCUT);

        mA11yManager.registerSystemAction(actionBack, SYSTEM_ACTION_ID_BACK);
        mA11yManager.registerSystemAction(actionHome, SYSTEM_ACTION_ID_HOME);
        mA11yManager.registerSystemAction(actionRecents, SYSTEM_ACTION_ID_RECENTS);
@@ -199,6 +206,8 @@ public class SystemActions extends SystemUI {
        mA11yManager.registerSystemAction(actionPowerDialog, SYSTEM_ACTION_ID_POWER_DIALOG);
        mA11yManager.registerSystemAction(actionLockScreen, SYSTEM_ACTION_ID_LOCK_SCREEN);
        mA11yManager.registerSystemAction(actionTakeScreenshot, SYSTEM_ACTION_ID_TAKE_SCREENSHOT);
        mA11yManager.registerSystemAction(
                actionAccessibilityShortcut, SYSTEM_ACTION_ID_ACCESSIBILITY_SHORTCUT);
    }

    /**
@@ -242,13 +251,18 @@ public class SystemActions extends SystemUI {
                intent = SystemActionsBroadcastReceiver.INTENT_ACTION_TAKE_SCREENSHOT;
                break;
            case SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON:
                labelId = R.string.accessibility_system_action_accessibility_button_label;
                labelId = R.string.accessibility_system_action_on_screen_a11y_shortcut_label;
                intent = SystemActionsBroadcastReceiver.INTENT_ACTION_ACCESSIBILITY_BUTTON;
                break;
            case SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON_CHOOSER:
                labelId = R.string.accessibility_system_action_accessibility_button_chooser_label;
                labelId =
                        R.string.accessibility_system_action_on_screen_a11y_shortcut_chooser_label;
                intent = SystemActionsBroadcastReceiver.INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER;
                break;
            case  SYSTEM_ACTION_ID_ACCESSIBILITY_SHORTCUT:
                labelId = R.string.accessibility_system_action_hardware_a11y_shortcut_label;
                intent = SystemActionsBroadcastReceiver.INTENT_ACTION_ACCESSIBILITY_SHORTCUT;
                break;
            default:
                return;
        }
@@ -349,6 +363,10 @@ public class SystemActions extends SystemUI {
        mContext.startActivityAsUser(intent, UserHandle.CURRENT);
    }

    private void handleAccessibilityShortcut() {
        mA11yManager.performAccessibilityShortcut();
    }

    private class SystemActionsBroadcastReceiver extends BroadcastReceiver {
        private static final String INTENT_ACTION_BACK = "SYSTEM_ACTION_BACK";
        private static final String INTENT_ACTION_HOME = "SYSTEM_ACTION_HOME";
@@ -362,6 +380,8 @@ public class SystemActions extends SystemUI {
                "SYSTEM_ACTION_ACCESSIBILITY_BUTTON";
        private static final String INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER =
                "SYSTEM_ACTION_ACCESSIBILITY_BUTTON_MENU";
        private static final String INTENT_ACTION_ACCESSIBILITY_SHORTCUT =
                "SYSTEM_ACTION_ACCESSIBILITY_SHORTCUT";

        private PendingIntent createPendingIntent(Context context, String intentAction) {
            switch (intentAction) {
@@ -374,7 +394,8 @@ public class SystemActions extends SystemUI {
                case INTENT_ACTION_LOCK_SCREEN:
                case INTENT_ACTION_TAKE_SCREENSHOT:
                case INTENT_ACTION_ACCESSIBILITY_BUTTON:
                case INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER: {
                case INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER:
                case INTENT_ACTION_ACCESSIBILITY_SHORTCUT: {
                    Intent intent = new Intent(intentAction);
                    return PendingIntent.getBroadcast(context, 0, intent, 0);
                }
@@ -396,6 +417,7 @@ public class SystemActions extends SystemUI {
            intentFilter.addAction(INTENT_ACTION_TAKE_SCREENSHOT);
            intentFilter.addAction(INTENT_ACTION_ACCESSIBILITY_BUTTON);
            intentFilter.addAction(INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER);
            intentFilter.addAction(INTENT_ACTION_ACCESSIBILITY_SHORTCUT);
            return intentFilter;
        }

@@ -443,6 +465,10 @@ public class SystemActions extends SystemUI {
                    handleAccessibilityButtonChooser();
                    break;
                }
                case INTENT_ACTION_ACCESSIBILITY_SHORTCUT: {
                    handleAccessibilityShortcut();
                    break;
                }
                default:
                    break;
            }