1 /*
2 * Copyright 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "../Macros.h"
18
19 #include <algorithm>
20 #include <chrono>
21 #include <iterator>
22 #include <limits>
23 #include <map>
24 #include <mutex>
25 #include <optional>
26
27 #include <android-base/logging.h>
28 #include <android-base/stringprintf.h>
29 #include <android-base/thread_annotations.h>
30 #include <android/input.h>
31 #include <com_android_input_flags.h>
32 #include <ftl/enum.h>
33 #include <input/AccelerationCurve.h>
34 #include <input/PrintTools.h>
35 #include <linux/input-event-codes.h>
36 #include <log/log_main.h>
37 #include <stats_pull_atom_callback.h>
38 #include <statslog.h>
39 #include "InputReaderBase.h"
40 #include "TouchCursorInputMapperCommon.h"
41 #include "TouchpadInputMapper.h"
42 #include "gestures/HardwareProperties.h"
43 #include "gestures/TimerProvider.h"
44 #include "ui/Rotation.h"
45
46 namespace input_flags = com::android::input::flags;
47
48 namespace android {
49
50 namespace {
51
52 /**
53 * Log details of each gesture output by the gestures library.
54 * Enable this via "adb shell setprop log.tag.TouchpadInputMapperGestures DEBUG" (requires
55 * restarting the shell)
56 */
57 const bool DEBUG_TOUCHPAD_GESTURES =
58 __android_log_is_loggable(ANDROID_LOG_DEBUG, "TouchpadInputMapperGestures",
59 ANDROID_LOG_INFO);
60
createAccelerationCurveForSensitivity(int32_t sensitivity,size_t propertySize)61 std::vector<double> createAccelerationCurveForSensitivity(int32_t sensitivity,
62 size_t propertySize) {
63 std::vector<AccelerationCurveSegment> segments =
64 createAccelerationCurveForPointerSensitivity(sensitivity);
65 LOG_ALWAYS_FATAL_IF(propertySize < 4 * segments.size());
66 std::vector<double> output(propertySize, 0);
67
68 // The Gestures library uses functions of the following form to define curve segments, where a,
69 // b, and c can be specified by us:
70 // output_speed(input_speed_mm) = a * input_speed_mm ^ 2 + b * input_speed_mm + c
71 //
72 // (a, b, and c are also called sqr_, mul_, and int_ in the Gestures library code.)
73 //
74 // createAccelerationCurveForPointerSensitivity gives us parameters for a function of the form:
75 // gain(input_speed_mm) = baseGain + reciprocal / input_speed_mm
76 // Where "gain" is a multiplier applied to the input speed to produce the output speed:
77 // output_speed(input_speed_mm) = input_speed_mm * gain(input_speed_mm)
78 //
79 // To put our function in the library's form, we substitute it into the function above:
80 // output_speed(input_speed_mm) = input_speed_mm * (baseGain + reciprocal / input_speed_mm)
81 // then expand the brackets so that input_speed_mm cancels out for the reciprocal term:
82 // gain(input_speed_mm) = baseGain * input_speed_mm + reciprocal
83 //
84 // This gives us the following parameters for the Gestures library function form:
85 // a = 0
86 // b = baseGain
87 // c = reciprocal
88
89 size_t i = 0;
90 for (AccelerationCurveSegment seg : segments) {
91 // The library's curve format consists of four doubles per segment:
92 // * maximum pointer speed for the segment (mm/s)
93 // * multiplier for the x² term (a.k.a. "a" or "sqr")
94 // * multiplier for the x term (a.k.a. "b" or "mul")
95 // * the intercept (a.k.a. "c" or "int")
96 // (see struct CurveSegment in the library's AccelFilterInterpreter)
97 output[i + 0] = seg.maxPointerSpeedMmPerS;
98 output[i + 1] = 0;
99 output[i + 2] = seg.baseGain;
100 output[i + 3] = seg.reciprocal;
101 i += 4;
102 }
103
104 return output;
105 }
106
gestureInterpreterCallback(void * clientData,const Gesture * gesture)107 void gestureInterpreterCallback(void* clientData, const Gesture* gesture) {
108 TouchpadInputMapper* mapper = static_cast<TouchpadInputMapper*>(clientData);
109 mapper->consumeGesture(gesture);
110 }
111
linuxBusToInputDeviceBusEnum(int32_t linuxBus,bool isUsiStylus)112 int32_t linuxBusToInputDeviceBusEnum(int32_t linuxBus, bool isUsiStylus) {
113 if (isUsiStylus) {
114 // This is a stylus connected over the Universal Stylus Initiative (USI) protocol.
115 // For metrics purposes, we treat this protocol as a separate bus.
116 return util::INPUT_DEVICE_USAGE_REPORTED__DEVICE_BUS__USI;
117 }
118
119 // When adding cases to this switch, also add them to the copy of this method in
120 // InputDeviceMetricsCollector.cpp.
121 // TODO(b/286394420): deduplicate this method with the one in InputDeviceMetricsCollector.cpp.
122 switch (linuxBus) {
123 case BUS_USB:
124 return util::INPUT_DEVICE_USAGE_REPORTED__DEVICE_BUS__USB;
125 case BUS_BLUETOOTH:
126 return util::INPUT_DEVICE_USAGE_REPORTED__DEVICE_BUS__BLUETOOTH;
127 default:
128 return util::INPUT_DEVICE_USAGE_REPORTED__DEVICE_BUS__OTHER;
129 }
130 }
131
132 class MetricsAccumulator {
133 public:
getInstance()134 static MetricsAccumulator& getInstance() {
135 static MetricsAccumulator sAccumulator;
136 return sAccumulator;
137 }
138
recordFinger(const TouchpadInputMapper::MetricsIdentifier & id)139 void recordFinger(const TouchpadInputMapper::MetricsIdentifier& id) {
140 std::scoped_lock lock(mLock);
141 mCounters[id].fingers++;
142 }
143
recordPalm(const TouchpadInputMapper::MetricsIdentifier & id)144 void recordPalm(const TouchpadInputMapper::MetricsIdentifier& id) {
145 std::scoped_lock lock(mLock);
146 mCounters[id].palms++;
147 }
148
149 // Checks whether a Gesture struct is for the end of a gesture that we log metrics for, and
150 // records it if so.
processGesture(const TouchpadInputMapper::MetricsIdentifier & id,const Gesture & gesture)151 void processGesture(const TouchpadInputMapper::MetricsIdentifier& id, const Gesture& gesture) {
152 std::scoped_lock lock(mLock);
153 switch (gesture.type) {
154 case kGestureTypeFling:
155 if (gesture.details.fling.fling_state == GESTURES_FLING_START) {
156 // Indicates the end of a two-finger scroll gesture.
157 mCounters[id].twoFingerSwipeGestures++;
158 }
159 break;
160 case kGestureTypeSwipeLift:
161 mCounters[id].threeFingerSwipeGestures++;
162 break;
163 case kGestureTypeFourFingerSwipeLift:
164 mCounters[id].fourFingerSwipeGestures++;
165 break;
166 case kGestureTypePinch:
167 if (gesture.details.pinch.zoom_state == GESTURES_ZOOM_END) {
168 mCounters[id].pinchGestures++;
169 }
170 break;
171 default:
172 // We're not interested in any other gestures.
173 break;
174 }
175 }
176
177 private:
MetricsAccumulator()178 MetricsAccumulator() {
179 AStatsManager_setPullAtomCallback(android::util::TOUCHPAD_USAGE, /*metadata=*/nullptr,
180 MetricsAccumulator::pullAtomCallback, /*cookie=*/nullptr);
181 }
182
~MetricsAccumulator()183 ~MetricsAccumulator() { AStatsManager_clearPullAtomCallback(android::util::TOUCHPAD_USAGE); }
184
pullAtomCallback(int32_t atomTag,AStatsEventList * outEventList,void * cookie)185 static AStatsManager_PullAtomCallbackReturn pullAtomCallback(int32_t atomTag,
186 AStatsEventList* outEventList,
187 void* cookie) {
188 LOG_ALWAYS_FATAL_IF(atomTag != android::util::TOUCHPAD_USAGE);
189 MetricsAccumulator& accumulator = MetricsAccumulator::getInstance();
190 accumulator.produceAtomsAndReset(*outEventList);
191 return AStatsManager_PULL_SUCCESS;
192 }
193
produceAtomsAndReset(AStatsEventList & outEventList)194 void produceAtomsAndReset(AStatsEventList& outEventList) {
195 std::scoped_lock lock(mLock);
196 produceAtomsLocked(outEventList);
197 resetCountersLocked();
198 }
199
produceAtomsLocked(AStatsEventList & outEventList) const200 void produceAtomsLocked(AStatsEventList& outEventList) const REQUIRES(mLock) {
201 for (auto& [id, counters] : mCounters) {
202 auto [busId, vendorId, productId, versionId] = id;
203 addAStatsEvent(&outEventList, android::util::TOUCHPAD_USAGE, vendorId, productId,
204 versionId, linuxBusToInputDeviceBusEnum(busId, /*isUsi=*/false),
205 counters.fingers, counters.palms, counters.twoFingerSwipeGestures,
206 counters.threeFingerSwipeGestures, counters.fourFingerSwipeGestures,
207 counters.pinchGestures);
208 }
209 }
210
resetCountersLocked()211 void resetCountersLocked() REQUIRES(mLock) { mCounters.clear(); }
212
213 // Stores the counters for a specific touchpad model. Fields have the same meanings as those of
214 // the TouchpadUsage atom; see that definition for detailed documentation.
215 struct Counters {
216 int32_t fingers = 0;
217 int32_t palms = 0;
218
219 int32_t twoFingerSwipeGestures = 0;
220 int32_t threeFingerSwipeGestures = 0;
221 int32_t fourFingerSwipeGestures = 0;
222 int32_t pinchGestures = 0;
223 };
224
225 // Metrics are aggregated by device model and version, so if two devices of the same model and
226 // version are connected at once, they will have the same counters.
227 std::map<TouchpadInputMapper::MetricsIdentifier, Counters> mCounters GUARDED_BY(mLock);
228
229 // Metrics are pulled by a binder thread, so we need to guard them with a mutex.
230 mutable std::mutex mLock;
231 };
232
233 } // namespace
234
TouchpadInputMapper(InputDeviceContext & deviceContext,const InputReaderConfiguration & readerConfig)235 TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext,
236 const InputReaderConfiguration& readerConfig)
237 : InputMapper(deviceContext, readerConfig),
238 mGestureInterpreter(NewGestureInterpreter(), DeleteGestureInterpreter),
239 mTimerProvider(*getContext()),
240 mStateConverter(deviceContext, mMotionAccumulator),
241 mGestureConverter(*getContext(), deviceContext, getDeviceId()),
242 mCapturedEventConverter(*getContext(), deviceContext, mMotionAccumulator, getDeviceId()),
243 mMetricsId(metricsIdFromInputDeviceIdentifier(deviceContext.getDeviceIdentifier())) {
244 if (std::optional<RawAbsoluteAxisInfo> slotAxis =
245 deviceContext.getAbsoluteAxisInfo(ABS_MT_SLOT);
246 slotAxis && slotAxis->maxValue >= 0) {
247 mMotionAccumulator.configure(deviceContext, slotAxis->maxValue + 1, true);
248 } else {
249 LOG(WARNING) << "Touchpad " << deviceContext.getName()
250 << " doesn't have a valid ABS_MT_SLOT axis, and probably won't work properly.";
251 mMotionAccumulator.configure(deviceContext, 1, true);
252 }
253
254 mGestureInterpreter->Initialize(GESTURES_DEVCLASS_TOUCHPAD);
255 mHardwareProperties = createHardwareProperties(deviceContext);
256 mGestureInterpreter->SetHardwareProperties(mHardwareProperties);
257 // Even though we don't explicitly delete copy/move semantics, it's safe to
258 // give away pointers to TouchpadInputMapper and its members here because
259 // 1) mGestureInterpreter's lifecycle is determined by TouchpadInputMapper, and
260 // 2) TouchpadInputMapper is stored as a unique_ptr and not moved.
261 mGestureInterpreter->SetPropProvider(const_cast<GesturesPropProvider*>(&gesturePropProvider),
262 &mPropertyProvider);
263 mGestureInterpreter->SetTimerProvider(const_cast<GesturesTimerProvider*>(
264 &kGestureTimerProvider),
265 &mTimerProvider);
266 mGestureInterpreter->SetCallback(gestureInterpreterCallback, this);
267 }
268
~TouchpadInputMapper()269 TouchpadInputMapper::~TouchpadInputMapper() {
270 // The gesture interpreter's destructor will try to free its property and timer providers,
271 // calling PropertyProvider::freeProperty and TimerProvider::freeTimer using a raw pointers.
272 // Depending on the declaration order in TouchpadInputMapper.h, those providers may have already
273 // been freed, causing allocation errors or use-after-free bugs. Depending on declaration order
274 // to avoid this seems rather fragile, so explicitly clear the providers here to ensure all the
275 // freeProperty and freeTimer calls happen before the providers are destructed.
276 mGestureInterpreter->SetPropProvider(nullptr, nullptr);
277 mGestureInterpreter->SetTimerProvider(nullptr, nullptr);
278 }
279
getSources() const280 uint32_t TouchpadInputMapper::getSources() const {
281 return AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD;
282 }
283
populateDeviceInfo(InputDeviceInfo & info)284 void TouchpadInputMapper::populateDeviceInfo(InputDeviceInfo& info) {
285 InputMapper::populateDeviceInfo(info);
286 if (mPointerCaptured) {
287 mCapturedEventConverter.populateMotionRanges(info);
288 } else {
289 mGestureConverter.populateMotionRanges(info);
290 }
291 }
292
dump(std::string & dump)293 void TouchpadInputMapper::dump(std::string& dump) {
294 dump += INDENT2 "Touchpad Input Mapper:\n";
295 if (mResettingInterpreter) {
296 dump += INDENT3 "Currently resetting gesture interpreter\n";
297 }
298 dump += StringPrintf(INDENT3 "Pointer captured: %s\n", toString(mPointerCaptured));
299 dump += INDENT3 "Gesture converter:\n";
300 dump += addLinePrefix(mGestureConverter.dump(), INDENT4);
301 dump += INDENT3 "Gesture properties:\n";
302 dump += addLinePrefix(mPropertyProvider.dump(), INDENT4);
303 dump += INDENT3 "Timer provider:\n";
304 dump += addLinePrefix(mTimerProvider.dump(), INDENT4);
305 dump += INDENT3 "Captured event converter:\n";
306 dump += addLinePrefix(mCapturedEventConverter.dump(), INDENT4);
307 dump += StringPrintf(INDENT3 "DisplayId: %s\n",
308 toString(mDisplayId, streamableToString).c_str());
309 }
310
reconfigure(nsecs_t when,const InputReaderConfiguration & config,ConfigurationChanges changes)311 std::list<NotifyArgs> TouchpadInputMapper::reconfigure(nsecs_t when,
312 const InputReaderConfiguration& config,
313 ConfigurationChanges changes) {
314 if (!changes.any()) {
315 // First time configuration
316 mPropertyProvider.loadPropertiesFromIdcFile(getDeviceContext().getConfiguration());
317 }
318
319 if (!changes.any() || changes.test(InputReaderConfiguration::Change::DISPLAY_INFO)) {
320 mDisplayId = ui::LogicalDisplayId::INVALID;
321 std::optional<DisplayViewport> resolvedViewport;
322 std::optional<FloatRect> boundsInLogicalDisplay;
323 if (auto assocViewport = mDeviceContext.getAssociatedViewport(); assocViewport) {
324 // This InputDevice is associated with a viewport.
325 // Only generate events for the associated display.
326 mDisplayId = assocViewport->displayId;
327 resolvedViewport = *assocViewport;
328 } else {
329 // The InputDevice is not associated with a viewport, but it controls the mouse pointer.
330 // Always use DISPLAY_ID_NONE for touchpad events.
331 // PointerChoreographer will make it target the correct the displayId later.
332 resolvedViewport = getContext()->getPolicy()->getPointerViewportForAssociatedDisplay();
333 mDisplayId = resolvedViewport ? std::make_optional(ui::LogicalDisplayId::INVALID)
334 : std::nullopt;
335 }
336
337 mGestureConverter.setDisplayId(mDisplayId);
338 mGestureConverter.setOrientation(resolvedViewport
339 ? getInverseRotation(resolvedViewport->orientation)
340 : ui::ROTATION_0);
341
342 if (!boundsInLogicalDisplay) {
343 boundsInLogicalDisplay = resolvedViewport
344 ? FloatRect{static_cast<float>(resolvedViewport->logicalLeft),
345 static_cast<float>(resolvedViewport->logicalTop),
346 static_cast<float>(resolvedViewport->logicalRight - 1),
347 static_cast<float>(resolvedViewport->logicalBottom - 1)}
348 : FloatRect{0, 0, 0, 0};
349 }
350 mGestureConverter.setBoundsInLogicalDisplay(*boundsInLogicalDisplay);
351
352 bumpGeneration();
353 }
354 std::list<NotifyArgs> out;
355 if (!changes.any() || changes.test(InputReaderConfiguration::Change::TOUCHPAD_SETTINGS)) {
356 mPropertyProvider.getProperty("Use Custom Touchpad Pointer Accel Curve")
357 .setBoolValues({true});
358 GesturesProp accelCurveProp = mPropertyProvider.getProperty("Pointer Accel Curve");
359 accelCurveProp.setRealValues(
360 createAccelerationCurveForSensitivity(config.touchpadPointerSpeed,
361 accelCurveProp.getCount()));
362 mPropertyProvider.getProperty("Use Custom Touchpad Scroll Accel Curve")
363 .setBoolValues({true});
364 GesturesProp scrollCurveProp = mPropertyProvider.getProperty("Scroll Accel Curve");
365 scrollCurveProp.setRealValues(
366 createAccelerationCurveForSensitivity(config.touchpadPointerSpeed,
367 scrollCurveProp.getCount()));
368 mPropertyProvider.getProperty("Scroll X Out Scale").setRealValues({1.0});
369 mPropertyProvider.getProperty("Scroll Y Out Scale").setRealValues({1.0});
370 mPropertyProvider.getProperty("Invert Scrolling")
371 .setBoolValues({config.touchpadNaturalScrollingEnabled});
372 mPropertyProvider.getProperty("Tap Enable")
373 .setBoolValues({config.touchpadTapToClickEnabled});
374 mPropertyProvider.getProperty("Tap Drag Enable")
375 .setBoolValues({config.touchpadTapDraggingEnabled});
376 mPropertyProvider.getProperty("Button Right Click Zone Enable")
377 .setBoolValues({config.touchpadRightClickZoneEnabled});
378 mTouchpadHardwareStateNotificationsEnabled = config.shouldNotifyTouchpadHardwareState;
379 mGestureConverter.setThreeFingerTapShortcutEnabled(
380 config.touchpadThreeFingerTapShortcutEnabled);
381 out += mGestureConverter.setEnableSystemGestures(when,
382 config.touchpadSystemGesturesEnabled);
383 }
384 if ((!changes.any() && config.pointerCaptureRequest.isEnable()) ||
385 changes.test(InputReaderConfiguration::Change::POINTER_CAPTURE)) {
386 mPointerCaptured = config.pointerCaptureRequest.isEnable();
387 // The motion ranges are going to change, so bump the generation to clear the cached ones.
388 bumpGeneration();
389 if (mPointerCaptured) {
390 // The touchpad is being captured, so we need to tidy up any fake fingers etc. that are
391 // still being reported for a gesture in progress.
392 out += reset(when);
393 } else {
394 // We're transitioning from captured to uncaptured.
395 mCapturedEventConverter.reset();
396 }
397 if (changes.any()) {
398 out.push_back(NotifyDeviceResetArgs(getContext()->getNextId(), when, getDeviceId()));
399 }
400 }
401 return out;
402 }
403
reset(nsecs_t when)404 std::list<NotifyArgs> TouchpadInputMapper::reset(nsecs_t when) {
405 mStateConverter.reset();
406 resetGestureInterpreter(when);
407 std::list<NotifyArgs> out = mGestureConverter.reset(when);
408 out += InputMapper::reset(when);
409 return out;
410 }
411
resetGestureInterpreter(nsecs_t when)412 void TouchpadInputMapper::resetGestureInterpreter(nsecs_t when) {
413 // The GestureInterpreter has no official reset method, but sending a HardwareState with no
414 // fingers down or buttons pressed should get it into a clean state.
415 HardwareState state;
416 state.timestamp = std::chrono::duration<stime_t>(std::chrono::nanoseconds(when)).count();
417 mResettingInterpreter = true;
418 mGestureInterpreter->PushHardwareState(&state);
419 mResettingInterpreter = false;
420 }
421
process(const RawEvent & rawEvent)422 std::list<NotifyArgs> TouchpadInputMapper::process(const RawEvent& rawEvent) {
423 if (mPointerCaptured) {
424 return mCapturedEventConverter.process(rawEvent);
425 }
426 if (mMotionAccumulator.getActiveSlotsCount() == 0) {
427 mGestureStartTime = rawEvent.when;
428 }
429 std::optional<SelfContainedHardwareState> state = mStateConverter.processRawEvent(rawEvent);
430 if (state) {
431 if (mTouchpadHardwareStateNotificationsEnabled) {
432 getPolicy()->notifyTouchpadHardwareState(*state, getDeviceId());
433 }
434 updatePalmDetectionMetrics();
435 return sendHardwareState(rawEvent.when, rawEvent.readTime, *state);
436 } else {
437 return {};
438 }
439 }
440
updatePalmDetectionMetrics()441 void TouchpadInputMapper::updatePalmDetectionMetrics() {
442 std::set<int32_t> currentTrackingIds;
443 for (size_t i = 0; i < mMotionAccumulator.getSlotCount(); i++) {
444 const MultiTouchMotionAccumulator::Slot& slot = mMotionAccumulator.getSlot(i);
445 if (!slot.isInUse()) {
446 continue;
447 }
448 currentTrackingIds.insert(slot.getTrackingId());
449 if (slot.getToolType() == ToolType::PALM) {
450 mPalmTrackingIds.insert(slot.getTrackingId());
451 }
452 }
453 std::vector<int32_t> liftedTouches;
454 std::set_difference(mLastFrameTrackingIds.begin(), mLastFrameTrackingIds.end(),
455 currentTrackingIds.begin(), currentTrackingIds.end(),
456 std::inserter(liftedTouches, liftedTouches.begin()));
457 for (int32_t trackingId : liftedTouches) {
458 if (mPalmTrackingIds.erase(trackingId) > 0) {
459 MetricsAccumulator::getInstance().recordPalm(mMetricsId);
460 } else {
461 MetricsAccumulator::getInstance().recordFinger(mMetricsId);
462 }
463 }
464 mLastFrameTrackingIds = currentTrackingIds;
465 }
466
sendHardwareState(nsecs_t when,nsecs_t readTime,SelfContainedHardwareState schs)467 std::list<NotifyArgs> TouchpadInputMapper::sendHardwareState(nsecs_t when, nsecs_t readTime,
468 SelfContainedHardwareState schs) {
469 ALOGD_IF(DEBUG_TOUCHPAD_GESTURES, "New hardware state: %s", schs.state.String().c_str());
470 mGestureInterpreter->PushHardwareState(&schs.state);
471 return processGestures(when, readTime);
472 }
473
timeoutExpired(nsecs_t when)474 std::list<NotifyArgs> TouchpadInputMapper::timeoutExpired(nsecs_t when) {
475 mTimerProvider.triggerCallbacks(when);
476 return processGestures(when, when);
477 }
478
consumeGesture(const Gesture * gesture)479 void TouchpadInputMapper::consumeGesture(const Gesture* gesture) {
480 ALOGD_IF(DEBUG_TOUCHPAD_GESTURES, "Gesture ready: %s", gesture->String().c_str());
481 if (mResettingInterpreter) {
482 // We already handle tidying up fake fingers etc. in GestureConverter::reset, so we should
483 // ignore any gestures produced from the interpreter while we're resetting it.
484 return;
485 }
486 mGesturesToProcess.push_back(*gesture);
487 if (mTouchpadHardwareStateNotificationsEnabled) {
488 getPolicy()->notifyTouchpadGestureInfo(gesture->type, getDeviceId());
489 }
490 }
491
processGestures(nsecs_t when,nsecs_t readTime)492 std::list<NotifyArgs> TouchpadInputMapper::processGestures(nsecs_t when, nsecs_t readTime) {
493 std::list<NotifyArgs> out = {};
494 if (mDisplayId) {
495 MetricsAccumulator& metricsAccumulator = MetricsAccumulator::getInstance();
496 for (Gesture& gesture : mGesturesToProcess) {
497 out += mGestureConverter.handleGesture(when, readTime, mGestureStartTime, gesture);
498 metricsAccumulator.processGesture(mMetricsId, gesture);
499 }
500 }
501 mGesturesToProcess.clear();
502 return out;
503 }
504
getAssociatedDisplayId()505 std::optional<ui::LogicalDisplayId> TouchpadInputMapper::getAssociatedDisplayId() {
506 return mDisplayId;
507 }
508
getTouchpadHardwareProperties()509 std::optional<HardwareProperties> TouchpadInputMapper::getTouchpadHardwareProperties() {
510 return mHardwareProperties;
511 }
512
513 } // namespace android
514