InputMapper: use a reference for InputDeviceInfo parameter
This makes the code a bit safer, especially since we never check for
this parameter being null.
Bug: 245989146
Test: atest inputflinger_tests
Test: dump motion ranges from a test app, check they're still there
Change-Id: I2754e57c8b261f86ad69891098c9762b96e9ec55
diff --git a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
index d7f8b17..7724cf7 100644
--- a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
@@ -29,7 +29,7 @@
return AINPUT_SOURCE_JOYSTICK;
}
-void JoystickInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+void JoystickInputMapper::populateDeviceInfo(InputDeviceInfo& info) {
InputMapper::populateDeviceInfo(info);
for (const auto& [_, axis] : mAxes) {
@@ -41,16 +41,16 @@
}
}
-void JoystickInputMapper::addMotionRange(int32_t axisId, const Axis& axis, InputDeviceInfo* info) {
- info->addMotionRange(axisId, AINPUT_SOURCE_JOYSTICK, axis.min, axis.max, axis.flat, axis.fuzz,
- axis.resolution);
+void JoystickInputMapper::addMotionRange(int32_t axisId, const Axis& axis, InputDeviceInfo& info) {
+ info.addMotionRange(axisId, AINPUT_SOURCE_JOYSTICK, axis.min, axis.max, axis.flat, axis.fuzz,
+ axis.resolution);
/* In order to ease the transition for developers from using the old axes
* to the newer, more semantically correct axes, we'll continue to register
* the old axes as duplicates of their corresponding new ones. */
int32_t compatAxis = getCompatAxis(axisId);
if (compatAxis >= 0) {
- info->addMotionRange(compatAxis, AINPUT_SOURCE_JOYSTICK, axis.min, axis.max, axis.flat,
- axis.fuzz, axis.resolution);
+ info.addMotionRange(compatAxis, AINPUT_SOURCE_JOYSTICK, axis.min, axis.max, axis.flat,
+ axis.fuzz, axis.resolution);
}
}