From 9dd83dc96e2f4d86093bc64d934d6c60c18d1edb Mon Sep 17 00:00:00 2001 From: Esteban de la Canal Date: Thu, 11 Sep 2014 11:02:17 -0700 Subject: [PATCH] 74602: Fixes adb not seeing connected devices on Mac. Every alternate time an adb server was started already connected devices were not being seen. This was caused by opened usb connections being "stalled". See this thread for more information: http://lists.apple.com/archives/usb/2011/Jun/msg00050.html Change-Id: Ic35b7a66c3f14a837b960066557f44e105609dcb Fixes: https://code.google.com/p/android/issues/detail?id=74602 --- adb/usb_osx.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/adb/usb_osx.c b/adb/usb_osx.c index 5efb23bdf..ee893f544 100644 --- a/adb/usb_osx.c +++ b/adb/usb_osx.c @@ -513,14 +513,18 @@ int usb_read(usb_handle *handle, void *buf, int len) return -1; } - result = - (*handle->interface)->ReadPipe(handle->interface, - handle->bulkIn, buf, &numBytes); + result = (*handle->interface)->ReadPipe(handle->interface, handle->bulkIn, buf, &numBytes); - if (0 == result) + if (kIOUSBPipeStalled == result) { + DBG(" Pipe stalled, clearing stall.\n"); + (*handle->interface)->ClearPipeStall(handle->interface, handle->bulkIn); + result = (*handle->interface)->ReadPipe(handle->interface, handle->bulkIn, buf, &numBytes); + } + + if (kIOReturnSuccess == result) return 0; else { - DBG("ERR: usb_read failed with status %d\n", result); + DBG("ERR: usb_read failed with status %x\n", result); } return -1;