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

Commit 3e0a60c0 authored by Harry Cutts's avatar Harry Cutts
Browse files

input: Remove edge flags from internals

For a long time, these have been unused by the input system (which
always sets them to NONE), so we can get rid of them from the input
internals. However, consumers of input events sometimes use
MotionEvents' edge flag fields to store their own metadata about the
event. (For example, Launcher sets a bit in the edge flags to denote
touches that were dispatched to the navigation bar.) This means that we
have to keep storing them in the MotionEvent, as opposed to changing
MotionEvent::getEdgeFlags to always return NONE.

Test: check that touchscreen and touchpad input still works, including
      for system navigation gestures
Test: $ m checkinput
Test: $ atest --host inputflinger_tests
Bug: 321101159
Flag: EXEMPT refactor

Change-Id: Id8eaed945875f5871cb57c1924e9642dbb8f8e59
parent d12ae836
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1035,6 +1035,9 @@ protected:
    int32_t mAction;
    int32_t mActionButton;
    ftl::Flags<MotionFlag> mFlags;
    // The input subsystem no longer sets edge flags to anything except NONE. However, some users of
    // the input API, such as Launcher, use it to store metadata about an event, so we have to keep
    // it around.
    int32_t mEdgeFlags;
    int32_t mMetaState;
    int32_t mButtonState;
