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

Commit da9b7eaa authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13081433 from 26627094 to 25Q2-release

Change-Id: I5319e5541b5d3759e9d0ca86286e9e7e20efbd4c
parents 3722e1bc 26627094
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -862,7 +862,7 @@ enum {
    AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,
    AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5,
    AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6,
    // LINT.ThenChange(/frameworks/native/libs/input/rust/input.rs)
    // LINT.ThenChange(/frameworks/native/libs/input/rust/input.rs,/frameworks/native/services/inputflinger/tests/fuzzers/FuzzedInputStream.h)
};

/**
+13 −0
Original line number Diff line number Diff line
@@ -316,6 +316,19 @@ struct PointerProperties;

bool isStylusEvent(uint32_t source, const std::vector<PointerProperties>& properties);

bool isStylusHoverEvent(uint32_t source, const std::vector<PointerProperties>& properties,
                        int32_t action);

bool isFromMouse(uint32_t source, ToolType tooltype);

bool isFromTouchpad(uint32_t source, ToolType tooltype);

bool isFromDrawingTablet(uint32_t source, ToolType tooltype);

bool isHoverAction(int32_t action);

bool isMouseOrTouchpad(uint32_t sources);

/*
 * Flags that flow alongside events in the input dispatch system to help with certain
 * policy decisions such as waking from device sleep.
+30 −0
Original line number Diff line number Diff line
@@ -284,6 +284,36 @@ bool isStylusEvent(uint32_t source, const std::vector<PointerProperties>& proper
    return false;
}

bool isStylusHoverEvent(uint32_t source, const std::vector<PointerProperties>& properties,
                        int32_t action) {
    return isStylusEvent(source, properties) && isHoverAction(action);
}

bool isFromMouse(uint32_t source, ToolType toolType) {
    return isFromSource(source, AINPUT_SOURCE_MOUSE) && toolType == ToolType::MOUSE;
}

bool isFromTouchpad(uint32_t source, ToolType toolType) {
    return isFromSource(source, AINPUT_SOURCE_MOUSE) && toolType == ToolType::FINGER;
}

bool isFromDrawingTablet(uint32_t source, ToolType toolType) {
    return isFromSource(source, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_STYLUS) &&
            isStylusToolType(toolType);
}

bool isHoverAction(int32_t action) {
    return action == AMOTION_EVENT_ACTION_HOVER_ENTER ||
            action == AMOTION_EVENT_ACTION_HOVER_MOVE || action == AMOTION_EVENT_ACTION_HOVER_EXIT;
}

bool isMouseOrTouchpad(uint32_t sources) {
    // Check if this is a mouse or touchpad, but not a drawing tablet.
    return isFromSource(sources, AINPUT_SOURCE_MOUSE_RELATIVE) ||
            (isFromSource(sources, AINPUT_SOURCE_MOUSE) &&
             !isFromSource(sources, AINPUT_SOURCE_STYLUS));
}

VerifiedKeyEvent verifiedKeyEventFromKeyEvent(const KeyEvent& event) {
    return {{VerifiedInputEvent::Type::KEY, event.getDeviceId(), event.getEventTime(),
             event.getSource(), event.getDisplayId()},
+13 −35
Original line number Diff line number Diff line
@@ -36,37 +36,6 @@ namespace android {

namespace {

bool isFromMouse(const NotifyMotionArgs& args) {
    return isFromSource(args.source, AINPUT_SOURCE_MOUSE) &&
            args.pointerProperties[0].toolType == ToolType::MOUSE;
}

bool isFromTouchpad(const NotifyMotionArgs& args) {
    return isFromSource(args.source, AINPUT_SOURCE_MOUSE) &&
            args.pointerProperties[0].toolType == ToolType::FINGER;
}

bool isFromDrawingTablet(const NotifyMotionArgs& args) {
    return isFromSource(args.source, AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_STYLUS) &&
            isStylusToolType(args.pointerProperties[0].toolType);
}

bool isHoverAction(int32_t action) {
    return action == AMOTION_EVENT_ACTION_HOVER_ENTER ||
            action == AMOTION_EVENT_ACTION_HOVER_MOVE || action == AMOTION_EVENT_ACTION_HOVER_EXIT;
}

bool isStylusHoverEvent(const NotifyMotionArgs& args) {
    return isStylusEvent(args.source, args.pointerProperties) && isHoverAction(args.action);
}

bool isMouseOrTouchpad(uint32_t sources) {
    // Check if this is a mouse or touchpad, but not a drawing tablet.
    return isFromSource(sources, AINPUT_SOURCE_MOUSE_RELATIVE) ||
            (isFromSource(sources, AINPUT_SOURCE_MOUSE) &&
             !isFromSource(sources, AINPUT_SOURCE_STYLUS));
}

inline void notifyPointerDisplayChange(std::optional<std::tuple<ui::LogicalDisplayId, vec2>> change,
                                       PointerChoreographerPolicyInterface& policy) {
    if (!change) {
@@ -239,15 +208,16 @@ NotifyMotionArgs PointerChoreographer::processMotion(const NotifyMotionArgs& arg
    PointerDisplayChange pointerDisplayChange;
    { // acquire lock
        std::scoped_lock _l(getLock());
        if (isFromMouse(args)) {
        if (isFromMouse(args.source, args.pointerProperties[0].toolType)) {
            newArgs = processMouseEventLocked(args);
            pointerDisplayChange = calculatePointerDisplayChangeToNotify();
        } else if (isFromTouchpad(args)) {
        } else if (isFromTouchpad(args.source, args.pointerProperties[0].toolType)) {
            newArgs = processTouchpadEventLocked(args);
            pointerDisplayChange = calculatePointerDisplayChangeToNotify();
        } else if (isFromDrawingTablet(args)) {
        } else if (isFromDrawingTablet(args.source, args.pointerProperties[0].toolType)) {
            processDrawingTabletEventLocked(args);
        } else if (mStylusPointerIconEnabled && isStylusHoverEvent(args)) {
        } else if (mStylusPointerIconEnabled &&
                   isStylusHoverEvent(args.source, args.pointerProperties, args.action)) {
            processStylusHoverEventLocked(args);
        } else if (isFromSource(args.source, AINPUT_SOURCE_TOUCHSCREEN)) {
            processTouchscreenAndStylusEventLocked(args);
@@ -506,6 +476,14 @@ void PointerChoreographer::processStylusHoverEventLocked(const NotifyMotionArgs&
                     << args.dump();
    }

    // Fade the mouse pointer on the display if there is one when the stylus starts hovering.
    if (args.action == AMOTION_EVENT_ACTION_HOVER_ENTER) {
        if (const auto it = mMousePointersByDisplay.find(args.displayId);
            it != mMousePointersByDisplay.end()) {
            it->second->fade(PointerControllerInterface::Transition::GRADUAL);
        }
    }

    // Get the stylus pointer controller for the device, or create one if it doesn't exist.
    auto [it, controllerAdded] =
            mStylusPointersByDevice.try_emplace(args.deviceId,
Loading