aboutsummaryrefslogtreecommitdiffstats
path: root/chimpchat
diff options
context:
space:
mode:
authorpzoli <pzoli>2013-01-23 20:25:44 +0100
committerpzoli <pzatya@gmail.com>2013-02-21 21:45:26 +0100
commit8dd0bc70cb283db5d38bfaa15f9cbb3948f02324 (patch)
tree8eb21029de0ba62ec5da9ab184625f63116a8cf9 /chimpchat
parent8f05484bde79afb980283512f85bbbe6cce91200 (diff)
downloadsdk-8dd0bc70cb283db5d38bfaa15f9cbb3948f02324.tar.gz
sdk-8dd0bc70cb283db5d38bfaa15f9cbb3948f02324.tar.bz2
sdk-8dd0bc70cb283db5d38bfaa15f9cbb3948f02324.zip
Extended the MonkeyRunner shell method with timeout arg.
In python via MonkeyRunner it is possible execute shell commands but the running time was reduced to 5 seconds. This patch adds an extra argument for the "shell" method. It decides the maximum amount of time during which the command is allowed to not output any response. A value of 0 means that the method will wait forever. This extra arg is optionally. So the original function works without any changes. Change-Id: I1a6d9b37e1846715342b252b2a2a346c2309a08f Signed-off-by: Zoltán Papp <pzatya@gmail.com>
Diffstat (limited to 'chimpchat')
-rw-r--r--chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java9
-rw-r--r--chimpchat/src/com/android/chimpchat/core/IChimpDevice.java11
2 files changed, 19 insertions, 1 deletions
diff --git a/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java b/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java
index 7c4b62a89..dadb017c9 100644
--- a/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java
+++ b/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java
@@ -264,9 +264,16 @@ public class AdbChimpDevice implements IChimpDevice {
@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 14b58a7d5..60cfa7645 100644
--- a/chimpchat/src/com/android/chimpchat/core/IChimpDevice.java
+++ b/chimpchat/src/com/android/chimpchat/core/IChimpDevice.java
@@ -131,12 +131,23 @@ public interface IChimpDevice {
/**
* 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