Index: build/android/adb_install_apk.py |
diff --git a/build/android/adb_install_apk.py b/build/android/adb_install_apk.py |
index adad48bdef84a445d58e3f443017b979302706d4..e57e0b375efda06c63948df8f5a445da6fa1eda3 100755 |
--- a/build/android/adb_install_apk.py |
+++ b/build/android/adb_install_apk.py |
@@ -10,6 +10,7 @@ import multiprocessing |
import optparse |
import os |
import sys |
+import time |
from pylib import android_commands |
from pylib import constants |
@@ -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 = 10 |
+ 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') |