autotest: Support adb host without serial

The current code assumes `adb devices` will always return valid serial
numbers, but there are cases where serial numbers are not available.

We have one such device where this is often the case, particularly when
we re-flash the firmware.

This should not prevent the tests from running, particularly when there
is only a single device attached, in which case `adb shell` command does
not really require a `-s` parameter with the serial number.

Tested on a device without serial number:

  $ adb devices
  List of devices attached
  (no serial number)      device

Autotest did not fail with error.AutoservError('No ADB devices attached.')

The code also checks for whether a device without serial number is
present when there are multiple devices attached and raises an exception
in that case.  Right now the code would raise an exception anyways,
error.AutoservError('Multiple ADB devices attached.'), but once that
check is lifted and we support multiple adb devices attached to the same
host, we will want to check for that particular case.

TEST=Tested on a device without serial number.

Change-Id: I9f456d222b5eef226c4f343491aac4645dad3e68
Reviewed-by: Christopher Wiley <>
Reviewed-by: Shelley Chen <>
Reviewed-by: Fang Deng <>
Commit-Queue: Filipe Brandenburger <>
Tested-by: Filipe Brandenburger <>
1 file changed