improve the wait logic in nested ssh bugreport

If this is the first time running an adb command on remote VM,
the nested virtual device might not become visible to the adb
server immediately. This is due to the implementation of
adb_connector on remote VM.

This patch prefixed the bugreport command with a
`wait-for-device` to ensure that the device is visible first
or until the preset 15m timeout. The previous retry loop is
also removed now that the cause of the behavior is clear.

Bug: 154613608
Test: updated unit test
      http://sponge/4503f5cc-0fc1-415e-9cb0-06e06317ae53
Change-Id: I2269be1085be23ecf0e97658502d387cbcc0d9f1
diff --git a/src/com/android/tradefed/device/cloud/GceManager.java b/src/com/android/tradefed/device/cloud/GceManager.java
index 3e4ea4e..3e6a77d 100644
--- a/src/com/android/tradefed/device/cloud/GceManager.java
+++ b/src/com/android/tradefed/device/cloud/GceManager.java
@@ -474,18 +474,15 @@
         if (gceAvd == null || gceAvd.hostAndPort() == null) {
             return null;
         }
-        String output = "";
-        // Retry a couple of time because adb might not be started for that user.
-        // FIXME: See if we can use vsoc-01 directly to avoid this
-        for (int i = 0; i < 3; i++) {
-            output =
-                    remoteSshCommandExec(
-                            gceAvd, options, runUtil, "./bin/adb", "shell", "bugreportz");
-            Matcher match = BUGREPORTZ_RESPONSE_PATTERN.matcher(output);
-            if (match.find()) {
-                break;
-            }
-        }
+        String output =
+                remoteSshCommandExec(
+                        gceAvd,
+                        options,
+                        runUtil,
+                        "./bin/adb",
+                        "wait-for-device",
+                        "shell",
+                        "bugreportz");
         Matcher match = BUGREPORTZ_RESPONSE_PATTERN.matcher(output);
         if (!match.find()) {
             CLog.e("Something went wrong during bugreportz collection: '%s'", output);
diff --git a/tests/src/com/android/tradefed/device/cloud/GceManagerTest.java b/tests/src/com/android/tradefed/device/cloud/GceManagerTest.java
index 5cf6f64..f3bdced 100644
--- a/tests/src/com/android/tradefed/device/cloud/GceManagerTest.java
+++ b/tests/src/com/android/tradefed/device/cloud/GceManagerTest.java
@@ -756,6 +756,7 @@
                                 EasyMock.anyObject(),
                                 EasyMock.eq("root@127.0.0.1"),
                                 EasyMock.eq("./bin/adb"),
+                                EasyMock.eq("wait-for-device"),
                                 EasyMock.eq("shell"),
                                 EasyMock.eq("bugreportz")))
                 .andReturn(res);