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

Commit 2f110fe5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add test for heuristic palm rejection" into tm-qpr-dev am: 1d100920

parents 985fe6f1 1d100920
Loading
Loading
Loading
Loading
+12 −14
Original line number Diff line number Diff line
@@ -99,17 +99,15 @@ static bool isPalmRejectionEnabled() {
    return false;
}

static int getLinuxToolType(int32_t toolType) {
    switch (toolType) {
        case AMOTION_EVENT_TOOL_TYPE_FINGER:
            return MT_TOOL_FINGER;
        case AMOTION_EVENT_TOOL_TYPE_STYLUS:
            return MT_TOOL_PEN;
        case AMOTION_EVENT_TOOL_TYPE_PALM:
            return MT_TOOL_PALM;
static int getLinuxToolCode(int toolType) {
    if (toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS) {
        return BTN_TOOL_PEN;
    }
    ALOGW("Got tool type %" PRId32 ", converting to MT_TOOL_FINGER", toolType);
    return MT_TOOL_FINGER;
    if (toolType == AMOTION_EVENT_TOOL_TYPE_FINGER) {
        return BTN_TOOL_FINGER;
    }
    ALOGW("Got tool type %" PRId32 ", converting to BTN_TOOL_FINGER", toolType);
    return BTN_TOOL_FINGER;
}

static int32_t getActionUpForPointerId(const NotifyMotionArgs& args, int32_t pointerId) {
@@ -562,7 +560,7 @@ std::vector<::ui::InProgressTouchEvdev> getTouches(const NotifyMotionArgs& args,
        touches.emplace_back(::ui::InProgressTouchEvdev());
        touches.back().major = args.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR);
        touches.back().minor = args.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR);
        touches.back().tool_type = getLinuxToolType(args.pointerProperties[i].toolType);
        // The field 'tool_type' is not used for palm rejection

        // Whether there is new information for the touch.
        touches.back().altered = true;
@@ -609,10 +607,10 @@ std::vector<::ui::InProgressTouchEvdev> getTouches(const NotifyMotionArgs& args,

        // The fields 'radius_x' and 'radius_x' are not used for palm rejection
        touches.back().pressure = args.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE);
        touches.back().tool_code = BTN_TOOL_FINGER;
        touches.back().tool_code = getLinuxToolCode(args.pointerProperties[i].toolType);
        // The field 'orientation' is not used for palm rejection
        // The fields 'tilt_x' and 'tilt_y' are not used for palm rejection
        touches.back().reported_tool_type = ::ui::EventPointerType::kTouch;
        // The field 'reported_tool_type' is not used for palm rejection
        touches.back().stylus_button = false;
    }
    return touches;
@@ -691,7 +689,7 @@ std::vector<NotifyMotionArgs> PalmRejector::processMotion(const NotifyMotionArgs
    return argsWithoutUnwantedPointers;
}

const AndroidPalmFilterDeviceInfo& PalmRejector::getPalmFilterDeviceInfo() {
const AndroidPalmFilterDeviceInfo& PalmRejector::getPalmFilterDeviceInfo() const {
    return mDeviceInfo;
}

+1 −1
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ public:
    std::vector<NotifyMotionArgs> processMotion(const NotifyMotionArgs& args);

    // Get the device info of this device, for comparison purposes
    const AndroidPalmFilterDeviceInfo& getPalmFilterDeviceInfo();
    const AndroidPalmFilterDeviceInfo& getPalmFilterDeviceInfo() const;
    std::string dump() const;

private:
+5 −4
Original line number Diff line number Diff line
@@ -110,7 +110,8 @@ void InputDevice::dump(std::string& dump, const std::string& eventHubDevStr) {
        dump += "<none>\n";
    }
    dump += StringPrintf(INDENT2 "HasMic:     %s\n", toString(mHasMic));
    dump += StringPrintf(INDENT2 "Sources: 0x%08x\n", deviceInfo.getSources());
    dump += StringPrintf(INDENT2 "Sources: %s\n",
                         inputEventSourceToString(deviceInfo.getSources()).c_str());
    dump += StringPrintf(INDENT2 "KeyboardType: %d\n", deviceInfo.getKeyboardType());
    dump += StringPrintf(INDENT2 "ControllerNum: %d\n", deviceInfo.getControllerNumber());

@@ -128,10 +129,10 @@ void InputDevice::dump(std::string& dump, const std::string& eventHubDevStr) {
                snprintf(name, sizeof(name), "%d", range.axis);
            }
            dump += StringPrintf(INDENT3
                                 "%s: source=0x%08x, "
                                 "%s: source=%s, "
                                 "min=%0.3f, max=%0.3f, flat=%0.3f, fuzz=%0.3f, resolution=%0.3f\n",
                                 name, range.source, range.min, range.max, range.flat, range.fuzz,
                                 range.resolution);
                                 name, inputEventSourceToString(range.source).c_str(), range.min,
                                 range.max, range.flat, range.fuzz, range.resolution);
        }
    }

+5 −4
Original line number Diff line number Diff line
@@ -216,9 +216,9 @@ void InputReader::addDeviceLocked(nsecs_t when, int32_t eventHubId) {
              "(ignored non-input device)",
              device->getId(), eventHubId, identifier.name.c_str(), identifier.descriptor.c_str());
    } else {
        ALOGI("Device added: id=%d, eventHubId=%d, name='%s', descriptor='%s',sources=0x%08x",
        ALOGI("Device added: id=%d, eventHubId=%d, name='%s', descriptor='%s',sources=%s",
              device->getId(), eventHubId, identifier.name.c_str(), identifier.descriptor.c_str(),
              device->getSources());
              inputEventSourceToString(device->getSources()).c_str());
    }

    mDevices.emplace(eventHubId, device);
@@ -270,9 +270,10 @@ void InputReader::removeDeviceLocked(nsecs_t when, int32_t eventHubId) {
              device->getId(), eventHubId, device->getName().c_str(),
              device->getDescriptor().c_str());
    } else {
        ALOGI("Device removed: id=%d, eventHubId=%d, name='%s', descriptor='%s', sources=0x%08x",
        ALOGI("Device removed: id=%d, eventHubId=%d, name='%s', descriptor='%s', sources=%s",
              device->getId(), eventHubId, device->getName().c_str(),
              device->getDescriptor().c_str(), device->getSources());
              device->getDescriptor().c_str(),
              inputEventSourceToString(device->getSources()).c_str());
    }

    device->removeEventHubDevice(eventHubId);
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ cc_test {
    },
    static_libs: [
        "libc++fs",
        "libgmock",
    ],
    require_root: true,
    test_suites: ["device-tests"],
Loading