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

Commit 1c7bc86a authored by Garfield Tan's avatar Garfield Tan
Browse files

Let InputFlinger generate event IDs.

Also send event IDs via InputMessage and add some atrace calls to form a
complete chain of input event processing.

Bug: 144889238
Test: systrace shows correct event IDs.
Test: atest inputflinger_tests
Change-Id: I3c561b03b0ba75c22115ae020e6b41855686ab64
Merged-In: I3c561b03b0ba75c22115ae020e6b41855686ab64
(cherry picked from commit ff1f1bb9)
parent c51d1ba0
Loading
Loading
Loading
Loading
+17 −14
Original line number Original line Diff line number Diff line
@@ -82,7 +82,7 @@ struct InputMessage {
    union Body {
    union Body {
        struct Key {
        struct Key {
            uint32_t seq;
            uint32_t seq;
            uint32_t empty1;
            int32_t eventId;
            nsecs_t eventTime __attribute__((aligned(8)));
            nsecs_t eventTime __attribute__((aligned(8)));
            int32_t deviceId;
            int32_t deviceId;
            int32_t source;
            int32_t source;
@@ -102,7 +102,7 @@ struct InputMessage {


        struct Motion {
        struct Motion {
            uint32_t seq;
            uint32_t seq;
            uint32_t empty1;
            int32_t eventId;
            nsecs_t eventTime __attribute__((aligned(8)));
            nsecs_t eventTime __attribute__((aligned(8)));
            int32_t deviceId;
            int32_t deviceId;
            int32_t source;
            int32_t source;
@@ -159,6 +159,8 @@ struct InputMessage {


        struct Focus {
        struct Focus {
            uint32_t seq;
            uint32_t seq;
            int32_t eventId;
            uint32_t empty1;
            // The following two fields take up 4 bytes total
            // The following two fields take up 4 bytes total
            uint16_t hasFocus;    // actually a bool
            uint16_t hasFocus;    // actually a bool
            uint16_t inTouchMode; // actually a bool, but we must maintain 8-byte alignment
            uint16_t inTouchMode; // actually a bool, but we must maintain 8-byte alignment
@@ -276,9 +278,9 @@ public:
     * Returns BAD_VALUE if seq is 0.
     * Returns BAD_VALUE if seq is 0.
     * Other errors probably indicate that the channel is broken.
     * Other errors probably indicate that the channel is broken.
     */
     */
    status_t publishKeyEvent(uint32_t seq, int32_t deviceId, int32_t source, int32_t displayId,
    status_t publishKeyEvent(uint32_t seq, int32_t eventId, int32_t deviceId, int32_t source,
                             std::array<uint8_t, 32> hmac, int32_t action, int32_t flags,
                             int32_t displayId, std::array<uint8_t, 32> hmac, int32_t action,
                             int32_t keyCode, int32_t scanCode, int32_t metaState,
                             int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState,
                             int32_t repeatCount, nsecs_t downTime, nsecs_t eventTime);
                             int32_t repeatCount, nsecs_t downTime, nsecs_t eventTime);


    /* Publishes a motion event to the input channel.
    /* Publishes a motion event to the input channel.
@@ -289,14 +291,15 @@ public:
     * Returns BAD_VALUE if seq is 0 or if pointerCount is less than 1 or greater than MAX_POINTERS.
     * Returns BAD_VALUE if seq is 0 or if pointerCount is less than 1 or greater than MAX_POINTERS.
     * Other errors probably indicate that the channel is broken.
     * Other errors probably indicate that the channel is broken.
     */
     */
    status_t publishMotionEvent(uint32_t seq, int32_t deviceId, int32_t source, int32_t displayId,
    status_t publishMotionEvent(uint32_t seq, int32_t eventId, int32_t deviceId, int32_t source,
                                std::array<uint8_t, 32> hmac, int32_t action, int32_t actionButton,
                                int32_t displayId, std::array<uint8_t, 32> hmac, int32_t action,
                                int32_t flags, int32_t edgeFlags, int32_t metaState,
                                int32_t actionButton, int32_t flags, int32_t edgeFlags,
                                int32_t buttonState, MotionClassification classification,
                                int32_t metaState, int32_t buttonState,
                                float xScale, float yScale, float xOffset, float yOffset,
                                MotionClassification classification, float xScale, float yScale,
                                float xPrecision, float yPrecision, float xCursorPosition,
                                float xOffset, float yOffset, float xPrecision, float yPrecision,
                                float yCursorPosition, nsecs_t downTime, nsecs_t eventTime,
                                float xCursorPosition, float yCursorPosition, nsecs_t downTime,
                                uint32_t pointerCount, const PointerProperties* pointerProperties,
                                nsecs_t eventTime, uint32_t pointerCount,
                                const PointerProperties* pointerProperties,
                                const PointerCoords* pointerCoords);
                                const PointerCoords* pointerCoords);


    /* Publishes a focus event to the input channel.
    /* Publishes a focus event to the input channel.
@@ -306,7 +309,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, bool hasFocus, bool inTouchMode);
    status_t publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus, bool inTouchMode);


    /* Receives the finished signal from the consumer in reply to the original dispatch signal.
    /* Receives the finished signal from the consumer in reply to the original dispatch signal.
     * If a signal was received, returns the message sequence number,
     * If a signal was received, returns the message sequence number,
+29 −24
Original line number Original line Diff line number Diff line
@@ -63,10 +63,6 @@ static const nsecs_t RESAMPLE_MAX_DELTA = 20 * NANOS_PER_MS;
// far into the future.  This time is further bounded by 50% of the last time delta.
// far into the future.  This time is further bounded by 50% of the last time delta.
static const nsecs_t RESAMPLE_MAX_PREDICTION = 8 * NANOS_PER_MS;
static const nsecs_t RESAMPLE_MAX_PREDICTION = 8 * NANOS_PER_MS;


// A placeholder sequence number used to initialize native input events before InputFlinger is
// migrated to new sequence number system.
static constexpr int32_t INPUT_FLINGER_SEQUENCE_NUM = 0;

/**
/**
 * System property for enabling / disabling touch resampling.
 * System property for enabling / disabling touch resampling.
 * Resampling extrapolates / interpolates the reported touch event coordinates to better
 * Resampling extrapolates / interpolates the reported touch event coordinates to better
@@ -143,6 +139,8 @@ void InputMessage::getSanitizedCopy(InputMessage* msg) const {
        case InputMessage::Type::KEY: {
        case InputMessage::Type::KEY: {
            // uint32_t seq
            // uint32_t seq
            msg->body.key.seq = body.key.seq;
            msg->body.key.seq = body.key.seq;
            // int32_t eventId
            msg->body.key.eventId = body.key.eventId;
            // nsecs_t eventTime
            // nsecs_t eventTime
            msg->body.key.eventTime = body.key.eventTime;
            msg->body.key.eventTime = body.key.eventTime;
            // int32_t deviceId
            // int32_t deviceId
@@ -172,6 +170,8 @@ void InputMessage::getSanitizedCopy(InputMessage* msg) const {
        case InputMessage::Type::MOTION: {
        case InputMessage::Type::MOTION: {
            // uint32_t seq
            // uint32_t seq
            msg->body.motion.seq = body.motion.seq;
            msg->body.motion.seq = body.motion.seq;
            // int32_t eventId
            msg->body.motion.eventId = body.motion.eventId;
            // nsecs_t eventTime
            // nsecs_t eventTime
            msg->body.motion.eventTime = body.motion.eventTime;
            msg->body.motion.eventTime = body.motion.eventTime;
            // int32_t deviceId
            // int32_t deviceId
@@ -238,6 +238,7 @@ void InputMessage::getSanitizedCopy(InputMessage* msg) const {
        }
        }
        case InputMessage::Type::FOCUS: {
        case InputMessage::Type::FOCUS: {
            msg->body.focus.seq = body.focus.seq;
            msg->body.focus.seq = body.focus.seq;
            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;
            msg->body.focus.inTouchMode = body.focus.inTouchMode;
            break;
            break;
@@ -436,11 +437,12 @@ InputPublisher::InputPublisher(const sp<InputChannel>& channel) :
InputPublisher::~InputPublisher() {
InputPublisher::~InputPublisher() {
}
}


status_t InputPublisher::publishKeyEvent(uint32_t seq, int32_t deviceId, int32_t source,
status_t InputPublisher::publishKeyEvent(uint32_t seq, int32_t eventId, int32_t deviceId,
                                         int32_t displayId, std::array<uint8_t, 32> hmac,
                                         int32_t source, int32_t displayId,
                                         int32_t action, int32_t flags, int32_t keyCode,
                                         std::array<uint8_t, 32> hmac, int32_t action,
                                         int32_t scanCode, int32_t metaState, int32_t repeatCount,
                                         int32_t flags, int32_t keyCode, int32_t scanCode,
                                         nsecs_t downTime, nsecs_t eventTime) {
                                         int32_t metaState, int32_t repeatCount, nsecs_t downTime,
                                         nsecs_t eventTime) {
    if (ATRACE_ENABLED()) {
    if (ATRACE_ENABLED()) {
        std::string message = StringPrintf("publishKeyEvent(inputChannel=%s, keyCode=%" PRId32 ")",
        std::string message = StringPrintf("publishKeyEvent(inputChannel=%s, keyCode=%" PRId32 ")",
                mChannel->getName().c_str(), keyCode);
                mChannel->getName().c_str(), keyCode);
@@ -462,6 +464,7 @@ status_t InputPublisher::publishKeyEvent(uint32_t seq, int32_t deviceId, int32_t
    InputMessage msg;
    InputMessage msg;
    msg.header.type = InputMessage::Type::KEY;
    msg.header.type = InputMessage::Type::KEY;
    msg.body.key.seq = seq;
    msg.body.key.seq = seq;
    msg.body.key.eventId = eventId;
    msg.body.key.deviceId = deviceId;
    msg.body.key.deviceId = deviceId;
    msg.body.key.source = source;
    msg.body.key.source = source;
    msg.body.key.displayId = displayId;
    msg.body.key.displayId = displayId;
@@ -478,7 +481,7 @@ status_t InputPublisher::publishKeyEvent(uint32_t seq, int32_t deviceId, int32_t
}
}


status_t InputPublisher::publishMotionEvent(
status_t InputPublisher::publishMotionEvent(
        uint32_t seq, int32_t deviceId, int32_t source, int32_t displayId,
        uint32_t seq, int32_t eventId, int32_t deviceId, int32_t source, int32_t displayId,
        std::array<uint8_t, 32> hmac, int32_t action, int32_t actionButton, int32_t flags,
        std::array<uint8_t, 32> hmac, int32_t action, int32_t actionButton, int32_t flags,
        int32_t edgeFlags, int32_t metaState, int32_t buttonState,
        int32_t edgeFlags, int32_t metaState, int32_t buttonState,
        MotionClassification classification, float xScale, float yScale, float xOffset,
        MotionClassification classification, float xScale, float yScale, float xOffset,
@@ -519,6 +522,7 @@ status_t InputPublisher::publishMotionEvent(
    InputMessage msg;
    InputMessage msg;
    msg.header.type = InputMessage::Type::MOTION;
    msg.header.type = InputMessage::Type::MOTION;
    msg.body.motion.seq = seq;
    msg.body.motion.seq = seq;
    msg.body.motion.eventId = eventId;
    msg.body.motion.deviceId = deviceId;
    msg.body.motion.deviceId = deviceId;
    msg.body.motion.source = source;
    msg.body.motion.source = source;
    msg.body.motion.displayId = displayId;
    msg.body.motion.displayId = displayId;
@@ -549,7 +553,8 @@ status_t InputPublisher::publishMotionEvent(
    return mChannel->sendMessage(&msg);
    return mChannel->sendMessage(&msg);
}
}


status_t InputPublisher::publishFocusEvent(uint32_t seq, bool hasFocus, bool inTouchMode) {
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, inTouchMode=%s)",
                StringPrintf("publishFocusEvent(inputChannel=%s, hasFocus=%s, inTouchMode=%s)",
@@ -561,6 +566,7 @@ status_t InputPublisher::publishFocusEvent(uint32_t seq, bool hasFocus, bool inT
    InputMessage msg;
    InputMessage msg;
    msg.header.type = InputMessage::Type::FOCUS;
    msg.header.type = InputMessage::Type::FOCUS;
    msg.body.focus.seq = seq;
    msg.body.focus.seq = seq;
    msg.body.focus.eventId = eventId;
    msg.body.focus.hasFocus = hasFocus ? 1 : 0;
    msg.body.focus.hasFocus = hasFocus ? 1 : 0;
    msg.body.focus.inTouchMode = inTouchMode ? 1 : 0;
    msg.body.focus.inTouchMode = inTouchMode ? 1 : 0;
    return mChannel->sendMessage(&msg);
    return mChannel->sendMessage(&msg);
@@ -1146,7 +1152,7 @@ ssize_t InputConsumer::findTouchState(int32_t deviceId, int32_t source) const {
}
}


void InputConsumer::initializeKeyEvent(KeyEvent* event, const InputMessage* msg) {
void InputConsumer::initializeKeyEvent(KeyEvent* event, const InputMessage* msg) {
    event->initialize(INPUT_FLINGER_SEQUENCE_NUM, msg->body.key.deviceId, msg->body.key.source,
    event->initialize(msg->body.key.eventId, msg->body.key.deviceId, msg->body.key.source,
                      msg->body.key.displayId, msg->body.key.hmac, msg->body.key.action,
                      msg->body.key.displayId, msg->body.key.hmac, msg->body.key.action,
                      msg->body.key.flags, msg->body.key.keyCode, msg->body.key.scanCode,
                      msg->body.key.flags, msg->body.key.keyCode, msg->body.key.scanCode,
                      msg->body.key.metaState, msg->body.key.repeatCount, msg->body.key.downTime,
                      msg->body.key.metaState, msg->body.key.repeatCount, msg->body.key.downTime,
@@ -1154,7 +1160,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(INPUT_FLINGER_SEQUENCE_NUM, msg->body.focus.hasFocus == 1,
    event->initialize(msg->body.focus.eventId, msg->body.focus.hasFocus == 1,
                      msg->body.focus.inTouchMode == 1);
                      msg->body.focus.inTouchMode == 1);
}
}


@@ -1167,17 +1173,16 @@ void InputConsumer::initializeMotionEvent(MotionEvent* event, const InputMessage
        pointerCoords[i].copyFrom(msg->body.motion.pointers[i].coords);
        pointerCoords[i].copyFrom(msg->body.motion.pointers[i].coords);
    }
    }


    event->initialize(INPUT_FLINGER_SEQUENCE_NUM, msg->body.motion.deviceId,
    event->initialize(msg->body.motion.eventId, msg->body.motion.deviceId, msg->body.motion.source,
                      msg->body.motion.source, msg->body.motion.displayId, msg->body.motion.hmac,
                      msg->body.motion.displayId, msg->body.motion.hmac, msg->body.motion.action,
                      msg->body.motion.action, msg->body.motion.actionButton,
                      msg->body.motion.actionButton, msg->body.motion.flags,
                      msg->body.motion.flags, msg->body.motion.edgeFlags,
                      msg->body.motion.edgeFlags, msg->body.motion.metaState,
                      msg->body.motion.metaState, msg->body.motion.buttonState,
                      msg->body.motion.buttonState, msg->body.motion.classification,
                      msg->body.motion.classification, msg->body.motion.xScale,
                      msg->body.motion.xScale, msg->body.motion.yScale, msg->body.motion.xOffset,
                      msg->body.motion.yScale, msg->body.motion.xOffset, msg->body.motion.yOffset,
                      msg->body.motion.yOffset, msg->body.motion.xPrecision,
                      msg->body.motion.xPrecision, msg->body.motion.yPrecision,
                      msg->body.motion.yPrecision, msg->body.motion.xCursorPosition,
                      msg->body.motion.xCursorPosition, msg->body.motion.yCursorPosition,
                      msg->body.motion.yCursorPosition, msg->body.motion.downTime,
                      msg->body.motion.downTime, msg->body.motion.eventTime, pointerCount,
                      msg->body.motion.eventTime, pointerCount, pointerProperties, pointerCoords);
                      pointerProperties, pointerCoords);
}
}


void InputConsumer::addSample(MotionEvent* event, const InputMessage* msg) {
void InputConsumer::addSample(MotionEvent* event, const InputMessage* msg) {
+16 −10
Original line number Original line Diff line number Diff line
@@ -73,6 +73,7 @@ void InputPublisherAndConsumerTest::PublishAndConsumeKeyEvent() {
    status_t status;
    status_t status;


    constexpr uint32_t seq = 15;
    constexpr uint32_t seq = 15;
    int32_t eventId = InputEvent::nextId();
    constexpr int32_t deviceId = 1;
    constexpr int32_t deviceId = 1;
    constexpr uint32_t source = AINPUT_SOURCE_KEYBOARD;
    constexpr uint32_t source = AINPUT_SOURCE_KEYBOARD;
    constexpr int32_t displayId = ADISPLAY_ID_DEFAULT;
    constexpr int32_t displayId = ADISPLAY_ID_DEFAULT;
@@ -88,8 +89,8 @@ void InputPublisherAndConsumerTest::PublishAndConsumeKeyEvent() {
    constexpr nsecs_t downTime = 3;
    constexpr nsecs_t downTime = 3;
    constexpr nsecs_t eventTime = 4;
    constexpr nsecs_t eventTime = 4;


    status = mPublisher->publishKeyEvent(seq, deviceId, source, displayId, hmac, action, flags,
    status = mPublisher->publishKeyEvent(seq, eventId, deviceId, source, displayId, hmac, action,
                                         keyCode, scanCode, metaState, repeatCount, downTime,
                                         flags, keyCode, scanCode, metaState, repeatCount, downTime,
                                         eventTime);
                                         eventTime);
    ASSERT_EQ(OK, status)
    ASSERT_EQ(OK, status)
            << "publisher publishKeyEvent should return OK";
            << "publisher publishKeyEvent should return OK";
@@ -107,6 +108,7 @@ void InputPublisherAndConsumerTest::PublishAndConsumeKeyEvent() {


    KeyEvent* keyEvent = static_cast<KeyEvent*>(event);
    KeyEvent* keyEvent = static_cast<KeyEvent*>(event);
    EXPECT_EQ(seq, consumeSeq);
    EXPECT_EQ(seq, consumeSeq);
    EXPECT_EQ(eventId, keyEvent->getId());
    EXPECT_EQ(deviceId, keyEvent->getDeviceId());
    EXPECT_EQ(deviceId, keyEvent->getDeviceId());
    EXPECT_EQ(source, keyEvent->getSource());
    EXPECT_EQ(source, keyEvent->getSource());
    EXPECT_EQ(displayId, keyEvent->getDisplayId());
    EXPECT_EQ(displayId, keyEvent->getDisplayId());
@@ -139,6 +141,7 @@ void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent() {
    status_t status;
    status_t status;


    constexpr uint32_t seq = 15;
    constexpr uint32_t seq = 15;
    int32_t eventId = InputEvent::nextId();
    constexpr int32_t deviceId = 1;
    constexpr int32_t deviceId = 1;
    constexpr uint32_t source = AINPUT_SOURCE_TOUCHSCREEN;
    constexpr uint32_t source = AINPUT_SOURCE_TOUCHSCREEN;
    constexpr int32_t displayId = ADISPLAY_ID_DEFAULT;
    constexpr int32_t displayId = ADISPLAY_ID_DEFAULT;
@@ -182,7 +185,7 @@ void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent() {
        pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 3.5 * i);
        pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, 3.5 * i);
    }
    }


    status = mPublisher->publishMotionEvent(seq, deviceId, source, displayId, hmac, action,
    status = mPublisher->publishMotionEvent(seq, eventId, deviceId, source, displayId, hmac, action,
                                            actionButton, flags, edgeFlags, metaState, buttonState,
                                            actionButton, flags, edgeFlags, metaState, buttonState,
                                            classification, xScale, yScale, xOffset, yOffset,
                                            classification, xScale, yScale, xOffset, yOffset,
                                            xPrecision, yPrecision, xCursorPosition,
                                            xPrecision, yPrecision, xCursorPosition,
@@ -204,6 +207,7 @@ void InputPublisherAndConsumerTest::PublishAndConsumeMotionEvent() {


    MotionEvent* motionEvent = static_cast<MotionEvent*>(event);
    MotionEvent* motionEvent = static_cast<MotionEvent*>(event);
    EXPECT_EQ(seq, consumeSeq);
    EXPECT_EQ(seq, consumeSeq);
    EXPECT_EQ(eventId, motionEvent->getId());
    EXPECT_EQ(deviceId, motionEvent->getDeviceId());
    EXPECT_EQ(deviceId, motionEvent->getDeviceId());
    EXPECT_EQ(source, motionEvent->getSource());
    EXPECT_EQ(source, motionEvent->getSource());
    EXPECT_EQ(displayId, motionEvent->getDisplayId());
    EXPECT_EQ(displayId, motionEvent->getDisplayId());
@@ -277,10 +281,11 @@ void InputPublisherAndConsumerTest::PublishAndConsumeFocusEvent() {
    status_t status;
    status_t status;


    constexpr uint32_t seq = 15;
    constexpr uint32_t seq = 15;
    int32_t eventId = InputEvent::nextId();
    constexpr bool hasFocus = true;
    constexpr bool hasFocus = true;
    constexpr bool inTouchMode = true;
    constexpr bool inTouchMode = true;


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


    uint32_t consumeSeq;
    uint32_t consumeSeq;
@@ -294,6 +299,7 @@ void InputPublisherAndConsumerTest::PublishAndConsumeFocusEvent() {


    FocusEvent* focusEvent = static_cast<FocusEvent*>(event);
    FocusEvent* focusEvent = static_cast<FocusEvent*>(event);
    EXPECT_EQ(seq, consumeSeq);
    EXPECT_EQ(seq, consumeSeq);
    EXPECT_EQ(eventId, focusEvent->getId());
    EXPECT_EQ(hasFocus, focusEvent->getHasFocus());
    EXPECT_EQ(hasFocus, focusEvent->getHasFocus());
    EXPECT_EQ(inTouchMode, focusEvent->getInTouchMode());
    EXPECT_EQ(inTouchMode, focusEvent->getInTouchMode());


@@ -332,8 +338,8 @@ TEST_F(InputPublisherAndConsumerTest, PublishMotionEvent_WhenSequenceNumberIsZer
        pointerCoords[i].clear();
        pointerCoords[i].clear();
    }
    }


    status = mPublisher->publishMotionEvent(0, 0, 0, 0, INVALID_HMAC, 0, 0, 0, 0, 0, 0,
    status = mPublisher->publishMotionEvent(0, InputEvent::nextId(), 0, 0, 0, INVALID_HMAC, 0, 0, 0,
                                            MotionClassification::NONE, 1 /* xScale */,
                                            0, 0, 0, MotionClassification::NONE, 1 /* xScale */,
                                            1 /* yScale */, 0, 0, 0, 0,
                                            1 /* yScale */, 0, 0, 0, 0,
                                            AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                            AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                            AMOTION_EVENT_INVALID_CURSOR_POSITION, 0, 0,
                                            AMOTION_EVENT_INVALID_CURSOR_POSITION, 0, 0,
@@ -348,8 +354,8 @@ TEST_F(InputPublisherAndConsumerTest, PublishMotionEvent_WhenPointerCountLessTha
    PointerProperties pointerProperties[pointerCount];
    PointerProperties pointerProperties[pointerCount];
    PointerCoords pointerCoords[pointerCount];
    PointerCoords pointerCoords[pointerCount];


    status = mPublisher->publishMotionEvent(1, 0, 0, 0, INVALID_HMAC, 0, 0, 0, 0, 0, 0,
    status = mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0, 0, INVALID_HMAC, 0, 0, 0,
                                            MotionClassification::NONE, 1 /* xScale */,
                                            0, 0, 0, MotionClassification::NONE, 1 /* xScale */,
                                            1 /* yScale */, 0, 0, 0, 0,
                                            1 /* yScale */, 0, 0, 0, 0,
                                            AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                            AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                            AMOTION_EVENT_INVALID_CURSOR_POSITION, 0, 0,
                                            AMOTION_EVENT_INVALID_CURSOR_POSITION, 0, 0,
@@ -369,8 +375,8 @@ TEST_F(InputPublisherAndConsumerTest,
        pointerCoords[i].clear();
        pointerCoords[i].clear();
    }
    }


    status = mPublisher->publishMotionEvent(1, 0, 0, 0, INVALID_HMAC, 0, 0, 0, 0, 0, 0,
    status = mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0, 0, INVALID_HMAC, 0, 0, 0,
                                            MotionClassification::NONE, 1 /* xScale */,
                                            0, 0, 0, MotionClassification::NONE, 1 /* xScale */,
                                            1 /* yScale */, 0, 0, 0, 0,
                                            1 /* yScale */, 0, 0, 0, 0,
                                            AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                            AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                            AMOTION_EVENT_INVALID_CURSOR_POSITION, 0, 0,
                                            AMOTION_EVENT_INVALID_CURSOR_POSITION, 0, 0,
+6 −3
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ void TestInputMessageAlignment() {
  CHECK_OFFSET(InputMessage, body, 8);
  CHECK_OFFSET(InputMessage, body, 8);


  CHECK_OFFSET(InputMessage::Body::Key, seq, 0);
  CHECK_OFFSET(InputMessage::Body::Key, seq, 0);
  CHECK_OFFSET(InputMessage::Body::Key, eventId, 4);
  CHECK_OFFSET(InputMessage::Body::Key, eventTime, 8);
  CHECK_OFFSET(InputMessage::Body::Key, eventTime, 8);
  CHECK_OFFSET(InputMessage::Body::Key, deviceId, 16);
  CHECK_OFFSET(InputMessage::Body::Key, deviceId, 16);
  CHECK_OFFSET(InputMessage::Body::Key, source, 20);
  CHECK_OFFSET(InputMessage::Body::Key, source, 20);
@@ -49,6 +50,7 @@ void TestInputMessageAlignment() {
  CHECK_OFFSET(InputMessage::Body::Key, downTime, 88);
  CHECK_OFFSET(InputMessage::Body::Key, downTime, 88);


  CHECK_OFFSET(InputMessage::Body::Motion, seq, 0);
  CHECK_OFFSET(InputMessage::Body::Motion, seq, 0);
  CHECK_OFFSET(InputMessage::Body::Motion, eventId, 4);
  CHECK_OFFSET(InputMessage::Body::Motion, eventTime, 8);
  CHECK_OFFSET(InputMessage::Body::Motion, eventTime, 8);
  CHECK_OFFSET(InputMessage::Body::Motion, deviceId, 16);
  CHECK_OFFSET(InputMessage::Body::Motion, deviceId, 16);
  CHECK_OFFSET(InputMessage::Body::Motion, source, 20);
  CHECK_OFFSET(InputMessage::Body::Motion, source, 20);
@@ -74,8 +76,9 @@ void TestInputMessageAlignment() {
  CHECK_OFFSET(InputMessage::Body::Motion, pointers, 136);
  CHECK_OFFSET(InputMessage::Body::Motion, pointers, 136);


  CHECK_OFFSET(InputMessage::Body::Focus, seq, 0);
  CHECK_OFFSET(InputMessage::Body::Focus, seq, 0);
  CHECK_OFFSET(InputMessage::Body::Focus, hasFocus, 4);
  CHECK_OFFSET(InputMessage::Body::Focus, eventId, 4);
  CHECK_OFFSET(InputMessage::Body::Focus, inTouchMode, 6);
  CHECK_OFFSET(InputMessage::Body::Focus, hasFocus, 12);
  CHECK_OFFSET(InputMessage::Body::Focus, inTouchMode, 14);


  CHECK_OFFSET(InputMessage::Body::Finished, seq, 0);
  CHECK_OFFSET(InputMessage::Body::Finished, seq, 0);
  CHECK_OFFSET(InputMessage::Body::Finished, handled, 4);
  CHECK_OFFSET(InputMessage::Body::Finished, handled, 4);
@@ -95,7 +98,7 @@ void TestBodySize() {
                  offsetof(InputMessage::Body::Motion, pointers) +
                  offsetof(InputMessage::Body::Motion, pointers) +
                          sizeof(InputMessage::Body::Motion::Pointer) * MAX_POINTERS);
                          sizeof(InputMessage::Body::Motion::Pointer) * MAX_POINTERS);
    static_assert(sizeof(InputMessage::Body::Finished) == 8);
    static_assert(sizeof(InputMessage::Body::Finished) == 8);
    static_assert(sizeof(InputMessage::Body::Focus) == 8);
    static_assert(sizeof(InputMessage::Body::Focus) == 16);
}
}


// --- VerifiedInputEvent ---
// --- VerifiedInputEvent ---
+1 −0
Original line number Original line Diff line number Diff line
@@ -108,6 +108,7 @@ cc_defaults {
    srcs: [":libinputflinger_base_sources"],
    srcs: [":libinputflinger_base_sources"],
    shared_libs: [
    shared_libs: [
        "libbase",
        "libbase",
        "libcutils",
        "libinput",
        "libinput",
        "liblog",
        "liblog",
        "libutils",
        "libutils",
Loading