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/tests/fuzzers/MapperHelpers.h b/services/inputflinger/tests/fuzzers/MapperHelpers.h
index 50fbf4b..6dea540 100644
--- a/services/inputflinger/tests/fuzzers/MapperHelpers.h
+++ b/services/inputflinger/tests/fuzzers/MapperHelpers.h
@@ -208,9 +208,12 @@
int32_t getKeyCodeForKeyLocation(int32_t deviceId, int32_t locationKeyCode) const override {
return mFdp->ConsumeIntegral<int32_t>();
}
- status_t getAbsoluteAxisValue(int32_t deviceId, int32_t axis,
- int32_t* outValue) const override {
- return mFdp->ConsumeIntegral<status_t>();
+ std::optional<int32_t> getAbsoluteAxisValue(int32_t deviceId, int32_t axis) const override {
+ if (mFdp->ConsumeBool()) {
+ return mFdp->ConsumeIntegral<int32_t>();
+ } else {
+ return std::nullopt;
+ }
}
base::Result<std::vector<int32_t>> getMtSlotValues(int32_t deviceId, int32_t axis,
size_t slotCount) const override {