Loading media/mtp/MtpFfsHandle.cpp +10 −4 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ int MtpFfsHandle::getPacketSize(int ffs_fd) { MtpFfsHandle::MtpFfsHandle(int controlFd) { mControl.reset(controlFd); mBatchCancel = android::base::GetBoolProperty("sys.usb.mtp.batchcancel", false); } MtpFfsHandle::~MtpFfsHandle() {} Loading Loading @@ -370,7 +371,7 @@ void MtpFfsHandle::cancelTransaction() { } int MtpFfsHandle::cancelEvents(struct iocb **iocb, struct io_event *events, unsigned start, unsigned end) { unsigned end, bool is_batch_cancel) { // 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 Loading @@ -386,6 +387,10 @@ 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; Loading Loading @@ -495,7 +500,8 @@ 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); cancelEvents(mIobuf[i].iocb.data(), ioevs, num_events, mIobuf[i].actual, mBatchCancel); return -1; } ret += event_ret; Loading @@ -512,7 +518,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)) { if (cancelEvents(mIobuf[i].iocb.data(), ioevs, short_i, mIobuf[i].actual, false)) { write_error = true; } } Loading Loading @@ -613,7 +619,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); mIobuf[(i-1)%NUM_IO_BUFS].actual, false); } has_write = false; } Loading media/mtp/MtpFfsHandle.h +4 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #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> Loading Loading @@ -57,6 +58,7 @@ 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 Loading @@ -76,7 +78,8 @@ 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); int cancelEvents(struct iocb **iocb, struct io_event *events, unsigned start, unsigned end, bool is_batch_cancel); // 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. Loading Loading
media/mtp/MtpFfsHandle.cpp +10 −4 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ int MtpFfsHandle::getPacketSize(int ffs_fd) { MtpFfsHandle::MtpFfsHandle(int controlFd) { mControl.reset(controlFd); mBatchCancel = android::base::GetBoolProperty("sys.usb.mtp.batchcancel", false); } MtpFfsHandle::~MtpFfsHandle() {} Loading Loading @@ -370,7 +371,7 @@ void MtpFfsHandle::cancelTransaction() { } int MtpFfsHandle::cancelEvents(struct iocb **iocb, struct io_event *events, unsigned start, unsigned end) { unsigned end, bool is_batch_cancel) { // 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 Loading @@ -386,6 +387,10 @@ 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; Loading Loading @@ -495,7 +500,8 @@ 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); cancelEvents(mIobuf[i].iocb.data(), ioevs, num_events, mIobuf[i].actual, mBatchCancel); return -1; } ret += event_ret; Loading @@ -512,7 +518,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)) { if (cancelEvents(mIobuf[i].iocb.data(), ioevs, short_i, mIobuf[i].actual, false)) { write_error = true; } } Loading Loading @@ -613,7 +619,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); mIobuf[(i-1)%NUM_IO_BUFS].actual, false); } has_write = false; } Loading
media/mtp/MtpFfsHandle.h +4 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #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> Loading Loading @@ -57,6 +58,7 @@ 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 Loading @@ -76,7 +78,8 @@ 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); int cancelEvents(struct iocb **iocb, struct io_event *events, unsigned start, unsigned end, bool is_batch_cancel); // 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. Loading