Skip to content

Commit 158dd36

Browse files
howaboutsynergyHainish
authored andcommitted
1 parent 5bcda43 commit 158dd36

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

utils/android-push.sh

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,32 @@ fi
1111

1212
# Push to Android Firefox if device is connected
1313
# XXX on some systems, adb may require sudo...
14-
if type adb > /dev/null 2>/dev/null && adb devices >/dev/null 2>/dev/null ; then
15-
ADB_FOUND=`adb devices | grep -v 'offline$' | tail -2 | head -1 | cut -f 1 | sed 's/ *$//g'`
16-
if [ "$ADB_FOUND" != "List of devices attached" ]; then
17-
echo Pushing "$XPI_NAME" to /sdcard/"$XPI_NAME"
18-
adb push "../$XPI_NAME" /sdcard/"$XPI_NAME"
19-
adb shell am start -a android.intent.action.VIEW \
20-
-c android.intent.category.DEFAULT \
21-
-d file:///mnt/sdcard/pkg/ \
22-
-n $ANDROID_APP_ID/.App
14+
if type adb > /dev/null 2>/dev/null ; then
15+
#running `adb devices` below will start adb server/daemon if it wasn't running already
16+
#we start it and make note if it's us that started it or not, so we can stop it afterwards
17+
if adb start-server 2>&1 |grep -qF 'daemon not running' ; then
18+
we_started_adb_daemon=1
19+
else
20+
we_started_adb_daemon=0
21+
fi
22+
on_exit() {
23+
if test "$we_started_adb_daemon" == "1"; then
24+
#if we started it we kill it, to avoid constant dmesg PME# spam, see issue 18103
25+
adb kill-server
26+
fi
27+
}
28+
trap on_exit EXIT SIGINT
29+
30+
if adb devices >/dev/null 2>/dev/null ; then
31+
ADB_FOUND=`adb devices | grep -v 'offline$' | tail -2 | head -1 | cut -f 1 | sed 's/ *$//g'`
32+
if [ "$ADB_FOUND" != "List of devices attached" ]; then
33+
echo Pushing "$XPI_NAME" to /sdcard/"$XPI_NAME"
34+
adb push "../$XPI_NAME" /sdcard/"$XPI_NAME"
35+
adb shell am start -a android.intent.action.VIEW \
36+
-c android.intent.category.DEFAULT \
37+
-d file:///mnt/sdcard/pkg/ \
38+
-n $ANDROID_APP_ID/.App
39+
fi
2340
fi
2441
fi
2542

0 commit comments

Comments
 (0)