Generate HOVER_EXIT if touchable region changes
The dispatcher crashes whenever we try adding pointers to a target,
but the target already had those pointers under a different mode.
Only one dispatch mode is allowed for each event, per target.
That's generally true, but there were instances where we ended up
with multiple dispatch modes for the same event.
For example, if a window changes bounds (for example, becomes hidden, or
the touchable region shrinks), the pointer would no longer be inside
that window. And if this window is also watching for outside touch,
then an ACTION_DOWN event of the mouse would cause 2 things to happen:
1) This would cause HOVER_EXIT, since the pointer is no longer in that
window
2) This would case ACTION_OUTSIDE, since the pointer is tapped outside
of the window's bounds.
This previously led to a crash in dispatcher because there would be two
different dispatch modes for the same window for the same ACTION_DOWN
event.
Update being done here:
When a window resizes, it's possible that the hovering pointer is no
longer inside that window's bounds. We should generate a HOVER_EXIT
event at that point; this will ensure that the next mouse event is still
maintaining the contract that it's only dispatched with a single mode.
Bug: 346121425
Test: TEST=inputflinger_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST --gtest_filter="*MouseClickUnderShrinkingTrustedOverlay"
Flag: EXEMPT bugfix
Change-Id: Ia5e5ac0421b127231d36ed375538eaebfb8994ac
diff --git a/services/inputflinger/dispatcher/InputState.cpp b/services/inputflinger/dispatcher/InputState.cpp
index 4df23c5..9b5a79b 100644
--- a/services/inputflinger/dispatcher/InputState.cpp
+++ b/services/inputflinger/dispatcher/InputState.cpp
@@ -638,6 +638,8 @@
return memento.source & AINPUT_SOURCE_CLASS_POINTER;
case CancelationOptions::Mode::CANCEL_NON_POINTER_EVENTS:
return !(memento.source & AINPUT_SOURCE_CLASS_POINTER);
+ case CancelationOptions::Mode::CANCEL_HOVER_EVENTS:
+ return memento.hovering;
default:
return false;
}