Add function to query if device has booted. Fixes PoC test.
Test: manual
Change-Id: I97fb4d6efc76303ccda7c33c3f051714cbf29886
diff --git a/utils/python/controllers/android_device.py b/utils/python/controllers/android_device.py
index 3f096f5..56ff3c6 100644
--- a/utils/python/controllers/android_device.py
+++ b/utils/python/controllers/android_device.py
@@ -549,18 +549,25 @@
except adb.AdbError as e:
# adb wait-for-device is not always possible in the lab
logging.exception(e)
- while True:
- try:
- out = self.adb.shell("getprop sys.boot_completed")
- completed = out.decode('utf-8').strip()
- if completed == '1':
- return
- except adb.AdbError:
- # adb shell calls may fail during certain period of booting
- # process, which is normal. Ignoring these errors.
- pass
+ while not self.hasBooted():
time.sleep(5)
+ def hasBooted(self):
+ """Checks whether the device has booted.
+
+ Returns:
+ True if booted, False otherwise.
+ """
+ try:
+ out = self.adb.shell("getprop sys.boot_completed")
+ completed = out.decode('utf-8').strip()
+ if completed == '1':
+ return True
+ except adb.AdbError:
+ # adb shell calls may fail during certain period of booting
+ # process, which is normal. Ignoring these errors.
+ return False
+
def reboot(self):
"""Reboots the device and wait for device to complete booting.