adb: Add ability to specify device path

For manufacturing and testing, there is a need to talk to
whatever device is connected to a given port on the host.  This
change modifies adb's "-s" option to take either a serial
number or a device path.  The device paths of the connected
devices can be listed using "adb devices -l" whose output
will resemble:

    List of devices attached
    016B75D60A00600D	usb:2-5	device
    3031D0B2E71D00EC	usb:1-4.3	device

The second column lists the device paths.  If the -l option is
not given, the output from "adb devices" will be the same as
it used to be (i.e. the paths will not be printed).

The device path can also be obtained with the get-devpath
command:

    $adb -s 3031D0B2E71D00EC get-devpath
    usb:1-4.3

Note that the format of the device paths are platform dependent.
The example above is from Linux.  On OS-X, the paths will be
"usb:" followed by hex digits.  For other platforms, the device
paths will be printed as "????????????" and the -s option will
not be able to select a device until someone implements the
underlying functionality.

Change-Id: I057d5d9f8c5bb72eddf5b8088aae110763f809d7
Signed-off-by: Scott Anderson <saa@android.com>
diff --git a/usb_osx.c b/usb_osx.c
index 00d02da..45ce444 100644
--- a/usb_osx.c
+++ b/usb_osx.c
@@ -125,10 +125,13 @@
     IOUSBDeviceInterface197  **dev = NULL;
     HRESULT                  result;
     SInt32                   score;
+    UInt32                   locationId;
     UInt16                   vendor;
     UInt16                   product;
     UInt8                    serialIndex;
     char                     serial[256];
+    char                     devpathBuf[64];
+    char                     *devpath = NULL;
 
     while ((usbInterface = IOIteratorNext(iterator))) {
         //* Create an intermediate interface plugin
@@ -192,6 +195,11 @@
 
         kr = (*dev)->GetDeviceVendor(dev, &vendor);
         kr = (*dev)->GetDeviceProduct(dev, &product);
+        kr = (*dev)->GetLocationID(dev, &locationId);
+        if (kr == 0) {
+            snprintf(devpathBuf, sizeof(devpathBuf), "usb:%lX", locationId);
+            devpath = devpathBuf;
+        }
         kr = (*dev)->USBGetSerialNumberStringIndex(dev, &serialIndex);
 
 	if (serialIndex > 0) {
@@ -256,7 +264,7 @@
         }
 
         DBG("AndroidDeviceAdded calling register_usb_transport\n");
-        register_usb_transport(handle, (serial[0] ? serial : NULL), 1);
+        register_usb_transport(handle, (serial[0] ? serial : NULL), devpath, 1);
 
         // Register for an interest notification of this device being removed.
         // Pass the reference to our private data as the refCon for the