Revert "Update the emulator setup script to not wait forever so we can isolate that failure."

This reverts commit f17ad0c5d211314606da21e2ecde900133f5e80c.

Reason for revert: https://github.com/flutter/flutter/issues/138267

Original change's description:
> Update the emulator setup script to not wait forever so we can isolate that failure.
>
> Bug: https://github.com/flutter/flutter/issues/137947
> Change-Id: Ie65fcedcb2fa117aacaddeb2af4768e3b06b8c08
> Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/52460
> Reviewed-by: Godofredo Contreras <godofredoc@google.com>
> Commit-Queue: Ricardo Amador <ricardoamador@google.com>

TBR=godofredoc@google.com,keyonghan@google.com,flutter-scoped@luci-project-accounts.iam.gserviceaccount.com,ricardoamador@google.com

Change-Id: Iea20a412a825f716e943ef86e7585cec0988ce9a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/flutter/flutter/issues/137947
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/52461
Reviewed-by: Keyong Han <keyonghan@google.com>
Reviewed-by: Ricardo Amador <ricardoamador@google.com>
Commit-Queue: Keyong Han <keyonghan@google.com>
diff --git a/recipe_modules/android_virtual_device/resources/avd_setup.sh b/recipe_modules/android_virtual_device/resources/avd_setup.sh
index 1522ce2..340e0e4 100644
--- a/recipe_modules/android_virtual_device/resources/avd_setup.sh
+++ b/recipe_modules/android_virtual_device/resources/avd_setup.sh
@@ -8,63 +8,19 @@
 #
 # Usage: ./avd_setup.sh <path-to-adb-executable>
 
-# $1 kill-server
-
-set -x
-
-# Monitor but it appears the device is always ready within a couple seconds.
-readonly WAIT_ITERS=60
-
-function wait_for_device_ready() {
-    local adb=${1}
-
-    local ready=1
-    # Wait for avd to reach home screen
-    for((i=0; i<${WAIT_ITERS}; i++)); do
-        out=$(${adb} -s emulator-5554 shell 'getprop sys.boot_completed')
-        if [[ "${out}" = "1" ]]; then
-            echo "Device is ready."
-            ready=0
-            break
-        else
-            echo "Device is not ready."
-            echo "output: ${out}"
-            sleep 1
-        fi
-    done
-
-    if [[ ${ready} -eq 1 ]]; then
-        echo "Device was not ready in time."
-        exit 1
-    fi
-}
-
-# path to the adb executable
-adb=${1}
-
-which ${adb}
-if [[ $? -eq 1 ]]; then
-    echo "Unable to locate adb on path."
-fi
-
-# when you run any adb command and the server is not up it will start it.
-${adb} start-server
-${adb} devices
-${adb} wait-for-device
-wait_for_device_ready ${adb}
-${adb} devices
+$1 kill-server
+$1 start-server
+$1 wait-for-device
+# Wait for avd to reach home screen
+$1 -s emulator-5554 shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
+$1 devices
 # Set the density DPI
-${adb} shell wm density 400
+$1 shell wm density 400
 # unlock avd
-${adb} shell input keyevent 82
+$1 shell input keyevent 82
 # Ensure developer mode is enabled
-${adb} shell settings put global development_settings_enabled 1
+$1 shell settings put global development_settings_enabled 1
 # Enable MTP file transfer
-${adb} shell svc usb setFunctions mtp
+$1 shell svc usb setFunctions mtp
 # Wait for device to boot and unlock device's screen.
-wait_for_device_ready ${adb}
-${adb} shell input keyevent 82
-
-# clear exit signal for the LUCI ci.
-echo "Emulator ready."
-exit 0
\ No newline at end of file
+$1 wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82'