diff options
author | Josh Gao <jmgao@google.com> | 2017-06-01 15:42:26 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2017-06-07 11:08:00 -0700 |
commit | 5b8b10e078ef12f21144cdb5fbc932dda47be212 (patch) | |
tree | 1c1e75ef7c0846526453273232c827086d31e9e1 /adb/client | |
parent | 7dd382ded948aa5adae3618f99d00c14c3703d05 (diff) | |
download | system_core-5b8b10e078ef12f21144cdb5fbc932dda47be212.tar.gz system_core-5b8b10e078ef12f21144cdb5fbc932dda47be212.tar.bz2 system_core-5b8b10e078ef12f21144cdb5fbc932dda47be212.zip |
adb: libusb: switch from polling for accessibility to a sleep.
For unclear reasons, it seems that for some people, devices are
becoming accessible, inaccessible, and then inaccessible again.
Switch to a sleep for now.
Bug: http://b/62200735
Test: manual
Change-Id: Id51dcb188c3534a57c35cbfd30a181c99115a23c
Diffstat (limited to 'adb/client')
-rw-r--r-- | adb/client/usb_libusb.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/adb/client/usb_libusb.cpp b/adb/client/usb_libusb.cpp index dc1a6b476..e7f44c685 100644 --- a/adb/client/usb_libusb.cpp +++ b/adb/client/usb_libusb.cpp @@ -180,10 +180,6 @@ static std::string get_device_dev_path(libusb_device* device) { if (port_count < 0) return ""; return StringPrintf("/dev/bus/usb/%03u/%03u", libusb_get_bus_number(device), ports[0]); } - -static bool is_device_accessible(libusb_device* device) { - return access(get_device_dev_path(device).c_str(), R_OK | W_OK) == 0; -} #endif static bool endpoint_is_output(uint8_t endpoint) { @@ -389,18 +385,12 @@ static std::atomic<int> connecting_devices(0); static void device_connected(libusb_device* device) { #if defined(__linux__) // Android's host linux libusb uses netlink instead of udev for device hotplug notification, - // which means we can get hotplug notifications before udev has updated ownership/perms on - // the device. Since we're not going to be able to link against the system's libudev any - // time soon, hack around this by checking for accessibility in a loop. + // which means we can get hotplug notifications before udev has updated ownership/perms on the + // device. Since we're not going to be able to link against the system's libudev any time soon, + // hack around this by inserting a sleep. auto thread = std::thread([device]() { std::string device_path = get_device_dev_path(device); - auto start = std::chrono::steady_clock::now(); - while (std::chrono::steady_clock::now() - start < 500ms) { - if (is_device_accessible(device)) { - break; - } - std::this_thread::sleep_for(10ms); - } + std::this_thread::sleep_for(1s); process_device(device); if (--connecting_devices == 0) { |