summaryrefslogtreecommitdiff
path: root/include/androidfw/Input.h
diff options
context:
space:
mode:
author Jeff Brown <jeffbrown@google.com> 2012-03-13 15:00:09 -0700
committer Jeff Brown <jeffbrown@google.com> 2012-03-13 15:00:09 -0700
commit2b6c32ca4177f1a97307f9cbd81ca485df28762c (patch)
treeabc217f8ff191ce1ecc7c4eb9b51185b6d47625d /include/androidfw/Input.h
parentb2679481b57d87945df02983f95ff8e6c9ba5928 (diff)
Fix spurious ANRs in native activities.
Some native activities experienced ANRs when the input consumer deferred an input event due to client-side batching. If the input channel was fully emptied then the client had no way of knowing that it should wake up to handle the deferred input event. This patch also fixes some lock issues in the native activity input queue implementation. In at least one error case, it was possible for a function to exit without releasing the lock. Bug: 6051176 Change-Id: I4d9d843237e69b9834f8d8b360031b677fcab8c3
Diffstat (limited to 'include/androidfw/Input.h')
-rw-r--r--include/androidfw/Input.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/androidfw/Input.h b/include/androidfw/Input.h
index f5db6e24e5d5..a4ebd95db552 100644
--- a/include/androidfw/Input.h
+++ b/include/androidfw/Input.h
@@ -616,6 +616,26 @@ private:
};
/*
+ * An input event factory implementation that maintains a pool of input events.
+ */
+class PooledInputEventFactory : public InputEventFactoryInterface {
+public:
+ PooledInputEventFactory(size_t maxPoolSize = 20);
+ virtual ~PooledInputEventFactory();
+
+ virtual KeyEvent* createKeyEvent();
+ virtual MotionEvent* createMotionEvent();
+
+ void recycle(InputEvent* event);
+
+private:
+ const size_t mMaxPoolSize;
+
+ Vector<KeyEvent*> mKeyEventPool;
+ Vector<MotionEvent*> mMotionEventPool;
+};
+
+/*
* Calculates the velocity of pointer movements over time.
*/
class VelocityTracker {