Switch MtpFfsHandle to aio, add control functions.
MtpFfsHandle now uses kaio to handle usb data.
This achieves better performance without using
the endpoint alloc ioctl.
This also allows ep0 events to be handled without
race conditions. Events will also include control
requests, which will allow both host and device
initiated cancellation.
Bug: 37916658
Bug: 36802721
Test: Transfer various size files, run MtpFfsHandleTest
Test: Cancel transfer on Windows
Test: Allow device to cancel transfer on Windows
Change-Id: Ib3ce996f00782ce7f68f29b2510dbc17f09fdf14
diff --git a/media/mtp/IMtpHandle.h b/media/mtp/IMtpHandle.h
index 0557596..c65bdd0 100644
--- a/media/mtp/IMtpHandle.h
+++ b/media/mtp/IMtpHandle.h
@@ -18,13 +18,13 @@
#include <linux/usb/f_mtp.h>
-constexpr char FFS_MTP_EP0[] = "/dev/usb-ffs/mtp/ep0";
+namespace android {
class IMtpHandle {
public:
// Return number of bytes read/written, or -1 and errno is set
- virtual int read(void *data, int len) = 0;
- virtual int write(const void *data, int len) = 0;
+ virtual int read(void *data, size_t len) = 0;
+ virtual int write(const void *data, size_t len) = 0;
// Return 0 if send/receive is successful, or -1 and errno is set
virtual int receiveFile(mtp_file_range mfr, bool zero_packet) = 0;
@@ -40,8 +40,7 @@
virtual ~IMtpHandle() {}
};
-IMtpHandle *get_ffs_handle();
-IMtpHandle *get_mtp_handle();
+}
#endif // _IMTP_HANDLE_H