commit | f39dfee1dd822bad053d1da40510ae6a61923a6b | [log] [tgz] |
---|---|---|
author | omarmt <[email protected]> | Tue Sep 10 11:53:52 2024 +0000 |
committer | omarmt <[email protected]> | Tue Sep 10 16:45:47 2024 +0000 |
tree | 84c43a191019327b0447ead09cbb074647cee470 | |
parent | 9810a187240b484c35d77a110d6e615d9d3eb87c [diff] |
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
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt index b99b7f9..fb9dde3 100644 --- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt +++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt
@@ -234,8 +234,8 @@ 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 @@ // 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) }
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt index 942cb23..af717ac 100644 --- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt +++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt
@@ -438,6 +438,9 @@ continueDraggingDown() assertThat(stopped).isTrue() + + // Complete the gesture + rule.onRoot().performTouchInput { up() } } @Test