diff options
author | 2025-03-18 16:06:01 +0000 | |
---|---|---|
committer | 2025-03-18 19:30:05 +0000 | |
commit | 9c3b9340fa177cfb5d9a1a498b9a278402d0a19a (patch) | |
tree | 28cc4deba1355edbb3e3d4d381b5815bda465496 | |
parent | 6b3c3bdab9c04da69e10ce4ddf6fe15d62cbc434 (diff) |
TouchpadInputMapper: dedup successive swipe lift gestures in metrics
In tests, the Gestures library occasionally outputs two lift gestures in
a row, which can cause inaccurate metrics reporting. To work around
this, keep track of the previous gesture the metrics collector saw, and
don't report additional swipe gestures if we see multiple lifts in a
row.
Bug: 397219482
Test: $ atest \
CtsInputHostTestCases:android.input.cts.hostside.InputAtomsTest
Flag: TEST_ONLY
Change-Id: Iac2b6ae68dc62e3a106a743b667eddd96a1a7a74
-rw-r--r-- | services/inputflinger/reader/mapper/TouchpadInputMapper.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp index c982dab019..63eb357bdb 100644 --- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp +++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp @@ -144,28 +144,39 @@ public: // records it if so. void processGesture(const TouchpadInputMapper::MetricsIdentifier& id, const Gesture& gesture) { std::scoped_lock lock(mLock); + Counters& counters = mCounters[id]; switch (gesture.type) { case kGestureTypeFling: if (gesture.details.fling.fling_state == GESTURES_FLING_START) { // Indicates the end of a two-finger scroll gesture. - mCounters[id].twoFingerSwipeGestures++; + counters.twoFingerSwipeGestures++; } break; case kGestureTypeSwipeLift: - mCounters[id].threeFingerSwipeGestures++; + // The Gestures library occasionally outputs two lift gestures in a row, which can + // cause inaccurate metrics reporting. To work around this, deduplicate successive + // lift gestures. + // TODO(b/404529050): fix the Gestures library, and remove this check. + if (counters.lastGestureType != kGestureTypeSwipeLift) { + counters.threeFingerSwipeGestures++; + } break; case kGestureTypeFourFingerSwipeLift: - mCounters[id].fourFingerSwipeGestures++; + // TODO(b/404529050): fix the Gestures library, and remove this check. + if (counters.lastGestureType != kGestureTypeFourFingerSwipeLift) { + counters.fourFingerSwipeGestures++; + } break; case kGestureTypePinch: if (gesture.details.pinch.zoom_state == GESTURES_ZOOM_END) { - mCounters[id].pinchGestures++; + counters.pinchGestures++; } break; default: // We're not interested in any other gestures. break; } + counters.lastGestureType = gesture.type; } private: @@ -214,6 +225,10 @@ private: int32_t threeFingerSwipeGestures = 0; int32_t fourFingerSwipeGestures = 0; int32_t pinchGestures = 0; + + // Records the last type of gesture received for this device, for deduplication purposes. + // TODO(b/404529050): fix the Gestures library and remove this field. + GestureType lastGestureType = kGestureTypeContactInitiated; }; // Metrics are aggregated by device model and version, so if two devices of the same model and |