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

Commit 3cfec7b1 authored by Antonio Kantek's avatar Antonio Kantek
Browse files

TouchMode (6.2/n) Fully detaching touch mode from focus event (native)

Bug: 193718270
Test: atest inputflinger_tests
Test: atest libinput_tests
Test: atest FrameworksCoreTests
Test: atest CtsInputMethodTestCases
Test: atest CtsInputTestCases
Test: atest CtsSecurityTestCases
Test: atest CtsWindowManagerDeviceTestCases
Change-Id: I334c63d781ee8e8c13d21cc4a6cf323d885fc985
parent a0b0a068
Loading
Loading
Loading
Loading
+1 −4
Original line number Original line Diff line number Diff line
@@ -840,15 +840,12 @@ public:


    inline bool getHasFocus() const { return mHasFocus; }
    inline bool getHasFocus() const { return mHasFocus; }


    inline bool getInTouchMode() const { return mInTouchMode; }
    void initialize(int32_t id, bool hasFocus);

    void initialize(int32_t id, bool hasFocus, bool inTouchMode);


    void initialize(const FocusEvent& from);
    void initialize(const FocusEvent& from);


protected:
protected:
    bool mHasFocus;
    bool mHasFocus;
    bool mInTouchMode;
};
};


/*
/*
+3 −4
Original line number Original line Diff line number Diff line
@@ -178,10 +178,9 @@ struct InputMessage {


        struct Focus {
        struct Focus {
            int32_t eventId;
            int32_t eventId;
            // The following 3 fields take up 4 bytes total
            // The following 2 fields take up 4 bytes total
            bool hasFocus;
            bool hasFocus;
            bool inTouchMode;
            uint8_t empty[3];
            uint8_t empty[2];


            inline size_t size() const { return sizeof(Focus); }
            inline size_t size() const { return sizeof(Focus); }
        } focus;
        } focus;
@@ -381,7 +380,7 @@ public:
     * Returns DEAD_OBJECT if the channel's peer has been closed.
     * Returns DEAD_OBJECT if the channel's peer has been closed.
     * Other errors probably indicate that the channel is broken.
     * Other errors probably indicate that the channel is broken.
     */
     */
    status_t publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus, bool inTouchMode);
    status_t publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus);


    /* Publishes a capture event to the input channel.
    /* Publishes a capture event to the input channel.
     *
     *
+1 −3
Original line number Original line Diff line number Diff line
@@ -820,17 +820,15 @@ float MotionEvent::calculateTransformedAxisValue(int32_t axis, uint32_t source,


// --- FocusEvent ---
// --- FocusEvent ---


void FocusEvent::initialize(int32_t id, bool hasFocus, bool inTouchMode) {
void FocusEvent::initialize(int32_t id, bool hasFocus) {
    InputEvent::initialize(id, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, AINPUT_SOURCE_UNKNOWN,
    InputEvent::initialize(id, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, AINPUT_SOURCE_UNKNOWN,
                           ADISPLAY_ID_NONE, INVALID_HMAC);
                           ADISPLAY_ID_NONE, INVALID_HMAC);
    mHasFocus = hasFocus;
    mHasFocus = hasFocus;
    mInTouchMode = inTouchMode;
}
}


void FocusEvent::initialize(const FocusEvent& from) {
void FocusEvent::initialize(const FocusEvent& from) {
    InputEvent::initialize(from);
    InputEvent::initialize(from);
    mHasFocus = from.mHasFocus;
    mHasFocus = from.mHasFocus;
    mInTouchMode = from.mInTouchMode;
}
}


// --- CaptureEvent ---
// --- CaptureEvent ---
+6 −13
Original line number Original line Diff line number Diff line
@@ -278,7 +278,6 @@ void InputMessage::getSanitizedCopy(InputMessage* msg) const {
        case InputMessage::Type::FOCUS: {
        case InputMessage::Type::FOCUS: {
            msg->body.focus.eventId = body.focus.eventId;
            msg->body.focus.eventId = body.focus.eventId;
            msg->body.focus.hasFocus = body.focus.hasFocus;
            msg->body.focus.hasFocus = body.focus.hasFocus;
            msg->body.focus.inTouchMode = body.focus.inTouchMode;
            break;
            break;
        }
        }
        case InputMessage::Type::CAPTURE: {
        case InputMessage::Type::CAPTURE: {
@@ -622,13 +621,10 @@ status_t InputPublisher::publishMotionEvent(
    return mChannel->sendMessage(&msg);
    return mChannel->sendMessage(&msg);
}
}


status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus,
status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus) {
                                           bool inTouchMode) {
    if (ATRACE_ENABLED()) {
    if (ATRACE_ENABLED()) {
        std::string message =
        std::string message = StringPrintf("publishFocusEvent(inputChannel=%s, hasFocus=%s)",
                StringPrintf("publishFocusEvent(inputChannel=%s, hasFocus=%s, inTouchMode=%s)",
                                           mChannel->getName().c_str(), toString(hasFocus));
                             mChannel->getName().c_str(), toString(hasFocus),
                             toString(inTouchMode));
        ATRACE_NAME(message.c_str());
        ATRACE_NAME(message.c_str());
    }
    }


@@ -637,7 +633,6 @@ status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool h
    msg.header.seq = seq;
    msg.header.seq = seq;
    msg.body.focus.eventId = eventId;
    msg.body.focus.eventId = eventId;
    msg.body.focus.hasFocus = hasFocus;
    msg.body.focus.hasFocus = hasFocus;
    msg.body.focus.inTouchMode = inTouchMode;
    return mChannel->sendMessage(&msg);
    return mChannel->sendMessage(&msg);
}
}


@@ -1371,8 +1366,7 @@ void InputConsumer::initializeKeyEvent(KeyEvent* event, const InputMessage* msg)
}
}


void InputConsumer::initializeFocusEvent(FocusEvent* event, const InputMessage* msg) {
void InputConsumer::initializeFocusEvent(FocusEvent* event, const InputMessage* msg) {
    event->initialize(msg->body.focus.eventId, msg->body.focus.hasFocus,
    event->initialize(msg->body.focus.eventId, msg->body.focus.hasFocus);
                      msg->body.focus.inTouchMode);
}
}


void InputConsumer::initializeCaptureEvent(CaptureEvent* event, const InputMessage* msg) {
void InputConsumer::initializeCaptureEvent(CaptureEvent* event, const InputMessage* msg) {
@@ -1491,9 +1485,8 @@ std::string InputConsumer::dump() const {
                    break;
                    break;
                }
                }
                case InputMessage::Type::FOCUS: {
                case InputMessage::Type::FOCUS: {
                    out += android::base::StringPrintf("hasFocus=%s inTouchMode=%s",
                    out += android::base::StringPrintf("hasFocus=%s",
                                                       toString(msg.body.focus.hasFocus),
                                                       toString(msg.body.focus.hasFocus));
                                                       toString(msg.body.focus.inTouchMode));
                    break;
                    break;
                }
                }
                case InputMessage::Type::CAPTURE: {
                case InputMessage::Type::CAPTURE: {
+1 −3
Original line number Original line Diff line number Diff line
@@ -290,10 +290,9 @@ void InputPublisherAndConsumerTest::PublishAndConsumeFocusEvent() {
    constexpr uint32_t seq = 15;
    constexpr uint32_t seq = 15;
    int32_t eventId = InputEvent::nextId();
    int32_t eventId = InputEvent::nextId();
    constexpr bool hasFocus = true;
    constexpr bool hasFocus = true;
    constexpr bool inTouchMode = true;
    const nsecs_t publishTime = systemTime(SYSTEM_TIME_MONOTONIC);
    const nsecs_t publishTime = systemTime(SYSTEM_TIME_MONOTONIC);


    status = mPublisher->publishFocusEvent(seq, eventId, hasFocus, inTouchMode);
    status = mPublisher->publishFocusEvent(seq, eventId, hasFocus);
    ASSERT_EQ(OK, status) << "publisher publishFocusEvent should return OK";
    ASSERT_EQ(OK, status) << "publisher publishFocusEvent should return OK";


    uint32_t consumeSeq;
    uint32_t consumeSeq;
@@ -309,7 +308,6 @@ void InputPublisherAndConsumerTest::PublishAndConsumeFocusEvent() {
    EXPECT_EQ(seq, consumeSeq);
    EXPECT_EQ(seq, consumeSeq);
    EXPECT_EQ(eventId, focusEvent->getId());
    EXPECT_EQ(eventId, focusEvent->getId());
    EXPECT_EQ(hasFocus, focusEvent->getHasFocus());
    EXPECT_EQ(hasFocus, focusEvent->getHasFocus());
    EXPECT_EQ(inTouchMode, focusEvent->getInTouchMode());


    status = mConsumer->sendFinishedSignal(seq, true);
    status = mConsumer->sendFinishedSignal(seq, true);
    ASSERT_EQ(OK, status) << "consumer sendFinishedSignal should return OK";
    ASSERT_EQ(OK, status) << "consumer sendFinishedSignal should return OK";
Loading