Use a const InputDeviceContext ref in HardwareStateConverter
This involved changing a number of other references that could have been
const but weren't, hence this being a separate CL from the original.
Bug: 251196347
Test: build succeeds
Test: m inputflinger_tests && \
$ANDROID_HOST_OUT/nativetest64/inputflinger_tests/inputflinger_tests \
--gtest_filter='*HardwareStateConverterTest*'
Change-Id: Id4ecad74c9be19bd26aac525f0ebf44536677f85
diff --git a/services/inputflinger/reader/include/InputDevice.h b/services/inputflinger/reader/include/InputDevice.h
index af59fe2..3994cfd 100644
--- a/services/inputflinger/reader/include/InputDevice.h
+++ b/services/inputflinger/reader/include/InputDevice.h
@@ -403,7 +403,7 @@
inline status_t enableDevice() { return mEventHub->enableDevice(mId); }
inline status_t disableDevice() { return mEventHub->disableDevice(mId); }
- inline const std::string getName() { return mDevice.getName(); }
+ inline const std::string getName() const { return mDevice.getName(); }
inline const std::string getDescriptor() { return mDevice.getDescriptor(); }
inline bool isExternal() { return mDevice.isExternal(); }
inline std::optional<uint8_t> getAssociatedDisplayPort() const {
diff --git a/services/inputflinger/reader/mapper/accumulator/CursorButtonAccumulator.cpp b/services/inputflinger/reader/mapper/accumulator/CursorButtonAccumulator.cpp
index 2d7d73b..153236c 100644
--- a/services/inputflinger/reader/mapper/accumulator/CursorButtonAccumulator.cpp
+++ b/services/inputflinger/reader/mapper/accumulator/CursorButtonAccumulator.cpp
@@ -25,7 +25,7 @@
clearButtons();
}
-void CursorButtonAccumulator::reset(InputDeviceContext& deviceContext) {
+void CursorButtonAccumulator::reset(const InputDeviceContext& deviceContext) {
mBtnLeft = deviceContext.isKeyPressed(BTN_LEFT);
mBtnRight = deviceContext.isKeyPressed(BTN_RIGHT);
mBtnMiddle = deviceContext.isKeyPressed(BTN_MIDDLE);
diff --git a/services/inputflinger/reader/mapper/accumulator/CursorButtonAccumulator.h b/services/inputflinger/reader/mapper/accumulator/CursorButtonAccumulator.h
index 1380604..6960644 100644
--- a/services/inputflinger/reader/mapper/accumulator/CursorButtonAccumulator.h
+++ b/services/inputflinger/reader/mapper/accumulator/CursorButtonAccumulator.h
@@ -27,7 +27,7 @@
class CursorButtonAccumulator {
public:
CursorButtonAccumulator();
- void reset(InputDeviceContext& deviceContext);
+ void reset(const InputDeviceContext& deviceContext);
void process(const RawEvent* rawEvent);
diff --git a/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.cpp b/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.cpp
index 8746729..f6a42bd 100644
--- a/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.cpp
+++ b/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.cpp
@@ -26,8 +26,8 @@
MultiTouchMotionAccumulator::MultiTouchMotionAccumulator()
: mCurrentSlot(-1), mUsingSlotsProtocol(false) {}
-void MultiTouchMotionAccumulator::configure(InputDeviceContext& deviceContext, size_t slotCount,
- bool usingSlotsProtocol) {
+void MultiTouchMotionAccumulator::configure(const InputDeviceContext& deviceContext,
+ size_t slotCount, bool usingSlotsProtocol) {
mUsingSlotsProtocol = usingSlotsProtocol;
mSlots = std::vector<Slot>(slotCount);
diff --git a/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.h b/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.h
index 62bc780..3c1a2a9 100644
--- a/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.h
+++ b/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.h
@@ -72,7 +72,8 @@
MultiTouchMotionAccumulator();
- void configure(InputDeviceContext& deviceContext, size_t slotCount, bool usingSlotsProtocol);
+ void configure(const InputDeviceContext& deviceContext, size_t slotCount,
+ bool usingSlotsProtocol);
void process(const RawEvent* rawEvent);
void finishSync();
diff --git a/services/inputflinger/reader/mapper/accumulator/TouchButtonAccumulator.h b/services/inputflinger/reader/mapper/accumulator/TouchButtonAccumulator.h
index 2e70e2e..c2aa2ad 100644
--- a/services/inputflinger/reader/mapper/accumulator/TouchButtonAccumulator.h
+++ b/services/inputflinger/reader/mapper/accumulator/TouchButtonAccumulator.h
@@ -27,7 +27,7 @@
/* Keeps track of the state of touch, stylus and tool buttons. */
class TouchButtonAccumulator {
public:
- explicit TouchButtonAccumulator(InputDeviceContext& deviceContext)
+ explicit TouchButtonAccumulator(const InputDeviceContext& deviceContext)
: mDeviceContext(deviceContext){};
void configure();
@@ -65,7 +65,7 @@
HidUsageAccumulator mHidUsageAccumulator{};
- InputDeviceContext& mDeviceContext;
+ const InputDeviceContext& mDeviceContext;
void processMappedKey(int32_t scanCode, bool down);
};
diff --git a/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.cpp b/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.cpp
index 49c13ca..2e175b8 100644
--- a/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.cpp
+++ b/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.cpp
@@ -23,7 +23,7 @@
namespace android {
-HardwareStateConverter::HardwareStateConverter(InputDeviceContext& deviceContext)
+HardwareStateConverter::HardwareStateConverter(const InputDeviceContext& deviceContext)
: mDeviceContext(deviceContext), mTouchButtonAccumulator(deviceContext) {
RawAbsoluteAxisInfo slotAxisInfo;
deviceContext.getAbsoluteAxisInfo(ABS_MT_SLOT, &slotAxisInfo);
diff --git a/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h b/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h
index fd63c05..8831299 100644
--- a/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h
+++ b/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h
@@ -40,7 +40,7 @@
// Converts RawEvents into the HardwareState structs used by the gestures library.
class HardwareStateConverter {
public:
- HardwareStateConverter(InputDeviceContext& deviceContext);
+ HardwareStateConverter(const InputDeviceContext& deviceContext);
std::optional<SelfContainedHardwareState> processRawEvent(const RawEvent* event);
void reset();
@@ -48,7 +48,7 @@
private:
SelfContainedHardwareState produceHardwareState(nsecs_t when);
- InputDeviceContext& mDeviceContext;
+ const InputDeviceContext& mDeviceContext;
CursorButtonAccumulator mCursorButtonAccumulator;
MultiTouchMotionAccumulator mMotionAccumulator;
TouchButtonAccumulator mTouchButtonAccumulator;