aboutsummaryrefslogtreecommitdiffstats
path: root/monkeyrunner
diff options
context:
space:
mode:
authorBill Napier <napier@google.com>2010-09-23 09:43:30 -0700
committerBill Napier <napier@google.com>2010-09-23 09:48:59 -0700
commitbcd4b888e7ac6128c19098d30c4fc23b3df0f352 (patch)
treee47b75cd264058ea50d391003ddc5bdfeba9a8e9 /monkeyrunner
parentadea5844b343dad373bf0d65bf84d1b5b31c0452 (diff)
downloadsdk-bcd4b888e7ac6128c19098d30c4fc23b3df0f352.zip
sdk-bcd4b888e7ac6128c19098d30c4fc23b3df0f352.tar.gz
sdk-bcd4b888e7ac6128c19098d30c4fc23b3df0f352.tar.bz2
Improve waitForConnection for booting devices.
Have waitForConnection actually wait until the device is ONLINE before returning it. Also give the on device monkey some more time to startup. Change-Id: I86193a8532a84d64dddd9a60012af4f3ef507841
Diffstat (limited to 'monkeyrunner')
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/adb/AdbBackend.java3
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/adb/AdbMonkeyDevice.java9
2 files changed, 10 insertions, 2 deletions
diff --git a/monkeyrunner/src/com/android/monkeyrunner/adb/AdbBackend.java b/monkeyrunner/src/com/android/monkeyrunner/adb/AdbBackend.java
index 63badf5..b9549a3 100644
--- a/monkeyrunner/src/com/android/monkeyrunner/adb/AdbBackend.java
+++ b/monkeyrunner/src/com/android/monkeyrunner/adb/AdbBackend.java
@@ -69,7 +69,8 @@ public class AdbBackend implements MonkeyRunnerBackend {
public MonkeyDevice waitForConnection(long timeoutMs, String deviceIdRegex) {
do {
IDevice device = findAttacedDevice(deviceIdRegex);
- if (device != null) {
+ // Only return the device when it is online
+ if (device != null && device.getState() == IDevice.DeviceState.ONLINE) {
AdbMonkeyDevice amd = new AdbMonkeyDevice(device);
devices.add(amd);
return amd;
diff --git a/monkeyrunner/src/com/android/monkeyrunner/adb/AdbMonkeyDevice.java b/monkeyrunner/src/com/android/monkeyrunner/adb/AdbMonkeyDevice.java
index dedc1ea..b180ccd 100644
--- a/monkeyrunner/src/com/android/monkeyrunner/adb/AdbMonkeyDevice.java
+++ b/monkeyrunner/src/com/android/monkeyrunner/adb/AdbMonkeyDevice.java
@@ -51,7 +51,8 @@ public class AdbMonkeyDevice extends MonkeyDevice {
private static final Logger LOG = Logger.getLogger(AdbMonkeyDevice.class.getName());
private static final String[] ZERO_LENGTH_STRING_ARRAY = new String[0];
- private static final long MANAGER_CREATE_TIMEOUT_MS = 5 * 1000; // 5 seconds
+ private static final long MANAGER_CREATE_TIMEOUT_MS = 30 * 1000; // 30 seconds
+ private static final long MANAGER_CREATE_WAIT_TIME_MS = 1000; // wait 1 second
private final ExecutorService executor = Executors.newCachedThreadPool();
@@ -151,6 +152,12 @@ public class AdbMonkeyDevice extends MonkeyDevice {
return null;
}
+ try {
+ Thread.sleep(MANAGER_CREATE_WAIT_TIME_MS);
+ } catch (InterruptedException e) {
+ LOG.log(Level.SEVERE, "Unable to sleep", e);
+ }
+
Socket monkeySocket;
try {
monkeySocket = new Socket(addr, port);