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

Commit 096257cc authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Use std::variant for NotifyArgs

Previously, NotifyArgs was a base class and we relied on inheritance in
order to refer to these args in a generic manner.

Unfortunately, this prevents us from being able to cast into a
descendant. If you got NotifyArgs, there was no way to figure out its
type.

In this CL, we switch to std::variant. Doing this allows us to remove
the inheritance, and several other functions. The classes are now mostly
about data.

This allows us to receive a generic NotifyArgs object and cast it into
NotifyMotionArgs (for example). This also allows us to separate
NotifyArgs from the InputListener interface (not done in this CL).

Furthermore, we don't need to store the args as unique_ptr anymore.

Bug: 211379801
Test: m checkinput
Change-Id: I5b10d485a9eb27b4ffb6a3a6e21227f52ac3dede
parent 007713dd
Loading
Loading
Loading
Loading
+46 −129
Original line number Diff line number Diff line
@@ -34,19 +34,7 @@ namespace android {
// --- NotifyConfigurationChangedArgs ---

NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs(int32_t id, nsecs_t eventTime)
      : NotifyArgs(id, eventTime) {}

NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs(
        const NotifyConfigurationChangedArgs& other)
      : NotifyArgs(other.id, other.eventTime) {}

bool NotifyConfigurationChangedArgs::operator==(const NotifyConfigurationChangedArgs& rhs) const {
    return id == rhs.id && eventTime == rhs.eventTime;
}

void NotifyConfigurationChangedArgs::notify(InputListenerInterface& listener) const {
    listener.notifyConfigurationChanged(this);
}
      : id(id), eventTime(eventTime) {}

// --- NotifyKeyArgs ---

@@ -54,7 +42,8 @@ NotifyKeyArgs::NotifyKeyArgs(int32_t id, nsecs_t eventTime, nsecs_t readTime, in
                             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),
      : id(id),
        eventTime(eventTime),
        deviceId(deviceId),
        source(source),
        displayId(displayId),
@@ -67,32 +56,6 @@ NotifyKeyArgs::NotifyKeyArgs(int32_t id, nsecs_t eventTime, nsecs_t readTime, in
        downTime(downTime),
        readTime(readTime) {}

NotifyKeyArgs::NotifyKeyArgs(const NotifyKeyArgs& other)
      : NotifyArgs(other.id, other.eventTime),
        deviceId(other.deviceId),
        source(other.source),
        displayId(other.displayId),
        policyFlags(other.policyFlags),
        action(other.action),
        flags(other.flags),
        keyCode(other.keyCode),
        scanCode(other.scanCode),
        metaState(other.metaState),
        downTime(other.downTime),
        readTime(other.readTime) {}

bool NotifyKeyArgs::operator==(const NotifyKeyArgs& rhs) const {
    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(InputListenerInterface& listener) const {
    listener.notifyKey(this);
}

// --- NotifyMotionArgs ---

NotifyMotionArgs::NotifyMotionArgs(
@@ -103,7 +66,8 @@ NotifyMotionArgs::NotifyMotionArgs(
        const PointerCoords* pointerCoords, float xPrecision, float yPrecision,
        float xCursorPosition, float yCursorPosition, nsecs_t downTime,
        const std::vector<TouchVideoFrame>& videoFrames)
      : NotifyArgs(id, eventTime),
      : id(id),
        eventTime(eventTime),
        deviceId(deviceId),
        source(source),
        displayId(displayId),
@@ -130,7 +94,8 @@ NotifyMotionArgs::NotifyMotionArgs(
}

NotifyMotionArgs::NotifyMotionArgs(const NotifyMotionArgs& other)
      : NotifyArgs(other.id, other.eventTime),
      : id(other.id),
        eventTime(other.eventTime),
        deviceId(other.deviceId),
        source(other.source),
        displayId(other.displayId),
@@ -220,41 +185,24 @@ std::string NotifyMotionArgs::dump() const {
                        flags);
}

void NotifyMotionArgs::notify(InputListenerInterface& listener) const {
    listener.notifyMotion(this);
}

// --- NotifySwitchArgs ---

NotifySwitchArgs::NotifySwitchArgs(int32_t id, nsecs_t eventTime, uint32_t policyFlags,
                                   uint32_t switchValues, uint32_t switchMask)
      : NotifyArgs(id, eventTime),
      : id(id),
        eventTime(eventTime),
        policyFlags(policyFlags),
        switchValues(switchValues),
        switchMask(switchMask) {}

NotifySwitchArgs::NotifySwitchArgs(const NotifySwitchArgs& other)
      : NotifyArgs(other.id, other.eventTime),
        policyFlags(other.policyFlags),
        switchValues(other.switchValues),
        switchMask(other.switchMask) {}

bool NotifySwitchArgs::operator==(const NotifySwitchArgs rhs) const {
    return id == rhs.id && eventTime == rhs.eventTime && policyFlags == rhs.policyFlags &&
            switchValues == rhs.switchValues && switchMask == rhs.switchMask;
}

void NotifySwitchArgs::notify(InputListenerInterface& listener) const {
    listener.notifySwitch(this);
}

// --- NotifySensorArgs ---

NotifySensorArgs::NotifySensorArgs(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source,
                                   InputDeviceSensorType sensorType,
                                   InputDeviceSensorAccuracy accuracy, bool accuracyChanged,
                                   nsecs_t hwTimestamp, std::vector<float> values)
      : NotifyArgs(id, eventTime),
      : id(id),
        eventTime(eventTime),
        deviceId(deviceId),
        source(source),
        sensorType(sensorType),
@@ -263,77 +211,25 @@ NotifySensorArgs::NotifySensorArgs(int32_t id, nsecs_t eventTime, int32_t device
        hwTimestamp(hwTimestamp),
        values(std::move(values)) {}

NotifySensorArgs::NotifySensorArgs(const NotifySensorArgs& other)
      : NotifyArgs(other.id, other.eventTime),
        deviceId(other.deviceId),
        source(other.source),
        sensorType(other.sensorType),
        accuracy(other.accuracy),
        accuracyChanged(other.accuracyChanged),
        hwTimestamp(other.hwTimestamp),
        values(other.values) {}

bool NotifySensorArgs::operator==(const NotifySensorArgs rhs) const {
    return id == rhs.id && eventTime == rhs.eventTime && sensorType == rhs.sensorType &&
            accuracy == rhs.accuracy && accuracyChanged == rhs.accuracyChanged &&
            hwTimestamp == rhs.hwTimestamp && values == rhs.values;
}

void NotifySensorArgs::notify(InputListenerInterface& listener) const {
    listener.notifySensor(this);
}

// --- NotifyVibratorStateArgs ---

NotifyVibratorStateArgs::NotifyVibratorStateArgs(int32_t id, nsecs_t eventTime, int32_t deviceId,
                                                 bool isOn)
      : NotifyArgs(id, eventTime), deviceId(deviceId), isOn(isOn) {}
      : id(id), eventTime(eventTime), deviceId(deviceId), isOn(isOn) {}

NotifyVibratorStateArgs::NotifyVibratorStateArgs(const NotifyVibratorStateArgs& other)
      : NotifyArgs(other.id, other.eventTime), deviceId(other.deviceId), isOn(other.isOn) {}

bool NotifyVibratorStateArgs::operator==(const NotifyVibratorStateArgs rhs) const {
    return id == rhs.id && eventTime == rhs.eventTime && deviceId == rhs.deviceId &&
            isOn == rhs.isOn;
}

void NotifyVibratorStateArgs::notify(InputListenerInterface& listener) const {
    listener.notifyVibratorState(this);
}
      : id(other.id), eventTime(other.eventTime), deviceId(other.deviceId), isOn(other.isOn) {}

// --- NotifyDeviceResetArgs ---

NotifyDeviceResetArgs::NotifyDeviceResetArgs(int32_t id, nsecs_t eventTime, int32_t deviceId)
      : NotifyArgs(id, eventTime), deviceId(deviceId) {}

NotifyDeviceResetArgs::NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other)
      : NotifyArgs(other.id, other.eventTime), deviceId(other.deviceId) {}

bool NotifyDeviceResetArgs::operator==(const NotifyDeviceResetArgs& rhs) const {
    return id == rhs.id && eventTime == rhs.eventTime && deviceId == rhs.deviceId;
}

void NotifyDeviceResetArgs::notify(InputListenerInterface& listener) const {
    listener.notifyDeviceReset(this);
}
      : id(id), eventTime(eventTime), deviceId(deviceId) {}

// --- NotifyPointerCaptureChangedArgs ---

NotifyPointerCaptureChangedArgs::NotifyPointerCaptureChangedArgs(
        int32_t id, nsecs_t eventTime, const PointerCaptureRequest& request)
      : NotifyArgs(id, eventTime), request(request) {}

NotifyPointerCaptureChangedArgs::NotifyPointerCaptureChangedArgs(
        const NotifyPointerCaptureChangedArgs& other)
      : NotifyArgs(other.id, other.eventTime), request(other.request) {}

bool NotifyPointerCaptureChangedArgs::operator==(const NotifyPointerCaptureChangedArgs& rhs) const {
    return id == rhs.id && eventTime == rhs.eventTime && request == rhs.request;
}

void NotifyPointerCaptureChangedArgs::notify(InputListenerInterface& listener) const {
    listener.notifyPointerCaptureChanged(this);
}
      : id(id), eventTime(eventTime), request(request) {}

// --- QueuedInputListener ---

@@ -350,47 +246,68 @@ QueuedInputListener::QueuedInputListener(InputListenerInterface& innerListener)
void QueuedInputListener::notifyConfigurationChanged(
        const NotifyConfigurationChangedArgs* args) {
    traceEvent(__func__, args->id);
    mArgsQueue.emplace_back(std::make_unique<NotifyConfigurationChangedArgs>(*args));
    mArgsQueue.emplace_back(*args);
}

void QueuedInputListener::notifyKey(const NotifyKeyArgs* args) {
    traceEvent(__func__, args->id);
    mArgsQueue.emplace_back(std::make_unique<NotifyKeyArgs>(*args));
    mArgsQueue.emplace_back(*args);
}

void QueuedInputListener::notifyMotion(const NotifyMotionArgs* args) {
    traceEvent(__func__, args->id);
    mArgsQueue.emplace_back(std::make_unique<NotifyMotionArgs>(*args));
    mArgsQueue.emplace_back(*args);
}

void QueuedInputListener::notifySwitch(const NotifySwitchArgs* args) {
    traceEvent(__func__, args->id);
    mArgsQueue.emplace_back(std::make_unique<NotifySwitchArgs>(*args));
    mArgsQueue.emplace_back(*args);
}

void QueuedInputListener::notifySensor(const NotifySensorArgs* args) {
    traceEvent(__func__, args->id);
    mArgsQueue.emplace_back(std::make_unique<NotifySensorArgs>(*args));
    mArgsQueue.emplace_back(*args);
}

void QueuedInputListener::notifyVibratorState(const NotifyVibratorStateArgs* args) {
    traceEvent(__func__, args->id);
    mArgsQueue.emplace_back(std::make_unique<NotifyVibratorStateArgs>(*args));
    mArgsQueue.emplace_back(*args);
}

void QueuedInputListener::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
    traceEvent(__func__, args->id);
    mArgsQueue.emplace_back(std::make_unique<NotifyDeviceResetArgs>(*args));
    mArgsQueue.emplace_back(*args);
}

void QueuedInputListener::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) {
    traceEvent(__func__, args->id);
    mArgsQueue.emplace_back(std::make_unique<NotifyPointerCaptureChangedArgs>(*args));
    mArgsQueue.emplace_back(*args);
}

// Helper to std::visit with lambdas.
template <typename... V>
struct Visitor : V... {};
// explicit deduction guide (not needed as of C++20)
template <typename... V>
Visitor(V...) -> Visitor<V...>;

void QueuedInputListener::flush() {
    for (const std::unique_ptr<NotifyArgs>& args : mArgsQueue) {
        args->notify(mInnerListener);
    Visitor v{
            [&](const NotifyConfigurationChangedArgs& args) {
                mInnerListener.notifyConfigurationChanged(&args);
            },
            [&](const NotifyKeyArgs& args) { mInnerListener.notifyKey(&args); },
            [&](const NotifyMotionArgs& args) { mInnerListener.notifyMotion(&args); },
            [&](const NotifySwitchArgs& args) { mInnerListener.notifySwitch(&args); },
            [&](const NotifySensorArgs& args) { mInnerListener.notifySensor(&args); },
            [&](const NotifyVibratorStateArgs& args) { mInnerListener.notifyVibratorState(&args); },
            [&](const NotifyDeviceResetArgs& args) { mInnerListener.notifyDeviceReset(&args); },
            [&](const NotifyPointerCaptureChangedArgs& args) {
                mInnerListener.notifyPointerCaptureChanged(&args);
            },
    };
    for (const NotifyArgs& args : mArgsQueue) {
        std::visit(v, args);
    }
    mArgsQueue.clear();
}
+19 −22
Original line number Diff line number Diff line
@@ -123,40 +123,38 @@ ScopedDeathRecipient::~ScopedDeathRecipient() {

// --- ClassifierEvent ---

ClassifierEvent::ClassifierEvent(std::unique_ptr<NotifyMotionArgs> args)
      : type(ClassifierEventType::MOTION), args(std::move(args)){};
ClassifierEvent::ClassifierEvent(std::unique_ptr<NotifyDeviceResetArgs> args)
      : type(ClassifierEventType::DEVICE_RESET), args(std::move(args)){};
ClassifierEvent::ClassifierEvent(ClassifierEventType type, std::unique_ptr<NotifyArgs> args)
      : type(type), args(std::move(args)){};
ClassifierEvent::ClassifierEvent(const NotifyMotionArgs& args)
      : type(ClassifierEventType::MOTION), args(args){};

ClassifierEvent::ClassifierEvent(ClassifierEvent&& other)
      : type(other.type), args(std::move(other.args)){};
ClassifierEvent::ClassifierEvent(const NotifyDeviceResetArgs& args)
      : type(ClassifierEventType::DEVICE_RESET), args(args){};

ClassifierEvent::ClassifierEvent(ClassifierEventType type, std::optional<NotifyArgs> args)
      : type(type), args(args){};

ClassifierEvent& ClassifierEvent::operator=(ClassifierEvent&& other) {
    type = other.type;
    args = std::move(other.args);
    args = other.args;
    return *this;
}

ClassifierEvent ClassifierEvent::createHalResetEvent() {
    return ClassifierEvent(ClassifierEventType::HAL_RESET, nullptr);
    return ClassifierEvent(ClassifierEventType::HAL_RESET, std::nullopt);
}

ClassifierEvent ClassifierEvent::createExitEvent() {
    return ClassifierEvent(ClassifierEventType::EXIT, nullptr);
    return ClassifierEvent(ClassifierEventType::EXIT, std::nullopt);
}

std::optional<int32_t> ClassifierEvent::getDeviceId() const {
    switch (type) {
        case ClassifierEventType::MOTION: {
            NotifyMotionArgs* motionArgs = static_cast<NotifyMotionArgs*>(args.get());
            return motionArgs->deviceId;
            const NotifyMotionArgs& motionArgs = std::get<NotifyMotionArgs>(*args);
            return motionArgs.deviceId;
        }
        case ClassifierEventType::DEVICE_RESET: {
            NotifyDeviceResetArgs* deviceResetArgs =
                    static_cast<NotifyDeviceResetArgs*>(args.get());
            return deviceResetArgs->deviceId;
            const NotifyDeviceResetArgs& deviceResetArgs = std::get<NotifyDeviceResetArgs>(*args);
            return deviceResetArgs.deviceId;
        }
        case ClassifierEventType::HAL_RESET: {
            return std::nullopt;
@@ -212,12 +210,12 @@ void MotionClassifier::processEvents() {
        bool halResponseOk = true;
        switch (event.type) {
            case ClassifierEventType::MOTION: {
                NotifyMotionArgs* motionArgs = static_cast<NotifyMotionArgs*>(event.args.get());
                common::MotionEvent motionEvent = notifyMotionArgsToHalMotionEvent(*motionArgs);
                NotifyMotionArgs& motionArgs = std::get<NotifyMotionArgs>(*event.args);
                common::MotionEvent motionEvent = notifyMotionArgsToHalMotionEvent(motionArgs);
                common::Classification classification;
                ndk::ScopedAStatus response = mService->classify(motionEvent, &classification);
                if (response.isOk()) {
                    updateClassification(motionArgs->deviceId, motionArgs->eventTime,
                    updateClassification(motionArgs.deviceId, motionArgs.eventTime,
                                         getMotionClassification(classification));
                }
                break;
@@ -307,8 +305,7 @@ MotionClassification MotionClassifier::classify(const NotifyMotionArgs& args) {
        updateLastDownTime(args.deviceId, args.downTime);
    }

    ClassifierEvent event(std::make_unique<NotifyMotionArgs>(args));
    enqueueEvent(std::move(event));
    enqueueEvent(args);
    return getClassification(args.deviceId);
}

@@ -328,7 +325,7 @@ void MotionClassifier::reset(const NotifyDeviceResetArgs& args) {
        std::optional<int32_t> eventDeviceId = event.getDeviceId();
        return eventDeviceId && (*eventDeviceId == deviceId);
    });
    enqueueEvent(std::make_unique<NotifyDeviceResetArgs>(args));
    enqueueEvent(args);
}

void MotionClassifier::dump(std::string& dump) {
+5 −5
Original line number Diff line number Diff line
@@ -35,12 +35,12 @@ enum class ClassifierEventType : uint8_t {

struct ClassifierEvent {
    ClassifierEventType type;
    std::unique_ptr<NotifyArgs> args;
    std::optional<NotifyArgs> args;

    ClassifierEvent(ClassifierEventType type, std::unique_ptr<NotifyArgs> args);
    ClassifierEvent(std::unique_ptr<NotifyMotionArgs> args);
    ClassifierEvent(std::unique_ptr<NotifyDeviceResetArgs> args);
    ClassifierEvent(ClassifierEvent&& other);
    ClassifierEvent(ClassifierEventType type, std::optional<NotifyArgs> args);
    ClassifierEvent(const NotifyMotionArgs& args);
    ClassifierEvent(const NotifyDeviceResetArgs& args);
    ClassifierEvent(ClassifierEvent&& other) = default;
    ClassifierEvent& operator=(ClassifierEvent&& other);

    // Convenience function to create a HAL_RESET event
+45 −75
Original line number Diff line number Diff line
@@ -26,41 +26,25 @@ namespace android {

class InputListenerInterface;


/* Superclass of all input event argument objects */
struct NotifyArgs {
/* Describes a configuration change event. */
struct NotifyConfigurationChangedArgs {
    int32_t id;
    nsecs_t eventTime;

    inline NotifyArgs() : id(0), eventTime(0) {}

    inline explicit NotifyArgs(int32_t id, nsecs_t eventTime) : id(id), eventTime(eventTime) {}

    virtual ~NotifyArgs() { }

    virtual void notify(InputListenerInterface& listener) const = 0;
};


/* Describes a configuration change event. */
struct NotifyConfigurationChangedArgs : public NotifyArgs {

    inline NotifyConfigurationChangedArgs() { }

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

    NotifyConfigurationChangedArgs(int32_t id, nsecs_t eventTime);

    NotifyConfigurationChangedArgs(const NotifyConfigurationChangedArgs& other);
    bool operator==(const NotifyConfigurationChangedArgs& rhs) const = default;

    virtual ~NotifyConfigurationChangedArgs() { }

    void notify(InputListenerInterface& listener) const override;
    NotifyConfigurationChangedArgs(const NotifyConfigurationChangedArgs& other) = default;
};


/* Describes a key event. */
struct NotifyKeyArgs : public NotifyArgs {
struct NotifyKeyArgs {
    int32_t id;
    nsecs_t eventTime;

    int32_t deviceId;
    uint32_t source;
    int32_t displayId;
@@ -80,18 +64,16 @@ struct NotifyKeyArgs : public NotifyArgs {
                  int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState,
                  nsecs_t downTime);

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

    NotifyKeyArgs(const NotifyKeyArgs& other);

    virtual ~NotifyKeyArgs() { }
    bool operator==(const NotifyKeyArgs& rhs) const = default;

    void notify(InputListenerInterface& listener) const override;
    NotifyKeyArgs(const NotifyKeyArgs& other) = default;
};


/* Describes a motion event. */
struct NotifyMotionArgs : public NotifyArgs {
struct NotifyMotionArgs {
    int32_t id;
    nsecs_t eventTime;

    int32_t deviceId;
    uint32_t source;
    int32_t displayId;
@@ -136,17 +118,16 @@ struct NotifyMotionArgs : public NotifyArgs {

    NotifyMotionArgs(const NotifyMotionArgs& other);

    virtual ~NotifyMotionArgs() { }

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

    void notify(InputListenerInterface& listener) const override;

    std::string dump() const;
};

/* Describes a sensor event. */
struct NotifySensorArgs : public NotifyArgs {
struct NotifySensorArgs {
    int32_t id;
    nsecs_t eventTime;

    int32_t deviceId;
    uint32_t source;
    InputDeviceSensorType sensorType;
@@ -161,17 +142,14 @@ struct NotifySensorArgs : public NotifyArgs {
                     InputDeviceSensorType sensorType, InputDeviceSensorAccuracy accuracy,
                     bool accuracyChanged, nsecs_t hwTimestamp, std::vector<float> values);

    NotifySensorArgs(const NotifySensorArgs& other);

    bool operator==(const NotifySensorArgs rhs) const;

    ~NotifySensorArgs() override {}

    void notify(InputListenerInterface& listener) const override;
    NotifySensorArgs(const NotifySensorArgs& other) = default;
};

/* Describes a switch event. */
struct NotifySwitchArgs : public NotifyArgs {
struct NotifySwitchArgs {
    int32_t id;
    nsecs_t eventTime;

    uint32_t policyFlags;
    uint32_t switchValues;
    uint32_t switchMask;
@@ -181,54 +159,48 @@ struct NotifySwitchArgs : public NotifyArgs {
    NotifySwitchArgs(int32_t id, nsecs_t eventTime, uint32_t policyFlags, uint32_t switchValues,
                     uint32_t switchMask);

    NotifySwitchArgs(const NotifySwitchArgs& other);

    bool operator==(const NotifySwitchArgs rhs) const;
    NotifySwitchArgs(const NotifySwitchArgs& other) = default;

    virtual ~NotifySwitchArgs() { }

    void notify(InputListenerInterface& listener) const override;
    bool operator==(const NotifySwitchArgs& rhs) const = default;
};


/* Describes a device reset event, such as when a device is added,
 * reconfigured, or removed. */
struct NotifyDeviceResetArgs : public NotifyArgs {
struct NotifyDeviceResetArgs {
    int32_t id;
    nsecs_t eventTime;

    int32_t deviceId;

    inline NotifyDeviceResetArgs() { }

    NotifyDeviceResetArgs(int32_t id, nsecs_t eventTime, int32_t deviceId);

    NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other);

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

    virtual ~NotifyDeviceResetArgs() { }
    NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other) = default;

    void notify(InputListenerInterface& listener) const override;
    bool operator==(const NotifyDeviceResetArgs& rhs) const = default;
};

/* Describes a change in the state of Pointer Capture. */
struct NotifyPointerCaptureChangedArgs : public NotifyArgs {
struct NotifyPointerCaptureChangedArgs {
    // The sequence number of the Pointer Capture request, if enabled.
    int32_t id;
    nsecs_t eventTime;

    PointerCaptureRequest request;

    inline NotifyPointerCaptureChangedArgs() {}

    NotifyPointerCaptureChangedArgs(int32_t id, nsecs_t eventTime, const PointerCaptureRequest&);

    NotifyPointerCaptureChangedArgs(const NotifyPointerCaptureChangedArgs& other);

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

    virtual ~NotifyPointerCaptureChangedArgs() {}

    void notify(InputListenerInterface& listener) const override;
    NotifyPointerCaptureChangedArgs(const NotifyPointerCaptureChangedArgs& other) = default;
};

/* Describes a vibrator state event. */
struct NotifyVibratorStateArgs : public NotifyArgs {
struct NotifyVibratorStateArgs {
    int32_t id;
    nsecs_t eventTime;

    int32_t deviceId;
    bool isOn;

@@ -237,14 +209,12 @@ struct NotifyVibratorStateArgs : public NotifyArgs {
    NotifyVibratorStateArgs(int32_t id, nsecs_t eventTIme, int32_t deviceId, bool isOn);

    NotifyVibratorStateArgs(const NotifyVibratorStateArgs& other);

    bool operator==(const NotifyVibratorStateArgs rhs) const;

    virtual ~NotifyVibratorStateArgs() {}

    void notify(InputListenerInterface& listener) const override;
};

using NotifyArgs = std::variant<NotifyConfigurationChangedArgs, NotifyKeyArgs, NotifyMotionArgs,
                                NotifySensorArgs, NotifySwitchArgs, NotifyDeviceResetArgs,
                                NotifyPointerCaptureChangedArgs, NotifyVibratorStateArgs>;

/*
 * The interface used by the InputReader to notify the InputListener about input events.
 */
@@ -287,7 +257,7 @@ public:

private:
    InputListenerInterface& mInnerListener;
    std::vector<std::unique_ptr<NotifyArgs>> mArgsQueue;
    std::vector<NotifyArgs> mArgsQueue;
};

} // namespace android