Fix historical timestamp for the first pointer
A fix was added to add event time when using multiple pointers,
but pointer zero was not populated.
Bug: 232941452
Test: gradlew :input:input-motionprediction:test
Change-Id: Ie3c27f02fe93781b9aec0b78fc4142fb3c94965f
diff --git a/input/input-motionprediction/src/main/java/androidx/input/motionprediction/kalman/MultiPointerPredictor.java b/input/input-motionprediction/src/main/java/androidx/input/motionprediction/kalman/MultiPointerPredictor.java
index aca41a1..895949e 100644
--- a/input/input-motionprediction/src/main/java/androidx/input/motionprediction/kalman/MultiPointerPredictor.java
+++ b/input/input-motionprediction/src/main/java/androidx/input/motionprediction/kalman/MultiPointerPredictor.java
@@ -183,7 +183,7 @@
MotionEvent multiPointerEvent =
MotionEvent.obtain(
0 /* down time */,
- 0 /* event time */,
+ pointerEventTimes[0] /* event time */,
MotionEvent.ACTION_MOVE /* action */,
pointerCount /* pointer count */,
pointerProperties /* pointer properties */,
diff --git a/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/kalman/MultiPointerPredictorTest.kt b/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/kalman/MultiPointerPredictorTest.kt
index caee9e0..d6f5230 100644
--- a/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/kalman/MultiPointerPredictorTest.kt
+++ b/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/kalman/MultiPointerPredictorTest.kt
@@ -46,7 +46,7 @@
val predicted = predictor.predict(PREDICT_SAMPLE * generator.getRateMs().toInt())!!
assertThat(predicted.getPointerCount()).isEqualTo(2)
var historicalTime = predicted.getEventTime()
- for (i in (PREDICT_SAMPLE - 2) downTo 1) {
+ for (i in (PREDICT_SAMPLE - 2) downTo 0) {
historicalTime -= generator.getRateMs().toInt();
assertThat(predicted.getHistoricalEventTime(i)).isEqualTo(historicalTime)
}