When doing an ADB reboot make sure device is ready.
Check that device state before returning that the device
reboot is complete. A test should have to pool for the device
waiting for the correct state.
I was also unclear why adb_host does not take advantage of
adb 'wait-for-device' as this is only used in initialize, but
tests will want to reboot a device in the middle of a test.
TEST=Manual; Ran it
BUG=chromium:570437
Change-Id: I6f6bc6ff137d7b501c20e75d88b265695bf37ce4
Reviewed-on: https://chromium-review.googlesource.com/318653
Commit-Ready: Kris Rambish <krisr@chromium.org>
Tested-by: Kris Rambish <krisr@chromium.org>
Reviewed-by: Dan Shi <dshi@google.com>
diff --git a/server/hosts/adb_host.py b/server/hosts/adb_host.py
index 6ac76c2..314481e 100644
--- a/server/hosts/adb_host.py
+++ b/server/hosts/adb_host.py
@@ -571,6 +571,11 @@
if command == ADB_CMD:
devices = self.adb_devices()
serial = self._adb_serial
+ # ADB has a device state, if the device is not online, no
+ # subsequent ADB command will complete.
+ if len(devices) == 0 or not self.is_device_ready():
+ logging.debug('Waiting for device to enter the ready state.')
+ return False
elif command == FASTBOOT_CMD:
devices = self.fastboot_devices()
serial = self._fastboot_serial
@@ -614,12 +619,18 @@
return '/data/autotest'
+ def is_device_ready(self):
+ """Return the if the device is ready for ADB commands."""
+ dev_state = self.adb_run('get-state').stdout.strip()
+ logging.debug('Current device state: %s', dev_state)
+ return dev_state == 'device'
+
+
def verify_connectivity(self):
"""Verify we can connect to the device."""
- dev_state = self.adb_run('get-state').stdout.strip()
- if dev_state != 'device':
- raise error.AutoservHostError('device state is not \'device\': %s' %
- dev_state)
+ if not self.is_device_ready():
+ raise error.AutoservHostError('device state is not in the '
+ '\'device\' state.')
def verify_software(self):