adb: Generalizing -s to take qualifiers.

Prior to this change, -s could take either a serial number or a
device path (e.g. "-s 01498B1F02015015" or "-s usb:1-4.2").  This
change extends -s to also allow product, model or device names
(e.g. "-s product:mysid").  These new qualifiers will only be
available on devices that are running an adb daemon that provides
properties in the connect message per Change-Id:
    I09200decde4facb8fc9b4056fdae910155f2bcb9

The product, model and device are derived from the
ro.product.name, ro.product.model and ro.product.device
properties respectively.  They are prefixed with "product:",
"model:" or "device:" as appropriate.  In addition, any
non-alphanumerics in the model are changed to underscores.

If the -s parameter matches multiple devices, the result will be
the same as when multiple devices are connected but no -d, -e or
-s option is specified.  In general, this means the user will get
"error: more than one device".  However for get-state,
get-devpath and get-serialno, they will get "unknown".

The format of "devices -l" was changed to list all of the
qualifiers that are available.  The following example output
(with the last digits of the serial numbers replaced with X's) is
with a Galaxy Prime with an older adb daemon and another Galaxy
Prime and Galaxy S both with the enhanced adb daemons:

List of devices attached
016B75D60A0060XX       device usb:2-5 product:mysid model:Galaxy_Nexus device:toro
3731B535FAC200XX       device usb:1-4.2 product:soju model:Nexus_S device:crespo
01498B1F020150XX       device usb:1-4.1

Note that the serial number and state are now column oriented
instead of tab delimited.  After the serial number and state, all
qualifiers are listed with each preceded by a space.  The output
of the original devices command (without -l) is unchanged.

Change-Id: Iceeb2789874effc25a630d514a375d6f1889dc56
Signed-off-by: Scott Anderson <saa@android.com>
diff --git a/adb/commandline.c b/adb/commandline.c
index 2de0516..22c878b 100644
--- a/adb/commandline.c
+++ b/adb/commandline.c
@@ -85,7 +85,7 @@
         " -e                            - directs command to the only running emulator.\n"
         "                                 returns an error if more than one emulator is running.\n"
         " -s <specific device>          - directs command to the device or emulator with the given\n"
-        "                                 serial number or device path. Overrides ANDROID_SERIAL\n"
+        "                                 serial number or qualifier. Overrides ANDROID_SERIAL\n"
         "                                 environment variable.\n"
         " -p <product name or path>     - simple product name like 'sooner', or\n"
         "                                 a relative/absolute path to a product\n"
@@ -94,7 +94,7 @@
         "                                 environment variable is used, which must\n"
         "                                 be an absolute path.\n"
         " devices [-l]                  - list all connected devices\n"
-        "                                 ('-l' means list device paths)\n"
+        "                                 ('-l' will also list device qualifiers)\n"
         " connect <host>[:<port>]       - connect to a device via TCP/IP\n"
         "                                 Port 5555 is used by default if no port number is specified.\n"
         " disconnect [<host>[:<port>]]  - disconnect from a TCP/IP device.\n"