Merge "Add triggering the accessibility shortcut as a system action" into rvc-dev am: a2172bb23d
Change-Id: I3ac0eef0b1a309ada745d4e8cb2e4ce450323351
This commit is contained in:
@@ -513,6 +513,13 @@ public abstract class AccessibilityService extends Service {
|
|||||||
*/
|
*/
|
||||||
public static final int GLOBAL_ACTION_ACCESSIBILITY_BUTTON_CHOOSER = 12;
|
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";
|
private static final String LOG_TAG = "AccessibilityService";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5441,10 +5441,12 @@
|
|||||||
<string name="accessibility_system_action_lock_screen_label">Lock Screen</string>
|
<string name="accessibility_system_action_lock_screen_label">Lock Screen</string>
|
||||||
<!-- Label for taking screenshot action [CHAR LIMIT=NONE] -->
|
<!-- Label for taking screenshot action [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_system_action_screenshot_label">Screenshot</string>
|
<string name="accessibility_system_action_screenshot_label">Screenshot</string>
|
||||||
<!-- Label for showing accessibility shortcut action [CHAR LIMIT=NONE] -->
|
<!-- Label for triggering on-screen accessibility shortcut action [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_system_action_accessibility_button_label">On-screen Accessibility Shortcut</string>
|
<string name="accessibility_system_action_on_screen_a11y_shortcut_label">On-screen Accessibility Shortcut</string>
|
||||||
<!-- Label for showing accessibility shortcut menu action [CHAR LIMIT=NONE] -->
|
<!-- Label for showing on-screen accessibility shortcut chooser action [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_system_action_accessibility_button_chooser_label">On-screen Accessibility Shortcut Chooser</string>
|
<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 -->
|
<!-- Accessibility description of caption view -->
|
||||||
<string name="accessibility_freeform_caption">Caption bar of <xliff:g id="app_name">%1$s</xliff:g>.</string>
|
<string name="accessibility_freeform_caption">Caption bar of <xliff:g id="app_name">%1$s</xliff:g>.</string>
|
||||||
|
|
||||||
|
|||||||
@@ -3844,8 +3844,9 @@
|
|||||||
<java-symbol type="string" name="accessibility_system_action_quick_settings_label" />
|
<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_recents_label" />
|
||||||
<java-symbol type="string" name="accessibility_system_action_screenshot_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_on_screen_a11y_shortcut_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_chooser_label" />
|
||||||
|
<java-symbol type="string" name="accessibility_system_action_hardware_a11y_shortcut_label" />
|
||||||
|
|
||||||
<java-symbol type="string" name="accessibility_freeform_caption" />
|
<java-symbol type="string" name="accessibility_freeform_caption" />
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,9 @@ public class SystemActions extends SystemUI {
|
|||||||
public static final int SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON_CHOOSER =
|
public static final int SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON_CHOOSER =
|
||||||
AccessibilityService.GLOBAL_ACTION_ACCESSIBILITY_BUTTON_CHOOSER; // 12
|
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 Recents mRecents;
|
||||||
private StatusBar mStatusBar;
|
private StatusBar mStatusBar;
|
||||||
private SystemActionsBroadcastReceiver mReceiver;
|
private SystemActionsBroadcastReceiver mReceiver;
|
||||||
@@ -191,6 +194,10 @@ public class SystemActions extends SystemUI {
|
|||||||
R.string.accessibility_system_action_screenshot_label,
|
R.string.accessibility_system_action_screenshot_label,
|
||||||
SystemActionsBroadcastReceiver.INTENT_ACTION_TAKE_SCREENSHOT);
|
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(actionBack, SYSTEM_ACTION_ID_BACK);
|
||||||
mA11yManager.registerSystemAction(actionHome, SYSTEM_ACTION_ID_HOME);
|
mA11yManager.registerSystemAction(actionHome, SYSTEM_ACTION_ID_HOME);
|
||||||
mA11yManager.registerSystemAction(actionRecents, SYSTEM_ACTION_ID_RECENTS);
|
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(actionPowerDialog, SYSTEM_ACTION_ID_POWER_DIALOG);
|
||||||
mA11yManager.registerSystemAction(actionLockScreen, SYSTEM_ACTION_ID_LOCK_SCREEN);
|
mA11yManager.registerSystemAction(actionLockScreen, SYSTEM_ACTION_ID_LOCK_SCREEN);
|
||||||
mA11yManager.registerSystemAction(actionTakeScreenshot, SYSTEM_ACTION_ID_TAKE_SCREENSHOT);
|
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;
|
intent = SystemActionsBroadcastReceiver.INTENT_ACTION_TAKE_SCREENSHOT;
|
||||||
break;
|
break;
|
||||||
case SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON:
|
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;
|
intent = SystemActionsBroadcastReceiver.INTENT_ACTION_ACCESSIBILITY_BUTTON;
|
||||||
break;
|
break;
|
||||||
case SYSTEM_ACTION_ID_ACCESSIBILITY_BUTTON_CHOOSER:
|
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;
|
intent = SystemActionsBroadcastReceiver.INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER;
|
||||||
break;
|
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:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -349,6 +363,10 @@ public class SystemActions extends SystemUI {
|
|||||||
mContext.startActivityAsUser(intent, UserHandle.CURRENT);
|
mContext.startActivityAsUser(intent, UserHandle.CURRENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleAccessibilityShortcut() {
|
||||||
|
mA11yManager.performAccessibilityShortcut();
|
||||||
|
}
|
||||||
|
|
||||||
private class SystemActionsBroadcastReceiver extends BroadcastReceiver {
|
private class SystemActionsBroadcastReceiver extends BroadcastReceiver {
|
||||||
private static final String INTENT_ACTION_BACK = "SYSTEM_ACTION_BACK";
|
private static final String INTENT_ACTION_BACK = "SYSTEM_ACTION_BACK";
|
||||||
private static final String INTENT_ACTION_HOME = "SYSTEM_ACTION_HOME";
|
private static final String INTENT_ACTION_HOME = "SYSTEM_ACTION_HOME";
|
||||||
@@ -362,6 +380,8 @@ public class SystemActions extends SystemUI {
|
|||||||
"SYSTEM_ACTION_ACCESSIBILITY_BUTTON";
|
"SYSTEM_ACTION_ACCESSIBILITY_BUTTON";
|
||||||
private static final String INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER =
|
private static final String INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER =
|
||||||
"SYSTEM_ACTION_ACCESSIBILITY_BUTTON_MENU";
|
"SYSTEM_ACTION_ACCESSIBILITY_BUTTON_MENU";
|
||||||
|
private static final String INTENT_ACTION_ACCESSIBILITY_SHORTCUT =
|
||||||
|
"SYSTEM_ACTION_ACCESSIBILITY_SHORTCUT";
|
||||||
|
|
||||||
private PendingIntent createPendingIntent(Context context, String intentAction) {
|
private PendingIntent createPendingIntent(Context context, String intentAction) {
|
||||||
switch (intentAction) {
|
switch (intentAction) {
|
||||||
@@ -374,7 +394,8 @@ public class SystemActions extends SystemUI {
|
|||||||
case INTENT_ACTION_LOCK_SCREEN:
|
case INTENT_ACTION_LOCK_SCREEN:
|
||||||
case INTENT_ACTION_TAKE_SCREENSHOT:
|
case INTENT_ACTION_TAKE_SCREENSHOT:
|
||||||
case INTENT_ACTION_ACCESSIBILITY_BUTTON:
|
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);
|
Intent intent = new Intent(intentAction);
|
||||||
return PendingIntent.getBroadcast(context, 0, intent, 0);
|
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_TAKE_SCREENSHOT);
|
||||||
intentFilter.addAction(INTENT_ACTION_ACCESSIBILITY_BUTTON);
|
intentFilter.addAction(INTENT_ACTION_ACCESSIBILITY_BUTTON);
|
||||||
intentFilter.addAction(INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER);
|
intentFilter.addAction(INTENT_ACTION_ACCESSIBILITY_BUTTON_CHOOSER);
|
||||||
|
intentFilter.addAction(INTENT_ACTION_ACCESSIBILITY_SHORTCUT);
|
||||||
return intentFilter;
|
return intentFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,6 +465,10 @@ public class SystemActions extends SystemUI {
|
|||||||
handleAccessibilityButtonChooser();
|
handleAccessibilityButtonChooser();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case INTENT_ACTION_ACCESSIBILITY_SHORTCUT: {
|
||||||
|
handleAccessibilityShortcut();
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user