diff options
author | Aaron Wisner <awisner@google.com> | 2018-07-23 15:40:58 -0500 |
---|---|---|
committer | Aaron Wisner <awisner@google.com> | 2018-07-24 11:24:15 -0500 |
commit | ceb7cbf5fde0ff26a35d442135d01e52b0ef0771 (patch) | |
tree | 839d5d4c329fe15e5391e02f829b886db4f00d05 /fastboot/usb.h | |
parent | 767506fc5a5023e815cdc36e56688adaac2fe0d5 (diff) | |
download | system_core-ceb7cbf5fde0ff26a35d442135d01e52b0ef0771.tar.gz system_core-ceb7cbf5fde0ff26a35d442135d01e52b0ef0771.tar.bz2 system_core-ceb7cbf5fde0ff26a35d442135d01e52b0ef0771.zip |
Add derived UsbTransport class with USB reset method
For testing there needs to be a way to simulate unplugging and
replugging a device. This change adds support for a USB reset
method that does this.
Also add timeouts, so USB reads/writes don't block forever
on an unresponsive device.
Test: glinux, fastboot tool still works
Test: Reset confirmed working via wireshark Linux URB captures
Change-Id: I7213a2395d4ef1c0238810e4929ab966e78c8b55
Diffstat (limited to 'fastboot/usb.h')
-rw-r--r-- | fastboot/usb.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/fastboot/usb.h b/fastboot/usb.h index 5b44468bb..96eb934d3 100644 --- a/fastboot/usb.h +++ b/fastboot/usb.h @@ -52,6 +52,13 @@ struct usb_ifc_info { char device_path[256]; }; +class UsbTransport : public Transport { + // Resets the underlying transport. Returns 0 on success. + // This effectively simulates unplugging and replugging + virtual int Reset() = 0; +}; + typedef int (*ifc_match_func)(usb_ifc_info *ifc); -Transport* usb_open(ifc_match_func callback); +// 0 is non blocking +UsbTransport* usb_open(ifc_match_func callback, uint32_t timeout_ms = 0); |