Return std::optional from getAbsoluteAxisValue
This makes the methods nicer to use, and forces callers to clearly
handle the case where there's no value to return.
Test: m checkinput
Test: atest inputflinger_tests
Test: build and run inputflinger_multitouch_input_fuzzer for a while
Bug: 245989146
Flag: EXEMPT refactor
Change-Id: I51c750d21d8a95ef631d93365ee76d18ebf71d43
diff --git a/services/inputflinger/reader/include/InputDevice.h b/services/inputflinger/reader/include/InputDevice.h
index 37c7e5c..7fd5597 100644
--- a/services/inputflinger/reader/include/InputDevice.h
+++ b/services/inputflinger/reader/include/InputDevice.h
@@ -381,8 +381,8 @@
return mEventHub->getKeyCodeForKeyLocation(mId, locationKeyCode);
}
inline int32_t getSwitchState(int32_t sw) const { return mEventHub->getSwitchState(mId, sw); }
- inline status_t getAbsoluteAxisValue(int32_t code, int32_t* outValue) const {
- return mEventHub->getAbsoluteAxisValue(mId, code, outValue);
+ inline std::optional<int32_t> getAbsoluteAxisValue(int32_t code) const {
+ return mEventHub->getAbsoluteAxisValue(mId, code);
}
inline base::Result<std::vector<int32_t>> getMtSlotValues(int32_t axis,
size_t slotCount) const {
@@ -443,11 +443,6 @@
inline bool isKeyCodePressed(int32_t keyCode) const {
return mEventHub->getKeyCodeState(mId, keyCode) == AKEY_STATE_DOWN;
}
- inline int32_t getAbsoluteAxisValue(int32_t code) const {
- int32_t value;
- mEventHub->getAbsoluteAxisValue(mId, code, &value);
- return value;
- }
inline bool isDeviceEnabled() { return mEventHub->isDeviceEnabled(mId); }
inline status_t enableDevice() { return mEventHub->enableDevice(mId); }
inline status_t disableDevice() { return mEventHub->disableDevice(mId); }