adb: add `adb reconnect offline` to reconnect offline devices.
Add a command to reconnect offline/unauthorized devices, mainly for use
with the inotify-monitoring of vendor key directories added by 22cb70bd.
Bug: http://b/29273531
Test: manually tested with a sailfish + copying vendor keys
Change-Id: If34cccee4ae553ada65d128b57d03cba8c0d7c46
diff --git a/transport.cpp b/transport.cpp
index 7b4bb1c..132702d 100644
--- a/transport.cpp
+++ b/transport.cpp
@@ -908,12 +908,18 @@
return result;
}
+void close_usb_devices(std::function<bool(const atransport*)> predicate) {
+ std::lock_guard<std::mutex> lock(transport_lock);
+ for (auto& t : transport_list) {
+ if (predicate(t)) {
+ t->Kick();
+ }
+ }
+}
+
/* hack for osx */
void close_usb_devices() {
- std::lock_guard<std::mutex> lock(transport_lock);
- for (const auto& t : transport_list) {
- t->Kick();
- }
+ close_usb_devices([](const atransport*) { return true; });
}
#endif // ADB_HOST