Skip to content

Commit 12c5cc4

Browse files
Asmita PoddarAndroid (Google) Code Review
authored andcommitted
Merge "Add scroll latency metrics" into main
2 parents 9c99cc1 + de86b13 commit 12c5cc4

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

services/inputflinger/dispatcher/LatencyAggregatorWithHistograms.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,11 @@ void LatencyAggregatorWithHistograms::addSampleToHistogram(
133133
}
134134

135135
void LatencyAggregatorWithHistograms::processStatistics(const InputEventTimeline& timeline) {
136-
// Only gather data for Down, Move and Up motion events and Key events
136+
// Only gather data for Down, Move, Up and Scroll motion events and Key events
137137
if (!(timeline.inputEventActionType == InputEventActionType::MOTION_ACTION_DOWN ||
138138
timeline.inputEventActionType == InputEventActionType::MOTION_ACTION_MOVE ||
139139
timeline.inputEventActionType == InputEventActionType::MOTION_ACTION_UP ||
140+
timeline.inputEventActionType == InputEventActionType::MOTION_ACTION_SCROLL ||
140141
timeline.inputEventActionType == InputEventActionType::KEY))
141142
return;
142143

services/inputflinger/tests/LatencyTracker_test.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ void setDefaultInputDeviceInfo(LatencyTracker& tracker) {
5757
}
5858

5959
const auto FIRST_TOUCH_POINTER = PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(200);
60+
const auto FIRST_MOUSE_POINTER = PointerBuilder(/*id=*/1, ToolType::MOUSE);
6061

6162
/**
6263
* This is a convenience method for comparing timelines that also prints the difference between
@@ -491,8 +492,13 @@ TEST_F(LatencyTrackerTest, TrackListenerCheck_InputEventActionTypeFieldInputEven
491492
/*vendorId*/ 0, /*productId*/ 0, {InputDeviceUsageSource::BUTTONS},
492493
InputEventActionType::KEY);
493494

494-
InputEventTimeline unknownTimeline(
495+
InputEventTimeline motionScrollTimeline(
495496
/*eventTime*/ 12, /*readTime*/ 13,
497+
/*vendorId*/ 0, /*productId*/ 0, {InputDeviceUsageSource::MOUSE},
498+
InputEventActionType::MOTION_ACTION_SCROLL);
499+
500+
InputEventTimeline unknownTimeline(
501+
/*eventTime*/ 14, /*readTime*/ 15,
496502
/*vendorId*/ 0, /*productId*/ 0, {InputDeviceUsageSource::TOUCHSCREEN},
497503
InputEventActionType::UNKNOWN_INPUT_EVENT);
498504

@@ -529,8 +535,15 @@ TEST_F(LatencyTrackerTest, TrackListenerCheck_InputEventActionTypeFieldInputEven
529535
.readTime(keyUpTimeline.readTime)
530536
.deviceId(DEVICE_ID)
531537
.build());
538+
mTracker->trackListener(
539+
MotionArgsBuilder(AMOTION_EVENT_ACTION_SCROLL, AINPUT_SOURCE_MOUSE, inputEventId + 5)
540+
.eventTime(motionScrollTimeline.eventTime)
541+
.readTime(motionScrollTimeline.readTime)
542+
.deviceId(DEVICE_ID)
543+
.pointer(FIRST_MOUSE_POINTER)
544+
.build());
532545
mTracker->trackListener(MotionArgsBuilder(AMOTION_EVENT_ACTION_POINTER_DOWN,
533-
AINPUT_SOURCE_TOUCHSCREEN, inputEventId + 5)
546+
AINPUT_SOURCE_TOUCHSCREEN, inputEventId + 6)
534547
.eventTime(unknownTimeline.eventTime)
535548
.readTime(unknownTimeline.readTime)
536549
.deviceId(DEVICE_ID)
@@ -541,7 +554,8 @@ TEST_F(LatencyTrackerTest, TrackListenerCheck_InputEventActionTypeFieldInputEven
541554

542555
std::vector<InputEventTimeline> expectedTimelines = {motionDownTimeline, motionMoveTimeline,
543556
motionUpTimeline, keyDownTimeline,
544-
keyUpTimeline, unknownTimeline};
557+
keyUpTimeline, motionScrollTimeline,
558+
unknownTimeline};
545559
assertReceivedTimelines(expectedTimelines);
546560
}
547561

0 commit comments

Comments
 (0)