Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 07446428 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

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
parent 94b29e54
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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 @@ void AndroidInputEventProtoConverter::toProtoMotionEvent(const TracedMotionEvent

        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();