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
diff --git a/services/inputflinger/dispatcher/InputEventTimeline.cpp b/services/inputflinger/dispatcher/InputEventTimeline.cpp
index 31ceb8d..6881964 100644
--- a/services/inputflinger/dispatcher/InputEventTimeline.cpp
+++ b/services/inputflinger/dispatcher/InputEventTimeline.cpp
@@ -66,12 +66,11 @@
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 @@
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;
}
diff --git a/services/inputflinger/dispatcher/InputEventTimeline.h b/services/inputflinger/dispatcher/InputEventTimeline.h
index 6668399..951fcc8 100644
--- a/services/inputflinger/dispatcher/InputEventTimeline.h
+++ b/services/inputflinger/dispatcher/InputEventTimeline.h
@@ -97,10 +97,9 @@
};
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;
diff --git a/services/inputflinger/dispatcher/LatencyAggregator.cpp b/services/inputflinger/dispatcher/LatencyAggregator.cpp
index e09d97a..4ddd2e9 100644
--- a/services/inputflinger/dispatcher/LatencyAggregator.cpp
+++ b/services/inputflinger/dispatcher/LatencyAggregator.cpp
@@ -134,7 +134,9 @@
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 @@
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)),
diff --git a/services/inputflinger/dispatcher/LatencyTracker.cpp b/services/inputflinger/dispatcher/LatencyTracker.cpp
index 721d009..69024b3 100644
--- a/services/inputflinger/dispatcher/LatencyTracker.cpp
+++ b/services/inputflinger/dispatcher/LatencyTracker.cpp
@@ -70,7 +70,7 @@
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 @@
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 @@
}
}();
- 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);
}
diff --git a/services/inputflinger/dispatcher/LatencyTracker.h b/services/inputflinger/dispatcher/LatencyTracker.h
index 532f422..b4053ba 100644
--- a/services/inputflinger/dispatcher/LatencyTracker.h
+++ b/services/inputflinger/dispatcher/LatencyTracker.h
@@ -53,7 +53,7 @@
* 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);