Skip to content

Commit

Permalink
[Android] When running android test, try killing adb if no devices found
Browse files Browse the repository at this point in the history
It randomly happens that adb devices return empty list even device
is actually connected, killing adb and restart it can fix this.

CL=https://codereview.chromium.org/24194002
  • Loading branch information
Shiliu Wang authored and Jesus Sanchez-Palencia committed Oct 7, 2013
1 parent e30def5 commit 1ebfe40
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion build/android/adb_install_apk.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import optparse
import os
import sys
import time

from pylib import android_commands
from pylib import constants
Expand Down Expand Up @@ -58,7 +59,20 @@ def main(argv):
if len(args) > 1:
raise Exception('Error: Unknown argument:', args[1:])

devices = android_commands.GetAttachedDevices()
retry_times = 5
retry_interval = 15
while retry_times > 0:
devices = android_commands.GetAttachedDevices()
if not devices:
print 'No connected devices found, '\
'kill adb server and retry in %d seconds...' % retry_interval
android_commands.AndroidCommands().KillAdbServer()
time.sleep(retry_interval)
retry_interval *= 2
retry_times -= 1
else:
break

if not devices:
raise Exception('Error: no connected devices')

Expand Down

0 comments on commit 1ebfe40

Please sign in to comment.