adb --one-device feature.

Added support for a new server option, --one-device.

When a server is started with that option, it will only communicate with
the USB device serial number or device address specified.

This allows multiple adb servers to run in parallel on a single host,
each communicating only with a single USB device.

example usage:
$ adb --one-device usb:2-4 -P 1138 start-server
$ adb --one-device usb:2-6 -P 1139 start-server
$ adb -P 1138 devices -l
List of devices attached
97221FFBA00016         device usb:2-4 transport_id:1
$ adb -P 1139 devices -l
List of devices attached
13031FDEE0000C         device usb:2-6 transport_id:1

Test: Manually tested as shown above with & without libusb, Linux & macOS.
Change-Id: Ibc4e3df7ecdefce737291185fa6a84071bff5340
diff --git a/transport.cpp b/transport.cpp
index 3493cc1..0dfad0e 100644
--- a/transport.cpp
+++ b/transport.cpp
@@ -96,6 +96,7 @@
 namespace {
 
 #if ADB_HOST
+
 // Tracks and handles atransport*s that are attempting reconnection.
 class ReconnectHandler {
   public:
@@ -948,6 +949,34 @@
     return !*ptr;
 }
 
+// Contains either a device serial string or a USB device address like "usb:2-6"
+const char* __transport_server_one_device = nullptr;
+
+void transport_set_one_device(const char* adb_one_device) {
+    __transport_server_one_device = adb_one_device;
+}
+
+const char* transport_get_one_device() {
+    return __transport_server_one_device;
+}
+
+bool transport_server_owns_device(std::string_view serial) {
+    if (!__transport_server_one_device) {
+        // If the server doesn't own one device, server owns all devices.
+        return true;
+    }
+    return serial.compare(__transport_server_one_device) == 0;
+}
+
+bool transport_server_owns_device(std::string_view dev_path, std::string_view serial) {
+    if (!__transport_server_one_device) {
+        // If the server doesn't own one device, server owns all devices.
+        return true;
+    }
+    return serial.compare(__transport_server_one_device) == 0 ||
+           dev_path.compare(__transport_server_one_device) == 0;
+}
+
 atransport* acquire_one_transport(TransportType type, const char* serial, TransportId transport_id,
                                   bool* is_ambiguous, std::string* error_out,
                                   bool accept_any_state) {