-
Notifications
You must be signed in to change notification settings - Fork 60
/
android
338 lines (323 loc) · 9.87 KB
/
android
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
## Bash completion for the Android SDK tools.
##
## Copyright (c) 2009 Matt Brubeck
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included in
## all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
## THE SOFTWARE.
function _android()
{
local cur prev opts cmds type types c subcommand
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="--help --silent --verbose"
cmds="list create move delete update"
types="avd target project lib-project test-project sdk"
subcommand=""
type=""
# Look for the subcommand.
c=1
while [ $c -lt $COMP_CWORD ]; do
word="${COMP_WORDS[c]}"
for cmd in $cmds; do
if [ "$cmd" = "$word" ]; then
subcommand="$word"
fi
done
for w in $types; do
if [ "$w" = "$word" ]; then
type="$word"
fi
done
c=$((++c))
done
case "$subcommand $type" in
" ")
case "$cur" in
-*)
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
;;
esac
COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )
;;
"list ")
COMPREPLY=( $(compgen -W "avd target sdk" -- ${cur}) )
;;
"create "|"update ")
COMPREPLY=( $(compgen -W "avd project test-project lib-project" -- ${cur}) )
;;
"move "|"delete ")
COMPREPLY=( $(compgen -W "avd" -- ${cur}) )
;;
esac
case "$cur" in
-*)
case "$subcommand $type" in
"delete ")
COMPREPLY=( $(compgen -W "avd" -- ${cur}) )
;;
"create avd")
COMPREPLY=( $(compgen -W "--target --sdcard --path --name --force --skin --snapshot --abi" -- ${cur}) )
;;
"move avd")
COMPREPLY=( $(compgen -W "--path --name --rename" -- ${cur}) )
;;
"delete avd"|"update avd")
COMPREPLY=( $(compgen -W "--name" -- ${cur}) )
;;
"create project")
COMPREPLY=( $(compgen -W "--package --name --activity --target --path" -- ${cur}) )
;;
"create lib-project")
COMPREPLY=( $(compgen -W "--package --name --target --path" -- ${cur}) )
;;
"create test-project")
COMPREPLY=( $(compgen -W "--main --name --path" -- ${cur}) )
;;
"update project")
COMPREPLY=( $(compgen -W "--target --path --name --library --subprojects" -- ${cur}) )
;;
"update lib-project")
COMPREPLY=( $(compgen -W "--target --path" -- ${cur}) )
;;
"update test-project")
COMPREPLY=( $(compgen -W "--main --path" -- ${cur}) )
;;
esac
;;
esac
return 0
}
complete -o default -F _android android
function _adb()
{
local cur prev opts cmds c subcommand device_selected
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-d -e -s -p"
cmds="devices push pull sync shell emu logcat forward jdwp install sideload \
uninstall bugreport help version wait-for-device start-server \
reboot reboot-bootloader \
connect disconnect \
kill-server get-state get-serialno status-window remount root ppp backup restore"
cmds_not_need_device="devices help version start-server kill-server connect disconnect"
subcommand=""
device_selected=""
# Look for the subcommand.
c=1
while [ $c -lt $COMP_CWORD ]; do
word="${COMP_WORDS[c]}"
if [ "$word" = "-d" -o "$word" = "-e" -o "$word" = "-s" ]; then
device_selected=true
opts="-p"
fi
for cmd in $cmds; do
if [ "$cmd" = "$word" ]; then
subcommand="$word"
fi
done
c=$((++c))
done
case "${subcommand}" in
'')
case "${prev}" in
-p)
return 0;
;;
-s)
# Use 'adb devices' to list serial numbers.
COMPREPLY=( $(compgen -W "$(adb devices |
awk '/(device|recovery|sideload)$/{print $1}')" -- ${cur} ) )
return 0
;;
esac
case "${cur}" in
-*)
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
return 0
;;
esac
if [ -z "$device_selected" ]; then
local num_devices=$(( $(adb devices 2>/dev/null|wc -l) - 2 ))
if [ "$num_devices" -gt "1" ]; then
# With multiple devices, you must choose a device first.
COMPREPLY=( $(compgen -W "${opts} ${cmds_not_need_device}" -- ${cur}) )
return 0
fi
fi
COMPREPLY=( $(compgen -W "${cmds}" -- ${cur}) )
return 0
;;
disconnect)
# Use 'adb devices' to list serial numbers.
COMPREPLY=( $(compgen -W "$(adb devices |
awk '/(device|recovery|sideload|offline|unauthorized)$/{print $1}')" -- ${cur} ) )
return 0
;;
install)
case "${cur}" in
-*)
COMPREPLY=( $(compgen -W "-l -r -s" -- ${cur}) )
return 0
;;
esac
;;
forward)
# Filename or installation option.
COMPREPLY=( $(compgen -W "tcp: localabstract: localreserved: localfilesystem: dev: jdwp:" -- ${cur}) )
return 0
;;
uninstall)
case "${cur}" in
-*)
COMPREPLY=( $(compgen -W "-k" -- ${cur}) )
return 0
;;
esac
;;
logcat)
case "${cur}" in
-*)
COMPREPLY=( $(compgen -W "-v -b -c -d -f -g -n -r -s" -- ${cur}) )
return 0
;;
esac
case "${prev}" in
-v)
COMPREPLY=( $(compgen -W "brief process tag thread raw time long" -- ${cur}) )
return 0
;;
-b)
COMPREPLY=( $(compgen -W "radio events main" -- ${cur}) )
return 0
;;
esac
;;
backup)
case "${cur}" in
-*)
COMPREPLY=( $(compgen -W "-f -apk -noapk -obb -noobb -shared -noshared -all -system -nosystem" -- ${cur}) )
return 0
;;
esac
;;
esac
}
complete -o default -F _adb adb
function _fastboot()
{
local cur prev opts cmds c subcommand device_selected
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-w -s -p -c -i -b -n"
cmds="update flashall flash erase getvar boot devices \
reboot reboot-bootloader oem continue"
subcommand=""
partition_list="boot recovery system userdata bootloader radio"
device_selected=""
# Look for the subcommand.
c=1
while [ $c -lt $COMP_CWORD ]; do
word="${COMP_WORDS[c]}"
if [ "$word" = "-s" ]; then
device_selected=true
fi
for cmd in $cmds; do
if [ "$cmd" = "$word" ]; then
subcommand="$word"
fi
done
c=$((++c))
done
case "${subcommand}" in
'')
case "${prev}" in
-s)
# Use 'fastboot devices' to list serial numbers.
COMPREPLY=( $(compgen -W "$(fastboot devices|cut -f1)" -- ${cur} ) )
return 0
;;
esac
case "${cur}" in
-*)
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
return 0
;;
esac
if [ -z "$device_selected" ]; then
local num_devices=$(( $(fastboot devices 2>/dev/null|wc -l) ))
if [ "$num_devices" -gt "1" ]; then
# With multiple devices, you must choose a device first.
COMPREPLY=( $(compgen -W "-s" -- ${cur}) )
return 0
fi
fi
COMPREPLY=( $(compgen -W "${cmds}" -- ${cur}) )
return 0
;;
flash)
# partition name
COMPREPLY=( $(compgen -W "${partition_list}" -- ${cur}) )
return 0
;;
erase)
# partition name
COMPREPLY=( $(compgen -W "${partition_list}" -- ${cur}) )
return 0
;;
esac
}
complete -o default -F _fastboot fastboot
function _emulator()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-system -datadir -kernel -ramdisk -init-data -data -partition-size -cache \
-no-cache -sdcard -wipe-data -avd -skindir -skin -no-skin -memory -netspeed -netdelay \
-netfast -trace -show-kernel -shell -no-jni -logcat -no-audio -audio \
-audio-in -audio-out -raw-keys -radio -port -ports -onion -onion-alpha \
-onion-rotation -scale -dpi-device -http-proxy -timezone -dns-server \
-cpu-delay -no-boot-anim -no-window -version -report-console -gps -keyset \
-shell-serial -old-system -tcpdump -bootchart -nand-limits -qemu -verbose -debug -help \
-help-disk-images -help-keys -help-debug-tags -help-char-devices \
-help-environment -help-keyset-file -help-virtual-device -help-sdk-images \
-help-build-images -help-all"
case "$prev" in
-avd)
COMPREPLY=( $(compgen -W "$(find ~/.android/avd -maxdepth 1 -name '*.ini' -exec basename {} .ini \;)" -- ${cur}) )
return 0
;;
esac
case "$cur" in
@*)
COMPREPLY=( $(compgen -P @ -W "$(find ~/.android/avd -maxdepth 1 -name '*.ini' -exec basename {} .ini \;)" -- ${cur:1} ) )
return 0
;;
esac
case "$cur" in
-*)
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
return 0
;;
esac
}
complete -o default -F _emulator emulator