Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit de86b13a authored by Asmita Poddar's avatar Asmita Poddar
Browse files

Add scroll latency metrics

Latency metrics will be logged for scroll events

Bug: 365020224
Flag: EXEMPT bugfix
Test: atest inputflinger_tests:LatencyTrackerTest
Change-Id: I3882e7cb6deac5862eee52a0edade3fd83cc009f
parent 978e6f32
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -133,10 +133,11 @@ void LatencyAggregatorWithHistograms::addSampleToHistogram(
}

void LatencyAggregatorWithHistograms::processStatistics(const InputEventTimeline& timeline) {
    // Only gather data for Down, Move and Up motion events and Key events
    // Only gather data for Down, Move, Up and Scroll motion events and Key events
    if (!(timeline.inputEventActionType == InputEventActionType::MOTION_ACTION_DOWN ||
          timeline.inputEventActionType == InputEventActionType::MOTION_ACTION_MOVE ||
          timeline.inputEventActionType == InputEventActionType::MOTION_ACTION_UP ||
          timeline.inputEventActionType == InputEventActionType::MOTION_ACTION_SCROLL ||
          timeline.inputEventActionType == InputEventActionType::KEY))
        return;

+17 −3
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ void setDefaultInputDeviceInfo(LatencyTracker& tracker) {
}

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

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

    InputEventTimeline unknownTimeline(
    InputEventTimeline motionScrollTimeline(
            /*eventTime*/ 12, /*readTime*/ 13,
            /*vendorId*/ 0, /*productId*/ 0, {InputDeviceUsageSource::MOUSE},
            InputEventActionType::MOTION_ACTION_SCROLL);

    InputEventTimeline unknownTimeline(
            /*eventTime*/ 14, /*readTime*/ 15,
            /*vendorId*/ 0, /*productId*/ 0, {InputDeviceUsageSource::TOUCHSCREEN},
            InputEventActionType::UNKNOWN_INPUT_EVENT);

@@ -529,8 +535,15 @@ TEST_F(LatencyTrackerTest, TrackListenerCheck_InputEventActionTypeFieldInputEven
                    .readTime(keyUpTimeline.readTime)
                    .deviceId(DEVICE_ID)
                    .build());
    mTracker->trackListener(
            MotionArgsBuilder(AMOTION_EVENT_ACTION_SCROLL, AINPUT_SOURCE_MOUSE, inputEventId + 5)
                    .eventTime(motionScrollTimeline.eventTime)
                    .readTime(motionScrollTimeline.readTime)
                    .deviceId(DEVICE_ID)
                    .pointer(FIRST_MOUSE_POINTER)
                    .build());
    mTracker->trackListener(MotionArgsBuilder(AMOTION_EVENT_ACTION_POINTER_DOWN,
                                              AINPUT_SOURCE_TOUCHSCREEN, inputEventId + 5)
                                              AINPUT_SOURCE_TOUCHSCREEN, inputEventId + 6)
                                    .eventTime(unknownTimeline.eventTime)
                                    .readTime(unknownTimeline.readTime)
                                    .deviceId(DEVICE_ID)
@@ -541,7 +554,8 @@ TEST_F(LatencyTrackerTest, TrackListenerCheck_InputEventActionTypeFieldInputEven

    std::vector<InputEventTimeline> expectedTimelines = {motionDownTimeline, motionMoveTimeline,
                                                         motionUpTimeline,   keyDownTimeline,
                                                         keyUpTimeline,      unknownTimeline};
                                                         keyUpTimeline,      motionScrollTimeline,
                                                         unknownTimeline};
    assertReceivedTimelines(expectedTimelines);
}