diff options
author | Alan Stokes <alanstokes@google.com> | 2024-04-05 12:10:12 +0100 |
---|---|---|
committer | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-04-05 15:17:36 +0000 |
commit | 6b2e07feeea41447daf7083078fb4c95e9315f5c (patch) | |
tree | 28c1aee2cbe3a70c9c495eca588a8bff33a8f89a | |
parent | c42a79b4517cc25d945b80cfc3dcbc71f5bf937b (diff) | |
download | tradefederation-6b2e07feeea41447daf7083078fb4c95e9315f5c.tar.gz |
Fix adbConnectToMicrodroid failure handling
Remove potential infinite loop waiting for connect to succeed - apply
the timeout we have.
Also, don't pass a non-positive timeout to `runTimedCmd()`, since it
interprets it as "no timeout".
Bug: 329424318
Test: atest MicrodroidHostTests
Change-Id: I70aced76bba6da62373e415f7f7a434fe7cc4d63
-rw-r--r-- | src/com/android/tradefed/device/TestDevice.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/com/android/tradefed/device/TestDevice.java b/src/com/android/tradefed/device/TestDevice.java index 40a26d10f..959d65643 100644 --- a/src/com/android/tradefed/device/TestDevice.java +++ b/src/com/android/tradefed/device/TestDevice.java @@ -3099,7 +3099,7 @@ public class TestDevice extends NativeDevice { .runTimedCmd(10000, deviceManager.getAdbPath(), "-s", serial, "forward", from, to); boolean disconnected = true; - while (disconnected) { + while (disconnected && timeoutMillis >= 0) { elapsed = System.currentTimeMillis() - start; timeoutMillis -= elapsed; start = System.currentTimeMillis(); @@ -3132,14 +3132,15 @@ public class TestDevice extends NativeDevice { elapsed = System.currentTimeMillis() - start; timeoutMillis -= elapsed; - getRunUtil() - .runTimedCmd( - timeoutMillis, - deviceManager.getAdbPath(), - "-s", - microdroidSerial, - "wait-for-device"); - + if (timeoutMillis > 0) { + getRunUtil() + .runTimedCmd( + timeoutMillis, + deviceManager.getAdbPath(), + "-s", + microdroidSerial, + "wait-for-device"); + } boolean dataAvailable = false; while (!dataAvailable && timeoutMillis >= 0) { elapsed = System.currentTimeMillis() - start; |