From c4fccd183f1bb47a027bb303af5e65bec2f68b1b Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Tue, 9 Apr 2013 12:58:41 -0700 Subject: Adding APIs for an accessibility service to intercept key events. Now that we have gestures which are detected by the system and interpreted by an accessibility service, there is an inconsistent behavior between using the gestures and the keyboard. Some devices have both. Therefore, an accessibility service should be able to interpret keys in addition to gestures to provide consistent user experience. Now an accessibility service can expose shortcuts for each gestural action. This change adds APIs for an accessibility service to observe and intercept at will key events before they are dispatched to the rest of the system. The service can return true or false from its onKeyEvent to either consume the event or to let it be delivered to the rest of the system. However, the service will *not* be able to inject key events or modify the observed ones. Previous ideas of allowing the service to say it "tracks" the event so the latter is not delivered to the system until a subsequent event is either "handled" or "not handled" will not work. If the service tracks a key but no other key is pressed essentially this key is not delivered to the app and at potentially much later point this stashed event will be delivered in maybe a completely different context.The correct way of implementing shortcuts is a combination of modifier keys plus some other key/key sequence. Key events already contain information about which modifier keys are down as well as the service can track them as well. bug:8088812 Change-Id: I81ba9a7de9f19ca6662661f27fdc852323e38c00 --- .../java/android/accessibilityservice/IAccessibilityServiceClient.aidl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl') diff --git a/core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl b/core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl index 5d684e3..c5e3d43a 100644 --- a/core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl +++ b/core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl @@ -18,6 +18,7 @@ package android.accessibilityservice; import android.accessibilityservice.IAccessibilityServiceConnection; import android.view.accessibility.AccessibilityEvent; +import android.view.KeyEvent; /** * Top-level interface to an accessibility service component. @@ -35,4 +36,6 @@ import android.view.accessibility.AccessibilityEvent; void onGesture(int gesture); void clearAccessibilityNodeInfoCache(); + + void onKeyEvent(in KeyEvent event, int sequence); } -- cgit v1.1