Nils Fürste | a8263f4 | 2020-11-23 14:45:15 +0100 | [diff] [blame] | 1 | #!/bin/bash |
Andre Puschmann | e98e129 | 2021-03-08 16:40:48 +0100 | [diff] [blame] | 2 | # This script reads the network type of an Android phone via ADB/SSH |
| 3 | # If the first argument (serial) is 0, SSH is used to remotely connect to the phone |
Nils Fürste | a8263f4 | 2020-11-23 14:45:15 +0100 | [diff] [blame] | 4 | # usage: osmo-gsm-tester_androidue_conn_chk.sh $serial $remote_ip $remote_port |
Andre Puschmann | e98e129 | 2021-03-08 16:40:48 +0100 | [diff] [blame] | 5 | #set -x |
| 6 | |
| 7 | # check if all parameters have been passed |
| 8 | if ([ ! $3 ]) |
| 9 | then |
| 10 | echo "Please call script with osmo-gsm-tester_androidue_conn_chk.sh $serial $remote_ip $remote_port" |
| 11 | echo "E.g. ./osmo-gsm-tester_androidue_conn_chk.sh df2df 10.12.1.106 130 10" |
| 12 | exit |
| 13 | fi |
| 14 | |
Nils Fürste | a8263f4 | 2020-11-23 14:45:15 +0100 | [diff] [blame] | 15 | serial=$1 |
| 16 | remote_ip=$2 |
| 17 | remote_port=$3 |
Andre Puschmann | e98e129 | 2021-03-08 16:40:48 +0100 | [diff] [blame] | 18 | |
| 19 | echo "Waiting for Android UE to become available .." |
| 20 | |
| 21 | # Check adb is available, if needed |
| 22 | if [ "$serial" != "0" ]; then |
| 23 | if ! [ -x "$(command -v adb)" ]; then |
| 24 | echo 'Error: adb is not installed.' >&2 |
| 25 | exit 1 |
| 26 | fi |
| 27 | echo "Using SSH to access device" |
| 28 | fi |
| 29 | |
Nils Fürste | a8263f4 | 2020-11-23 14:45:15 +0100 | [diff] [blame] | 30 | while true; do |
Andre Puschmann | e98e129 | 2021-03-08 16:40:48 +0100 | [diff] [blame] | 31 | if [ "$serial" == "0" ]; then |
Nils Fürste | a8263f4 | 2020-11-23 14:45:15 +0100 | [diff] [blame] | 32 | # run_type == ssh |
| 33 | ssh -p "${remote_port}" root@"${remote_ip}" getprop "gsm.network.type" |
| 34 | else |
| 35 | # run_type = local |
| 36 | adb -s "${serial}" shell getprop "gsm.network.type" |
| 37 | fi |
| 38 | sleep 1 |
Andre Puschmann | e98e129 | 2021-03-08 16:40:48 +0100 | [diff] [blame] | 39 | done |