Support sending KEYCODE_HEADSETHOOK KeyEvent from an a11y service

Add a private global action to be made public in S. A service can
trigger the event by calling performGlobalAction(10) in R.

Note: Currently 10 is being used by SystemActions for the Accessibility
shortcut. Update ag/10921262 to avoid a conflict.

Bug: 154038741
Test: Tested with modified TalkBack and Youtube play/pause
Change-Id: I3ca5d25948bfb3eb8520030484cb466ec7188784
This commit is contained in:
sallyyuen
2020-04-15 13:46:39 -07:00
parent 53e927f890
commit 867c6d2786
2 changed files with 10 additions and 0 deletions

View File

@@ -494,6 +494,13 @@ public abstract class AccessibilityService extends Service {
*/
public static final int GLOBAL_ACTION_TAKE_SCREENSHOT = 9;
/**
* Action to send the KEYCODE_HEADSETHOOK KeyEvent, which is used to answer/hang up calls and
* play/stop media
* @hide
*/
public static final int GLOBAL_ACTION_KEYCODE_HEADSETHOOK = 10;
private static final String LOG_TAG = "AccessibilityService";
/**

View File

@@ -301,6 +301,9 @@ public class SystemActionPerformer {
return lockScreen();
case AccessibilityService.GLOBAL_ACTION_TAKE_SCREENSHOT:
return takeScreenshot();
case AccessibilityService.GLOBAL_ACTION_KEYCODE_HEADSETHOOK :
sendDownAndUpKeyEvents(KeyEvent.KEYCODE_HEADSETHOOK);
return true;
default:
return false;
}