Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6a7626a0 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

TouchInputMapper: Add fatal check expecting x/y axes to always be present

Bug: 358694799
Flag: EXEMPT bug fix
Test: Presubmit
Change-Id: Iabf9a40c220dcaff7a4fdd6b16b0b117c7a198d9
parent 744e83f9
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#include "../Macros.h"

#include <android-base/logging.h>
#include <android/sysprop/InputProperties.sysprop.h>
#include "MultiTouchInputMapper.h"

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

    // TODO(b/351870641): Investigate why we are sometime not getting valid axis infos for the x/y
    //   axes, even though those axes are required to be supported.
    if (const auto xInfo = getAbsoluteAxisInfo(ABS_MT_POSITION_X); xInfo.has_value()) {
    const auto xInfo = getAbsoluteAxisInfo(ABS_MT_POSITION_X);
    const auto yInfo = getAbsoluteAxisInfo(ABS_MT_POSITION_Y);
    LOG_IF(FATAL, !xInfo || !yInfo) << "X/Y axes not found for multi-touch device";
    mRawPointerAxes.x = *xInfo;
    }
    if (const auto yInfo = getAbsoluteAxisInfo(ABS_MT_POSITION_Y); yInfo.has_value()) {
    mRawPointerAxes.y = *yInfo;
    }
    mRawPointerAxes.touchMajor = getAbsoluteAxisInfo(ABS_MT_TOUCH_MAJOR);
    mRawPointerAxes.touchMinor = getAbsoluteAxisInfo(ABS_MT_TOUCH_MINOR);
    mRawPointerAxes.toolMajor = getAbsoluteAxisInfo(ABS_MT_WIDTH_MAJOR);
+7 −8
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#include "SingleTouchInputMapper.h"

#include <android-base/logging.h>

namespace android {

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

    // TODO(b/351870641): Investigate why we are sometime not getting valid axis infos for the x/y
    //   axes, even though those axes are required to be supported.
    if (const auto xInfo = getAbsoluteAxisInfo(ABS_X); xInfo.has_value()) {
    const auto xInfo = getAbsoluteAxisInfo(ABS_X);
    const auto yInfo = getAbsoluteAxisInfo(ABS_Y);
    LOG_IF(FATAL, !xInfo || !yInfo) << "X/Y axes not found for single-touch device";
    mRawPointerAxes.x = *xInfo;
    }
    if (const auto yInfo = getAbsoluteAxisInfo(ABS_Y); yInfo.has_value()) {
    mRawPointerAxes.y = *yInfo;
    }
    mRawPointerAxes.pressure = getAbsoluteAxisInfo(ABS_PRESSURE);
    mRawPointerAxes.toolMajor = getAbsoluteAxisInfo(ABS_TOOL_WIDTH);
    mRawPointerAxes.distance = getAbsoluteAxisInfo(ABS_DISTANCE);
+9 −0
Original line number Diff line number Diff line
@@ -616,6 +616,15 @@ protected:
        mFakeEventHub->addDevice(eventHubId, name, classes);
        mFakeEventHub->setSysfsRootPath(eventHubId, sysfsRootPath);

        // Populate required axis info.
        if (classes.test(InputDeviceClass::TOUCH_MT)) {
            mFakeEventHub->addAbsoluteAxis(eventHubId, ABS_MT_POSITION_X, 0, 1, 0, 0);
            mFakeEventHub->addAbsoluteAxis(eventHubId, ABS_MT_POSITION_Y, 0, 1, 0, 0);
        } else if (classes.test(InputDeviceClass::TOUCH)) {
            mFakeEventHub->addAbsoluteAxis(eventHubId, ABS_X, 0, 1, 0, 0);
            mFakeEventHub->addAbsoluteAxis(eventHubId, ABS_Y, 0, 1, 0, 0);
        }

        if (configuration) {
            mFakeEventHub->addConfigurationMap(eventHubId, configuration);
        }