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

Commit ed89cbbc authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Allow multiple input device in the same window

With this change, all restrictions about only having a single input
device active in a window are lifted.

The window will get multiple input devices at once.

21 native tests were forked in this CL to reflect the new behaviour.

Bug: 211379801
Test: navigate settings with touch + stylus at the same time
Test: swipe inside IME with touch + stylus
Test: draw in test app with touch + stylus
Test: TEST=inputflinger_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST
Change-Id: I259c0c87e47a1fa3090cddba6a595cf032877bb2
parent 51699b86
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -137,3 +137,10 @@ flag {
  is_fixed_read_only: true

}

flag {
  name: "enable_multi_device_same_window_stream"
  namespace: "input"
  description: "Allow multiple input devices to be active in the same window simultaneously"
  bug: "330752824"
}
+1 −1
Original line number Diff line number Diff line
@@ -4390,7 +4390,7 @@ std::unique_ptr<MotionEntry> InputDispatcher::splitMotionEvent(
        // different pointer ids than we expected based on the previous ACTION_DOWN
        // or ACTION_POINTER_DOWN events that caused us to decide to split the pointers
        // in this way.
        ALOGW("Dropping split motion event because the pointer count is %d but "
        ALOGW("Dropping split motion event because the pointer count is %zu but "
              "we expected there to be %zu pointers.  This probably means we received "
              "a broken sequence of pointer ids from the input device: %s",
              pointerCoords.size(), pointerIds.count(),
+26 −22
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ bool InputState::trackMotion(const MotionEntry& entry, int32_t flags) {
        return true;
    }

    if (!input_flags::enable_multi_device_same_window_stream()) {
        if (!mMotionMementos.empty()) {
            const MotionMemento& lastMemento = mMotionMementos.back();
            if (isStylusEvent(lastMemento.source, lastMemento.pointerProperties) &&
@@ -103,6 +104,7 @@ bool InputState::trackMotion(const MotionEntry& entry, int32_t flags) {
                return false;
            }
        }
    }

    int32_t actionMasked = entry.action & AMOTION_EVENT_ACTION_MASK;
    switch (actionMasked) {
@@ -345,6 +347,7 @@ bool InputState::shouldCancelPreviousStream(const MotionEntry& motionEntry) cons
        return false;
    }

    if (!input_flags::enable_multi_device_same_window_stream()) {
        if (isStylusEvent(lastMemento.source, lastMemento.pointerProperties)) {
            // A stylus is already active.
            if (isStylusEvent(motionEntry.source, motionEntry.pointerProperties) &&
@@ -364,6 +367,7 @@ bool InputState::shouldCancelPreviousStream(const MotionEntry& motionEntry) cons
            actionMasked == AMOTION_EVENT_ACTION_HOVER_ENTER) {
            return true;
        }
    }
    // By default, don't cancel any events.
    return false;
}
+5 −3
Original line number Diff line number Diff line
@@ -298,16 +298,18 @@ std::unique_ptr<MotionEvent> FakeWindowHandle::consumeMotionEvent(
        const ::testing::Matcher<MotionEvent>& matcher) {
    std::unique_ptr<InputEvent> event = consume(CONSUME_TIMEOUT_EVENT_EXPECTED);
    if (event == nullptr) {
        ADD_FAILURE() << "No event";
        std::ostringstream matcherDescription;
        matcher.DescribeTo(&matcherDescription);
        ADD_FAILURE() << "No event (expected " << matcherDescription.str() << ") on " << mName;
        return nullptr;
    }
    if (event->getType() != InputEventType::MOTION) {
        ADD_FAILURE() << "Instead of motion event, got " << *event;
        ADD_FAILURE() << "Instead of motion event, got " << *event << " on " << mName;
        return nullptr;
    }
    std::unique_ptr<MotionEvent> motionEvent =
            std::unique_ptr<MotionEvent>(static_cast<MotionEvent*>(event.release()));
    EXPECT_THAT(*motionEvent, matcher);
    EXPECT_THAT(*motionEvent, matcher) << " on " << mName;
    return motionEvent;
}

+1500 −79

File changed.

Preview size limit exceeded, changes collapsed.