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

Commit 599126ca authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by Android (Google) Code Review
Browse files

Merge "Add ChromeOS palm rejection model"

parents 25d42b5a ba0a8758
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -534,7 +534,7 @@ public:

    inline int32_t getActionMasked() const { return getActionMasked(mAction); }

    static int32_t getActionIndex(int32_t action) {
    static uint8_t getActionIndex(int32_t action) {
        return (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >>
                AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
    }
+3 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ filegroup {
    srcs: [
        "InputClassifier.cpp",
        "InputClassifierConverter.cpp",
        "UnwantedInteractionBlocker.cpp",
        "InputManager.cpp",
    ],
}
@@ -60,6 +61,7 @@ cc_defaults {
        "android.hardware.input.classifier@1.0",
        "libbase",
        "libbinder",
        "libchrome",
        "libcrypto",
        "libcutils",
        "libhidlbase",
@@ -76,6 +78,7 @@ cc_defaults {
    ],
    static_libs: [
        "libattestation",
        "libpalmrejection",
    ],
}

+1 −6
Original line number Diff line number Diff line
@@ -325,11 +325,6 @@ static std::vector<common::V1_0::VideoFrame> convertVideoFrames(
    return out;
}

static uint8_t getActionIndex(int32_t action) {
    return (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >>
            AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
}

static void getHidlPropertiesAndCoords(const NotifyMotionArgs& args,
        std::vector<common::V1_0::PointerProperties>* outPointerProperties,
        std::vector<common::V1_0::PointerCoords>* outPointerCoords) {
@@ -360,7 +355,7 @@ common::V1_0::MotionEvent notifyMotionArgsToHalMotionEvent(const NotifyMotionArg
    event.eventTime = args.eventTime;
    event.deviceTimestamp = 0;
    event.action = getAction(args.action & AMOTION_EVENT_ACTION_MASK);
    event.actionIndex = getActionIndex(args.action);
    event.actionIndex = MotionEvent::getActionIndex(args.action);
    event.actionButton = getActionButton(args.actionButton);
    event.flags = getFlags(args.flags);
    event.policyFlags = getPolicyFlags(args.policyFlags);
+19 −0
Original line number Diff line number Diff line
@@ -188,6 +188,25 @@ bool NotifyMotionArgs::operator==(const NotifyMotionArgs& rhs) const {
    return true;
}

std::string NotifyMotionArgs::dump() const {
    std::string coords;
    for (uint32_t i = 0; i < pointerCount; i++) {
        if (!coords.empty()) {
            coords += ", ";
        }
        coords += StringPrintf("{%" PRIu32 ": ", i);
        coords +=
                StringPrintf("id=%" PRIu32 " x=%.1f y=%.1f, pressure=%.1f", pointerProperties[i].id,
                             pointerCoords[i].getX(), pointerCoords[i].getY(),
                             pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE));
        coords += "}";
    }
    return StringPrintf("NotifyMotionArgs(id=%" PRId32 ", eventTime=%" PRId64 ", deviceId=%" PRId32
                        ", source=%s, action=%s, pointerCount=%" PRIu32 " pointers=%s)",
                        id, eventTime, deviceId, inputEventSourceToString(source).c_str(),
                        MotionEvent::actionToString(action).c_str(), pointerCount, coords.c_str());
}

void NotifyMotionArgs::notify(InputListenerInterface& listener) const {
    listener.notifyMotion(this);
}
+11 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include "InputManager.h"
#include "InputDispatcherFactory.h"
#include "InputReaderFactory.h"
#include "UnwantedInteractionBlocker.h"

#include <binder/IPCThreadState.h>

@@ -54,12 +55,17 @@ static int32_t exceptionCodeFromStatusT(status_t status) {
    }
}

/**
 * The event flow is via the "InputListener" interface, as follows:
 * InputReader -> UnwantedInteractionBlocker -> InputClassifier -> InputDispatcher
 */
InputManager::InputManager(
        const sp<InputReaderPolicyInterface>& readerPolicy,
        const sp<InputDispatcherPolicyInterface>& dispatcherPolicy) {
    mDispatcher = createInputDispatcher(dispatcherPolicy);
    mClassifier = std::make_unique<InputClassifier>(*mDispatcher);
    mReader = createInputReader(readerPolicy, *mClassifier);
    mUnwantedInteractionBlocker = std::make_unique<UnwantedInteractionBlocker>(*mClassifier);
    mReader = createInputReader(readerPolicy, *mUnwantedInteractionBlocker);
}

InputManager::~InputManager() {
@@ -106,6 +112,10 @@ InputReaderInterface& InputManager::getReader() {
    return *mReader;
}

UnwantedInteractionBlockerInterface& InputManager::getUnwantedInteractionBlocker() {
    return *mUnwantedInteractionBlocker;
}

InputClassifierInterface& InputManager::getClassifier() {
    return *mClassifier;
}
Loading