-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflash.sh
executable file
·59 lines (53 loc) · 1.31 KB
/
flash.sh
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
52
53
54
55
56
57
58
59
#!/bin/bash
# Colors
RED="\033[1;31m" # For errors / warnings
GREEN="\033[1;32m" # For info
YELLOW="\033[1;33m" # For info
BLUE="\033[1;36m" # For info
NC="\033[0m" # reset color
cd
BUILD_FILE_NAME='Derp*.zip'
ADB_DEST_FOLDER='/home/prady/platform-tools'
SCRIPT=/home/prady/MyScripts
PRODUCT_PATH=/home/prady/derpfest/out/target/product/jasmine_sprout/
notif_adb_push(){
cd ${SCRIPT} && ./telegram "Pushing zip to /sdcard/flashing"
}
notif_adb_reb(){
echo -e "${YELLOW}Rebooting to Recovery${NC}"
cd ${SCRIPT} && ./telegram "Rebooting to Recovery"
}
notif_adb_fl(){
echo -e "${YELLOW}Flashing to Inactive Slot${NC}"
cd ${SCRIPT} && ./telegram "Flashing to Inactive Slot"
}
# resets adb server
adb_reset()
{
echo -e "${GREEN}Restarting ADB server${NC}"
adb kill-server
adb start-server
}
# waits for a recognizeable device in given state
# $1: device state
# $2: delay between scans in seconds
adb_wait()
{
state=$1
delay=$2
echo -e "${GREEN}Waiting for device${NC}"
while [[ $isDet != '0' ]]; do # wait until detected
adb kill-server &> /dev/null
adb start-server &> /dev/null
adb devices | grep -w "${state}" &> /dev/null
isDet=$?
sleep $delay
done
}
notif_adb_reb
adb reboot recovery
adb_wait
notif_adb_push
cd ${PRODUCT_PATH}
pwd
adb push ${BUILD_FILE_NAME} /sdcard/xflashing