blob: d7db55ffa35b5669c1d2c14fe61625ebf767a362 [file] [log] [blame]
#!/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
}
# Helper function to count number of source arguments in a list
# when more than one argument is supplied, it is assumed the last argument
# is a destination
count_sources() {
local source_count=$#
if [ $source_count -gt 1 ]; then
source_count=$((source_count - 1))
fi
echo "$source_count"
}