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

Commit d6a3fb5d authored by Harry Cutts's avatar Harry Cutts
Browse files

EventHub: log error when getting axis info for non-existent device

It's possible that getAbsoluteAxisInfo not finding the device is the
cause of a hard-to-reproduce crash in GestureConverter, where nullopt is
returned for an axis despite the EventHub classification code requiring
that axis to classify a device as a touchpad. Trying to retrieve axis
info for a non-existent device is always an error of some kind, so let's
at least log that.

Bug: 374255515
Test: m checkinput
Flag: EXEMPT log only update
Change-Id: Ifb0c82d88c11ac31671e947d5f5805949931060f
parent 048a1814
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@
#include <android-base/strings.h>
#include <cutils/properties.h>
#include <ftl/enum.h>
#include <input/InputEventLabels.h>
#include <input/KeyCharacterMap.h>
#include <input/KeyLayoutMap.h>
#include <input/PrintTools.h>
@@ -1021,6 +1022,8 @@ std::optional<RawAbsoluteAxisInfo> EventHub::getAbsoluteAxisInfo(int32_t deviceI
    std::scoped_lock _l(mLock);
    const Device* device = getDeviceLocked(deviceId);
    if (device == nullptr) {
        ALOGE("Couldn't find device with ID %d, so returning null axis info for axis %s", deviceId,
              InputEventLookup::getLinuxEvdevLabel(EV_ABS, axis, 0).code.c_str());
        return std::nullopt;
    }
    // We can read the RawAbsoluteAxisInfo even if the device is disabled and doesn't have a valid