Loading include/input/Input.h +2 −0 Original line number Diff line number Diff line Loading @@ -251,6 +251,8 @@ enum class InputEventType { TOUCH_MODE = AINPUT_EVENT_TYPE_TOUCH_MODE, ftl_first = KEY, ftl_last = TOUCH_MODE, // Used by LatencyTracker fuzzer kMaxValue = ftl_last }; std::string inputEventSourceToString(int32_t source); Loading services/inputflinger/dispatcher/InputDispatcher.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ #include "Connection.h" #include "DebugConfig.h" #include "InputDispatcher.h" #include "InputEventTimeline.h" #include "trace/InputTracer.h" #include "trace/InputTracingPerfettoBackend.h" #include "trace/ThreadedBackend.h" Loading Loading @@ -4642,10 +4643,9 @@ void InputDispatcher::notifyMotion(const NotifyMotionArgs& args) { if (args.id != android::os::IInputConstants::INVALID_INPUT_EVENT_ID && IdGenerator::getSource(args.id) == IdGenerator::Source::INPUT_READER && !mInputFilterEnabled) { const bool isDown = args.action == AMOTION_EVENT_ACTION_DOWN; std::set<InputDeviceUsageSource> sources = getUsageSourcesForMotionArgs(args); mLatencyTracker.trackListener(args.id, isDown, args.eventTime, args.readTime, args.deviceId, sources); mLatencyTracker.trackListener(args.id, args.eventTime, args.readTime, args.deviceId, sources, args.action, InputEventType::MOTION); } needWake = enqueueInboundEventLocked(std::move(newEntry)); Loading services/inputflinger/dispatcher/InputEventTimeline.cpp +6 −3 Original line number Diff line number Diff line Loading @@ -68,13 +68,15 @@ bool ConnectionTimeline::operator!=(const ConnectionTimeline& rhs) const { InputEventTimeline::InputEventTimeline(bool isDown, nsecs_t eventTime, nsecs_t readTime, uint16_t vendorId, uint16_t productId, const std::set<InputDeviceUsageSource>& sources) const std::set<InputDeviceUsageSource>& sources, InputEventActionType inputEventActionType) : isDown(isDown), eventTime(eventTime), readTime(readTime), vendorId(vendorId), productId(productId), sources(sources) {} sources(sources), inputEventActionType(inputEventActionType) {} bool InputEventTimeline::operator==(const InputEventTimeline& rhs) const { if (connectionTimelines.size() != rhs.connectionTimelines.size()) { Loading @@ -90,7 +92,8 @@ bool InputEventTimeline::operator==(const InputEventTimeline& rhs) const { } } return isDown == rhs.isDown && eventTime == rhs.eventTime && readTime == rhs.readTime && vendorId == rhs.vendorId && productId == rhs.productId && sources == rhs.sources; vendorId == rhs.vendorId && productId == rhs.productId && sources == rhs.sources && inputEventActionType == rhs.inputEventActionType; } } // namespace android::inputdispatcher services/inputflinger/dispatcher/InputEventTimeline.h +25 −1 Original line number Diff line number Diff line Loading @@ -74,15 +74,39 @@ private: bool mHasGraphicsTimeline = false; }; enum class InputEventActionType : int32_t { UNKNOWN_INPUT_EVENT = 0, MOTION_ACTION_DOWN = 1, // Motion events for ACTION_MOVE (characterizes scrolling motion) MOTION_ACTION_MOVE = 2, // Motion events for ACTION_UP (when the pointer first goes up) MOTION_ACTION_UP = 3, // Motion events for ACTION_HOVER_MOVE (pointer position on screen changes but pointer is not // down) MOTION_ACTION_HOVER_MOVE = 4, // Motion events for ACTION_SCROLL (moving the mouse wheel) MOTION_ACTION_SCROLL = 5, // Key events for both ACTION_DOWN and ACTION_UP (key press and key release) KEY = 6, ftl_first = UNKNOWN_INPUT_EVENT, ftl_last = KEY, // Used by latency fuzzer kMaxValue = ftl_last }; struct InputEventTimeline { InputEventTimeline(bool isDown, nsecs_t eventTime, nsecs_t readTime, uint16_t vendorId, uint16_t productId, const std::set<InputDeviceUsageSource>& sources); 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; const uint16_t productId; const std::set<InputDeviceUsageSource> sources; const InputEventActionType inputEventActionType; struct IBinderHash { std::size_t operator()(const sp<IBinder>& b) const { Loading services/inputflinger/dispatcher/LatencyTracker.cpp +39 −4 Original line number Diff line number Diff line Loading @@ -67,9 +67,10 @@ LatencyTracker::LatencyTracker(InputEventTimelineProcessor* processor) LOG_ALWAYS_FATAL_IF(processor == nullptr); } void LatencyTracker::trackListener(int32_t inputEventId, bool isDown, nsecs_t eventTime, nsecs_t readTime, DeviceId deviceId, const std::set<InputDeviceUsageSource>& sources) { void LatencyTracker::trackListener(int32_t inputEventId, nsecs_t eventTime, nsecs_t readTime, DeviceId deviceId, const std::set<InputDeviceUsageSource>& sources, int inputEventAction, InputEventType inputEventType) { reportAndPruneMatureRecords(eventTime); const auto it = mTimelines.find(inputEventId); if (it != mTimelines.end()) { Loading Loading @@ -101,9 +102,43 @@ void LatencyTracker::trackListener(int32_t inputEventId, bool isDown, nsecs_t ev return; } const InputEventActionType inputEventActionType = [&]() { switch (inputEventType) { case InputEventType::MOTION: { switch (inputEventAction) { case AMOTION_EVENT_ACTION_DOWN: return InputEventActionType::MOTION_ACTION_DOWN; case AMOTION_EVENT_ACTION_MOVE: return InputEventActionType::MOTION_ACTION_MOVE; case AMOTION_EVENT_ACTION_UP: return InputEventActionType::MOTION_ACTION_UP; case AMOTION_EVENT_ACTION_HOVER_MOVE: return InputEventActionType::MOTION_ACTION_HOVER_MOVE; case AMOTION_EVENT_ACTION_SCROLL: return InputEventActionType::MOTION_ACTION_SCROLL; default: return InputEventActionType::UNKNOWN_INPUT_EVENT; } } case InputEventType::KEY: { switch (inputEventAction) { case AKEY_EVENT_ACTION_DOWN: case AKEY_EVENT_ACTION_UP: return InputEventActionType::KEY; default: return InputEventActionType::UNKNOWN_INPUT_EVENT; } } default: return InputEventActionType::UNKNOWN_INPUT_EVENT; } }(); bool isDown = inputEventType == InputEventType::MOTION && inputEventAction == AMOTION_EVENT_ACTION_DOWN; mTimelines.emplace(inputEventId, InputEventTimeline(isDown, eventTime, readTime, identifier->vendor, identifier->product, sources)); identifier->product, sources, inputEventActionType)); mEventTimes.emplace(eventTime, inputEventId); } Loading Loading
include/input/Input.h +2 −0 Original line number Diff line number Diff line Loading @@ -251,6 +251,8 @@ enum class InputEventType { TOUCH_MODE = AINPUT_EVENT_TYPE_TOUCH_MODE, ftl_first = KEY, ftl_last = TOUCH_MODE, // Used by LatencyTracker fuzzer kMaxValue = ftl_last }; std::string inputEventSourceToString(int32_t source); Loading
services/inputflinger/dispatcher/InputDispatcher.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ #include "Connection.h" #include "DebugConfig.h" #include "InputDispatcher.h" #include "InputEventTimeline.h" #include "trace/InputTracer.h" #include "trace/InputTracingPerfettoBackend.h" #include "trace/ThreadedBackend.h" Loading Loading @@ -4642,10 +4643,9 @@ void InputDispatcher::notifyMotion(const NotifyMotionArgs& args) { if (args.id != android::os::IInputConstants::INVALID_INPUT_EVENT_ID && IdGenerator::getSource(args.id) == IdGenerator::Source::INPUT_READER && !mInputFilterEnabled) { const bool isDown = args.action == AMOTION_EVENT_ACTION_DOWN; std::set<InputDeviceUsageSource> sources = getUsageSourcesForMotionArgs(args); mLatencyTracker.trackListener(args.id, isDown, args.eventTime, args.readTime, args.deviceId, sources); mLatencyTracker.trackListener(args.id, args.eventTime, args.readTime, args.deviceId, sources, args.action, InputEventType::MOTION); } needWake = enqueueInboundEventLocked(std::move(newEntry)); Loading
services/inputflinger/dispatcher/InputEventTimeline.cpp +6 −3 Original line number Diff line number Diff line Loading @@ -68,13 +68,15 @@ bool ConnectionTimeline::operator!=(const ConnectionTimeline& rhs) const { InputEventTimeline::InputEventTimeline(bool isDown, nsecs_t eventTime, nsecs_t readTime, uint16_t vendorId, uint16_t productId, const std::set<InputDeviceUsageSource>& sources) const std::set<InputDeviceUsageSource>& sources, InputEventActionType inputEventActionType) : isDown(isDown), eventTime(eventTime), readTime(readTime), vendorId(vendorId), productId(productId), sources(sources) {} sources(sources), inputEventActionType(inputEventActionType) {} bool InputEventTimeline::operator==(const InputEventTimeline& rhs) const { if (connectionTimelines.size() != rhs.connectionTimelines.size()) { Loading @@ -90,7 +92,8 @@ bool InputEventTimeline::operator==(const InputEventTimeline& rhs) const { } } return isDown == rhs.isDown && eventTime == rhs.eventTime && readTime == rhs.readTime && vendorId == rhs.vendorId && productId == rhs.productId && sources == rhs.sources; vendorId == rhs.vendorId && productId == rhs.productId && sources == rhs.sources && inputEventActionType == rhs.inputEventActionType; } } // namespace android::inputdispatcher
services/inputflinger/dispatcher/InputEventTimeline.h +25 −1 Original line number Diff line number Diff line Loading @@ -74,15 +74,39 @@ private: bool mHasGraphicsTimeline = false; }; enum class InputEventActionType : int32_t { UNKNOWN_INPUT_EVENT = 0, MOTION_ACTION_DOWN = 1, // Motion events for ACTION_MOVE (characterizes scrolling motion) MOTION_ACTION_MOVE = 2, // Motion events for ACTION_UP (when the pointer first goes up) MOTION_ACTION_UP = 3, // Motion events for ACTION_HOVER_MOVE (pointer position on screen changes but pointer is not // down) MOTION_ACTION_HOVER_MOVE = 4, // Motion events for ACTION_SCROLL (moving the mouse wheel) MOTION_ACTION_SCROLL = 5, // Key events for both ACTION_DOWN and ACTION_UP (key press and key release) KEY = 6, ftl_first = UNKNOWN_INPUT_EVENT, ftl_last = KEY, // Used by latency fuzzer kMaxValue = ftl_last }; struct InputEventTimeline { InputEventTimeline(bool isDown, nsecs_t eventTime, nsecs_t readTime, uint16_t vendorId, uint16_t productId, const std::set<InputDeviceUsageSource>& sources); 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; const uint16_t productId; const std::set<InputDeviceUsageSource> sources; const InputEventActionType inputEventActionType; struct IBinderHash { std::size_t operator()(const sp<IBinder>& b) const { Loading
services/inputflinger/dispatcher/LatencyTracker.cpp +39 −4 Original line number Diff line number Diff line Loading @@ -67,9 +67,10 @@ LatencyTracker::LatencyTracker(InputEventTimelineProcessor* processor) LOG_ALWAYS_FATAL_IF(processor == nullptr); } void LatencyTracker::trackListener(int32_t inputEventId, bool isDown, nsecs_t eventTime, nsecs_t readTime, DeviceId deviceId, const std::set<InputDeviceUsageSource>& sources) { void LatencyTracker::trackListener(int32_t inputEventId, nsecs_t eventTime, nsecs_t readTime, DeviceId deviceId, const std::set<InputDeviceUsageSource>& sources, int inputEventAction, InputEventType inputEventType) { reportAndPruneMatureRecords(eventTime); const auto it = mTimelines.find(inputEventId); if (it != mTimelines.end()) { Loading Loading @@ -101,9 +102,43 @@ void LatencyTracker::trackListener(int32_t inputEventId, bool isDown, nsecs_t ev return; } const InputEventActionType inputEventActionType = [&]() { switch (inputEventType) { case InputEventType::MOTION: { switch (inputEventAction) { case AMOTION_EVENT_ACTION_DOWN: return InputEventActionType::MOTION_ACTION_DOWN; case AMOTION_EVENT_ACTION_MOVE: return InputEventActionType::MOTION_ACTION_MOVE; case AMOTION_EVENT_ACTION_UP: return InputEventActionType::MOTION_ACTION_UP; case AMOTION_EVENT_ACTION_HOVER_MOVE: return InputEventActionType::MOTION_ACTION_HOVER_MOVE; case AMOTION_EVENT_ACTION_SCROLL: return InputEventActionType::MOTION_ACTION_SCROLL; default: return InputEventActionType::UNKNOWN_INPUT_EVENT; } } case InputEventType::KEY: { switch (inputEventAction) { case AKEY_EVENT_ACTION_DOWN: case AKEY_EVENT_ACTION_UP: return InputEventActionType::KEY; default: return InputEventActionType::UNKNOWN_INPUT_EVENT; } } default: return InputEventActionType::UNKNOWN_INPUT_EVENT; } }(); bool isDown = inputEventType == InputEventType::MOTION && inputEventAction == AMOTION_EVENT_ACTION_DOWN; mTimelines.emplace(inputEventId, InputEventTimeline(isDown, eventTime, readTime, identifier->vendor, identifier->product, sources)); identifier->product, sources, inputEventActionType)); mEventTimes.emplace(eventTime, inputEventId); } Loading