@@ -144,28 +144,39 @@ class MetricsAccumulator {
144144 // records it if so.
145145 void processGesture (const TouchpadInputMapper::MetricsIdentifier& id, const Gesture& gesture) {
146146 std::scoped_lock lock (mLock );
147+ Counters& counters = mCounters [id];
147148 switch (gesture.type ) {
148149 case kGestureTypeFling :
149150 if (gesture.details .fling .fling_state == GESTURES_FLING_START) {
150151 // Indicates the end of a two-finger scroll gesture.
151- mCounters [id] .twoFingerSwipeGestures ++;
152+ counters .twoFingerSwipeGestures ++;
152153 }
153154 break ;
154155 case kGestureTypeSwipeLift :
155- mCounters [id].threeFingerSwipeGestures ++;
156+ // The Gestures library occasionally outputs two lift gestures in a row, which can
157+ // cause inaccurate metrics reporting. To work around this, deduplicate successive
158+ // lift gestures.
159+ // TODO(b/404529050): fix the Gestures library, and remove this check.
160+ if (counters.lastGestureType != kGestureTypeSwipeLift ) {
161+ counters.threeFingerSwipeGestures ++;
162+ }
156163 break ;
157164 case kGestureTypeFourFingerSwipeLift :
158- mCounters [id].fourFingerSwipeGestures ++;
165+ // TODO(b/404529050): fix the Gestures library, and remove this check.
166+ if (counters.lastGestureType != kGestureTypeFourFingerSwipeLift ) {
167+ counters.fourFingerSwipeGestures ++;
168+ }
159169 break ;
160170 case kGestureTypePinch :
161171 if (gesture.details .pinch .zoom_state == GESTURES_ZOOM_END) {
162- mCounters [id] .pinchGestures ++;
172+ counters .pinchGestures ++;
163173 }
164174 break ;
165175 default :
166176 // We're not interested in any other gestures.
167177 break ;
168178 }
179+ counters.lastGestureType = gesture.type ;
169180 }
170181
171182private:
@@ -214,6 +225,10 @@ class MetricsAccumulator {
214225 int32_t threeFingerSwipeGestures = 0 ;
215226 int32_t fourFingerSwipeGestures = 0 ;
216227 int32_t pinchGestures = 0 ;
228+
229+ // Records the last type of gesture received for this device, for deduplication purposes.
230+ // TODO(b/404529050): fix the Gestures library and remove this field.
231+ GestureType lastGestureType = kGestureTypeContactInitiated ;
217232 };
218233
219234 // Metrics are aggregated by device model and version, so if two devices of the same model and
0 commit comments