xwords/xwords4/android/scripts/adb-install.sh

85 lines
1.7 KiB
Bash
Raw Normal View History

#!/bin/bash
2012-01-21 17:50:12 +01:00
set -u -e
usage() {
[ $# -ge 1 ] && echo "Error: $1"
echo "usage: $(basename $0) [-e|-d] (-p /path/to/.apk)+"
2012-01-21 17:50:12 +01:00
exit 1
}
if [ ! -e build.xml ]; then
usage "No build.xml; please run me from the top android directory"
fi
APKS=''
DEVICES=''
DIRNAME=$(basename $(pwd))
ADB="$(which adb)"
MAIN=MainActivity
case $DIRNAME in
2014-02-12 07:11:28 +01:00
XWords4-dbg)
PKG=xw4dbg
;;
XWords4-bt)
PKG=xw4bt
;;
XWords4)
PKG=xw4
;;
*)
usage "running in unexpected directory $DIRNAME"
;;
esac
2012-01-21 17:50:12 +01:00
while [ $# -ge 1 ]; do
case $1 in
-e)
DEV="$($ADB devices | grep '^emulator' | awk '{print $1}')"
2013-11-10 18:01:52 +01:00
DEVICES="$DEVICES $DEV"
2012-01-21 17:50:12 +01:00
;;
-d)
DEV="$($ADB devices | grep -v emulator | grep 'device$' | awk '{print $1}')"
2013-11-10 18:01:52 +01:00
DEVICES="$DEVICES $DEV"
2012-01-21 17:50:12 +01:00
;;
2012-02-22 22:01:00 +01:00
-p)
[ $# -gt 1 ] || usage "-p requires an argument"
shift
APKS="$APKS $1"
2012-02-22 22:01:00 +01:00
;;
2012-01-21 17:50:12 +01:00
*)
usage
;;
esac
shift
done
if [ -z "$DEVICES" ]; then
while read LINE; do
if echo $LINE | grep -q "device$"; then
DEVICE=$(echo $LINE | awk '{print $1}')
DEVICES="$DEVICES $DEVICE"
fi
done <<< "$($ADB devices)"
fi
# If no apk specified, take the newest built
if [ -z "$APKS" ]; then
APKS=$(ls -t bin/*.apk | head -n 1)
2012-01-21 17:50:12 +01:00
fi
COUNT=0
for DEVICE in $DEVICES; do
for APK in $APKS; do
echo "installing $APK; details:"
ls -l $APK
$ADB -s $DEVICE install -r $APK
$ADB -s $DEVICE shell am start \
-n org.eehouse.android.${PKG}/org.eehouse.android.${PKG}.${MAIN}
done
COUNT=$((COUNT+1))
done
2012-01-21 17:50:12 +01:00
echo "installed into $COUNT devices/emulators"