| #!/bin/bash -x |
| # Utilities to interact with android more easily |
| |
| make_csv() { |
| out="" |
| in=$1 |
| for p in $in; do |
| if [ "x$out" == "x" ]; then |
| out=$p |
| else |
| out="$out,$p" |
| fi |
| done |
| echo $out |
| } |
| |
| make_spaces() { |
| out="" |
| in=$1 |
| for p in $in; do |
| if [ "x$out" == "x" ]; then |
| out=$p |
| else |
| out="$out $p" |
| fi |
| done |
| echo $out |
| } |
| |
| cmd_exists() { |
| which $1 > /dev/null |
| return $? |
| } |
| |
| do_adb_root() { |
| ADB="$1" |
| $ADB root > /dev/null 2>&1 |
| return $? |
| } |
| |
| die() { |
| exit_code=$1 |
| msg=$2 |
| echo "ERROR: $msg" |
| exit $exit_code |
| } |
| |
| die_if_no_androdeb() { |
| set +e |
| $ADB shell ls /data/androdeb/debian > /dev/null 2>&1 |
| if [ $? -ne 0 ]; then die 8 "Existing androdeb env not found on device. $1"; fi |
| set -e |
| } |