assert when the touch event goes back to the future

bug: 7911739

Change-Id: I29db6a5cb6749999666b1c53857ea61bcc19b8f1
diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h
index 46595d8..7069011 100644
--- a/native/jni/src/defines.h
+++ b/native/jni/src/defines.h
@@ -93,6 +93,7 @@
 #include <execinfo.h>
 #include <stdlib.h>
 
+#define DO_ASSERT_TEST
 #define ASSERT(success) do { if (!(success)) { showStackTrace(); assert(success);} } while (0)
 #define SHOW_STACK_TRACE do { showStackTrace(); } while (0)
 
@@ -111,6 +112,7 @@
 }
 #else
 #include <cassert>
+#define DO_ASSERT_TEST
 #define ASSERT(success) assert(success)
 #define SHOW_STACK_TRACE
 #endif
@@ -120,6 +122,7 @@
 #define AKLOGI(fmt, ...)
 #define DUMP_RESULT(words, frequencies, maxWordCount, maxWordLength)
 #define DUMP_WORD(word, length)
+#undef DO_ASSERT_TEST
 #define ASSERT(success)
 #define SHOW_STACK_TRACE
 #define INTS_TO_CHARS(input, length, output)
diff --git a/native/jni/src/proximity_info_state.cpp b/native/jni/src/proximity_info_state.cpp
index bd2149a..5362d69 100644
--- a/native/jni/src/proximity_info_state.cpp
+++ b/native/jni/src/proximity_info_state.cpp
@@ -123,6 +123,15 @@
                 }
             }
         }
+#ifdef DO_ASSERT_TEST
+        if (times) {
+            for (int i = 0; i < inputSize; ++i) {
+                if (i > 0) {
+                    ASSERT(times[i] >= times[i - 1]);
+                }
+            }
+        }
+#endif
         const bool proximityOnly = !isGeometric && (xCoordinates[0] < 0 || yCoordinates[0] < 0);
         int lastInputIndex = pushTouchPointStartIndex;
         for (int i = lastInputIndex; i < inputSize; ++i) {