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

Commit a0b1e44a authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by Android (Google) Code Review
Browse files

Merge "Pass RawEvent latency from InputReader to InputListener" into sc-dev

parents 6fd33e3d 58ba3d15
Loading
Loading
Loading
Loading
+29 −24
Original line number Diff line number Diff line
@@ -50,9 +50,10 @@ void NotifyConfigurationChangedArgs::notify(const sp<InputListenerInterface>& li

// --- NotifyKeyArgs ---

NotifyKeyArgs::NotifyKeyArgs(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source,
                             int32_t displayId, uint32_t policyFlags, int32_t action, int32_t flags,
                             int32_t keyCode, int32_t scanCode, int32_t metaState, nsecs_t downTime)
NotifyKeyArgs::NotifyKeyArgs(int32_t id, nsecs_t eventTime, nsecs_t readTime, int32_t deviceId,
                             uint32_t source, int32_t displayId, uint32_t policyFlags,
                             int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode,
                             int32_t metaState, nsecs_t downTime)
      : NotifyArgs(id, eventTime),
        deviceId(deviceId),
        source(source),
@@ -63,7 +64,8 @@ NotifyKeyArgs::NotifyKeyArgs(int32_t id, nsecs_t eventTime, int32_t deviceId, ui
        keyCode(keyCode),
        scanCode(scanCode),
        metaState(metaState),
        downTime(downTime) {}
        downTime(downTime),
        readTime(readTime) {}

NotifyKeyArgs::NotifyKeyArgs(const NotifyKeyArgs& other)
      : NotifyArgs(other.id, other.eventTime),
@@ -76,13 +78,15 @@ NotifyKeyArgs::NotifyKeyArgs(const NotifyKeyArgs& other)
        keyCode(other.keyCode),
        scanCode(other.scanCode),
        metaState(other.metaState),
        downTime(other.downTime) {}
        downTime(other.downTime),
        readTime(other.readTime) {}

bool NotifyKeyArgs::operator==(const NotifyKeyArgs& rhs) const {
    return id == rhs.id && eventTime == rhs.eventTime && deviceId == rhs.deviceId &&
            source == rhs.source && displayId == rhs.displayId && policyFlags == rhs.policyFlags &&
            action == rhs.action && flags == rhs.flags && keyCode == rhs.keyCode &&
            scanCode == rhs.scanCode && metaState == rhs.metaState && downTime == rhs.downTime;
    return id == rhs.id && eventTime == rhs.eventTime && readTime == rhs.readTime &&
            deviceId == rhs.deviceId && source == rhs.source && displayId == rhs.displayId &&
            policyFlags == rhs.policyFlags && action == rhs.action && flags == rhs.flags &&
            keyCode == rhs.keyCode && scanCode == rhs.scanCode && metaState == rhs.metaState &&
            downTime == rhs.downTime;
}

void NotifyKeyArgs::notify(const sp<InputListenerInterface>& listener) const {
@@ -91,15 +95,13 @@ void NotifyKeyArgs::notify(const sp<InputListenerInterface>& listener) const {

// --- NotifyMotionArgs ---

NotifyMotionArgs::NotifyMotionArgs(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source,
                                   int32_t displayId, uint32_t policyFlags, int32_t action,
                                   int32_t actionButton, int32_t flags, int32_t metaState,
                                   int32_t buttonState, MotionClassification classification,
                                   int32_t edgeFlags, uint32_t pointerCount,
                                   const PointerProperties* pointerProperties,
                                   const PointerCoords* pointerCoords, float xPrecision,
                                   float yPrecision, float xCursorPosition, float yCursorPosition,
                                   nsecs_t downTime,
NotifyMotionArgs::NotifyMotionArgs(
        int32_t id, nsecs_t eventTime, nsecs_t readTime, int32_t deviceId, uint32_t source,
        int32_t displayId, uint32_t policyFlags, int32_t action, int32_t actionButton,
        int32_t flags, int32_t metaState, int32_t buttonState, MotionClassification classification,
        int32_t edgeFlags, uint32_t pointerCount, const PointerProperties* pointerProperties,
        const PointerCoords* pointerCoords, float xPrecision, float yPrecision,
        float xCursorPosition, float yCursorPosition, nsecs_t downTime,
        const std::vector<TouchVideoFrame>& videoFrames)
      : NotifyArgs(id, eventTime),
        deviceId(deviceId),
@@ -119,6 +121,7 @@ NotifyMotionArgs::NotifyMotionArgs(int32_t id, nsecs_t eventTime, int32_t device
        xCursorPosition(xCursorPosition),
        yCursorPosition(yCursorPosition),
        downTime(downTime),
        readTime(readTime),
        videoFrames(videoFrames) {
    for (uint32_t i = 0; i < pointerCount; i++) {
        this->pointerProperties[i].copyFrom(pointerProperties[i]);
@@ -145,6 +148,7 @@ NotifyMotionArgs::NotifyMotionArgs(const NotifyMotionArgs& other)
        xCursorPosition(other.xCursorPosition),
        yCursorPosition(other.yCursorPosition),
        downTime(other.downTime),
        readTime(other.readTime),
        videoFrames(other.videoFrames) {
    for (uint32_t i = 0; i < pointerCount; i++) {
        pointerProperties[i].copyFrom(other.pointerProperties[i]);
@@ -157,11 +161,12 @@ static inline bool isCursorPositionEqual(float lhs, float rhs) {
}

bool NotifyMotionArgs::operator==(const NotifyMotionArgs& rhs) const {
    bool equal = id == rhs.id && eventTime == rhs.eventTime && deviceId == rhs.deviceId &&
            source == rhs.source && displayId == rhs.displayId && policyFlags == rhs.policyFlags &&
            action == rhs.action && actionButton == rhs.actionButton && flags == rhs.flags &&
            metaState == rhs.metaState && buttonState == rhs.buttonState &&
            classification == rhs.classification && edgeFlags == rhs.edgeFlags &&
    bool equal = id == rhs.id && eventTime == rhs.eventTime && readTime == rhs.readTime &&
            deviceId == rhs.deviceId && source == rhs.source && displayId == rhs.displayId &&
            policyFlags == rhs.policyFlags && action == rhs.action &&
            actionButton == rhs.actionButton && flags == rhs.flags && metaState == rhs.metaState &&
            buttonState == rhs.buttonState && classification == rhs.classification &&
            edgeFlags == rhs.edgeFlags &&
            pointerCount == rhs.pointerCount
            // PointerProperties and PointerCoords are compared separately below
            && xPrecision == rhs.xPrecision && yPrecision == rhs.yPrecision &&
+3 −2
Original line number Diff line number Diff line
@@ -249,8 +249,9 @@ static NotifyMotionArgs generateMotionArgs() {

    const nsecs_t currentTime = now();
    // Define a valid motion event.
    NotifyMotionArgs args(/* id */ 0, currentTime, DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN,
                          ADISPLAY_ID_DEFAULT, POLICY_FLAG_PASS_TO_USER, AMOTION_EVENT_ACTION_DOWN,
    NotifyMotionArgs args(/* id */ 0, currentTime, currentTime, DEVICE_ID,
                          AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT, POLICY_FLAG_PASS_TO_USER,
                          AMOTION_EVENT_ACTION_DOWN,
                          /* actionButton */ 0, /* flags */ 0, AMETA_NONE, /* buttonState */ 0,
                          MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, 1,
                          pointerProperties, pointerCoords,
+9 −6
Original line number Diff line number Diff line
@@ -73,12 +73,14 @@ struct NotifyKeyArgs : public NotifyArgs {
    int32_t scanCode;
    int32_t metaState;
    nsecs_t downTime;
    nsecs_t readTime;

    inline NotifyKeyArgs() { }

    NotifyKeyArgs(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source,
                  int32_t displayId, uint32_t policyFlags, int32_t action, int32_t flags,
                  int32_t keyCode, int32_t scanCode, int32_t metaState, nsecs_t downTime);
    NotifyKeyArgs(int32_t id, nsecs_t eventTime, nsecs_t readTime, int32_t deviceId,
                  uint32_t source, int32_t displayId, uint32_t policyFlags, int32_t action,
                  int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState,
                  nsecs_t downTime);

    bool operator==(const NotifyKeyArgs& rhs) const;

@@ -120,13 +122,14 @@ struct NotifyMotionArgs : public NotifyArgs {
    float xCursorPosition;
    float yCursorPosition;
    nsecs_t downTime;
    nsecs_t readTime;
    std::vector<TouchVideoFrame> videoFrames;

    inline NotifyMotionArgs() { }

    NotifyMotionArgs(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source,
                     int32_t displayId, uint32_t policyFlags, int32_t action, int32_t actionButton,
                     int32_t flags, int32_t metaState, int32_t buttonState,
    NotifyMotionArgs(int32_t id, nsecs_t eventTime, nsecs_t readTime, int32_t deviceId,
                     uint32_t source, int32_t displayId, uint32_t policyFlags, int32_t action,
                     int32_t actionButton, int32_t flags, int32_t metaState, int32_t buttonState,
                     MotionClassification classification, int32_t edgeFlags, uint32_t pointerCount,
                     const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
                     float xPrecision, float yPrecision, float xCursorPosition,
+1 −0
Original line number Diff line number Diff line
@@ -1567,6 +1567,7 @@ size_t EventHub::getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSiz
                    for (size_t i = 0; i < count; i++) {
                        struct input_event& iev = readBuffer[i];
                        event->when = processEventTimestamp(iev);
                        event->readTime = systemTime(SYSTEM_TIME_MONOTONIC);
                        event->deviceId = deviceId;
                        event->type = iev.type;
                        event->code = iev.code;
+2 −2
Original line number Diff line number Diff line
@@ -506,8 +506,8 @@ void InputDevice::flushSensor(InputDeviceSensorType sensorType) {
    for_each_mapper([sensorType](InputMapper& mapper) { mapper.flushSensor(sensorType); });
}

void InputDevice::cancelTouch(nsecs_t when) {
    for_each_mapper([when](InputMapper& mapper) { mapper.cancelTouch(when); });
void InputDevice::cancelTouch(nsecs_t when, nsecs_t readTime) {
    for_each_mapper([when, readTime](InputMapper& mapper) { mapper.cancelTouch(when, readTime); });
}

std::optional<int32_t> InputDevice::getBatteryCapacity() {
Loading