InputTracer: Ensure 0 coordinate values are traced
The axis bits in PointerCoords are not set when
the value is 0, since that's the default value.
Make sure the coordinate values are always traced
for pointer events.
Bug: 245989146
Change-Id: Ib9fc647f1d3166ae51b265c40e77018ad2682d23
Flag: EXEMPT tracing only
Test: Presubmit
diff --git a/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.cpp b/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.cpp
index cc04684..d64f375 100644
--- a/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.cpp
+++ b/services/inputflinger/dispatcher/trace/AndroidInputEventProtoConverter.cpp
@@ -16,7 +16,9 @@
#include "AndroidInputEventProtoConverter.h"
+#include <android/input.h>
#include <android-base/logging.h>
+#include <input/Input.h>
#include <perfetto/trace/android/android_input_event.pbzero.h>
namespace android::inputdispatcher::trace {
@@ -67,6 +69,12 @@
const auto& coords = event.pointerCoords[i];
auto bits = BitSet64(coords.bits);
+ if (isFromSource(event.source, AINPUT_SOURCE_CLASS_POINTER)) {
+ // Always include the X and Y axes for pointer events, since the
+ // bits will not be marked if the value is 0.
+ bits.markBit(AMOTION_EVENT_AXIS_X);
+ bits.markBit(AMOTION_EVENT_AXIS_Y);
+ }
for (int32_t axisIndex = 0; !bits.isEmpty(); axisIndex++) {
const auto axis = bits.clearFirstMarkedBit();
auto axisEntry = pointer->add_axis_value();