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

Commit f39dfee1 authored by omarmt's avatar omarmt
Browse files

Fixed errors after updated ag/29186008

After ag/29186008 the last event in the PointerInput API can contain
multiple pointers, but always and only one pointer with id
== velocityPointerId.
Completed the swipe gesture in
multiPointerWaitAConsumableEventInMainPass to avoid possible errors.

Test: atest ElementTest
Test: atest MultiPointerDraggableTest
Bug: 365564010
Flag: com.android.systemui.scene_container
Change-Id: I69beecd0ae7c0b993da4812a663ae95077dff749
parent 9810a187
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -234,8 +234,8 @@ internal class MultiPointerDraggableNode(
                    pointersDown == 0 -> {
                        startedPosition = null

                        // This is the last pointer up
                        velocityTracker.addPointerInputChange(changes.single())
                        val lastPointerUp = changes.single { it.id == velocityPointerId }
                        velocityTracker.addPointerInputChange(lastPointerUp)
                    }

                    // The first pointer down, startedPosition was not set.
@@ -271,7 +271,12 @@ internal class MultiPointerDraggableNode(

                        // If the previous pointer has been removed, we use the first available
                        // change to keep tracking the velocity.
                        velocityPointerId = pointerChange.id
                        velocityPointerId =
                            if (pointerChange.pressed) {
                                pointerChange.id
                            } else {
                                changes.first { it.pressed }.id
                            }

                        velocityTracker.addPointerInputChange(pointerChange)
                    }
+3 −0
Original line number Diff line number Diff line
@@ -438,6 +438,9 @@ class MultiPointerDraggableTest {

        continueDraggingDown()
        assertThat(stopped).isTrue()

        // Complete the gesture
        rule.onRoot().performTouchInput { up() }
    }

    @Test