Dump dispatcher state before crashing due to unexpected events
This will help us understand the state of the dispatcher that leads to
the bad conditions.
Bug: 358933243
Test: atest inputflinger_tests
Flag: EXEMPT refactor
Change-Id: I3730f64544b3e8601a3524e2d3f4e3ad0493d199
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index fcea0f3..0384257 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -693,7 +693,8 @@
*/
std::vector<TouchedWindow> getHoveringWindowsLocked(const TouchState* oldState,
const TouchState& newTouchState,
- const MotionEntry& entry) {
+ const MotionEntry& entry,
+ std::function<void()> dump) {
const int32_t maskedAction = MotionEvent::getActionMasked(entry.action);
if (maskedAction == AMOTION_EVENT_ACTION_SCROLL) {
@@ -741,6 +742,7 @@
// crashing the device with FATAL.
severity = android::base::LogSeverity::ERROR;
}
+ dump();
LOG(severity) << "Expected ACTION_HOVER_MOVE instead of " << entry.getDescription();
}
touchedWindow.dispatchMode = InputTarget::DispatchMode::AS_IS;
@@ -2710,7 +2712,8 @@
// Update dispatching for hover enter and exit.
{
std::vector<TouchedWindow> hoveringWindows =
- getHoveringWindowsLocked(oldState, tempTouchState, entry);
+ getHoveringWindowsLocked(oldState, tempTouchState, entry,
+ [this]() REQUIRES(mLock) { logDispatchStateLocked(); });
// Hardcode to single hovering pointer for now.
std::bitset<MAX_POINTER_ID + 1> pointerIds;
pointerIds.set(entry.pointerProperties[0].id);