adb: disable USB packet overflow checking on OS X.
OS X appears to be misreporting the maximum packet size on some hardware. Disable this on OS X until we figure out what's going on. Bug: http://b/65063965 Bug: https://issuetracker.google.com/70244520 Test: python test_device.py on linux with CHECK_PACKET_OVERFLOW disabled Test: python test_device.py on darwin (but on hardware that wasn't reproducing this) Change-Id: I57e1adfa162e40ed79f71f97af552b3f0519324e
This commit is contained in:
parent
cce381e307
commit
801048c6ea
|
@ -305,6 +305,7 @@ AndroidInterfaceAdded(io_iterator_t iterator)
|
|||
handle->devpath = devpath;
|
||||
usb_handle* handle_p = handle.get();
|
||||
VLOG(USB) << "Add usb device " << serial;
|
||||
LOG(INFO) << "reported max packet size for " << serial << " is " << handle->max_packet_size;
|
||||
AddDevice(std::move(handle));
|
||||
register_usb_transport(reinterpret_cast<::usb_handle*>(handle_p), serial, devpath.c_str(),
|
||||
1);
|
||||
|
|
|
@ -27,11 +27,18 @@
|
|||
|
||||
#if ADB_HOST
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#define CHECK_PACKET_OVERFLOW 0
|
||||
#else
|
||||
#define CHECK_PACKET_OVERFLOW 1
|
||||
#endif
|
||||
|
||||
// Call usb_read using a buffer having a multiple of usb_get_max_packet_size() bytes
|
||||
// to avoid overflow. See http://libusb.sourceforge.net/api-1.0/packetoverflow.html.
|
||||
static int UsbReadMessage(usb_handle* h, amessage* msg) {
|
||||
D("UsbReadMessage");
|
||||
|
||||
#if CHECK_PACKET_OVERFLOW
|
||||
size_t usb_packet_size = usb_get_max_packet_size(h);
|
||||
CHECK_GE(usb_packet_size, sizeof(*msg));
|
||||
CHECK_LT(usb_packet_size, 4096ULL);
|
||||
|
@ -44,6 +51,9 @@ static int UsbReadMessage(usb_handle* h, amessage* msg) {
|
|||
}
|
||||
memcpy(msg, buffer, sizeof(*msg));
|
||||
return n;
|
||||
#else
|
||||
return usb_read(h, msg, sizeof(*msg));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Call usb_read using a buffer having a multiple of usb_get_max_packet_size() bytes
|
||||
|
@ -51,6 +61,7 @@ static int UsbReadMessage(usb_handle* h, amessage* msg) {
|
|||
static int UsbReadPayload(usb_handle* h, apacket* p) {
|
||||
D("UsbReadPayload(%d)", p->msg.data_length);
|
||||
|
||||
#if CHECK_PACKET_OVERFLOW
|
||||
size_t usb_packet_size = usb_get_max_packet_size(h);
|
||||
CHECK_EQ(0ULL, sizeof(p->data) % usb_packet_size);
|
||||
|
||||
|
@ -64,6 +75,9 @@ static int UsbReadPayload(usb_handle* h, apacket* p) {
|
|||
}
|
||||
CHECK_LE(len, sizeof(p->data));
|
||||
return usb_read(h, &p->data, len);
|
||||
#else
|
||||
return usb_read(h, &p->data, p->msg.data_length);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int remote_read(apacket* p, atransport* t) {
|
||||
|
|
Loading…
Reference in New Issue