summaryrefslogtreecommitdiff
path: root/trusty/coverage/coverage_test.cpp
diff options
context:
space:
mode:
authorSpencer Low <CompareAndSwap@gmail.com>2015-07-22 16:17:07 -0700
committerSpencer Low <CompareAndSwap@gmail.com>2015-08-01 19:19:09 -0700
commita5b06b0ff8d7c99ce2678f61536cbf1430783dba (patch)
tree09bd891db4108634bba7b72427f0981d7394335c /trusty/coverage/coverage_test.cpp
parentc70ac57db0df9736f50a6b1fe29b151292b09e6b (diff)
adb: win32: fix USB device hang when resuming from sleep/hibernation
After resuming Windows from sleep or hibernation, USB connections are not automatically disconnected. Writing to the USB connections does not return any errors, but read never returns. My theory is that the device saw the host sleep/hibernation as a disconnect, so the device is waiting for re-auth from the host as if the host was just connected. To solve this, detect resume from sleep/hibernation, disconnect all USB connections and let the device poll thread re-detect the USB devices in 1 sec. This is done by using a hidden window that receives power notifications. The hidden window code is based on Chromium's similar code (platform-tools already includes the Chromium Authors license). This depends on a change to AdbWinUsbApi.dll that makes AdbCloseHandle(endpoint) abort any pending IOs and wait for those IOs to be aborted. I expect that this should solve many adb and Android Studio related bugs regarding hangs or errors. Also in this change: - Add D() logging for any errors from AdbWinApi.dll API calls. - Stop setting errno to Win32 error values which the caller can't really do anything with. Stop calling SetLastError() because the callers don't check GetLastError() anyway. - Check the return value from writing zero length packets. - If the full amount of data isn't written, return an error. - Upon any usb_read/usb_write error, kick the connection instead of only kicking when ERROR_INVALID_HANDLE is encountered. - Restructure some code from nested-if-trees to goto-fail to make it easier to follow. - Delete usb_name() since it isn't thread-safe and it isn't used. Change-Id: Iffcf5315ad8593d0c7e93012afaabe6fae354ac1 Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
Diffstat (limited to 'trusty/coverage/coverage_test.cpp')
0 files changed, 0 insertions, 0 deletions