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

Commit 59a90609 authored by Daichi Hirono's avatar Daichi Hirono
Browse files

Reland "Return parameters of event as well as event code."

The CL was previously reviewed at ag/842911.

> The CL makes MtpDevice#reapEvent return event parameters as well as
> event code.
>
> BUG=26480986

Change-Id: Ie750a58248068cd0e804f20b57e7e86eef19d315
parent 4a9fc960
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -866,15 +866,19 @@ int MtpDevice::submitEventRequest() {
    return currentHandle;
}

int MtpDevice::reapEventRequest(int handle) {
int MtpDevice::reapEventRequest(int handle, uint32_t (*parameters)[3]) {
    Mutex::Autolock autoLock(mEventMutex);
    if (!mProcessingEvent || mCurrentEventHandle != handle) {
    if (!mProcessingEvent || mCurrentEventHandle != handle || !parameters) {
        return -1;
    }
    mProcessingEvent = false;
    const int readSize = mEventPacket.readResponse(mRequestIntr->dev);
    const int result = mEventPacket.getEventCode();
    return readSize == 0 ? 0 : result;
    // MTP event has three parameters.
    (*parameters)[0] = mEventPacket.getParameter(1);
    (*parameters)[1] = mEventPacket.getParameter(2);
    (*parameters)[2] = mEventPacket.getParameter(3);
    return readSize != 0 ? result : 0;
}

void MtpDevice::discardEventRequest(int handle) {
+3 −2
Original line number Diff line number Diff line
@@ -124,8 +124,9 @@ public:
    int                     submitEventRequest();
    // Waits for MTP event from the device and returns MTP event code. It blocks the current thread
    // until it receives an event from the device. |handle| should be a request handle returned
    // by |submitEventRequest|. Returns 0 for cancellations. Returns -1 for errors.
    int                     reapEventRequest(int handle);
    // by |submitEventRequest|. The function writes event parameters to |parameters|. Returns 0 for
    // cancellations. Returns -1 for errors.
    int                     reapEventRequest(int handle, uint32_t (*parameters)[3]);
    // Cancels an event request. |handle| should be request handle returned by
    // |submitEventRequest|. If there is a thread blocked by |reapEventRequest| with the same
    // |handle|, the thread will resume.