Merge "add gitignore"
diff --git a/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java b/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java
index 200c69e..af09efe 100644
--- a/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java
+++ b/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java
@@ -264,9 +264,16 @@
 
     @Override
     public String shell(String cmd) {
+        // 5000 is the default timeout from the ddmlib.
+        // This timeout arg is needed to the backwards compatibility.
+        return shell(cmd, 5000);
+    }
+
+    @Override
+    public String shell(String cmd, int timeout) {
         CommandOutputCapture capture = new CommandOutputCapture();
         try {
-            device.executeShellCommand(cmd, capture);
+            device.executeShellCommand(cmd, capture, timeout);
         } catch (TimeoutException e) {
             LOG.log(Level.SEVERE, "Error executing command: " + cmd, e);
             return null;
diff --git a/chimpchat/src/com/android/chimpchat/core/IChimpDevice.java b/chimpchat/src/com/android/chimpchat/core/IChimpDevice.java
index 14b58a7..60cfa76 100644
--- a/chimpchat/src/com/android/chimpchat/core/IChimpDevice.java
+++ b/chimpchat/src/com/android/chimpchat/core/IChimpDevice.java
@@ -131,12 +131,23 @@
     /**
      * Execute a shell command.
      *
+     * Will timeout if there is no ouput for 5 secounds.
+     *
      * @param cmd the command to execute
      * @return the output of the command
      */
     String shell(String cmd);
 
     /**
+     * Execute a shell command.
+     *
+     * @param cmd the command to execute
+     * @param timeout maximum time to output response
+     * @return the output of the command
+     */
+    String shell(String cmd, int timeout);
+
+    /**
      * Install a given package.
      *
      * @param path the path to the installation package
diff --git a/monkeyrunner/src/com/android/monkeyrunner/MonkeyDevice.java b/monkeyrunner/src/com/android/monkeyrunner/MonkeyDevice.java
index 41e58f9..5dc7e7b 100644
--- a/monkeyrunner/src/com/android/monkeyrunner/MonkeyDevice.java
+++ b/monkeyrunner/src/com/android/monkeyrunner/MonkeyDevice.java
@@ -209,15 +209,22 @@
     }
 
     @MonkeyRunnerExported(doc = "Executes an adb shell command and returns the result, if any.",
-            args = { "cmd"},
-            argDocs = { "The adb shell command to execute." },
+            args = { "cmd", "timeout"},
+            argDocs = { "The adb shell command to execute.",
+            "This arg is optional. It specifies the maximum amount of time during which the" +
+            "command can go without any output. A value of 0 means the method" +
+            "will wait forever. The unit of the timeout is millisecond"},
             returns = "The output from the command.")
     public String shell(PyObject[] args, String[] kws) {
         ArgParser ap = JythonUtils.createArgParser(args, kws);
         Preconditions.checkNotNull(ap);
-
         String cmd = ap.getString(0);
-        return impl.shell(cmd);
+
+        if (args.length == 2) {
+            return impl.shell(cmd, ap.getInt(1));
+        } else {
+            return impl.shell(cmd);
+        }
     }
 
     @MonkeyRunnerExported(doc = "Reboots the specified device into a specified bootloader.",