diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java
index 77b3c81dee854..ed0ea556dc9d6 100644
--- a/core/java/android/accessibilityservice/AccessibilityService.java
+++ b/core/java/android/accessibilityservice/AccessibilityService.java
@@ -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";
/**
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 33dd81dca33ea..51b23dbfb59b5 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -5441,10 +5441,12 @@
Lock Screen
Screenshot
-
- On-screen Accessibility Shortcut
-
- On-screen Accessibility Shortcut Chooser
+
+ On-screen Accessibility Shortcut
+
+ On-screen Accessibility Shortcut Chooser
+
+ Accessibility Shortcut
Caption bar of %1$s.
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 3dc3b0b0acbea..098c25170218c 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -3844,8 +3844,9 @@
-
-
+
+
+
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java b/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java
index 73dfd32d03a2e..b7275634c6a60 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java
@@ -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;
}