Skip to content

Commit 6a7626a

Browse files
committed
TouchInputMapper: Add fatal check expecting x/y axes to always be present
Bug: 358694799 Flag: EXEMPT bug fix Test: Presubmit Change-Id: Iabf9a40c220dcaff7a4fdd6b16b0b117c7a198d9
1 parent 744e83f commit 6a7626a

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "../Macros.h"
1818

19+
#include <android-base/logging.h>
1920
#include <android/sysprop/InputProperties.sysprop.h>
2021
#include "MultiTouchInputMapper.h"
2122

@@ -187,14 +188,11 @@ std::list<NotifyArgs> MultiTouchInputMapper::reconfigure(nsecs_t when,
187188
void MultiTouchInputMapper::configureRawPointerAxes() {
188189
TouchInputMapper::configureRawPointerAxes();
189190

190-
// TODO(b/351870641): Investigate why we are sometime not getting valid axis infos for the x/y
191-
// axes, even though those axes are required to be supported.
192-
if (const auto xInfo = getAbsoluteAxisInfo(ABS_MT_POSITION_X); xInfo.has_value()) {
193-
mRawPointerAxes.x = *xInfo;
194-
}
195-
if (const auto yInfo = getAbsoluteAxisInfo(ABS_MT_POSITION_Y); yInfo.has_value()) {
196-
mRawPointerAxes.y = *yInfo;
197-
}
191+
const auto xInfo = getAbsoluteAxisInfo(ABS_MT_POSITION_X);
192+
const auto yInfo = getAbsoluteAxisInfo(ABS_MT_POSITION_Y);
193+
LOG_IF(FATAL, !xInfo || !yInfo) << "X/Y axes not found for multi-touch device";
194+
mRawPointerAxes.x = *xInfo;
195+
mRawPointerAxes.y = *yInfo;
198196
mRawPointerAxes.touchMajor = getAbsoluteAxisInfo(ABS_MT_TOUCH_MAJOR);
199197
mRawPointerAxes.touchMinor = getAbsoluteAxisInfo(ABS_MT_TOUCH_MINOR);
200198
mRawPointerAxes.toolMajor = getAbsoluteAxisInfo(ABS_MT_WIDTH_MAJOR);

services/inputflinger/reader/mapper/SingleTouchInputMapper.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include "SingleTouchInputMapper.h"
1818

19+
#include <android-base/logging.h>
20+
1921
namespace android {
2022

2123
SingleTouchInputMapper::SingleTouchInputMapper(InputDeviceContext& deviceContext,
@@ -72,14 +74,11 @@ void SingleTouchInputMapper::syncTouch(nsecs_t when, RawState* outState) {
7274
void SingleTouchInputMapper::configureRawPointerAxes() {
7375
TouchInputMapper::configureRawPointerAxes();
7476

75-
// TODO(b/351870641): Investigate why we are sometime not getting valid axis infos for the x/y
76-
// axes, even though those axes are required to be supported.
77-
if (const auto xInfo = getAbsoluteAxisInfo(ABS_X); xInfo.has_value()) {
78-
mRawPointerAxes.x = *xInfo;
79-
}
80-
if (const auto yInfo = getAbsoluteAxisInfo(ABS_Y); yInfo.has_value()) {
81-
mRawPointerAxes.y = *yInfo;
82-
}
77+
const auto xInfo = getAbsoluteAxisInfo(ABS_X);
78+
const auto yInfo = getAbsoluteAxisInfo(ABS_Y);
79+
LOG_IF(FATAL, !xInfo || !yInfo) << "X/Y axes not found for single-touch device";
80+
mRawPointerAxes.x = *xInfo;
81+
mRawPointerAxes.y = *yInfo;
8382
mRawPointerAxes.pressure = getAbsoluteAxisInfo(ABS_PRESSURE);
8483
mRawPointerAxes.toolMajor = getAbsoluteAxisInfo(ABS_TOOL_WIDTH);
8584
mRawPointerAxes.distance = getAbsoluteAxisInfo(ABS_DISTANCE);

services/inputflinger/tests/InputReader_test.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,15 @@ class InputReaderTest : public testing::Test {
616616
mFakeEventHub->addDevice(eventHubId, name, classes);
617617
mFakeEventHub->setSysfsRootPath(eventHubId, sysfsRootPath);
618618

619+
// Populate required axis info.
620+
if (classes.test(InputDeviceClass::TOUCH_MT)) {
621+
mFakeEventHub->addAbsoluteAxis(eventHubId, ABS_MT_POSITION_X, 0, 1, 0, 0);
622+
mFakeEventHub->addAbsoluteAxis(eventHubId, ABS_MT_POSITION_Y, 0, 1, 0, 0);
623+
} else if (classes.test(InputDeviceClass::TOUCH)) {
624+
mFakeEventHub->addAbsoluteAxis(eventHubId, ABS_X, 0, 1, 0, 0);
625+
mFakeEventHub->addAbsoluteAxis(eventHubId, ABS_Y, 0, 1, 0, 0);
626+
}
627+
619628
if (configuration) {
620629
mFakeEventHub->addConfigurationMap(eventHubId, configuration);
621630
}

0 commit comments

Comments
 (0)