InputDevice: clear absolute axis info if not found
In change I57de645c889de53c8be0f9f8744a62e92fafdadb, getAbsoluteAxisInfo
was modified to handle EventHub::getAbsoluteAxisInfo returning an
optional. However, the old form of EventHub::getAbsoluteAxisInfo had the
side effect of clearing the RawAbsoluteAxisInfo struct that it was
passed a pointer to if the axis isn't present, crucially setting valid
to false. To avoid a behaviour change due to the refactor, mimic that in
InputDevice::getAbsoluteAxisInfo.
Test: atest inputflinger_tests
Test: m checkinput
Bug: 245989146
Flag: EXEMPT refactor
Change-Id: If32272f983139c2e9d5f1e548fb209c21d191180
diff --git a/services/inputflinger/reader/include/InputDevice.h b/services/inputflinger/reader/include/InputDevice.h
index 7fd5597..086c26f 100644
--- a/services/inputflinger/reader/include/InputDevice.h
+++ b/services/inputflinger/reader/include/InputDevice.h
@@ -308,6 +308,7 @@
inline status_t getAbsoluteAxisInfo(int32_t code, RawAbsoluteAxisInfo* axisInfo) const {
std::optional<RawAbsoluteAxisInfo> info = mEventHub->getAbsoluteAxisInfo(mId, code);
if (!info.has_value()) {
+ axisInfo->clear();
return NAME_NOT_FOUND;
}
*axisInfo = *info;