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/MultiTouchInputMapper_test.cpp b/services/inputflinger/tests/MultiTouchInputMapper_test.cpp
index b5f8971..d4d3c38 100644
--- a/services/inputflinger/tests/MultiTouchInputMapper_test.cpp
+++ b/services/inputflinger/tests/MultiTouchInputMapper_test.cpp
@@ -99,11 +99,8 @@
setupAxis(ABS_MT_TOOL_TYPE, /*valid=*/false, /*min=*/0, /*max=*/0, /*resolution=*/0);
// reset current slot at the beginning
- EXPECT_CALL(mMockEventHub, getAbsoluteAxisValue(EVENTHUB_ID, ABS_MT_SLOT, _))
- .WillRepeatedly([](int32_t, int32_t, int32_t* outValue) {
- *outValue = 0;
- return OK;
- });
+ EXPECT_CALL(mMockEventHub, getAbsoluteAxisValue(EVENTHUB_ID, ABS_MT_SLOT))
+ .WillRepeatedly(Return(0));
// mark all slots not in use
mockSlotValues({});
@@ -211,11 +208,8 @@
const auto pointerCoordsBeforeReset = std::get<NotifyMotionArgs>(args.back()).pointerCoords;
// On buffer overflow mapper will be reset and MT slots data will be repopulated
- EXPECT_CALL(mMockEventHub, getAbsoluteAxisValue(EVENTHUB_ID, ABS_MT_SLOT, _))
- .WillRepeatedly([=](int32_t, int32_t, int32_t* outValue) {
- *outValue = 1;
- return OK;
- });
+ EXPECT_CALL(mMockEventHub, getAbsoluteAxisValue(EVENTHUB_ID, ABS_MT_SLOT))
+ .WillRepeatedly(Return(1));
mockSlotValues(
{{1, {Point{x1, y1}, FIRST_TRACKING_ID}}, {2, {Point{x2, y2}, SECOND_TRACKING_ID}}});