-
Notifications
You must be signed in to change notification settings - Fork 2
/
jflash.sh
executable file
·204 lines (159 loc) · 5.27 KB
/
jflash.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/bin/bash
JFLASH_DIR="$(pwd)"
source $JFLASH_DIR/Utilities/messages.sh
echo_cyn "Linux Version"
uname -a
echo_cyn "Linux Shell"
echo_info $SHELL
function listUSBDevices () {
lsusb
}
function findQualcommDevice () {
# a device in full Android mode should display something like ths.
# Bus 001 Device 097: ID 05c6:9025 Qualcomm, Inc.
listUSBDevices
androiddevice="unknown"
set -f
IFS=$'\n'
result=$(lsusb 2>&1)
usblist=(${result//$\n/})
found=0
for index in "${!usblist[@]}"
do
if [[ ${usblist[index]} = *"Qualcomm"* ]]; then
#echo "${usblist[index]}"
androiddevice="${usblist[index]}"
found=1
break
fi
done
echo
if [ $found == 0 ]; then
warning "No devices attached in ADB mode"
else
success "Found a fully booted Device $androiddevice"
fi
}
function findGoogleDevice () {
# a device in fastboot mode should display something like ths.
# Bus 001 Device 098: ID 18d1:d00d Google Inc.
googledevice="unknown"
listUSBDevices
set -f
IFS=$'\n'
result=$(lsusb 2>&1)
usblist=(${result//$\n/})
found=0
for index in "${!usblist[@]}"
do
if [[ ${usblist[index]} = *"Google"* ]]; then
# echo "${usblist[index]}"
googledevice="${usblist[index]}"
found=1
break
fi
done
echo
if [ $found == 0 ]; then
echo_error "No device found in Fastboot mode"
exit 1
fi
success "Found a device in Fastboot mode $googledevice"
}
# ================================================================
# MODIFY THE ZIP FILENAME AND PRODUCT INFORMATION
# ================================================================
textString=$(cat Product.txt)
list=($textString)
ZipName=${list[0]}
BuildVersion=${list[1]}
ProductMatch=${list[2]}
echo
echo_grn "Intrinsyc Technologies Corporation"
echo_grn "JFlash Updater for the $ProductMatch"
echo_grn "Build Version $BuildVersion"
echo
chmod 777 ./AdbFastboot/adb
chmod 777 ./AdbFastboot/fastboot
chmod 777 ./Android/flashAndroid.sh
java -fullversion
if [ $? != 0 ]; then
echo
warning2 "Java does not appear to be installed on this computer" "Please install at a minimum OpenJDK Java 1.7.xxx x64"
echo
warning2 "JDK can be found here:" "http://openjdk.java.net/install/"
echo
else
JVER=4
version=$("java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
echo_grn "Java Version"
java -version
version=${version%_*}
result=
IFS="._"
for num in $version;do
result+=$num
done
#echo "Java version $result"
if (( $result < 170 )); then
echo
warning2 "The current version of Java is from an older release." "Please install at a minimum OpenJDK Java 1.7.xxx x64"
echo
warning2 "JDK can be found here:" "http://openjdk.java.net/install/"
echo
else
message "Rebooting the device into fastboot mode."
warning "Ignore <error: no devices found> potentially in fastboot already"
findQualcommDevice
IFS=$'\n'
usbid=$("./AdbFastboot/adb" devices 2>&1)
response=(${usbid//\n/})
for i in "${response[@]}"
do
if [[ $i != *"attached"* ]]; then
if [[ $i != *"server"* ]]; then
if [[ $i != *"successfully"* ]]; then
if [[ $i == *"device"* ]]; then
echo
echo_info "Device Build Information"
./AdbFastboot/adb shell getprop ro.build.description
echo
message "Rebooting to Fastboot mode"
response=$("./AdbFastboot/adb" reboot-bootloader 2>&1)
warning2 "Giving the device some time to reboot. Press Enter if already in" " in fastboot mode."
sleep 2
fi
fi
fi
fi
done
findGoogleDevice
usbid=$("./AdbFastboot/fastboot" devices 2>&1 | awk -F ' ' '{print $1}')
echo
if [ -n "${usbid}" ]; then
message "Attached USB device ID $usbid"
modelid=$("./AdbFastboot/fastboot" getvar product 2>&1 | awk -F ': ' '{print $2}')
message "Looking for {$ProductMatch}"
productid=$(echo "$modelid"|tr '\n' ' ' | awk -F ' ' '{print $1}')
message "productid {$productid}"
if [ -n "${productid}" ]; then
if [ "${productid}" = "${ProductMatch}" ]; then
success "Correct product"
echo
message "Running jflash utility"
java -Xms1G -Xmx1G -jar jflash.jar ./"$ZipName$BuildVersion".zip NoPrompt
message "Flashing Android"
./Android/flashAndroid.sh
message "Rebooting the device"
./AdbFastboot/fastboot reboot
else
error "Not the correct device"
fi
else
error "Did not get a product id from the device"
fi
else
warning "No Devices Attached"
fi
fi
fi