From 93ee540fcf178c7a852841e861ff10d704cb5f71 Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Wed, 9 Oct 2024 00:07:23 +0000 Subject: Use a single trackListener method in LatencyTracker This simplifies the code for the caller (InputDispatcher) and reduces the API surface of LatencyTracker. Bug: 270049345 Change-Id: Ia25e95a24b5e89abcfce8060893ec3cce0c7892e Flag: EXEMPT refactor Test: atest inputflinger_tests --- services/inputflinger/InputDeviceMetricsSource.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'services/inputflinger/InputDeviceMetricsSource.cpp') diff --git a/services/inputflinger/InputDeviceMetricsSource.cpp b/services/inputflinger/InputDeviceMetricsSource.cpp index dee4cb836e..70262fbb04 100644 --- a/services/inputflinger/InputDeviceMetricsSource.cpp +++ b/services/inputflinger/InputDeviceMetricsSource.cpp @@ -50,6 +50,18 @@ InputDeviceUsageSource getUsageSourceForKeyArgs(int32_t keyboardType, return InputDeviceUsageSource::BUTTONS; } +std::set getUsageSourcesForKeyArgs( + const NotifyKeyArgs& args, const std::vector& inputDevices) { + int32_t keyboardType = AINPUT_KEYBOARD_TYPE_NONE; + for (const InputDeviceInfo& inputDevice : inputDevices) { + if (args.deviceId == inputDevice.getId()) { + keyboardType = inputDevice.getKeyboardType(); + break; + } + } + return std::set{getUsageSourceForKeyArgs(keyboardType, args)}; +} + std::set getUsageSourcesForMotionArgs(const NotifyMotionArgs& motionArgs) { LOG_ALWAYS_FATAL_IF(motionArgs.getPointerCount() < 1, "Received motion args without pointers"); std::set sources; -- cgit v1.2.3-59-g8ed1b