-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprepare_tablet_de1.sh
364 lines (283 loc) · 13.2 KB
/
prepare_tablet_de1.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
#!/bin/bash
###############################
# NOTES:
# first put the tablet manually into adb-receptive mode
# user must go to "settings/about" and tap repeatedly on "build number"
# user then chooses "developer options" and "developer options: on" and then "usb debugging: on"
#
# keycode docs: http://thecodeartist.blogspot.hk/2011/03/simulating-keyevents-on-android-device.html https://developer.android.com/reference/android/view/KeyEvent.html http://publish.illinois.edu/weiyang-david/2013/08/08/code-numbers-for-adb-input/
# more keycode docs: https://stackoverflow.com/questions/7789826/adb-shell-input-events
###############################
# if there are any parameters on the url then this is a DE1+ tablet pre, otherwise this is a DE1 tablet prep
tableterase=0
if [ "$1" != "" ]
then
tableterase=1;
fi
###############################
# optional: reset the tablet to factory settings (requires user to then proceed through setup menu)
if [ $tableterase = 1 ]
then
adb shell am broadcast -a android.intent.action.MASTER_CLEAR; sleep 10
sleep 60
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 2; done; input keyevent 3'
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 2; done; input keyevent 3'
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 2; done; input keyevent 3'
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 2; done; input keyevent 3'
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 2; done; input keyevent 3'
fi
###############################
###############################
# make the display bright
echo "Setting screen brightness to max"
adb shell 'echo 255 > /sys/devices/platform/leds-mt65xx/leds/lcd-backlight/brightness'
###############################
###############################
# install wallpaper
#adb pull /data/system/users/0/wallpaper
#adb pull /data/system/users/0/wallpaper_info.xml
echo "Setting wallpaper"
adb push android/wallpaper_info.xml /data/system/users/0/wallpaper_info.xml
adb push android/wallpaper /data/system/users/0/wallpaper
###############################
###############################
adb shell am force-stop com.android.settings
sleep 1
adb shell input keyevent KEYCODE_HOME
###############################
###############################
# set screen timeout to 30 minutes, when not plugged in
# note: maybe not needed any longer since we are replacing the global settings.db
echo "Setting screen timeout to 'never'"
#adb shell settings put system screen_off_timeout 2147483646
adb shell settings put system screen_off_timeout 360000
###############################
###############################
# disable screen swipe lock
echo "Disabling screen swipe to lock"
adb shell am force-stop com.android.settings
#sleep 1
adb shell input keyevent KEYCODE_HOME
#sleep 1
adb shell am start -a android.intent.action.MAIN -n com.android.settings/.SecuritySettings
#sleep 1
adb shell input swipe 100 100 100 500 100
#sleep 1
adb shell input keyevent KEYCODE_ENTER
#sleep 1
adb shell input keyevent KEYCODE_ENTER
#sleep 1
adb shell input keyevent KEYCODE_ENTER
#sleep 1
adb shell am force-stop com.android.settings
###############################
###############################
# run supersu so that the user gets prompted to update the app, which causes a reboot afterwards
# user should click OK to supersu update promps, IF a supersu update is needed.
# supersu updates survive a factory reset, so they only need to be done once per tablet
adb shell am start -W -a android.intent.action.MAIN -n eu.chainfire.supersu/.MainActivity
###############################
###############################
# and for good measure disable screen timeout while plugged in
# note: maybe not needed any longer since we are replacing the global settings.db
echo "Setting screen on when plugged in"
adb shell settings put global stay_on_while_plugged_in 3
###############################
###############################
# enable bluetooth
# echo "Enabling bluetooth"
adb shell service call bluetooth_manager 8
adb shell service call bluetooth_manager 6
###############################
###############################
# install androwish
echo "Installing Androwish"
adb install android/androwish.apk
###############################
###############################
# copy our source files over
#adb push /d/download/sync/de1plus /mnt/sdcard/de1plus
#if [ $de1plus = 0 ]
#then
# echo "Copying DE1 software"
# adb shell rm -rf /mnt/sdcard/de1
# adb push /d/download/sync/de1 /mnt/sdcard/de1
#else
echo "Copying DE1+ software"
adb shell rm -rf /mnt/sdcard/de1plus
adb push /d/download/sync/de1plus /mnt/sdcard/de1plus
#fi
###############################
###############################
# changes to global settings sqlite table
# turn global/bluetooth_on to 1
# global/device_name to "Decent Tablet"
# system/dim_screen 0
# system/screen_brightness 255
# secure/lockscreen.disabled 1
# secure/bluetooth_name "Decent Tablet"
# adb pull /data/data/com.android.providers.settings/databases/settings.db android/settings3a.db
echo "Replacing system settings"
adb push android/settings.db /data/data/com.android.providers.settings/databases/settings.db
###############################
###############################
# replace the launcher3 database with our own, which moves the icons where we want them and removes all tne toolbar noise of all those google icons
# adb pull /data/data/com.android.launcher3/databases/launcher.db android/launcher.db.de1
# adb pull /data/data/com.android.launcher3/databases/launcher.db android/launcher.db.de1plus
#
# optional: create our app icons with code
# note: need to manually drag the icons to their desired place
# note #2 : this is not needed since we are wiping out the launcher.db with our own in the next line. This script is only used
# to create the icons the first time, and then we use the sqlite table to restore them to a new tablet
# adb shell am start -n tk.tcl.wish/.AndroWishLauncher -a android.intent.action.ACTION_VIEW -e arg file:///mnt/sdcard/de1plus/create_de1plus_icon.tcl
# adb shell am start -n tk.tcl.wish/.AndroWishLauncher -a android.intent.action.ACTION_VIEW -e arg file:///sdcard/de1/create_de1_icon.tcl
#
#if [ $de1plus = 0 ]
#then
# echo "Replacing DE1 launcher settings"
# adb push android/launcher.db.de1 /data/data/com.android.launcher3/databases/launcher.db
#else
echo "Replacing DE1+ launcher settings"
adb push android/launcher.db.de1plus /data/data/com.android.launcher3/databases/launcher.db
#fi
###############################
###############################
# lower volume to zero
# from https://developer.android.com/reference/android/view/KeyEvent
adb shell input keyevent KEYCODE_VOLUME_DOWN
adb shell input keyevent KEYCODE_VOLUME_DOWN
adb shell input keyevent KEYCODE_VOLUME_DOWN
adb shell input keyevent KEYCODE_VOLUME_DOWN
adb shell input keyevent KEYCODE_VOLUME_DOWN
adb shell input keyevent KEYCODE_VOLUME_DOWN
adb shell input keyevent KEYCODE_VOLUME_DOWN
adb shell input keyevent KEYCODE_VOLUME_DOWN
adb shell input keyevent KEYCODE_VOLUME_DOWN
adb shell input keyevent KEYCODE_VOLUME_DOWN
###############################
###############################
# enable wifi
# note: maybe not needed any longer since we are replacing the global settings.db
#echo "Setting wifi on"
#adb shell settings put global wifi_on 1
adb shell settings put global wifi_on 0
adb shell settings put global wifi_scan_always_enabled 0
adb shell settings put global wifi_watchdog_on 0
adb shell svc wifi disable
###############################
###############################
echo "Rebooting tablet"
adb reboot
sleep 15
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 2; done; input keyevent 3'
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 2; done; input keyevent 3'
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 2; done; input keyevent 3'
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 2; done; input keyevent 3'
###############################
###############################
# pair with DE1 via bluetooth
#if [ $de1plus = 0 ]
#then
#echo "Auto-pairing with DE1"
#adb shell am start -W -n tk.tcl.wish/.AndroWishLauncher -a android.intent.action.ACTION_VIEW -e arg file:///sdcard/de1/autopair_with_de1.tcl
#else
#echo "Auto-pairing with DE1+"
#adb shell am start -W -n tk.tcl.wish/.AndroWishLauncher -a android.intent.action.ACTION_VIEW -e arg file:///sdcard/de1plus/autopair_with_de1plus.tcl
#fi
# wait for a few seconds seconds for this happen
#sleep 10
###############################
###############################
# pair with DE1 via bluetooth
# from https://android.stackexchange.com/questions/83726/how-to-adb-wait-for-device-until-the-home-screen-shows-up
#if [ $de1plus = 0 ]
#then
# echo "Launching DE1 tablet software for final testing"
# adb shell am start -W -n tk.tcl.wish/.AndroWishLauncher -a android.intent.action.ACTION_VIEW -e arg file:///sdcard/de1/de1.tcl
#else
echo "Launching DE1+ tablet software for final testing"
adb shell am start -W -n tk.tcl.wish/.AndroWishLauncher -a android.intent.action.ACTION_VIEW -e arg file:///sdcard/de1plus/de1plus.tcl
#fi
###############################
# update supersu binary
#adb reboot
#adb shell am force-stop com.android.launcher3
exit
###############################################################################################
# everything below is historical attempts and no longer used.
# todo: move icons to their rightful place?
#
# install wallpaper
adb shell am start -a android.app.WallpaperManager -c android.intent.ACTION_CHANGE_LIVE_WALLPAPER -d file:///mnt/sdcard/de1/wallpaper/spy_2560x1600.jpg -t 'image/jpeg' -e mimeType 'image/jpeg'
adb shell input tap 500 700
adb shell input tap 600 600
adb shell input tap 600 600
adb reboot
exit
adb shell uiautomator
adb shell input tap 200 200 & PIDTAP=$!
adb shell input swipe 200 200 200 100 1000 & PIDSWIPE=$!
wait $PIDTAP
wait $PIDSWIPE
# all keycodes
#http://thecodeartist.blogspot.hk/2011/03/simulating-keyevents-on-android-device.html
###################
# example - set FRENCH as the system language. The "swipe" command is the crucial one to get precisely right
adb shell input keyevent KEYCODE_HOME
adb shell am start -a android.intent.action.MAIN -n com.android.settings/.LanguageSettings
sleep 1
adb shell input keyevent KEYCODE_ENTER
sleep 1
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_ENTER
sleep 1
adb shell input keyevent KEYCODE_HOME
###################
###################
# example - set ENGLISH USA as the system language. The "swipe" command is the crucial one to get precisely right
adb shell input keyevent KEYCODE_HOME
adb shell am start -a android.intent.action.MAIN -n com.android.settings/.LanguageSettings
sleep 1
adb shell input keyevent KEYCODE_ENTER
sleep 1
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_DPAD_DOWN
adb shell input keyevent KEYCODE_ENTER
sleep 1
adb shell input keyevent KEYCODE_HOME
###################
adb shell am start tk.tcl.wish/.AndroWishLauncher --es "android.intent.extra.TEXT" "/sdcard/de1plus/create_de1plus_icon.tcl" -t "text/plain"
adb shell am start tk.tcl.wish/.AndroWishLauncher --es "android.intent.extra.TEXT" "/sdcard/de1plus/create_de1plus_icon.tcl" -t "text/plain"
adb shell am start tk.tcl.wish/.AndroWishLauncher --es "android.intent.extra.TEXT" "/sdcard/de1/create_de1_icon.tcl" -t "text/plain"
adb shell am start -n tk.tcl.wish/.AndroWishLauncher -a android.intent.action.ACTION_VIEW -e arg file:///sdcard/de1/create_de1_icon.tcl
adb shell am start -a "android.intent.action.SEND" --es "android.intent.extra.TEXT" "Hello World" -t "text/plain"
adb shell am start -a "android.intent.action.VIEW" -d "http://developer.android.com"
/sys/devices/platform/leds-mt65xx/leds/lcd-backlight
stty raw -echo ; ( echo "255" > /sys/devices/platform/leds-mt65xx/leds/lcd-backlight && exit ) | adb shell ; stty sane
stty raw -echo ; ( echo 255 > /sys/devices/platform/leds-mt65xx/leds/lcd-backlight/brightness ) | adb shell ; stty sane
adb push /tmp/1 /sys/devices/platform/leds-mt65xx/leds/lcd-backlight
adb push /tmp/brightness /sys/devices/platform/leds-mt65xx/leds/lcd-backlight/brightness
adb shell 'echo 255 > /sys/devices/platform/leds-mt65xx/leds/lcd-backlight/brightness'
adb shell input keyevent 26
adb shell input keyevent 82
adb shell settings put system screen_off_timeout 60000
adb shell settings put system screen_off_timeout 2147483646