osmo-gsm-tester_androidue_conn_chk.sh: improve error handling

fix check of $serial and check passed arguments.
exit when adb isn't installed on host

Change-Id: I6190a840dbc86838457da96d188afc17f83ab15f
diff --git a/utils/bin/osmo-gsm-tester_androidue_conn_chk.sh b/utils/bin/osmo-gsm-tester_androidue_conn_chk.sh
index d8ff049..2bdb9de 100644
--- a/utils/bin/osmo-gsm-tester_androidue_conn_chk.sh
+++ b/utils/bin/osmo-gsm-tester_androidue_conn_chk.sh
@@ -1,11 +1,34 @@
 #!/bin/bash
-# This script reads the network type of an Android phone via ADB
+# This script reads the network type of an Android phone via ADB/SSH
+# If the first argument (serial) is 0, SSH is used to remotely connect to the phone
 # usage: osmo-gsm-tester_androidue_conn_chk.sh $serial $remote_ip $remote_port
+#set -x
+
+# check if all parameters have been passed
+if ([ ! $3 ])
+then
+  echo "Please call script with osmo-gsm-tester_androidue_conn_chk.sh $serial $remote_ip $remote_port"
+  echo "E.g. ./osmo-gsm-tester_androidue_conn_chk.sh df2df 10.12.1.106 130 10"
+  exit
+fi
+
 serial=$1
 remote_ip=$2
 remote_port=$3
+
+echo "Waiting for Android UE to become available .."
+
+# Check adb is available, if needed
+if [ "$serial" != "0" ]; then
+  if ! [ -x "$(command -v adb)" ]; then
+    echo 'Error: adb is not installed.' >&2
+    exit 1
+  fi
+  echo "Using SSH to access device"
+fi
+
 while true; do
-  if [ "${serial}" == "0" ]; then
+  if [ "$serial" == "0" ]; then
     # run_type == ssh
     ssh -p "${remote_port}" root@"${remote_ip}" getprop "gsm.network.type"
   else
@@ -13,4 +36,4 @@
     adb -s "${serial}" shell getprop "gsm.network.type"
   fi
   sleep 1
-done
+done
\ No newline at end of file