summaryrefslogtreecommitdiffstats
path: root/services/input/InputDispatcher.h
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-03-30 02:25:18 -0700
committerJeff Brown <jeffbrown@google.com>2011-03-30 16:55:15 -0700
commit0029c66203ab9ded4342976bf7a17bb63af8c44a (patch)
treea0d5f54ff6f88dae18179d1621dd2c87f1fa8d27 /services/input/InputDispatcher.h
parent6e6cd7a5660af1a4b5a9ad091c41ef1c72ad2000 (diff)
downloadframeworks_base-0029c66203ab9ded4342976bf7a17bb63af8c44a.zip
frameworks_base-0029c66203ab9ded4342976bf7a17bb63af8c44a.tar.gz
frameworks_base-0029c66203ab9ded4342976bf7a17bb63af8c44a.tar.bz2
Add input filter mechanism for accessibility.
This patch adds a mechanism for capturing, filtering, transforming and injecting input events at a very low level before the input dispatcher attempts to deliver them to applications. At this time, the mechanism is only intended to be used by the accessibility system to implement built-in system-level accessibility affordances. The accessibility input filter is currently just a stub. It logs the input events receives and reinjects them unchanged, except that it transforms KEYCODE_Q into KEYCODE_Z. Currently, the accessibility input filter is installed whenever accessibility is enabled. We'll probably want to change that so it only enables the input filter when a screen reader is installed and we want touch exploration. Change-Id: I35764fdf75522b69d09ebd78c9766eb7593c1afe
Diffstat (limited to 'services/input/InputDispatcher.h')
-rw-r--r--services/input/InputDispatcher.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/services/input/InputDispatcher.h b/services/input/InputDispatcher.h
index 48e4d43..162e606 100644
--- a/services/input/InputDispatcher.h
+++ b/services/input/InputDispatcher.h
@@ -176,6 +176,13 @@ public:
*/
virtual int32_t getMaxEventsPerSecond() = 0;
+ /* Filters an input event.
+ * Return true to dispatch the event unmodified, false to consume the event.
+ * A filter can also transform and inject events later by passing POLICY_FLAG_FILTERED
+ * to injectInputEvent.
+ */
+ virtual bool filterInputEvent(const InputEvent* inputEvent, uint32_t policyFlags) = 0;
+
/* Intercepts a key event immediately before queueing it.
* The policy can use this method as an opportunity to perform power management functions
* and early event preprocessing such as updating policy flags.
@@ -266,7 +273,8 @@ public:
* This method may be called on any thread (usually by the input manager).
*/
virtual int32_t injectInputEvent(const InputEvent* event,
- int32_t injectorPid, int32_t injectorUid, int32_t syncMode, int32_t timeoutMillis) = 0;
+ int32_t injectorPid, int32_t injectorUid, int32_t syncMode, int32_t timeoutMillis,
+ uint32_t policyFlags) = 0;
/* Sets the list of input windows.
*
@@ -286,6 +294,14 @@ public:
*/
virtual void setInputDispatchMode(bool enabled, bool frozen) = 0;
+ /* Sets whether input event filtering is enabled.
+ * When enabled, incoming input events are sent to the policy's filterInputEvent
+ * method instead of being dispatched. The filter is expected to use
+ * injectInputEvent to inject the events it would like to have dispatched.
+ * It should include POLICY_FLAG_FILTERED in the policy flags during injection.
+ */
+ virtual void setInputFilterEnabled(bool enabled) = 0;
+
/* Transfers touch focus from the window associated with one channel to the
* window associated with the other channel.
*
@@ -345,11 +361,13 @@ public:
int32_t switchCode, int32_t switchValue, uint32_t policyFlags) ;
virtual int32_t injectInputEvent(const InputEvent* event,
- int32_t injectorPid, int32_t injectorUid, int32_t syncMode, int32_t timeoutMillis);
+ int32_t injectorPid, int32_t injectorUid, int32_t syncMode, int32_t timeoutMillis,
+ uint32_t policyFlags);
virtual void setInputWindows(const Vector<InputWindow>& inputWindows);
virtual void setFocusedApplication(const InputApplication* inputApplication);
virtual void setInputDispatchMode(bool enabled, bool frozen);
+ virtual void setInputFilterEnabled(bool enabled);
virtual bool transferTouchFocus(const sp<InputChannel>& fromChannel,
const sp<InputChannel>& toChannel);
@@ -863,6 +881,7 @@ private:
// Dispatch state.
bool mDispatchEnabled;
bool mDispatchFrozen;
+ bool mInputFilterEnabled;
Vector<InputWindow> mWindows;