Fix broken input tests
InputPublisherAndConsumer_test currently segfaults due to
null pointer dereference. This is because 0 is passed instead
of a valid pointer to an allocated int32_t. Also, enforce strict
compiler warnings, include signed comparisons.
Bug: 62033391
Test: m -j libinput_tests_InputEvent_test
libinput_tests_InputChannel_test
libinput_tests_InputPublisherAndConsumer_test
libinput_tests_InputTransport_test libinput_tests_VelocityTracker_test
&& adb push out/target/product/taimen/data/nativetest/libinput_tests/
/data/nativetest/
then run the above tests individually, for example
/data/nativetest/libinput_tests # ./InputPublisherAndConsumer_test
and others in a similar manner
Change-Id: Ia030cdbfa22d2bf7bdf6274a337b059ca3f9a6c3
diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp
index 6dd12d6..4304982 100644
--- a/services/inputflinger/InputReader.cpp
+++ b/services/inputflinger/InputReader.cpp
@@ -2258,7 +2258,7 @@
dump.appendFormat(INDENT3 "Orientation: %d\n", mOrientation);
dump.appendFormat(INDENT3 "KeyDowns: %zu keys currently down\n", mKeyDowns.size());
dump.appendFormat(INDENT3 "MetaState: 0x%0x\n", mMetaState);
- dump.appendFormat(INDENT3 "DownTime: %lld\n", (long long)mDownTime);
+ dump.appendFormat(INDENT3 "DownTime: %" PRId64 "\n", mDownTime);
}
@@ -2619,7 +2619,7 @@
dump.appendFormat(INDENT3 "Orientation: %d\n", mOrientation);
dump.appendFormat(INDENT3 "ButtonState: 0x%08x\n", mButtonState);
dump.appendFormat(INDENT3 "Down: %s\n", toString(isPointerDown(mButtonState)));
- dump.appendFormat(INDENT3 "DownTime: %lld\n", (long long)mDownTime);
+ dump.appendFormat(INDENT3 "DownTime: %" PRId64 "\n", mDownTime);
}
void CursorInputMapper::configure(nsecs_t when,
@@ -5508,18 +5508,15 @@
// Otherwise choose an arbitrary remaining pointer.
// This guarantees we always have an active touch id when there is at least one pointer.
// We keep the same active touch id for as long as possible.
- bool activeTouchChanged = false;
int32_t lastActiveTouchId = mPointerGesture.activeTouchId;
int32_t activeTouchId = lastActiveTouchId;
if (activeTouchId < 0) {
if (!mCurrentCookedState.fingerIdBits.isEmpty()) {
- activeTouchChanged = true;
activeTouchId = mPointerGesture.activeTouchId =
mCurrentCookedState.fingerIdBits.firstMarkedBit();
mPointerGesture.firstTouchTime = when;
}
} else if (!mCurrentCookedState.fingerIdBits.hasBit(activeTouchId)) {
- activeTouchChanged = true;
if (!mCurrentCookedState.fingerIdBits.isEmpty()) {
activeTouchId = mPointerGesture.activeTouchId =
mCurrentCookedState.fingerIdBits.firstMarkedBit();
@@ -5615,7 +5612,6 @@
}
if (bestId >= 0 && bestId != activeTouchId) {
mPointerGesture.activeTouchId = activeTouchId = bestId;
- activeTouchChanged = true;
#if DEBUG_GESTURES
ALOGD("Gestures: BUTTON_CLICK_OR_DRAG switched pointers, "
"bestId=%d, bestSpeed=%0.3f", bestId, bestSpeed);