diff options
author | 2024-07-23 17:23:06 +0000 | |
---|---|---|
committer | 2024-07-23 17:23:06 +0000 | |
commit | 09163b73b3f591b882a1daea695722e52eee37ed (patch) | |
tree | 506cb61a65f6670c9fb9922df0b82349863c30df | |
parent | 67e1ae63301dc02f4d940b5f480b1f495b3b977e (diff) |
Revert "InputDevice: return std::optional from getAbsoluteAxisInfo"
This reverts commit 67e1ae63301dc02f4d940b5f480b1f495b3b977e.
Reason for revert: b/353921348
Change-Id: I6148dec70b7ca1c9a21d841b791168b5bfc67ca3
22 files changed, 196 insertions, 194 deletions
diff --git a/services/inputflinger/reader/EventHub.cpp b/services/inputflinger/reader/EventHub.cpp index 7095928d5b..65583e95bf 100644 --- a/services/inputflinger/reader/EventHub.cpp +++ b/services/inputflinger/reader/EventHub.cpp @@ -513,10 +513,10 @@ ftl::Flags<InputDeviceClass> getAbsAxisUsage(int32_t axis, // --- RawAbsoluteAxisInfo --- -std::ostream& operator<<(std::ostream& out, const std::optional<RawAbsoluteAxisInfo>& info) { - if (info) { - out << "min=" << info->minValue << ", max=" << info->maxValue << ", flat=" << info->flat - << ", fuzz=" << info->fuzz << ", resolution=" << info->resolution; +std::ostream& operator<<(std::ostream& out, const RawAbsoluteAxisInfo& info) { + if (info.valid) { + out << "min=" << info.minValue << ", max=" << info.maxValue << ", flat=" << info.flat + << ", fuzz=" << info.fuzz << ", resolution=" << info.resolution; } else { out << "unknown range"; } @@ -645,6 +645,7 @@ void EventHub::Device::populateAbsoluteAxisStates() { continue; } auto& [axisInfo, value] = absState[axis]; + axisInfo.valid = true; axisInfo.minValue = info.minimum; axisInfo.maxValue = info.maximum; axisInfo.flat = info.flat; diff --git a/services/inputflinger/reader/include/EventHub.h b/services/inputflinger/reader/include/EventHub.h index c647558c9f..2a4346694a 100644 --- a/services/inputflinger/reader/include/EventHub.h +++ b/services/inputflinger/reader/include/EventHub.h @@ -71,14 +71,18 @@ struct RawEvent { /* Describes an absolute axis. */ struct RawAbsoluteAxisInfo { + bool valid{false}; // true if the information is valid, false otherwise + int32_t minValue{}; // minimum value int32_t maxValue{}; // maximum value int32_t flat{}; // center flat position, eg. flat == 8 means center is between -8 and 8 int32_t fuzz{}; // error tolerance, eg. fuzz == 4 means value is +/- 4 due to noise int32_t resolution{}; // resolution in units per mm or radians per mm + + inline void clear() { *this = RawAbsoluteAxisInfo(); } }; -std::ostream& operator<<(std::ostream& out, const std::optional<RawAbsoluteAxisInfo>& info); +std::ostream& operator<<(std::ostream& out, const RawAbsoluteAxisInfo& info); /* * Input device classes. diff --git a/services/inputflinger/reader/include/InputDevice.h b/services/inputflinger/reader/include/InputDevice.h index f2fdc37047..086c26f5e2 100644 --- a/services/inputflinger/reader/include/InputDevice.h +++ b/services/inputflinger/reader/include/InputDevice.h @@ -305,17 +305,22 @@ public: inline int32_t getDeviceControllerNumber() const { return mEventHub->getDeviceControllerNumber(mId); } - inline std::optional<RawAbsoluteAxisInfo> getAbsoluteAxisInfo(int32_t code) const { + 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; // Validate axis info for InputDevice. - if (info && info->minValue == info->maxValue) { + if (axisInfo->valid && axisInfo->minValue == axisInfo->maxValue) { // Historically, we deem axes with the same min and max values as invalid to avoid // dividing by zero when scaling by max - min. // TODO(b/291772515): Perform axis info validation on a per-axis basis when it is used. - return std::nullopt; + axisInfo->valid = false; } - return info; + return OK; } inline bool hasRelativeAxis(int32_t code) const { return mEventHub->hasRelativeAxis(mId, code); @@ -430,7 +435,8 @@ public: } inline bool hasAbsoluteAxis(int32_t code) const { - return mEventHub->getAbsoluteAxisInfo(mId, code).has_value(); + std::optional<RawAbsoluteAxisInfo> info = mEventHub->getAbsoluteAxisInfo(mId, code); + return info.has_value() && info->valid; } inline bool isKeyPressed(int32_t scanCode) const { return mEventHub->getScanCodeState(mId, scanCode) == AKEY_STATE_DOWN; diff --git a/services/inputflinger/reader/mapper/CapturedTouchpadEventConverter.cpp b/services/inputflinger/reader/mapper/CapturedTouchpadEventConverter.cpp index c8e7790c86..90685dec2b 100644 --- a/services/inputflinger/reader/mapper/CapturedTouchpadEventConverter.cpp +++ b/services/inputflinger/reader/mapper/CapturedTouchpadEventConverter.cpp @@ -16,7 +16,6 @@ #include "CapturedTouchpadEventConverter.h" -#include <optional> #include <sstream> #include <android-base/stringprintf.h> @@ -54,33 +53,32 @@ CapturedTouchpadEventConverter::CapturedTouchpadEventConverter( mMotionAccumulator(motionAccumulator), mHasTouchMinor(deviceContext.hasAbsoluteAxis(ABS_MT_TOUCH_MINOR)), mHasToolMinor(deviceContext.hasAbsoluteAxis(ABS_MT_WIDTH_MINOR)) { - if (std::optional<RawAbsoluteAxisInfo> orientation = - deviceContext.getAbsoluteAxisInfo(ABS_MT_ORIENTATION); - orientation) { - if (orientation->maxValue > 0) { - mOrientationScale = M_PI_2 / orientation->maxValue; - } else if (orientation->minValue < 0) { - mOrientationScale = -M_PI_2 / orientation->minValue; + RawAbsoluteAxisInfo orientationInfo; + deviceContext.getAbsoluteAxisInfo(ABS_MT_ORIENTATION, &orientationInfo); + if (orientationInfo.valid) { + if (orientationInfo.maxValue > 0) { + mOrientationScale = M_PI_2 / orientationInfo.maxValue; + } else if (orientationInfo.minValue < 0) { + mOrientationScale = -M_PI_2 / orientationInfo.minValue; } } // TODO(b/275369880): support touch.pressure.calibration and .scale properties when captured. - if (std::optional<RawAbsoluteAxisInfo> pressure = - deviceContext.getAbsoluteAxisInfo(ABS_MT_PRESSURE); - pressure && pressure->maxValue > 0) { - mPressureScale = 1.0 / pressure->maxValue; + RawAbsoluteAxisInfo pressureInfo; + deviceContext.getAbsoluteAxisInfo(ABS_MT_PRESSURE, &pressureInfo); + if (pressureInfo.valid && pressureInfo.maxValue > 0) { + mPressureScale = 1.0 / pressureInfo.maxValue; } - std::optional<RawAbsoluteAxisInfo> touchMajor = - deviceContext.getAbsoluteAxisInfo(ABS_MT_TOUCH_MAJOR); - std::optional<RawAbsoluteAxisInfo> toolMajor = - deviceContext.getAbsoluteAxisInfo(ABS_MT_WIDTH_MAJOR); - mHasTouchMajor = touchMajor.has_value(); - mHasToolMajor = toolMajor.has_value(); - if (mHasTouchMajor && touchMajor->maxValue != 0) { - mSizeScale = 1.0f / touchMajor->maxValue; - } else if (mHasToolMajor && toolMajor->maxValue != 0) { - mSizeScale = 1.0f / toolMajor->maxValue; + RawAbsoluteAxisInfo touchMajorInfo, toolMajorInfo; + deviceContext.getAbsoluteAxisInfo(ABS_MT_TOUCH_MAJOR, &touchMajorInfo); + deviceContext.getAbsoluteAxisInfo(ABS_MT_WIDTH_MAJOR, &toolMajorInfo); + mHasTouchMajor = touchMajorInfo.valid; + mHasToolMajor = toolMajorInfo.valid; + if (mHasTouchMajor && touchMajorInfo.maxValue != 0) { + mSizeScale = 1.0f / touchMajorInfo.maxValue; + } else if (mHasToolMajor && toolMajorInfo.maxValue != 0) { + mSizeScale = 1.0f / toolMajorInfo.maxValue; } } @@ -115,13 +113,15 @@ void CapturedTouchpadEventConverter::populateMotionRanges(InputDeviceInfo& info) tryAddRawMotionRange(/*byref*/ info, AMOTION_EVENT_AXIS_TOOL_MAJOR, ABS_MT_WIDTH_MAJOR); tryAddRawMotionRange(/*byref*/ info, AMOTION_EVENT_AXIS_TOOL_MINOR, ABS_MT_WIDTH_MINOR); - if (mDeviceContext.hasAbsoluteAxis(ABS_MT_PRESSURE)) { + RawAbsoluteAxisInfo pressureInfo; + mDeviceContext.getAbsoluteAxisInfo(ABS_MT_PRESSURE, &pressureInfo); + if (pressureInfo.valid) { info.addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, SOURCE, 0, 1, 0, 0, 0); } - if (std::optional<RawAbsoluteAxisInfo> orientation = - mDeviceContext.getAbsoluteAxisInfo(ABS_MT_ORIENTATION); - orientation && (orientation->maxValue > 0 || orientation->minValue < 0)) { + RawAbsoluteAxisInfo orientationInfo; + mDeviceContext.getAbsoluteAxisInfo(ABS_MT_ORIENTATION, &orientationInfo); + if (orientationInfo.valid && (orientationInfo.maxValue > 0 || orientationInfo.minValue < 0)) { info.addMotionRange(AMOTION_EVENT_AXIS_ORIENTATION, SOURCE, -M_PI_2, M_PI_2, 0, 0, 0); } @@ -133,10 +133,11 @@ void CapturedTouchpadEventConverter::populateMotionRanges(InputDeviceInfo& info) void CapturedTouchpadEventConverter::tryAddRawMotionRange(InputDeviceInfo& deviceInfo, int32_t androidAxis, int32_t evdevAxis) const { - std::optional<RawAbsoluteAxisInfo> info = mDeviceContext.getAbsoluteAxisInfo(evdevAxis); - if (info) { - deviceInfo.addMotionRange(androidAxis, SOURCE, info->minValue, info->maxValue, info->flat, - info->fuzz, info->resolution); + RawAbsoluteAxisInfo info; + mDeviceContext.getAbsoluteAxisInfo(evdevAxis, &info); + if (info.valid) { + deviceInfo.addMotionRange(androidAxis, SOURCE, info.minValue, info.maxValue, info.flat, + info.fuzz, info.resolution); } } diff --git a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp index 7cc8940379..3af1d04073 100644 --- a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp +++ b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp @@ -33,7 +33,7 @@ uint32_t ExternalStylusInputMapper::getSources() const { void ExternalStylusInputMapper::populateDeviceInfo(InputDeviceInfo& info) { InputMapper::populateDeviceInfo(info); - if (mRawPressureAxis) { + if (mRawPressureAxis.valid) { info.addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, AINPUT_SOURCE_STYLUS, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f); } @@ -50,7 +50,7 @@ void ExternalStylusInputMapper::dump(std::string& dump) { std::list<NotifyArgs> ExternalStylusInputMapper::reconfigure(nsecs_t when, const InputReaderConfiguration& config, ConfigurationChanges changes) { - mRawPressureAxis = getAbsoluteAxisInfo(ABS_PRESSURE); + getAbsoluteAxisInfo(ABS_PRESSURE, &mRawPressureAxis); mTouchButtonAccumulator.configure(); return {}; } @@ -82,10 +82,10 @@ std::list<NotifyArgs> ExternalStylusInputMapper::sync(nsecs_t when) { mStylusState.toolType = ToolType::STYLUS; } - if (mRawPressureAxis) { + if (mRawPressureAxis.valid) { auto rawPressure = static_cast<float>(mSingleTouchMotionAccumulator.getAbsolutePressure()); - mStylusState.pressure = (rawPressure - mRawPressureAxis->minValue) / - static_cast<float>(mRawPressureAxis->maxValue - mRawPressureAxis->minValue); + mStylusState.pressure = (rawPressure - mRawPressureAxis.minValue) / + static_cast<float>(mRawPressureAxis.maxValue - mRawPressureAxis.minValue); } else if (mTouchButtonAccumulator.hasButtonTouch()) { mStylusState.pressure = mTouchButtonAccumulator.isHovering() ? 0.0f : 1.0f; } diff --git a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.h b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.h index d48fd9b469..c040a7b996 100644 --- a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.h +++ b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.h @@ -16,8 +16,6 @@ #pragma once -#include <optional> - #include "InputMapper.h" #include "SingleTouchMotionAccumulator.h" @@ -45,7 +43,7 @@ public: private: SingleTouchMotionAccumulator mSingleTouchMotionAccumulator; - std::optional<RawAbsoluteAxisInfo> mRawPressureAxis; + RawAbsoluteAxisInfo mRawPressureAxis; TouchButtonAccumulator mTouchButtonAccumulator; StylusState mStylusState; diff --git a/services/inputflinger/reader/mapper/InputMapper.cpp b/services/inputflinger/reader/mapper/InputMapper.cpp index c44c48c0bf..b6c5c9806c 100644 --- a/services/inputflinger/reader/mapper/InputMapper.cpp +++ b/services/inputflinger/reader/mapper/InputMapper.cpp @@ -18,7 +18,6 @@ #include "InputMapper.h" -#include <optional> #include <sstream> #include <ftl/enum.h> @@ -117,16 +116,15 @@ std::list<NotifyArgs> InputMapper::updateExternalStylusState(const StylusState& return {}; } -std::optional<RawAbsoluteAxisInfo> InputMapper::getAbsoluteAxisInfo(int32_t axis) { - return getDeviceContext().getAbsoluteAxisInfo(axis); +status_t InputMapper::getAbsoluteAxisInfo(int32_t axis, RawAbsoluteAxisInfo* axisInfo) { + return getDeviceContext().getAbsoluteAxisInfo(axis, axisInfo); } void InputMapper::bumpGeneration() { getDeviceContext().bumpGeneration(); } -void InputMapper::dumpRawAbsoluteAxisInfo(std::string& dump, - const std::optional<RawAbsoluteAxisInfo>& axis, +void InputMapper::dumpRawAbsoluteAxisInfo(std::string& dump, const RawAbsoluteAxisInfo& axis, const char* name) { std::stringstream out; out << INDENT4 << name << ": " << axis << "\n"; diff --git a/services/inputflinger/reader/mapper/InputMapper.h b/services/inputflinger/reader/mapper/InputMapper.h index e5afcc798e..2c51448b4e 100644 --- a/services/inputflinger/reader/mapper/InputMapper.h +++ b/services/inputflinger/reader/mapper/InputMapper.h @@ -16,8 +16,6 @@ #pragma once -#include <optional> - #include "EventHub.h" #include "InputDevice.h" #include "InputListener.h" @@ -128,11 +126,10 @@ protected: explicit InputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig); - std::optional<RawAbsoluteAxisInfo> getAbsoluteAxisInfo(int32_t axis); + status_t getAbsoluteAxisInfo(int32_t axis, RawAbsoluteAxisInfo* axisInfo); void bumpGeneration(); - static void dumpRawAbsoluteAxisInfo(std::string& dump, - const std::optional<RawAbsoluteAxisInfo>& axis, + static void dumpRawAbsoluteAxisInfo(std::string& dump, const RawAbsoluteAxisInfo& axis, const char* name); static void dumpStylusState(std::string& dump, const StylusState& state); }; diff --git a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp index 3091714e00..41e018d392 100644 --- a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp +++ b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp @@ -117,8 +117,9 @@ std::list<NotifyArgs> JoystickInputMapper::reconfigure(nsecs_t when, continue; // axis must be claimed by a different device } - if (std::optional<RawAbsoluteAxisInfo> rawAxisInfo = getAbsoluteAxisInfo(abs); - rawAxisInfo) { + RawAbsoluteAxisInfo rawAxisInfo; + getAbsoluteAxisInfo(abs, &rawAxisInfo); + if (rawAxisInfo.valid) { // Map axis. AxisInfo axisInfo; const bool explicitlyMapped = !getDeviceContext().mapAxis(abs, &axisInfo); @@ -128,7 +129,7 @@ std::list<NotifyArgs> JoystickInputMapper::reconfigure(nsecs_t when, axisInfo.mode = AxisInfo::MODE_NORMAL; axisInfo.axis = -1; } - mAxes.insert({abs, createAxis(axisInfo, rawAxisInfo.value(), explicitlyMapped)}); + mAxes.insert({abs, createAxis(axisInfo, rawAxisInfo, explicitlyMapped)}); } } diff --git a/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp b/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp index 3ea3c20385..1986fe286a 100644 --- a/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp +++ b/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp @@ -133,7 +133,7 @@ void MultiTouchInputMapper::syncTouch(nsecs_t when, RawState* outState) { bool isHovering = mTouchButtonAccumulator.getToolType() != ToolType::MOUSE && (mTouchButtonAccumulator.isHovering() || - (mRawPointerAxes.pressure && inSlot.getPressure() <= 0)); + (mRawPointerAxes.pressure.valid && inSlot.getPressure() <= 0)); outPointer.isHovering = isHovering; // Assign pointer id using tracking id if available. @@ -189,23 +189,21 @@ std::list<NotifyArgs> MultiTouchInputMapper::reconfigure(nsecs_t when, void MultiTouchInputMapper::configureRawPointerAxes() { TouchInputMapper::configureRawPointerAxes(); - // We can safely assume that ABS_MT_POSITION_X and _Y axes will be available, as EventHub won't - // classify a device as multitouch if they're not present. - mRawPointerAxes.x = getAbsoluteAxisInfo(ABS_MT_POSITION_X).value(); - mRawPointerAxes.y = getAbsoluteAxisInfo(ABS_MT_POSITION_Y).value(); - mRawPointerAxes.touchMajor = getAbsoluteAxisInfo(ABS_MT_TOUCH_MAJOR); - mRawPointerAxes.touchMinor = getAbsoluteAxisInfo(ABS_MT_TOUCH_MINOR); - mRawPointerAxes.toolMajor = getAbsoluteAxisInfo(ABS_MT_WIDTH_MAJOR); - mRawPointerAxes.toolMinor = getAbsoluteAxisInfo(ABS_MT_WIDTH_MINOR); - mRawPointerAxes.orientation = getAbsoluteAxisInfo(ABS_MT_ORIENTATION); - mRawPointerAxes.pressure = getAbsoluteAxisInfo(ABS_MT_PRESSURE); - mRawPointerAxes.distance = getAbsoluteAxisInfo(ABS_MT_DISTANCE); - mRawPointerAxes.trackingId = getAbsoluteAxisInfo(ABS_MT_TRACKING_ID); - mRawPointerAxes.slot = getAbsoluteAxisInfo(ABS_MT_SLOT); - - if (mRawPointerAxes.trackingId && mRawPointerAxes.slot && mRawPointerAxes.slot->minValue == 0 && - mRawPointerAxes.slot->maxValue > 0) { - size_t slotCount = mRawPointerAxes.slot->maxValue + 1; + getAbsoluteAxisInfo(ABS_MT_POSITION_X, &mRawPointerAxes.x); + getAbsoluteAxisInfo(ABS_MT_POSITION_Y, &mRawPointerAxes.y); + getAbsoluteAxisInfo(ABS_MT_TOUCH_MAJOR, &mRawPointerAxes.touchMajor); + getAbsoluteAxisInfo(ABS_MT_TOUCH_MINOR, &mRawPointerAxes.touchMinor); + getAbsoluteAxisInfo(ABS_MT_WIDTH_MAJOR, &mRawPointerAxes.toolMajor); + getAbsoluteAxisInfo(ABS_MT_WIDTH_MINOR, &mRawPointerAxes.toolMinor); + getAbsoluteAxisInfo(ABS_MT_ORIENTATION, &mRawPointerAxes.orientation); + getAbsoluteAxisInfo(ABS_MT_PRESSURE, &mRawPointerAxes.pressure); + getAbsoluteAxisInfo(ABS_MT_DISTANCE, &mRawPointerAxes.distance); + getAbsoluteAxisInfo(ABS_MT_TRACKING_ID, &mRawPointerAxes.trackingId); + getAbsoluteAxisInfo(ABS_MT_SLOT, &mRawPointerAxes.slot); + + if (mRawPointerAxes.trackingId.valid && mRawPointerAxes.slot.valid && + mRawPointerAxes.slot.minValue == 0 && mRawPointerAxes.slot.maxValue > 0) { + size_t slotCount = mRawPointerAxes.slot.maxValue + 1; if (slotCount > MAX_SLOTS) { ALOGW("MultiTouch Device %s reported %zu slots but the framework " "only supports a maximum of %zu slots at this time.", diff --git a/services/inputflinger/reader/mapper/SensorInputMapper.cpp b/services/inputflinger/reader/mapper/SensorInputMapper.cpp index 4233f789d6..d7f2993daa 100644 --- a/services/inputflinger/reader/mapper/SensorInputMapper.cpp +++ b/services/inputflinger/reader/mapper/SensorInputMapper.cpp @@ -133,8 +133,9 @@ std::list<NotifyArgs> SensorInputMapper::reconfigure(nsecs_t when, .test(InputDeviceClass::SENSOR))) { continue; } - if (std::optional<RawAbsoluteAxisInfo> rawAxisInfo = getAbsoluteAxisInfo(abs); - rawAxisInfo) { + RawAbsoluteAxisInfo rawAxisInfo; + getAbsoluteAxisInfo(abs, &rawAxisInfo); + if (rawAxisInfo.valid) { AxisInfo axisInfo; // Axis doesn't need to be mapped, as sensor mapper doesn't generate any motion // input events @@ -145,7 +146,7 @@ std::list<NotifyArgs> SensorInputMapper::reconfigure(nsecs_t when, if (ret.ok()) { InputDeviceSensorType sensorType = (*ret).first; int32_t sensorDataIndex = (*ret).second; - const Axis& axis = createAxis(axisInfo, rawAxisInfo.value()); + const Axis& axis = createAxis(axisInfo, rawAxisInfo); parseSensorConfiguration(sensorType, abs, sensorDataIndex, axis); mAxes.insert({abs, axis}); diff --git a/services/inputflinger/reader/mapper/SingleTouchInputMapper.cpp b/services/inputflinger/reader/mapper/SingleTouchInputMapper.cpp index 869feb4359..140bb0c4ed 100644 --- a/services/inputflinger/reader/mapper/SingleTouchInputMapper.cpp +++ b/services/inputflinger/reader/mapper/SingleTouchInputMapper.cpp @@ -44,7 +44,7 @@ void SingleTouchInputMapper::syncTouch(nsecs_t when, RawState* outState) { bool isHovering = mTouchButtonAccumulator.getToolType() != ToolType::MOUSE && (mTouchButtonAccumulator.isHovering() || - (mRawPointerAxes.pressure && + (mRawPointerAxes.pressure.valid && mSingleTouchMotionAccumulator.getAbsolutePressure() <= 0)); outState->rawPointerData.markIdBit(0, isHovering); @@ -72,15 +72,13 @@ void SingleTouchInputMapper::syncTouch(nsecs_t when, RawState* outState) { void SingleTouchInputMapper::configureRawPointerAxes() { TouchInputMapper::configureRawPointerAxes(); - // We can safely assume that ABS_X and _Y axes will be available, as EventHub won't classify a - // device as a touch device if they're not present. - mRawPointerAxes.x = getAbsoluteAxisInfo(ABS_X).value(); - mRawPointerAxes.y = getAbsoluteAxisInfo(ABS_Y).value(); - mRawPointerAxes.pressure = getAbsoluteAxisInfo(ABS_PRESSURE); - mRawPointerAxes.toolMajor = getAbsoluteAxisInfo(ABS_TOOL_WIDTH); - mRawPointerAxes.distance = getAbsoluteAxisInfo(ABS_DISTANCE); - mRawPointerAxes.tiltX = getAbsoluteAxisInfo(ABS_TILT_X); - mRawPointerAxes.tiltY = getAbsoluteAxisInfo(ABS_TILT_Y); + getAbsoluteAxisInfo(ABS_X, &mRawPointerAxes.x); + getAbsoluteAxisInfo(ABS_Y, &mRawPointerAxes.y); + getAbsoluteAxisInfo(ABS_PRESSURE, &mRawPointerAxes.pressure); + getAbsoluteAxisInfo(ABS_TOOL_WIDTH, &mRawPointerAxes.toolMajor); + getAbsoluteAxisInfo(ABS_DISTANCE, &mRawPointerAxes.distance); + getAbsoluteAxisInfo(ABS_TILT_X, &mRawPointerAxes.tiltX); + getAbsoluteAxisInfo(ABS_TILT_Y, &mRawPointerAxes.tiltY); } bool SingleTouchInputMapper::hasStylus() const { diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp index beba3b896f..81ec24e094 100644 --- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp +++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp @@ -600,10 +600,10 @@ void TouchInputMapper::initializeSizeRanges() { const float diagonalSize = hypotf(mDisplayBounds.width, mDisplayBounds.height); // Size factors. - if (mRawPointerAxes.touchMajor && mRawPointerAxes.touchMajor->maxValue != 0) { - mSizeScale = 1.0f / mRawPointerAxes.touchMajor->maxValue; - } else if (mRawPointerAxes.toolMajor && mRawPointerAxes.toolMajor->maxValue != 0) { - mSizeScale = 1.0f / mRawPointerAxes.toolMajor->maxValue; + if (mRawPointerAxes.touchMajor.valid && mRawPointerAxes.touchMajor.maxValue != 0) { + mSizeScale = 1.0f / mRawPointerAxes.touchMajor.maxValue; + } else if (mRawPointerAxes.toolMajor.valid && mRawPointerAxes.toolMajor.maxValue != 0) { + mSizeScale = 1.0f / mRawPointerAxes.toolMajor.maxValue; } else { mSizeScale = 0.0f; } @@ -618,18 +618,18 @@ void TouchInputMapper::initializeSizeRanges() { .resolution = 0, }; - if (mRawPointerAxes.touchMajor) { - mRawPointerAxes.touchMajor->resolution = - clampResolution("touchMajor", mRawPointerAxes.touchMajor->resolution); - mOrientedRanges.touchMajor->resolution = mRawPointerAxes.touchMajor->resolution; + if (mRawPointerAxes.touchMajor.valid) { + mRawPointerAxes.touchMajor.resolution = + clampResolution("touchMajor", mRawPointerAxes.touchMajor.resolution); + mOrientedRanges.touchMajor->resolution = mRawPointerAxes.touchMajor.resolution; } mOrientedRanges.touchMinor = mOrientedRanges.touchMajor; mOrientedRanges.touchMinor->axis = AMOTION_EVENT_AXIS_TOUCH_MINOR; - if (mRawPointerAxes.touchMinor) { - mRawPointerAxes.touchMinor->resolution = - clampResolution("touchMinor", mRawPointerAxes.touchMinor->resolution); - mOrientedRanges.touchMinor->resolution = mRawPointerAxes.touchMinor->resolution; + if (mRawPointerAxes.touchMinor.valid) { + mRawPointerAxes.touchMinor.resolution = + clampResolution("touchMinor", mRawPointerAxes.touchMinor.resolution); + mOrientedRanges.touchMinor->resolution = mRawPointerAxes.touchMinor.resolution; } mOrientedRanges.toolMajor = InputDeviceInfo::MotionRange{ @@ -641,18 +641,18 @@ void TouchInputMapper::initializeSizeRanges() { .fuzz = 0, .resolution = 0, }; - if (mRawPointerAxes.toolMajor) { - mRawPointerAxes.toolMajor->resolution = - clampResolution("toolMajor", mRawPointerAxes.toolMajor->resolution); - mOrientedRanges.toolMajor->resolution = mRawPointerAxes.toolMajor->resolution; + if (mRawPointerAxes.toolMajor.valid) { + mRawPointerAxes.toolMajor.resolution = + clampResolution("toolMajor", mRawPointerAxes.toolMajor.resolution); + mOrientedRanges.toolMajor->resolution = mRawPointerAxes.toolMajor.resolution; } mOrientedRanges.toolMinor = mOrientedRanges.toolMajor; mOrientedRanges.toolMinor->axis = AMOTION_EVENT_AXIS_TOOL_MINOR; - if (mRawPointerAxes.toolMinor) { - mRawPointerAxes.toolMinor->resolution = - clampResolution("toolMinor", mRawPointerAxes.toolMinor->resolution); - mOrientedRanges.toolMinor->resolution = mRawPointerAxes.toolMinor->resolution; + if (mRawPointerAxes.toolMinor.valid) { + mRawPointerAxes.toolMinor.resolution = + clampResolution("toolMinor", mRawPointerAxes.toolMinor.resolution); + mOrientedRanges.toolMinor->resolution = mRawPointerAxes.toolMinor.resolution; } if (mCalibration.sizeCalibration == Calibration::SizeCalibration::GEOMETRIC) { @@ -704,10 +704,9 @@ void TouchInputMapper::initializeOrientedRanges() { mCalibration.pressureCalibration == Calibration::PressureCalibration::AMPLITUDE) { if (mCalibration.pressureScale) { mPressureScale = *mCalibration.pressureScale; - pressureMax = mPressureScale * - (mRawPointerAxes.pressure ? mRawPointerAxes.pressure->maxValue : 0); - } else if (mRawPointerAxes.pressure && mRawPointerAxes.pressure->maxValue != 0) { - mPressureScale = 1.0f / mRawPointerAxes.pressure->maxValue; + pressureMax = mPressureScale * mRawPointerAxes.pressure.maxValue; + } else if (mRawPointerAxes.pressure.valid && mRawPointerAxes.pressure.maxValue != 0) { + mPressureScale = 1.0f / mRawPointerAxes.pressure.maxValue; } } @@ -726,18 +725,18 @@ void TouchInputMapper::initializeOrientedRanges() { mTiltXScale = 0; mTiltYCenter = 0; mTiltYScale = 0; - mHaveTilt = mRawPointerAxes.tiltX && mRawPointerAxes.tiltY; + mHaveTilt = mRawPointerAxes.tiltX.valid && mRawPointerAxes.tiltY.valid; if (mHaveTilt) { - mTiltXCenter = avg(mRawPointerAxes.tiltX->minValue, mRawPointerAxes.tiltX->maxValue); - mTiltYCenter = avg(mRawPointerAxes.tiltY->minValue, mRawPointerAxes.tiltY->maxValue); + mTiltXCenter = avg(mRawPointerAxes.tiltX.minValue, mRawPointerAxes.tiltX.maxValue); + mTiltYCenter = avg(mRawPointerAxes.tiltY.minValue, mRawPointerAxes.tiltY.maxValue); mTiltXScale = M_PI / 180; mTiltYScale = M_PI / 180; - if (mRawPointerAxes.tiltX->resolution) { - mTiltXScale = 1.0 / mRawPointerAxes.tiltX->resolution; + if (mRawPointerAxes.tiltX.resolution) { + mTiltXScale = 1.0 / mRawPointerAxes.tiltX.resolution; } - if (mRawPointerAxes.tiltY->resolution) { - mTiltYScale = 1.0 / mRawPointerAxes.tiltY->resolution; + if (mRawPointerAxes.tiltY.resolution) { + mTiltYScale = 1.0 / mRawPointerAxes.tiltY.resolution; } mOrientedRanges.tilt = InputDeviceInfo::MotionRange{ @@ -767,11 +766,11 @@ void TouchInputMapper::initializeOrientedRanges() { } else if (mCalibration.orientationCalibration != Calibration::OrientationCalibration::NONE) { if (mCalibration.orientationCalibration == Calibration::OrientationCalibration::INTERPOLATED) { - if (mRawPointerAxes.orientation) { - if (mRawPointerAxes.orientation->maxValue > 0) { - mOrientationScale = M_PI_2 / mRawPointerAxes.orientation->maxValue; - } else if (mRawPointerAxes.orientation->minValue < 0) { - mOrientationScale = -M_PI_2 / mRawPointerAxes.orientation->minValue; + if (mRawPointerAxes.orientation.valid) { + if (mRawPointerAxes.orientation.maxValue > 0) { + mOrientationScale = M_PI_2 / mRawPointerAxes.orientation.maxValue; + } else if (mRawPointerAxes.orientation.minValue < 0) { + mOrientationScale = -M_PI_2 / mRawPointerAxes.orientation.minValue; } else { mOrientationScale = 0; } @@ -796,14 +795,14 @@ void TouchInputMapper::initializeOrientedRanges() { mDistanceScale = mCalibration.distanceScale.value_or(1.0f); } - const bool hasDistance = mRawPointerAxes.distance.has_value(); mOrientedRanges.distance = InputDeviceInfo::MotionRange{ + .axis = AMOTION_EVENT_AXIS_DISTANCE, .source = mSource, - .min = hasDistance ? mRawPointerAxes.distance->minValue * mDistanceScale : 0, - .max = hasDistance ? mRawPointerAxes.distance->maxValue * mDistanceScale : 0, + .min = mRawPointerAxes.distance.minValue * mDistanceScale, + .max = mRawPointerAxes.distance.maxValue * mDistanceScale, .flat = 0, - .fuzz = hasDistance ? mRawPointerAxes.distance->fuzz * mDistanceScale : 0, + .fuzz = mRawPointerAxes.distance.fuzz * mDistanceScale, .resolution = 0, }; } @@ -944,7 +943,12 @@ void TouchInputMapper::configureInputDevice(nsecs_t when, bool* outResetNeeded) const std::optional<DisplayViewport> newViewportOpt = findViewport(); // Ensure the device is valid and can be used. - if (!newViewportOpt) { + if (!mRawPointerAxes.x.valid || !mRawPointerAxes.y.valid) { + ALOGW("Touch device '%s' did not report support for X or Y axis! " + "The device will be inoperable.", + getDeviceName().c_str()); + mDeviceMode = DeviceMode::DISABLED; + } else if (!newViewportOpt) { ALOGI("Touch device '%s' could not query the properties of its associated " "display. The device will be inoperable until the display size " "becomes available.", @@ -1233,7 +1237,7 @@ void TouchInputMapper::parseCalibration() { void TouchInputMapper::resolveCalibration() { // Size - if (mRawPointerAxes.touchMajor || mRawPointerAxes.toolMajor) { + if (mRawPointerAxes.touchMajor.valid || mRawPointerAxes.toolMajor.valid) { if (mCalibration.sizeCalibration == Calibration::SizeCalibration::DEFAULT) { mCalibration.sizeCalibration = Calibration::SizeCalibration::GEOMETRIC; } @@ -1242,7 +1246,7 @@ void TouchInputMapper::resolveCalibration() { } // Pressure - if (mRawPointerAxes.pressure) { + if (mRawPointerAxes.pressure.valid) { if (mCalibration.pressureCalibration == Calibration::PressureCalibration::DEFAULT) { mCalibration.pressureCalibration = Calibration::PressureCalibration::PHYSICAL; } @@ -1251,7 +1255,7 @@ void TouchInputMapper::resolveCalibration() { } // Orientation - if (mRawPointerAxes.orientation) { + if (mRawPointerAxes.orientation.valid) { if (mCalibration.orientationCalibration == Calibration::OrientationCalibration::DEFAULT) { mCalibration.orientationCalibration = Calibration::OrientationCalibration::INTERPOLATED; } @@ -1260,7 +1264,7 @@ void TouchInputMapper::resolveCalibration() { } // Distance - if (mRawPointerAxes.distance) { + if (mRawPointerAxes.distance.valid) { if (mCalibration.distanceCalibration == Calibration::DistanceCalibration::DEFAULT) { mCalibration.distanceCalibration = Calibration::DistanceCalibration::SCALED; } @@ -2247,25 +2251,25 @@ void TouchInputMapper::cookPointerData() { case Calibration::SizeCalibration::DIAMETER: case Calibration::SizeCalibration::BOX: case Calibration::SizeCalibration::AREA: - if (mRawPointerAxes.touchMajor && mRawPointerAxes.toolMajor) { + if (mRawPointerAxes.touchMajor.valid && mRawPointerAxes.toolMajor.valid) { touchMajor = in.touchMajor; - touchMinor = mRawPointerAxes.touchMinor ? in.touchMinor : in.touchMajor; + touchMinor = mRawPointerAxes.touchMinor.valid ? in.touchMinor : in.touchMajor; toolMajor = in.toolMajor; - toolMinor = mRawPointerAxes.toolMinor ? in.toolMinor : in.toolMajor; - size = mRawPointerAxes.touchMinor ? avg(in.touchMajor, in.touchMinor) - : in.touchMajor; - } else if (mRawPointerAxes.touchMajor) { + toolMinor = mRawPointerAxes.toolMinor.valid ? in.toolMinor : in.toolMajor; + size = mRawPointerAxes.touchMinor.valid ? avg(in.touchMajor, in.touchMinor) + : in.touchMajor; + } else if (mRawPointerAxes.touchMajor.valid) { toolMajor = touchMajor = in.touchMajor; toolMinor = touchMinor = - mRawPointerAxes.touchMinor ? in.touchMinor : in.touchMajor; - size = mRawPointerAxes.touchMinor ? avg(in.touchMajor, in.touchMinor) - : in.touchMajor; - } else if (mRawPointerAxes.toolMajor) { + mRawPointerAxes.touchMinor.valid ? in.touchMinor : in.touchMajor; + size = mRawPointerAxes.touchMinor.valid ? avg(in.touchMajor, in.touchMinor) + : in.touchMajor; + } else if (mRawPointerAxes.toolMajor.valid) { touchMajor = toolMajor = in.toolMajor; touchMinor = toolMinor = - mRawPointerAxes.toolMinor ? in.toolMinor : in.toolMajor; - size = mRawPointerAxes.toolMinor ? avg(in.toolMajor, in.toolMinor) - : in.toolMajor; + mRawPointerAxes.toolMinor.valid ? in.toolMinor : in.toolMajor; + size = mRawPointerAxes.toolMinor.valid ? avg(in.toolMajor, in.toolMinor) + : in.toolMajor; } else { ALOG_ASSERT(false, "No touch or tool axes. " diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.h b/services/inputflinger/reader/mapper/TouchInputMapper.h index beab6e7179..30c58a59c5 100644 --- a/services/inputflinger/reader/mapper/TouchInputMapper.h +++ b/services/inputflinger/reader/mapper/TouchInputMapper.h @@ -61,17 +61,17 @@ static constexpr nsecs_t TOUCH_DATA_TIMEOUT = ms2ns(20); struct RawPointerAxes { RawAbsoluteAxisInfo x{}; RawAbsoluteAxisInfo y{}; - std::optional<RawAbsoluteAxisInfo> pressure{}; - std::optional<RawAbsoluteAxisInfo> touchMajor{}; - std::optional<RawAbsoluteAxisInfo> touchMinor{}; - std::optional<RawAbsoluteAxisInfo> toolMajor{}; - std::optional<RawAbsoluteAxisInfo> toolMinor{}; - std::optional<RawAbsoluteAxisInfo> orientation{}; - std::optional<RawAbsoluteAxisInfo> distance{}; - std::optional<RawAbsoluteAxisInfo> tiltX{}; - std::optional<RawAbsoluteAxisInfo> tiltY{}; - std::optional<RawAbsoluteAxisInfo> trackingId{}; - std::optional<RawAbsoluteAxisInfo> slot{}; + RawAbsoluteAxisInfo pressure{}; + RawAbsoluteAxisInfo touchMajor{}; + RawAbsoluteAxisInfo touchMinor{}; + RawAbsoluteAxisInfo toolMajor{}; + RawAbsoluteAxisInfo toolMinor{}; + RawAbsoluteAxisInfo orientation{}; + RawAbsoluteAxisInfo distance{}; + RawAbsoluteAxisInfo tiltX{}; + RawAbsoluteAxisInfo tiltY{}; + RawAbsoluteAxisInfo trackingId{}; + RawAbsoluteAxisInfo slot{}; inline int32_t getRawWidth() const { return x.maxValue - x.minValue + 1; } inline int32_t getRawHeight() const { return y.maxValue - y.minValue + 1; } diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp index daab636c59..24efae893e 100644 --- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp +++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp @@ -240,15 +240,14 @@ TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext, mGestureConverter(*getContext(), deviceContext, getDeviceId()), mCapturedEventConverter(*getContext(), deviceContext, mMotionAccumulator, getDeviceId()), mMetricsId(metricsIdFromInputDeviceIdentifier(deviceContext.getDeviceIdentifier())) { - if (std::optional<RawAbsoluteAxisInfo> slotAxis = - deviceContext.getAbsoluteAxisInfo(ABS_MT_SLOT); - slotAxis && slotAxis->maxValue >= 0) { - mMotionAccumulator.configure(deviceContext, slotAxis->maxValue + 1, true); - } else { + RawAbsoluteAxisInfo slotAxisInfo; + deviceContext.getAbsoluteAxisInfo(ABS_MT_SLOT, &slotAxisInfo); + if (!slotAxisInfo.valid || slotAxisInfo.maxValue < 0) { LOG(WARNING) << "Touchpad " << deviceContext.getName() << " doesn't have a valid ABS_MT_SLOT axis, and probably won't work properly."; - mMotionAccumulator.configure(deviceContext, 1, true); + slotAxisInfo.maxValue = 0; } + mMotionAccumulator.configure(deviceContext, slotAxisInfo.maxValue + 1, true); mGestureInterpreter->Initialize(GESTURES_DEVCLASS_TOUCHPAD); mGestureInterpreter->SetHardwareProperties(createHardwareProperties(deviceContext)); diff --git a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp index 9924d0d491..e8e7376e92 100644 --- a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp +++ b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp @@ -66,11 +66,10 @@ GestureConverter::GestureConverter(InputReaderContext& readerContext, const InputDeviceContext& deviceContext, int32_t deviceId) : mDeviceId(deviceId), mReaderContext(readerContext), - mEnableFlingStop(input_flags::enable_touchpad_fling_stop()), - // We can safely assume that ABS_MT_POSITION_X and _Y axes will be available, as EventHub - // won't classify a device as a touchpad if they're not present. - mXAxisInfo(deviceContext.getAbsoluteAxisInfo(ABS_MT_POSITION_X).value()), - mYAxisInfo(deviceContext.getAbsoluteAxisInfo(ABS_MT_POSITION_Y).value()) {} + mEnableFlingStop(input_flags::enable_touchpad_fling_stop()) { + deviceContext.getAbsoluteAxisInfo(ABS_MT_POSITION_X, &mXAxisInfo); + deviceContext.getAbsoluteAxisInfo(ABS_MT_POSITION_Y, &mYAxisInfo); +} std::string GestureConverter::dump() const { std::stringstream out; diff --git a/services/inputflinger/reader/mapper/gestures/HardwareProperties.cpp b/services/inputflinger/reader/mapper/gestures/HardwareProperties.cpp index d8a1f501d1..04655dc439 100644 --- a/services/inputflinger/reader/mapper/gestures/HardwareProperties.cpp +++ b/services/inputflinger/reader/mapper/gestures/HardwareProperties.cpp @@ -16,8 +16,6 @@ #include "HardwareProperties.h" -#include <optional> - namespace android { namespace { @@ -35,34 +33,26 @@ unsigned short getMaxTouchCount(const InputDeviceContext& context) { HardwareProperties createHardwareProperties(const InputDeviceContext& context) { HardwareProperties props; - // We can safely assume that ABS_MT_POSITION_X and _Y axes will be available, as EventHub won't - // classify a device as a touchpad if they're not present. - RawAbsoluteAxisInfo absMtPositionX = context.getAbsoluteAxisInfo(ABS_MT_POSITION_X).value(); + RawAbsoluteAxisInfo absMtPositionX; + context.getAbsoluteAxisInfo(ABS_MT_POSITION_X, &absMtPositionX); props.left = absMtPositionX.minValue; props.right = absMtPositionX.maxValue; props.res_x = absMtPositionX.resolution; - RawAbsoluteAxisInfo absMtPositionY = context.getAbsoluteAxisInfo(ABS_MT_POSITION_Y).value(); + RawAbsoluteAxisInfo absMtPositionY; + context.getAbsoluteAxisInfo(ABS_MT_POSITION_Y, &absMtPositionY); props.top = absMtPositionY.minValue; props.bottom = absMtPositionY.maxValue; props.res_y = absMtPositionY.resolution; - if (std::optional<RawAbsoluteAxisInfo> absMtOrientation = - context.getAbsoluteAxisInfo(ABS_MT_ORIENTATION); - absMtOrientation) { - props.orientation_minimum = absMtOrientation->minValue; - props.orientation_maximum = absMtOrientation->maxValue; - } else { - props.orientation_minimum = 0; - props.orientation_maximum = 0; - } + RawAbsoluteAxisInfo absMtOrientation; + context.getAbsoluteAxisInfo(ABS_MT_ORIENTATION, &absMtOrientation); + props.orientation_minimum = absMtOrientation.minValue; + props.orientation_maximum = absMtOrientation.maxValue; - if (std::optional<RawAbsoluteAxisInfo> absMtSlot = context.getAbsoluteAxisInfo(ABS_MT_SLOT); - absMtSlot) { - props.max_finger_cnt = absMtSlot->maxValue - absMtSlot->minValue + 1; - } else { - props.max_finger_cnt = 1; - } + RawAbsoluteAxisInfo absMtSlot; + context.getAbsoluteAxisInfo(ABS_MT_SLOT, &absMtSlot); + props.max_finger_cnt = absMtSlot.maxValue - absMtSlot.minValue + 1; props.max_touch_cnt = getMaxTouchCount(context); // T5R2 ("Track 5, Report 2") is a feature of some old Synaptics touchpads that could track 5 @@ -81,7 +71,9 @@ HardwareProperties createHardwareProperties(const InputDeviceContext& context) { // are haptic. props.is_haptic_pad = false; - props.reports_pressure = context.hasAbsoluteAxis(ABS_MT_PRESSURE); + RawAbsoluteAxisInfo absMtPressure; + context.getAbsoluteAxisInfo(ABS_MT_PRESSURE, &absMtPressure); + props.reports_pressure = absMtPressure.valid; return props; } diff --git a/services/inputflinger/tests/FakeEventHub.cpp b/services/inputflinger/tests/FakeEventHub.cpp index 7079278a90..12736c8cc0 100644 --- a/services/inputflinger/tests/FakeEventHub.cpp +++ b/services/inputflinger/tests/FakeEventHub.cpp @@ -105,6 +105,7 @@ void FakeEventHub::addAbsoluteAxis(int32_t deviceId, int axis, int32_t minValue, Device* device = getDevice(deviceId); RawAbsoluteAxisInfo info; + info.valid = true; info.minValue = minValue; info.maxValue = maxValue; info.flat = flat; diff --git a/services/inputflinger/tests/HardwareProperties_test.cpp b/services/inputflinger/tests/HardwareProperties_test.cpp index e87f8228c8..643fab6d44 100644 --- a/services/inputflinger/tests/HardwareProperties_test.cpp +++ b/services/inputflinger/tests/HardwareProperties_test.cpp @@ -50,6 +50,7 @@ protected: void setupValidAxis(int axis, int32_t min, int32_t max, int32_t resolution) { EXPECT_CALL(mMockEventHub, getAbsoluteAxisInfo(EVENTHUB_ID, axis)) .WillRepeatedly(Return(std::optional<RawAbsoluteAxisInfo>{{ + .valid = true, .minValue = min, .maxValue = max, .flat = 0, diff --git a/services/inputflinger/tests/InputMapperTest.cpp b/services/inputflinger/tests/InputMapperTest.cpp index 5722444f16..19bc5bef66 100644 --- a/services/inputflinger/tests/InputMapperTest.cpp +++ b/services/inputflinger/tests/InputMapperTest.cpp @@ -59,6 +59,7 @@ void InputMapperUnitTest::setupAxis(int axis, bool valid, int32_t min, int32_t m int32_t resolution) { EXPECT_CALL(mMockEventHub, getAbsoluteAxisInfo(EVENTHUB_ID, axis)) .WillRepeatedly(Return(valid ? std::optional<RawAbsoluteAxisInfo>{{ + .valid = true, .minValue = min, .maxValue = max, .flat = 0, diff --git a/services/inputflinger/tests/fuzzers/MapperHelpers.h b/services/inputflinger/tests/fuzzers/MapperHelpers.h index 969c03268e..6dea540e9c 100644 --- a/services/inputflinger/tests/fuzzers/MapperHelpers.h +++ b/services/inputflinger/tests/fuzzers/MapperHelpers.h @@ -130,6 +130,7 @@ public: } if (mFdp->ConsumeBool()) { return std::optional<RawAbsoluteAxisInfo>({ + .valid = mFdp->ConsumeBool(), .minValue = mFdp->ConsumeIntegral<int32_t>(), .maxValue = mFdp->ConsumeIntegral<int32_t>(), .flat = mFdp->ConsumeIntegral<int32_t>(), diff --git a/services/inputflinger/tests/fuzzers/TouchpadInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/TouchpadInputFuzzer.cpp index ebbb311512..c620032eef 100644 --- a/services/inputflinger/tests/fuzzers/TouchpadInputFuzzer.cpp +++ b/services/inputflinger/tests/fuzzers/TouchpadInputFuzzer.cpp @@ -34,6 +34,7 @@ void setAxisInfo(ThreadSafeFuzzedDataProvider& fdp, FuzzEventHub& eventHub, int3 if (fdp.ConsumeBool()) { eventHub.setAbsoluteAxisInfo(id, axis, RawAbsoluteAxisInfo{ + .valid = fdp.ConsumeBool(), .minValue = fdp.ConsumeIntegral<int32_t>(), .maxValue = fdp.ConsumeIntegral<int32_t>(), .flat = fdp.ConsumeIntegral<int32_t>(), |