summaryrefslogtreecommitdiff
path: root/libs/ui/InputDispatcher.cpp
diff options
context:
space:
mode:
author Jeff Brown <jeffbrown@google.com> 2010-10-20 15:33:38 -0700
committer Jeff Brown <jeffbrown@google.com> 2010-10-23 03:52:57 -0700
commit3c3cc62e243a7796f5c1e88773d34e2054cc26c6 (patch)
tree48004ee9a8dcdcbb625d8fcc0ac3d2c45973d806 /libs/ui/InputDispatcher.cpp
parent48a862ef5f1a9fe9f646f0862d676170fd8dc51d (diff)
Add unit tests for native input and fix bugs identified.
Fixed a bug where we would lose the first touch point when swiping out of the virtual key area. Fixed a bug where we would not send an ACTION_MOVE event in cases where individual pointers went down/up and the remaining pointers actually moved. This is important since many applications do not handle pointer movements during ACTION_POINTER_DOWN or ACTION_POINTER_UP. In the case of ACTION_POINTER_UP the movement was completely lost since all pointers were dispatched using their old location rather than the new location. Improved motion event validation to check for duplicate pointer ids. Added an input source constant that was missing from the NDK api but defined in the framework api. Added a timestamp when reporting added/removed devices in EventHub. Bug: 3070082 Change-Id: I3206a030f43b7616e2f48006e5a9d522c4d92e56
Diffstat (limited to 'libs/ui/InputDispatcher.cpp')
-rw-r--r--libs/ui/InputDispatcher.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp
index 303075f1bc..fef8148183 100644
--- a/libs/ui/InputDispatcher.cpp
+++ b/libs/ui/InputDispatcher.cpp
@@ -124,12 +124,19 @@ static bool validateMotionEvent(int32_t action, size_t pointerCount,
pointerCount, MAX_POINTERS);
return false;
}
+ BitSet32 pointerIdBits;
for (size_t i = 0; i < pointerCount; i++) {
- if (pointerIds[i] < 0 || pointerIds[i] > MAX_POINTER_ID) {
+ int32_t id = pointerIds[i];
+ if (id < 0 || id > MAX_POINTER_ID) {
LOGE("Motion event has invalid pointer id %d; value must be between 0 and %d",
- pointerIds[i], MAX_POINTER_ID);
+ id, MAX_POINTER_ID);
return false;
}
+ if (pointerIdBits.hasBit(id)) {
+ LOGE("Motion event has duplicate pointer id %d", id);
+ return false;
+ }
+ pointerIdBits.markBit(id);
}
return true;
}