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

Commit d828b8f1 authored by Fiona Campbell's avatar Fiona Campbell Committed by Android (Google) Code Review
Browse files

Merge "Revert "MTP: add a new parameter for cancelEvents function"" into sc-dev

parents b68d0515 d7d8cf98
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -74,7 +74,6 @@ int MtpFfsHandle::getPacketSize(int ffs_fd) {

MtpFfsHandle::MtpFfsHandle(int controlFd) {
    mControl.reset(controlFd);
    mBatchCancel = android::base::GetBoolProperty("sys.usb.mtp.batchcancel", false);
}

MtpFfsHandle::~MtpFfsHandle() {}
@@ -371,7 +370,7 @@ void MtpFfsHandle::cancelTransaction() {
}

int MtpFfsHandle::cancelEvents(struct iocb **iocb, struct io_event *events, unsigned start,
        unsigned end, bool is_batch_cancel) {
        unsigned end) {
    // Some manpages for io_cancel are out of date and incorrect.
    // io_cancel will return -EINPROGRESS on success and does
    // not place the event in the given memory. We have to use
@@ -387,10 +386,6 @@ int MtpFfsHandle::cancelEvents(struct iocb **iocb, struct io_event *events, unsi
        } else {
            num_events++;
        }
        if (is_batch_cancel && num_events == 1) {
            num_events = end - start;
            break;
        }
    }
    if (num_events != end - start) {
        ret = -1;
@@ -500,8 +495,7 @@ int MtpFfsHandle::receiveFile(mtp_file_range mfr, bool zero_packet) {
                num_events += this_events;

                if (event_ret == -1) {
                    cancelEvents(mIobuf[i].iocb.data(), ioevs, num_events, mIobuf[i].actual,
                            mBatchCancel);
                    cancelEvents(mIobuf[i].iocb.data(), ioevs, num_events, mIobuf[i].actual);
                    return -1;
                }
                ret += event_ret;
@@ -518,7 +512,7 @@ int MtpFfsHandle::receiveFile(mtp_file_range mfr, bool zero_packet) {
                }
            }
            if (short_packet) {
                if (cancelEvents(mIobuf[i].iocb.data(), ioevs, short_i, mIobuf[i].actual, false)) {
                if (cancelEvents(mIobuf[i].iocb.data(), ioevs, short_i, mIobuf[i].actual)) {
                    write_error = true;
                }
            }
@@ -619,7 +613,7 @@ int MtpFfsHandle::sendFile(mtp_file_range mfr) {
                        &num_events) != ret) {
                error = true;
                cancelEvents(mIobuf[(i-1)%NUM_IO_BUFS].iocb.data(), ioevs, num_events,
                        mIobuf[(i-1)%NUM_IO_BUFS].actual, false);
                        mIobuf[(i-1)%NUM_IO_BUFS].actual);
            }
            has_write = false;
        }
+1 −4
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
#ifndef _MTP_FFS_HANDLE_H
#define _MTP_FFS_HANDLE_H

#include <android-base/properties.h>
#include <android-base/unique_fd.h>
#include <linux/aio_abi.h>
#include <mutex>
@@ -58,7 +57,6 @@ protected:
    static int getPacketSize(int ffs_fd);

    bool mCanceled;
    bool mBatchCancel;

    android::base::unique_fd mControl;
    // "in" from the host's perspective => sink for mtp server
@@ -78,8 +76,7 @@ protected:
    int iobufSubmit(struct io_buffer *buf, int fd, unsigned length, bool read);

    // Cancel submitted requests from start to end in the given array. Return 0 or -1.
    int cancelEvents(struct iocb **iocb, struct io_event *events, unsigned start, unsigned end,
		     bool is_batch_cancel);
    int cancelEvents(struct iocb **iocb, struct io_event *events, unsigned start, unsigned end);

    // Wait for at minimum the given number of events. Returns the amount of data in the returned
    // events. Increments counter by the number of events returned.