Extract HardwareState conversion into a class and test it
Putting the conversion logic into its own class makes it more obvious
which variables are used for HardwareState conversion, and also provides
a clean public API to write tests against.
Bug: 251196347
Test: m inputflinger_tests && \
$ANDROID_HOST_OUT/nativetest64/inputflinger_tests/inputflinger_tests \
--gtest_filter='*HardwareStateConverterTest*'
Test: atest inputflinger_tests
Change-Id: I26771887b6b2eae46c9cec7190499da0016fdb1f
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.h b/services/inputflinger/reader/mapper/TouchpadInputMapper.h
index fe6b1fe..c6863f5 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.h
@@ -17,6 +17,7 @@
#pragma once
#include <memory>
+#include <vector>
#include <PointerControllerInterface.h>
@@ -24,9 +25,7 @@
#include "InputDevice.h"
#include "InputMapper.h"
#include "NotifyArgs.h"
-#include "accumulator/CursorButtonAccumulator.h"
-#include "accumulator/MultiTouchMotionAccumulator.h"
-#include "accumulator/TouchButtonAccumulator.h"
+#include "gestures/HardwareStateConverter.h"
#include "include/gestures.h"
@@ -44,7 +43,8 @@
void consumeGesture(const Gesture* gesture);
private:
- [[nodiscard]] std::list<NotifyArgs> sync(nsecs_t when, nsecs_t readTime);
+ [[nodiscard]] std::list<NotifyArgs> sendHardwareState(nsecs_t when, nsecs_t readTime,
+ SelfContainedHardwareState schs);
[[nodiscard]] std::list<NotifyArgs> processGestures(nsecs_t when, nsecs_t readTime);
NotifyArgs handleMove(nsecs_t when, nsecs_t readTime, const Gesture& gesture);
[[nodiscard]] std::list<NotifyArgs> handleButtonsChange(nsecs_t when, nsecs_t readTime,
@@ -61,10 +61,7 @@
mGestureInterpreter;
std::shared_ptr<PointerControllerInterface> mPointerController;
- CursorButtonAccumulator mCursorButtonAccumulator;
- MultiTouchMotionAccumulator mMotionAccumulator;
- TouchButtonAccumulator mTouchButtonAccumulator;
- int32_t mMscTimestamp = 0;
+ HardwareStateConverter mStateConverter;
bool mProcessing = false;
std::vector<Gesture> mGesturesToProcess;