+2 −1
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ struct InputMessage {
            int32_t buttonState;
            MotionClassification classification; // base type: uint8_t
            uint8_t empty2[3];                   // 3 bytes to fill gap created by classification
            // TODO(b/321101159): remove edgeFlags; it's always set to AMOTION_EVENT_EDGE_FLAG_NONE.
            int32_t edgeFlags;
            nsecs_t downTime __attribute__((aligned(8)));
            float dsdx; // Begin window transform
@@ -371,7 +372,7 @@ public:
    status_t publishMotionEvent(uint32_t seq, int32_t eventId, int32_t deviceId, int32_t source,
                                ui::LogicalDisplayId displayId, 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 metaState, int32_t buttonState,
                                MotionClassification classification, const ui::Transform& transform,
                                float xPrecision, float yPrecision, float xCursorPosition,
                                float yCursorPosition, const ui::Transform& rawTransform,
+8 −8
Original line number Diff line number Diff line
@@ -586,9 +586,9 @@ status_t InputPublisher::publishKeyEvent(uint32_t seq, int32_t eventId, int32_t
status_t InputPublisher::publishMotionEvent(
        uint32_t seq, int32_t eventId, int32_t deviceId, int32_t source,
        ui::LogicalDisplayId displayId, std::array<uint8_t, 32> hmac, int32_t action,
        int32_t actionButton, int32_t flags, int32_t edgeFlags, int32_t metaState,
        int32_t buttonState, MotionClassification classification, const ui::Transform& transform,
        float xPrecision, float yPrecision, float xCursorPosition, float yCursorPosition,
        int32_t actionButton, int32_t flags, int32_t metaState, int32_t buttonState,
        MotionClassification classification, const ui::Transform& transform, float xPrecision,
        float yPrecision, float xCursorPosition, float yCursorPosition,
        const ui::Transform& rawTransform, nsecs_t downTime, nsecs_t eventTime,
        uint32_t pointerCount, const PointerProperties* pointerProperties,
        const PointerCoords* pointerCoords) {
@@ -601,15 +601,15 @@ status_t InputPublisher::publishMotionEvent(
        transform.dump(transformString, "transform", "        ");
        ALOGD("channel '%s' publisher ~ %s: seq=%u, id=%d, deviceId=%d, source=%s, "
              "displayId=%s, "
              "action=%s, actionButton=0x%08x, flags=0x%x, edgeFlags=0x%x, "
              "action=%s, actionButton=0x%08x, flags=0x%x, "
              "metaState=0x%x, buttonState=0x%x, classification=%s, "
              "xPrecision=%f, yPrecision=%f, downTime=%" PRId64 "ns, eventTime=%" PRId64 "ns, "
              "pointerCount=%" PRIu32 "\n%s",
              mChannel->getName().c_str(), __func__, seq, eventId, deviceId,
              inputEventSourceToString(source).c_str(), displayId.toString().c_str(),
              MotionEvent::actionToString(action).c_str(), actionButton, flags, edgeFlags,
              metaState, buttonState, motionClassificationToString(classification), xPrecision,
              yPrecision, downTime, eventTime, pointerCount, transformString.c_str());
              MotionEvent::actionToString(action).c_str(), actionButton, flags, metaState,
              buttonState, motionClassificationToString(classification), xPrecision, yPrecision,
              downTime, eventTime, pointerCount, transformString.c_str());
    }

    if (!seq) {
@@ -634,7 +634,7 @@ status_t InputPublisher::publishMotionEvent(
    msg.body.motion.action = action;
    msg.body.motion.actionButton = actionButton;
    msg.body.motion.flags = flags;
    msg.body.motion.edgeFlags = edgeFlags;
    msg.body.motion.edgeFlags = AMOTION_EVENT_EDGE_FLAG_NONE;
    msg.body.motion.metaState = metaState;
    msg.body.motion.buttonState = buttonState;
    msg.body.motion.classification = classification;
+11 −14
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ struct PublishMotionArgs {
    const uint32_t source = AINPUT_SOURCE_TOUCHSCREEN;
    const ui::LogicalDisplayId displayId = ui::LogicalDisplayId::DEFAULT;
    const int32_t actionButton = 0;
    const int32_t edgeFlags = AMOTION_EVENT_EDGE_FLAG_TOP;
    const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
    const int32_t buttonState = AMOTION_EVENT_BUTTON_PRIMARY;
    const MotionClassification classification = MotionClassification::AMBIGUOUS_GESTURE;
@@ -140,7 +139,6 @@ void verifyArgsEqualToEvent(const PublishMotionArgs& args, const MotionEvent& mo
    EXPECT_EQ(args.action, motionEvent.getAction());
    EXPECT_EQ(args.downTime, motionEvent.getDownTime());
    EXPECT_EQ(args.flags, static_cast<int32_t>(motionEvent.getFlags().get()));
    EXPECT_EQ(args.edgeFlags, motionEvent.getEdgeFlags());
    EXPECT_EQ(args.metaState, motionEvent.getMetaState());
    EXPECT_EQ(args.buttonState, motionEvent.getButtonState());
    EXPECT_EQ(args.classification, motionEvent.getClassification());
@@ -193,12 +191,11 @@ void verifyArgsEqualToEvent(const PublishMotionArgs& args, const MotionEvent& mo
void publishMotionEvent(InputPublisher& publisher, const PublishMotionArgs& a) {
    status_t status =
            publisher.publishMotionEvent(a.seq, a.eventId, a.deviceId, a.source, a.displayId,
                                         a.hmac, a.action, a.actionButton, a.flags, a.edgeFlags,
                                         a.metaState, a.buttonState, a.classification, a.transform,
                                         a.xPrecision, a.yPrecision, a.xCursorPosition,
                                         a.yCursorPosition, a.rawTransform, a.downTime, a.eventTime,
                                         a.pointerCount, a.pointerProperties.data(),
                                         a.pointerCoords.data());
                                         a.hmac, a.action, a.actionButton, a.flags, a.metaState,
                                         a.buttonState, a.classification, a.transform, a.xPrecision,
                                         a.yPrecision, a.xCursorPosition, a.yCursorPosition,
                                         a.rawTransform, a.downTime, a.eventTime, a.pointerCount,
                                         a.pointerProperties.data(), a.pointerCoords.data());
    ASSERT_EQ(OK, status) << "publisher publishMotionEvent should return OK";
}

@@ -892,8 +889,8 @@ TEST_F(InputPublisherAndConsumerNoResamplingTest,
    status =
            mPublisher->publishMotionEvent(0, InputEvent::nextId(), 0, 0,
                                           ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0,
                                           0, 0, MotionClassification::NONE, identityTransform, 0,
                                           0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                           0, MotionClassification::NONE, identityTransform, 0, 0,
                                           AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                           AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform,
                                           0, 0, pointerCount, pointerProperties, pointerCoords);
    ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE";
@@ -910,8 +907,8 @@ TEST_F(InputPublisherAndConsumerNoResamplingTest,
    status =
            mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0,
                                           ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0,
                                           0, 0, MotionClassification::NONE, identityTransform, 0,
                                           0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                           0, MotionClassification::NONE, identityTransform, 0, 0,
                                           AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                           AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform,
                                           0, 0, pointerCount, pointerProperties, pointerCoords);
    ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE";
@@ -932,8 +929,8 @@ TEST_F(InputPublisherAndConsumerNoResamplingTest,
    status =
            mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0,
                                           ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0,
                                           0, 0, MotionClassification::NONE, identityTransform, 0,
                                           0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                           0, MotionClassification::NONE, identityTransform, 0, 0,
                                           AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                           AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform,
                                           0, 0, pointerCount, pointerProperties, pointerCoords);
    ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE";
+11 −14
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ struct PublishMotionArgs {
    const uint32_t source = AINPUT_SOURCE_TOUCHSCREEN;
    const ui::LogicalDisplayId displayId = ui::LogicalDisplayId::DEFAULT;
    const int32_t actionButton = 0;
    const int32_t edgeFlags = AMOTION_EVENT_EDGE_FLAG_TOP;
    const int32_t metaState = AMETA_ALT_LEFT_ON | AMETA_ALT_ON;
    const int32_t buttonState = AMOTION_EVENT_BUTTON_PRIMARY;
    const MotionClassification classification = MotionClassification::AMBIGUOUS_GESTURE;
@@ -130,7 +129,6 @@ void verifyArgsEqualToEvent(const PublishMotionArgs& args, const MotionEvent& mo
    EXPECT_EQ(args.action, motionEvent.getAction());
    EXPECT_EQ(args.downTime, motionEvent.getDownTime());
    EXPECT_EQ(args.flags, static_cast<int32_t>(motionEvent.getFlags().get()));
    EXPECT_EQ(args.edgeFlags, motionEvent.getEdgeFlags());
    EXPECT_EQ(args.metaState, motionEvent.getMetaState());
    EXPECT_EQ(args.buttonState, motionEvent.getButtonState());
    EXPECT_EQ(args.classification, motionEvent.getClassification());
@@ -183,12 +181,11 @@ void verifyArgsEqualToEvent(const PublishMotionArgs& args, const MotionEvent& mo
void publishMotionEvent(InputPublisher& publisher, const PublishMotionArgs& a) {
    status_t status =
            publisher.publishMotionEvent(a.seq, a.eventId, a.deviceId, a.source, a.displayId,
                                         a.hmac, a.action, a.actionButton, a.flags, a.edgeFlags,
                                         a.metaState, a.buttonState, a.classification, a.transform,
                                         a.xPrecision, a.yPrecision, a.xCursorPosition,
                                         a.yCursorPosition, a.rawTransform, a.downTime, a.eventTime,
                                         a.pointerCount, a.pointerProperties.data(),
                                         a.pointerCoords.data());
                                         a.hmac, a.action, a.actionButton, a.flags, a.metaState,
                                         a.buttonState, a.classification, a.transform, a.xPrecision,
                                         a.yPrecision, a.xCursorPosition, a.yCursorPosition,
                                         a.rawTransform, a.downTime, a.eventTime, a.pointerCount,
                                         a.pointerProperties.data(), a.pointerCoords.data());
    ASSERT_EQ(OK, status) << "publisher publishMotionEvent should return OK";
}

@@ -626,8 +623,8 @@ TEST_F(InputPublisherAndConsumerTest, PublishMotionEvent_WhenSequenceNumberIsZer
    status =
            mPublisher->publishMotionEvent(0, InputEvent::nextId(), 0, 0,
                                           ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0,
                                           0, 0, MotionClassification::NONE, identityTransform, 0,
                                           0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                           0, MotionClassification::NONE, identityTransform, 0, 0,
                                           AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                           AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform,
                                           0, 0, pointerCount, pointerProperties, pointerCoords);
    ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE";
@@ -643,8 +640,8 @@ TEST_F(InputPublisherAndConsumerTest, PublishMotionEvent_WhenPointerCountLessTha
    status =
            mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0,
                                           ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0,
                                           0, 0, MotionClassification::NONE, identityTransform, 0,
                                           0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                           0, MotionClassification::NONE, identityTransform, 0, 0,
                                           AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                           AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform,
                                           0, 0, pointerCount, pointerProperties, pointerCoords);
    ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE";
@@ -665,8 +662,8 @@ TEST_F(InputPublisherAndConsumerTest,
    status =
            mPublisher->publishMotionEvent(1, InputEvent::nextId(), 0, 0,
                                           ui::LogicalDisplayId::DEFAULT, INVALID_HMAC, 0, 0, 0, 0,
                                           0, 0, MotionClassification::NONE, identityTransform, 0,
                                           0, AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                           0, MotionClassification::NONE, identityTransform, 0, 0,
                                           AMOTION_EVENT_INVALID_CURSOR_POSITION,
                                           AMOTION_EVENT_INVALID_CURSOR_POSITION, identityTransform,
                                           0, 0, pointerCount, pointerProperties, pointerCoords);
    ASSERT_EQ(BAD_VALUE, status) << "publisher publishMotionEvent should return BAD_VALUE";
Loading