summaryrefslogtreecommitdiff
path: root/automated/lib/android-test-lib
diff options
context:
space:
mode:
Diffstat (limited to 'automated/lib/android-test-lib')
-rwxr-xr-xautomated/lib/android-test-lib36
1 files changed, 33 insertions, 3 deletions
diff --git a/automated/lib/android-test-lib b/automated/lib/android-test-lib
index 087256c..bad964f 100755
--- a/automated/lib/android-test-lib
+++ b/automated/lib/android-test-lib
@@ -23,8 +23,13 @@ adb_debug_info() {
else
info_msg "usbutils not installed, unable to get device information with 'lsusb'."
info_msg "Listing 'find /dev/bus/usb' output directly..."
- find /dev/bus/usb
+ # avoid returning 1 when 'find' doesn't work
+ find /dev/bus/usb || true
fi
+ info_msg "===== list fastboot devices start ========="
+ fastboot devices
+ info_msg "===== list fastboot devices end ========="
+ info_msg "===== default ANDROID_SERIAL=${ANDROID_SERIAL} ========="
}
initialize_adb() {
@@ -32,7 +37,7 @@ initialize_adb() {
set -x
adb_debug_info
adb start-server
- timeout 600 adb wait-for-device || error_msg "Device NOT found!"
+ timeout 600 adb wait-for-device || error_fatal "Device NOT found!"
adb devices
if [ -z "${ANDROID_SERIAL}" ]; then
@@ -59,7 +64,7 @@ initialize_adb() {
adb_root() {
if [ "$(adb shell whoami)" = "root" ]; then
- info_msg "DUT already has adbd running as root"
+ echo "DUT already has adbd running as root"
else
adb root
timeout 600 adb wait-for-device || error_msg "Device NOT found!"
@@ -226,3 +231,28 @@ parse_common_args() {
esac
done
}
+
+# Try to find the WIFI AP info and connect to it
+# depends on WIFI AP information specified by lava job like following:
+# secrets:
+# AP_SSID: "${AP_SSID}"
+# AP_KEY: "${AP_KEY}"
+adb_join_wifi() {
+ AP_SSID=$1
+ AP_KEY=$2
+ if [ -z "${AP_SSID}" ] || [ -z "${AP_KEY}" ]; then
+ # Try to find the WIFI AP information specified by the job definition if not specified via command line
+ lava_test_dir="$(find /lava-* -maxdepth 0 -type d -regex '/lava-[0-9]+' 2>/dev/null | sort | tail -1)"
+ if test -f "${lava_test_dir}/secrets"; then
+ # shellcheck disable=SC1090
+ . "${lava_test_dir}/secrets"
+ fi
+ fi
+
+ # Try to connect to wifi if found the WIFI AP information
+ if [ ! -z "${AP_SSID}" ] && [ ! -z "${AP_KEY}" ]; then
+ wget http://testdata.validation.linaro.org/apks/wifi/wifi.apk
+ adb install wifi.apk
+ adb shell am start -n com.steinwurf.adbjoinwifi/.MainActivity -e ssid "${AP_SSID}" -e password_type WPA -e password "${AP_KEY}"
+ fi
+}