Prevent processing touch after receiving an invalid tracking id
Touch driver would send an INVALID_TRACKING_ID value when touch
released from touch screen. That tells input framework should send an
up or pointer up event and stop processing the pointer, so if any
unexpected data is also updating from driver side, we have to prevent
it becomes as a valid pointer.
Bug: 190460965
Bug: 190144579
Bug: 190860244
Bug: 188375341
Test: atest inputflingger_tests
Change-Id: Iee15ab7f7edd19f0cfe1ee27dcaf17c301e8f780
diff --git a/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp b/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp
index ca43123..fab7f4c 100644
--- a/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp
@@ -104,36 +104,37 @@
#endif
} else {
Slot* slot = &mSlots[mCurrentSlot];
+ // If mUsingSlotsProtocol is true, it means the raw pointer has axis info of
+ // ABS_MT_TRACKING_ID and ABS_MT_SLOT, so driver should send a valid trackingId while
+ // updating the slot.
+ if (!mUsingSlotsProtocol) {
+ slot->mInUse = true;
+ }
switch (rawEvent->code) {
case ABS_MT_POSITION_X:
- slot->mInUse = true;
slot->mAbsMTPositionX = rawEvent->value;
+ warnIfNotInUse(*rawEvent, *slot);
break;
case ABS_MT_POSITION_Y:
- slot->mInUse = true;
slot->mAbsMTPositionY = rawEvent->value;
+ warnIfNotInUse(*rawEvent, *slot);
break;
case ABS_MT_TOUCH_MAJOR:
- slot->mInUse = true;
slot->mAbsMTTouchMajor = rawEvent->value;
break;
case ABS_MT_TOUCH_MINOR:
- slot->mInUse = true;
slot->mAbsMTTouchMinor = rawEvent->value;
slot->mHaveAbsMTTouchMinor = true;
break;
case ABS_MT_WIDTH_MAJOR:
- slot->mInUse = true;
slot->mAbsMTWidthMajor = rawEvent->value;
break;
case ABS_MT_WIDTH_MINOR:
- slot->mInUse = true;
slot->mAbsMTWidthMinor = rawEvent->value;
slot->mHaveAbsMTWidthMinor = true;
break;
case ABS_MT_ORIENTATION:
- slot->mInUse = true;
slot->mAbsMTOrientation = rawEvent->value;
break;
case ABS_MT_TRACKING_ID:
@@ -147,15 +148,12 @@
}
break;
case ABS_MT_PRESSURE:
- slot->mInUse = true;
slot->mAbsMTPressure = rawEvent->value;
break;
case ABS_MT_DISTANCE:
- slot->mInUse = true;
slot->mAbsMTDistance = rawEvent->value;
break;
case ABS_MT_TOOL_TYPE:
- slot->mInUse = true;
slot->mAbsMTToolType = rawEvent->value;
slot->mHaveAbsMTToolType = true;
break;
@@ -177,6 +175,13 @@
return mHaveStylus;
}
+void MultiTouchMotionAccumulator::warnIfNotInUse(const RawEvent& event, const Slot& slot) {
+ if (!slot.mInUse) {
+ ALOGW("Received unexpected event (0x%0x, 0x%0x) for slot %i with tracking id %i",
+ event.code, event.value, mCurrentSlot, slot.mAbsMTTrackingId);
+ }
+}
+
// --- MultiTouchMotionAccumulator::Slot ---
MultiTouchMotionAccumulator::Slot::Slot() {