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

Commit d7d8cf98 authored by Fiona Campbell's avatar Fiona Campbell
Browse files

Revert "MTP: add a new parameter for cancelEvents function"

Revert "usb: set sys.usb.mtp.batchcancel to true"

Revert "Add sys.usb.mtp.batchcancel to usb_config_prop"

Revert submission 14910151-mtp_cancel-sc-dev

Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=git_sc-dev&target=cf_x86_64_phone-userdebug&lkgb=7458085&lkbb=7458560&fkbb=7458104, bug b/191120942

Reverted Changes:
I44b2d9c36:Add sys.usb.mtp.batchcancel to usb_config_prop
I4e172fa62:MTP: add a new parameter for cancelEvents function...
Iad744e27e:usb: set sys.usb.mtp.batchcancel to true

Change-Id: I9aa47b80ea56671d277d1eda5deede63875e8a0a
parent c24226c9
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.