summaryrefslogtreecommitdiffstats
path: root/fastboot/usb_windows.cpp
diff options
context:
space:
mode:
authorAaron Wisner <awisner@google.com>2018-07-23 15:40:58 -0500
committerAaron Wisner <awisner@google.com>2018-07-24 11:24:15 -0500
commitceb7cbf5fde0ff26a35d442135d01e52b0ef0771 (patch)
tree839d5d4c329fe15e5391e02f829b886db4f00d05 /fastboot/usb_windows.cpp
parent767506fc5a5023e815cdc36e56688adaac2fe0d5 (diff)
downloadsystem_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_windows.cpp')
-rw-r--r--fastboot/usb_windows.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/fastboot/usb_windows.cpp b/fastboot/usb_windows.cpp
index 0e5fba125..8c60a7173 100644
--- a/fastboot/usb_windows.cpp
+++ b/fastboot/usb_windows.cpp
@@ -66,7 +66,7 @@ struct usb_handle {
std::string interface_name;
};
-class WindowsUsbTransport : public Transport {
+class WindowsUsbTransport : public UsbTransport {
public:
WindowsUsbTransport(std::unique_ptr<usb_handle> handle) : handle_(std::move(handle)) {}
~WindowsUsbTransport() override = default;
@@ -74,6 +74,7 @@ class WindowsUsbTransport : public Transport {
ssize_t Read(void* data, size_t len) override;
ssize_t Write(const void* data, size_t len) override;
int Close() override;
+ int Reset() override;
private:
std::unique_ptr<usb_handle> handle_;
@@ -261,6 +262,12 @@ int WindowsUsbTransport::Close() {
return 0;
}
+int WindowsUsbTransport::Reset() {
+ DBG("usb_reset currently unsupported\n\n");
+ // TODO, this is a bit complicated since it is using ADB
+ return -1;
+}
+
int recognized_device(usb_handle* handle, ifc_match_func callback) {
struct usb_ifc_info info;
USB_DEVICE_DESCRIPTOR device_desc;
@@ -366,8 +373,7 @@ static std::unique_ptr<usb_handle> find_usb_device(ifc_match_func callback) {
return handle;
}
-Transport* usb_open(ifc_match_func callback)
-{
+UsbTransport* usb_open(ifc_match_func callback, uint32_t) {
std::unique_ptr<usb_handle> handle = find_usb_device(callback);
return handle ? new WindowsUsbTransport(std::move(handle)) : nullptr;
}