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

Commit 97cc8ac0 authored by jioana's avatar jioana Committed by Ioana Jianu
Browse files

InputEventTimeline field fixes

Small fixes and removed isDown field from InputEventTimeline.
Modified LatencyAggregator to use inputEventActionType instead of isDown to distinguish between down and other types of motion events.

Bug: 270049345
Test: atest inputflinger_tests
Flag: EXEMPT bugfix
Change-Id: I3d0fd64baf7b3b5df412cfbd0525818667135b1c
parent 0984bd2d
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -66,12 +66,11 @@ bool ConnectionTimeline::operator!=(const ConnectionTimeline& rhs) const {
    return !operator==(rhs);
}

InputEventTimeline::InputEventTimeline(bool isDown, nsecs_t eventTime, nsecs_t readTime,
                                       uint16_t vendorId, uint16_t productId,
InputEventTimeline::InputEventTimeline(nsecs_t eventTime, nsecs_t readTime, uint16_t vendorId,
                                       uint16_t productId,
                                       const std::set<InputDeviceUsageSource>& sources,
                                       InputEventActionType inputEventActionType)
      : isDown(isDown),
        eventTime(eventTime),
      : eventTime(eventTime),
        readTime(readTime),
        vendorId(vendorId),
        productId(productId),
@@ -91,8 +90,8 @@ bool InputEventTimeline::operator==(const InputEventTimeline& rhs) const {
            return false;
        }
    }
    return isDown == rhs.isDown && eventTime == rhs.eventTime && readTime == rhs.readTime &&
            vendorId == rhs.vendorId && productId == rhs.productId && sources == rhs.sources &&
    return eventTime == rhs.eventTime && readTime == rhs.readTime && vendorId == rhs.vendorId &&
            productId == rhs.productId && sources == rhs.sources &&
            inputEventActionType == rhs.inputEventActionType;
}

+2 −3
Original line number Diff line number Diff line
@@ -97,10 +97,9 @@ enum class InputEventActionType : int32_t {
};

struct InputEventTimeline {
    InputEventTimeline(bool isDown, nsecs_t eventTime, nsecs_t readTime, uint16_t vendorId,
                       uint16_t productId, const std::set<InputDeviceUsageSource>& sources,
    InputEventTimeline(nsecs_t eventTime, nsecs_t readTime, uint16_t vendorId, uint16_t productId,
                       const std::set<InputDeviceUsageSource>& sources,
                       InputEventActionType inputEventActionType);
    const bool isDown; // True if this is an ACTION_DOWN event
    const nsecs_t eventTime;
    const nsecs_t readTime;
    const uint16_t vendorId;
+6 −2
Original line number Diff line number Diff line
@@ -134,7 +134,9 @@ void LatencyAggregator::processStatistics(const InputEventTimeline& timeline) {
    mNumSketchEventsProcessed++;

    std::array<std::unique_ptr<KllQuantile>, SketchIndex::SIZE>& sketches =
            timeline.isDown ? mDownSketches : mMoveSketches;
            timeline.inputEventActionType == InputEventActionType::MOTION_ACTION_DOWN
            ? mDownSketches
            : mMoveSketches;

    // Process common ones first
    const nsecs_t eventToRead = timeline.readTime - timeline.eventTime;
@@ -242,7 +244,9 @@ void LatencyAggregator::processSlowEvent(const InputEventTimeline& timeline) {
        const nsecs_t consumeToGpuComplete = gpuCompletedTime - connectionTimeline.consumeTime;
        const nsecs_t gpuCompleteToPresent = presentTime - gpuCompletedTime;

        android::util::stats_write(android::util::SLOW_INPUT_EVENT_REPORTED, timeline.isDown,
        android::util::stats_write(android::util::SLOW_INPUT_EVENT_REPORTED,
                                   timeline.inputEventActionType ==
                                           InputEventActionType::MOTION_ACTION_DOWN,
                                   static_cast<int32_t>(ns2us(eventToRead)),
                                   static_cast<int32_t>(ns2us(readToDeliver)),
                                   static_cast<int32_t>(ns2us(deliverToConsume)),
+3 −5
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ LatencyTracker::LatencyTracker(InputEventTimelineProcessor* processor)
void LatencyTracker::trackListener(int32_t inputEventId, nsecs_t eventTime, nsecs_t readTime,
                                   DeviceId deviceId,
                                   const std::set<InputDeviceUsageSource>& sources,
                                   int inputEventAction, InputEventType inputEventType) {
                                   int32_t inputEventAction, InputEventType inputEventType) {
    reportAndPruneMatureRecords(eventTime);
    const auto it = mTimelines.find(inputEventId);
    if (it != mTimelines.end()) {
@@ -105,7 +105,7 @@ void LatencyTracker::trackListener(int32_t inputEventId, nsecs_t eventTime, nsec
    const InputEventActionType inputEventActionType = [&]() {
        switch (inputEventType) {
            case InputEventType::MOTION: {
                switch (inputEventAction) {
                switch (MotionEvent::getActionMasked(inputEventAction)) {
                    case AMOTION_EVENT_ACTION_DOWN:
                        return InputEventActionType::MOTION_ACTION_DOWN;
                    case AMOTION_EVENT_ACTION_MOVE:
@@ -134,10 +134,8 @@ void LatencyTracker::trackListener(int32_t inputEventId, nsecs_t eventTime, nsec
        }
    }();

    bool isDown = inputEventType == InputEventType::MOTION &&
            inputEventAction == AMOTION_EVENT_ACTION_DOWN;
    mTimelines.emplace(inputEventId,
                       InputEventTimeline(isDown, eventTime, readTime, identifier->vendor,
                       InputEventTimeline(eventTime, readTime, identifier->vendor,
                                          identifier->product, sources, inputEventActionType));
    mEventTimes.emplace(eventTime, inputEventId);
}
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ public:
     * must drop all duplicate data.
     */
    void trackListener(int32_t inputEventId, nsecs_t eventTime, nsecs_t readTime, DeviceId deviceId,
                       const std::set<InputDeviceUsageSource>& sources, int inputEventActionType,
                       const std::set<InputDeviceUsageSource>& sources, int32_t inputEventAction,
                       InputEventType inputEventType);
    void trackFinishedEvent(int32_t inputEventId, const sp<IBinder>& connectionToken,
                            nsecs_t deliveryTime, nsecs_t consumeTime, nsecs_t finishTime);
Loading