summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yeabkal Wubshit <yeabkal@google.com> 2023-07-24 17:04:54 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-07-24 17:04:54 +0000
commit9d9af9f8c2024ef9286673de80a8506e3eed681d (patch)
tree550839f0c1be41afcaf617fc4804545fdecf91c6
parentbfcbc39c032580fc8dc122aed60c016aa9e3c76f (diff)
parentd9c4008a731999a141faa518b42fc3385c5540f6 (diff)
Merge "Improve VelocityTracker bad pointer ID crash log" into main
-rw-r--r--libs/input/VelocityTracker.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/libs/input/VelocityTracker.cpp b/libs/input/VelocityTracker.cpp
index 87c7768f25..8704eee73d 100644
--- a/libs/input/VelocityTracker.cpp
+++ b/libs/input/VelocityTracker.cpp
@@ -16,10 +16,11 @@
#define LOG_TAG "VelocityTracker"
-#include <array>
+#include <android-base/logging.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
+#include <array>
#include <optional>
#include <input/PrintTools.h>
@@ -243,6 +244,11 @@ void VelocityTracker::clearPointer(int32_t pointerId) {
void VelocityTracker::addMovement(nsecs_t eventTime, int32_t pointerId, int32_t axis,
float position) {
+ if (pointerId < 0 || pointerId > MAX_POINTER_ID) {
+ LOG(FATAL) << "Invalid pointer ID " << pointerId << " for axis "
+ << MotionEvent::getLabel(axis);
+ }
+
if (mCurrentPointerIdBits.hasBit(pointerId) &&
std::chrono::nanoseconds(eventTime - mLastEventTime) > ASSUME_POINTER_STOPPED_TIME) {
ALOGD_IF(DEBUG_VELOCITY, "VelocityTracker: stopped for %s, clearing state.",