-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadb-service
executable file
·51 lines (37 loc) · 974 Bytes
/
adb-service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
function log {
STATUS=$1
MSG=$2
if [ ! -t 0 ]; then
INPUT=$(cat)
else
INPUT=""
fi
case "$STATUS" in
warning) COLOR_CODE='93'; ;;
success) COLOR_CODE='92'; ;;
error) COLOR_CODE='91'; ;;
info) COLOR_CODE='94'; ;;
*) COLOR_CODE='39'; MSG=$1 ;;
esac
RESET="\e[0m";
COLOR="\e[0;${COLOR_CODE}m";
if [[ "$OSTYPE" == "darwin"* ]]; then
RESET="\x1B[0m";
COLOR="\x1B[0;${COLOR_CODE}m";
fi
echo ${COLOR}${MSG}${INPUT}${RESET}
}
function adb_shell () {
echo $(adb shell 'echo 1' 2> /dev/null);
}
function adb_watch () {
while [ $(adb_shell) ]; do sleep 2; done
log "error" "ADB has been restarted"
adb kill-server 1> /dev/null 2> /dev/null
adb start-server 1> /dev/null 2> /dev/null
source ./custom-shell.sh
}
adb start-server 1> /dev/null
log "success" "ADB Started"
while [ true ]; do adb_watch ; done