Ignore hover events while pointers are already down
If pointers are already down from another device, finish the current
gesture and ignore events from other devices.
When multi-device support is enabled, we can remove this restriction.
Bug: 268538505
Test: m inputflinger_tests && $ANDROID_HOST_OUT/nativetest64/inputflinger_tests/inputflinger_tests
Change-Id: I6419b6d118760d285457bc9e5127e055f21ecf7f
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 079b80d..fd24249 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -2185,8 +2185,9 @@
const bool isFromMouse = isFromSource(entry.source, AINPUT_SOURCE_MOUSE);
if (newGesture) {
- bool down = maskedAction == AMOTION_EVENT_ACTION_DOWN;
- if (switchedDevice && tempTouchState.isDown() && !down && !isHoverAction) {
+ // If pointers are already down, let's finish the current gesture and ignore the new events
+ // from another device.
+ if (switchedDevice && wasDown) {
ALOGI("Dropping event because a pointer for a different device is already down "
"in display %" PRId32,
displayId);
@@ -3761,9 +3762,9 @@
}
if (DEBUG_OUTBOUND_EVENT_DETAILS) {
ALOGD("channel '%s' ~ Synthesized %zu cancelation events to bring channel back in sync "
- "with reality: %s, mode=%d.",
+ "with reality: %s, mode=%s.",
connection->getInputChannelName().c_str(), cancelationEvents.size(), options.reason,
- options.mode);
+ ftl::enum_string(options.mode).c_str());
}
std::string reason = std::string("reason=").append(options.reason);