From cc9b00673e1644c2f76649007f3c4549f3a4bcfa Mon Sep 17 00:00:00 2001
From: Sascha Bischoff <sascha.bischoff@arm.com>
Date: Wed, 9 Dec 2015 10:23:59 +0000
Subject: [PATCH] Gem5AndroidDevice: No longer wait for disabled boot animation

Adjust the wait_for_boot method of Gem5AndroidDevice to no longer wait
for the boot animation to finish if the animation has been
disabled. The service.bootanim.exit property is only set (to 0) when
the animation starts, and is set to 1 when the animation finishes. If
the animation never starts, then the property is not set at
all. Hence, we assume the boot animation has finished, unless the
property has been set.
---
 wlauto/devices/android/gem5/__init__.py | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/wlauto/devices/android/gem5/__init__.py b/wlauto/devices/android/gem5/__init__.py
index ceef8816..853d06ba 100644
--- a/wlauto/devices/android/gem5/__init__.py
+++ b/wlauto/devices/android/gem5/__init__.py
@@ -93,15 +93,27 @@ class Gem5AndroidDevice(BaseGem5Device, AndroidDevice):
         pass
 
     def wait_for_boot(self):
+        """
+        Wait for the system to boot
+
+        We monitor the sys.boot_completed and service.bootanim.exit system
+        properties to determine when the system has finished booting. In the
+        event that we cannot coerce the result of service.bootanim.exit to an
+        integer, we assume that the boot animation was disabled and do not wait
+        for it to finish.
+
+        """
         self.logger.info("Waiting for Android to boot...")
         while True:
+            booted = False
+            anim_finished = True  # Assume boot animation was disabled on except
             try:
-                booted = (int('0' + self.gem5_shell('getprop sys.boot_completed', check_exit_code=False)) == 1)
-                anim_finished = (int('0' + self.gem5_shell('getprop service.bootanim.exit', check_exit_code=False)) == 1)
-                if booted and anim_finished:
-                    break
-            except (DeviceError, ValueError):
+                booted = (int('0' + self.gem5_shell('getprop sys.boot_completed', check_exit_code=False).strip()) == 1)
+                anim_finished = (int(self.gem5_shell('getprop service.bootanim.exit', check_exit_code=False).strip()) == 1)
+            except ValueError:
                 pass
+            if booted and anim_finished:
+                break
             time.sleep(60)
 
         self.logger.info("Android booted")