aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/bots/recipe_modules/flavor/gn_android_flavor.py
diff options
context:
space:
mode:
authorGravatar Kevin Lubick <kjlubick@google.com>2017-02-09 16:13:10 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-09 21:33:35 +0000
commit549638c8525eaa8e78ac8b758325c749cd3fba45 (patch)
treed19b3d320e23f17ed87209c35172cf2733ecad27 /infra/bots/recipe_modules/flavor/gn_android_flavor.py
parent3d1a6bc5f3124dd5cd237ccc39ead26fe4b3355f (diff)
Prevent waiting for NexusPlayers indefinitely
Also, I noticed that sometimes the NexusPlayers would come back up such that adb would recognize them, but not such that the sys.boot_completed was set to 1. This was usually fixed by rebooting the devices again. This code will reboot them up to three times in total before giving up and killing the device. BUG=skia: TBR=borenet,rmistry NOTREECHECKS=true NOTRY=true Change-Id: Ic2217855ad643ab256a598a3f55a67ba84ebcb25 Reviewed-on: https://skia-review.googlesource.com/8285 Reviewed-by: Kevin Lubick <kjlubick@google.com> Commit-Queue: Kevin Lubick <kjlubick@google.com>
Diffstat (limited to 'infra/bots/recipe_modules/flavor/gn_android_flavor.py')
-rw-r--r--infra/bots/recipe_modules/flavor/gn_android_flavor.py42
1 files changed, 25 insertions, 17 deletions
diff --git a/infra/bots/recipe_modules/flavor/gn_android_flavor.py b/infra/bots/recipe_modules/flavor/gn_android_flavor.py
index d99a25722d..3c77e849d7 100644
--- a/infra/bots/recipe_modules/flavor/gn_android_flavor.py
+++ b/infra/bots/recipe_modules/flavor/gn_android_flavor.py
@@ -47,25 +47,32 @@ class GNAndroidFlavorUtils(default_flavor.DefaultFlavorUtils):
# Waits for an android device to be available
def _wait_for_device(self):
- self.m.python.inline('wait for device', """
+ self.m.run(self.m.python.inline, 'wait for device', program="""
import subprocess
import sys
import time
- times = 0
-
- while times < 30:
- print 'Waiting for the device to be connected and ready.'
- try:
- output = subprocess.check_output(['adb', 'shell',
- 'getprop', 'sys.boot_completed'])
- if '1' in output:
- print 'Connected'
- sys.exit(0)
- except subprocess.CalledProcessError:
- # no device connected/authorized yet
- pass
- time.sleep(5)
+ kicks = 0
+ while kicks < 2:
+
+ times = 0
+
+ while times < 30:
+ print 'Waiting for the device to be connected and ready.'
+ try:
+ times += 1
+ output = subprocess.check_output(['adb', 'shell',
+ 'getprop', 'sys.boot_completed'])
+ if '1' in output:
+ print 'Connected'
+ sys.exit(0)
+ except subprocess.CalledProcessError:
+ # no device connected/authorized yet
+ pass
+ time.sleep(5)
+ print 'Giving the device a "kick" by trying to reboot it.'
+ kicks += 1
+ print subprocess.check_output(['adb', 'reboot'])
print 'Timed out waiting for device'
sys.exit(1)
@@ -128,7 +135,7 @@ class GNAndroidFlavorUtils(default_flavor.DefaultFlavorUtils):
def cleanup_steps(self):
if self._ever_ran_adb:
- self.m.python.inline('dump log', """
+ self.m.run(self.m.python.inline, 'dump log', program="""
import os
import subprocess
import sys
@@ -188,7 +195,8 @@ class GNAndroidFlavorUtils(default_flavor.DefaultFlavorUtils):
def copy_directory_contents_to_device(self, host, device):
# Copy the tree, avoiding hidden directories and resolving symlinks.
- self.m.python.inline('push %s/* %s' % (host, device), """
+ self.m.run(self.m.python.inline, 'push %s/* %s' % (host, device),
+ program="""
import os
import subprocess
import sys