arc.py: Add adb_cmd timeout

BUG=chromium:737030
TEST=On DUT, use test_that with a adb_cmd('logcat') which lasts longer than
the timeout value and it fails eventually.

Change-Id: Ida5e17cf0d50c421300ebdf1cbd3f9c2641d3fd9
Signed-off-by: Chung-yih Wang <cywang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/549741
Reviewed-by: Shuo-Peng Liao <deanliao@chromium.org>
diff --git a/client/common_lib/cros/arc.py b/client/common_lib/cros/arc.py
index 00e4182..4ae8ff6 100644
--- a/client/common_lib/cros/arc.py
+++ b/client/common_lib/cros/arc.py
@@ -26,6 +26,7 @@
 _ANDROID_ADB_KEYS_PATH = '/data/misc/adb/adb_keys'
 _PROCESS_CHECK_INTERVAL_SECONDS = 1
 _WAIT_FOR_ADB_READY = 60
+_WAIT_FOR_ADB_CMD = 300
 _WAIT_FOR_ANDROID_PROCESS_SECONDS = 60
 _WAIT_FOR_DATA_MOUNTED_SECONDS = 60
 _VAR_LOGCAT_PATH = '/var/log/logcat'
@@ -135,13 +136,14 @@
                   pipes.quote(package), pipes.quote(permission)))
 
 
-def adb_cmd(cmd, **kwargs):
+def adb_cmd(cmd, timeout=_WAIT_FOR_ADB_CMD, **kwargs):
     """Executed cmd using adb. Must wait for adb ready.
 
     @param cmd: Command to run.
+    @param timeout: Timeout in seconds.
     """
     wait_for_adb_ready()
-    return utils.system_output('adb %s' % cmd, **kwargs)
+    return utils.system_output('adb %s' % cmd, timeout=timeout, **kwargs)
 
 
 def adb_shell(cmd, **kwargs):