blob: cbca332c710bdc0cad33328c7fd0684c31c77129 [file] [log] [blame]
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001#include "android/help.h"
2#include "android/cmdline-option.h"
3#include "android/utils/path.h"
4#include "android/utils/bufprint.h"
5#include "android/utils/debug.h"
6#include "android/utils/misc.h"
7#include "android/skin/keyset.h"
David 'Digit' Turner318e4f22009-05-25 18:01:03 +02008#include "android/boot-properties.h"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08009#include "android/android.h"
10#include <stdint.h>
11#include "audio/audio.h"
12#include <string.h>
13#include <stdlib.h>
14
15/* XXX: TODO: put most of the help stuff in auto-generated files */
16
17#define PRINTF(...) stralloc_add_format(out,__VA_ARGS__)
18
19static void
20help_virtual_device( stralloc_t* out )
21{
22 PRINTF(
23 " An Android Virtual Device (AVD) models a single virtual\n"
24 " device running the Android platform that has, at least, its own\n"
25 " kernel, system image and data partition.\n\n"
26
27 " Only one emulator process can run a given AVD at a time, but\n"
28 " you can create several AVDs and run them concurrently.\n\n"
29
30 " You can invoke a given AVD at startup using either '-avd <name>'\n"
31 " or '@<name>', both forms being equivalent. For example, to launch\n"
32 " the AVD named 'foo', type:\n\n"
33
34 " emulator @foo\n\n"
35
36 " The 'android' helper tool can be used to manage virtual devices.\n"
37 " For example:\n\n"
38
David Turnerb58c44e2009-03-25 02:42:45 -070039 " android create avd -n <name> -t 1 # creates a new virtual device.\n"
40 " android list avd # list all virtual devices available.\n\n"
41
42 " Try 'android --help' for more commands.\n\n"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080043
44 " Each AVD really corresponds to a content directory which stores\n"
45 " persistent and writable disk images as well as configuration files.\n"
46
47 " Each AVD must be created against an existing SDK platform or add-on.\n"
48 " For more information on this topic, see -help-sdk-images.\n\n"
49
50 " SPECIAL NOTE: in the case where you are *not* using the emulator\n"
51 " with the Android SDK, but with the Android build system, you will\n"
52 " need to define the ANDROID_PRODUCT_OUT variable in your environment.\n"
53 " See -help-build-images for the details.\n"
54 );
55}
56
57
58static void
59help_sdk_images( stralloc_t* out )
60{
61 PRINTF(
62 " The Android SDK now supports multiple versions of the Android platform.\n"
63 " Each SDK 'platform' corresponds to:\n\n"
64
65 " - a given version of the Android API.\n"
66 " - a set of corresponding system image files.\n"
67 " - build and configuration properties.\n"
68 " - an android.jar file used when building your application.\n"
69 " - skins.\n\n"
70
71 " The Android SDK also supports the concept of 'add-ons'. Each add-on is\n"
72 " based on an existing platform, and provides replacement or additional\n"
73 " image files, android.jar, hardware configuration options and/or skins.\n\n"
74
75 " The purpose of add-ons is to allow vendors to provide their own customized\n"
76 " system images and APIs without needing to package a complete SDK.\n\n"
77
78 " Before using the SDK, you need to create an Android Virtual Device (AVD)\n"
79 " (see -help-virtual-device for details). Each AVD is created in reference\n"
80 " to a given SDK platform *or* add-on, and will search the corresponding\n"
81 " directories for system image files, in the following order:\n\n"
82
83 " - in the AVD's content directory.\n"
84 " - in the AVD's SDK add-on directory, if any.\n"
85 " - in the AVD's SDK platform directory, if any.\n\n"
86
87 " The image files are documented in -help-disk-images. By default, an AVD\n"
88 " content directory will contain the following persistent image files:\n\n"
89
90 " userdata-qemu.img - the /data partition image file\n"
91 " cache.img - the /cache partition image file\n\n"
92
93 " You can use -wipe-data to re-initialize the /data partition to its factory\n"
94 " defaults. This will erase all user settings for the virtual device.\n\n"
95 );
96}
97
98static void
99help_build_images( stralloc_t* out )
100{
101 PRINTF(
102 " The emulator detects that you are working from the Android build system\n"
103 " by looking at the ANDROID_PRODUCT_OUT variable in your environment.\n\n"
104
105 " If it is defined, it should point to the product-specific directory that\n"
106 " contains the generated system images.\n"
107
108 " In this case, the emulator will look by default for the following image\n"
109 " files there:\n\n"
110
111 " - system.img : the *initial* system image.\n"
112 " - ramdisk.img : the ramdisk image used to boot the system.\n"
113 " - userdata.img : the *initial* user data image (see below).\n"
114 " - kernel-qemu : the emulator-specific Linux kernel image.\n\n"
115
116 " If the kernel image is not found in the out directory, then it is searched\n"
117 " in <build-root>/prebuilt/android-arm/kernel/.\n\n"
118
Xavier Ducrohet5bc61822009-11-20 12:24:17 -0800119 " Skins will be looked in <build-root>/sdk/emulator/skins/\n\n"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800120
121 " You can use the -sysdir, -system, -kernel, -ramdisk, -datadir, -data options\n"
122 " to specify different search directories or specific image files. You can\n"
San Mehat68a8f7b2009-12-05 09:54:44 -0800123 " also use the -cache, -sdcard, and -sdcard2 options to indicate specific \n"
124 " cache partition and SD Card image files.\n\n"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800125
126 " For more details, see the corresponding -help-<option> section.\n\n"
127
128 " Note that the following behaviour is specific to 'build mode':\n\n"
129
130 " - the *initial* system image is copied to a temporary file which is\n"
131 " automatically removed when the emulator exits. There is thus no way to\n"
132 " make persistent changes to this image through the emulator, even if\n"
133 " you use the '-image <file>' option.\n\n"
134
135 " - unless you use the '-cache <file>' option, the cache partition image\n"
136 " is backed by a temporary file that is initially empty and destroyed on\n"
137 " program exit.\n\n"
138
139 " SPECIAL NOTE: If you are using the emulator with the Android SDK, the\n"
140 " information above doesn't apply. See -help-sdk-images for more details.\n"
141 );
142}
143
144static void
145help_disk_images( stralloc_t* out )
146{
147 char datadir[256];
148
149 bufprint_config_path( datadir, datadir + sizeof(datadir) );
150
151 PRINTF(
152 " The emulator needs several key image files to run appropriately.\n"
153 " Their exact location depends on whether you're using the emulator\n"
154 " from the Android SDK, or not (more details below).\n\n"
155
156 " The minimal required image files are the following:\n\n"
157
158 " kernel-qemu the emulator-specific Linux kernel image\n"
159 " ramdisk.img the ramdisk image used to boot the system\n"
160 " system.img the *initial* system image\n"
161 " userdata.img the *initial* data partition image\n\n"
162
163 " It will also use the following writable image files:\n\n"
164
165 " userdata-qemu.img the persistent data partition image\n"
166 " system-qemu.img an *optional* persistent system image\n"
167 " cache.img an *optional* cache partition image\n"
168 " sdcard.img an *optional* SD Card partition image\n\n"
San Mehat68a8f7b2009-12-05 09:54:44 -0800169 " sdcard2.img an *optional* second SD Card partition image\n\n"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800170
171 " If you use a virtual device, its content directory should store\n"
172 " all writable images, and read-only ones will be found from the\n"
173 " corresponding platform/add-on directories. See -help-sdk-images\n"
174 " for more details.\n\n"
175
176 " If you are building from the Android build system, you should\n"
177 " have ANDROID_PRODUCT_OUT defined in your environment, and the\n"
178 " emulator shall be able to pick-up the right image files automatically.\n"
179 " See -help-build-images for more details.\n\n"
180
181 " If you're neither using the SDK or the Android build system, you\n"
182 " can still run the emulator by explicitely providing the paths to\n"
183 " *all* required disk images through a combination of the following\n"
184 " options: -sysdir, -datadir, -kernel, -ramdisk, -system, -data, -cache\n"
San Mehat68a8f7b2009-12-05 09:54:44 -0800185 " -sdcard, and -sdcard2\n\n"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800186
187 " The actual logic being that the emulator should be able to find all\n"
188 " images from the options you give it.\n\n"
189
190 " For more detail, see the corresponding -help-<option> entry.\n\n"
191
192 " Other related options are:\n\n"
193
194 " -init-data Specify an alernative *initial* user data image\n\n"
195
196 " -wipe-data Copy the content of the *initial* user data image\n"
197 " (userdata.img) into the writable one (userdata-qemu.img)\n\n"
198
199 " -no-cache do not use a cache partition, even if one is\n"
200 " available.\n\n"
201 ,
202 datadir );
203}
204
205static void
206help_keys(stralloc_t* out)
207{
208 int pass, maxw = 0;
209
210 stralloc_add_str( out, " When running the emulator, use the following keypresses:\n\n");
211
212 if (!android_keyset)
213 android_keyset = skin_keyset_new_from_text( skin_keyset_get_default() );
214
215 for (pass = 0; pass < 2; pass++) {
216 SkinKeyCommand cmd;
217
218 for (cmd = SKIN_KEY_COMMAND_NONE+1; cmd < SKIN_KEY_COMMAND_MAX; cmd++)
219 {
220 SkinKeyBinding bindings[ SKIN_KEY_COMMAND_MAX_BINDINGS ];
221 int n, count, len;
222 char temp[32], *p = temp, *end = p + sizeof(temp);
223
224 count = skin_keyset_get_bindings( android_keyset, cmd, bindings );
225 if (count <= 0)
226 continue;
227
228 for (n = 0; n < count; n++) {
229 p = bufprint(p, end, "%s%s", (n == 0) ? "" : ", ",
230 skin_key_symmod_to_str( bindings[n].sym, bindings[n].mod ) );
231 }
232
233 if (pass == 0) {
234 len = strlen(temp);
235 if (len > maxw)
236 maxw = len;
237 } else {
238 PRINTF( " %-*s %s\n", maxw, temp, skin_key_command_description(cmd) );
239 }
240 }
241 }
242 PRINTF( "\n" );
243 PRINTF( " note that NumLock must be deactivated for keypad keys to work\n\n" );
244}
245
246
247static void
248help_environment(stralloc_t* out)
249{
250 PRINTF(
251 " The Android emulator looks at various environment variables when it starts:\n\n"
252
253 " If ANDROID_LOG_TAGS is defined, it will be used as in '-logcat <tags>'.\n\n"
254
255 " If 'http_proxy' is defined, it will be used as in '-http-proxy <proxy>'.\n\n"
256
257 " If ANDROID_VERBOSE is defined, it can contain a comma-separated list of\n"
258 " verbose items. for example:\n\n"
259
260 " ANDROID_VERBOSE=socket,radio\n\n"
261
262 " is equivalent to using the '-verbose -verbose-socket -verbose-radio'\n"
263 " options together. unsupported items will be ignored.\n\n"
264
265 " If ANDROID_LOG_TAGS is defined, it will be used as in '-logcat <tags>'.\n\n"
266
267 " If ANDROID_SDK_HOME is defined, it indicates the path of the '.android'\n"
268 " directory which contains the SDK user data (Android Virtual Devices,\n"
269 " DDMS preferences, key stores, etc.).\n\n"
270
271 " If ANDROID_SDK_ROOT is defined, it indicates the path of the SDK\n"
272 " installation directory.\n\n"
273
274 );
275}
276
277
278static void
279help_keyset_file(stralloc_t* out)
280{
281 int n, count;
282 const char** strings;
283 char temp[MAX_PATH];
284
285 PRINTF(
286 " on startup, the emulator looks for 'keyset' file that contains the\n"
287 " configuration of key-bindings to use. the default location on this\n"
288 " system is:\n\n"
289 );
290
291 bufprint_config_file( temp, temp+sizeof(temp), KEYSET_FILE );
292 PRINTF( " %s\n\n", temp );
293
294 PRINTF(
295 " if the file doesn't exist, the emulator writes one containing factory\n"
296 " defaults. you are then free to modify it to suit specific needs.\n\n"
297 " this file shall contain a list of text lines in the following format:\n\n"
298
299 " <command> [<modifiers>]<key>\n\n"
300
301 " where <command> is an emulator-specific command name, i.e. one of:\n\n"
302 );
303
304 count = SKIN_KEY_COMMAND_MAX-1;
305 strings = calloc( count, sizeof(char*) );
306 for (n = 0; n < count; n++)
307 strings[n] = skin_key_command_to_str(n+1);
308
309 stralloc_tabular( out, strings, count, " ", 80-8 );
310 free(strings);
311
312 PRINTF(
313 "\n"
314 " <modifers> is an optional list of <modifier> elements (without separators)\n"
315 " which can be one of:\n\n"
316
317 " Ctrl- Left Control Key\n"
318 " Shift- Left Shift Key\n"
319 " Alt- Left Alt key\n"
320 " RCtrl- Right Control Key\n"
321 " RShift- Right Shift Key\n"
322 " RAlt- Right Alt key (a.k.a AltGr)\n"
323 "\n"
324 " finally <key> is a QWERTY-specific keyboard symbol which can be one of:\n\n"
325 );
326 count = skin_keysym_str_count();
327 strings = calloc( count, sizeof(char*) );
328 for (n = 0; n < count; n++)
329 strings[n] = skin_keysym_str(n);
330
331 stralloc_tabular( out, strings, count, " ", 80-8 );
332 free(strings);
333
334 PRINTF(
335 "\n"
336 " case is not significant, and a single command can be associated to up\n"
337 " to %d different keys. to bind a command to multiple keys, use commas to\n"
338 " separate them. here are some examples:\n\n",
339 SKIN_KEY_COMMAND_MAX_BINDINGS );
340
341 PRINTF(
342 " TOGGLE_NETWORK F8 # toggle the network on/off\n"
343 " CHANGE_LAYOUT_PREV Keypad_7,Ctrl-J # switch to a previous skin layout\n"
344 "\n"
345 );
346}
347
348
349static void
350help_debug_tags(stralloc_t* out)
351{
352 int n;
353
354#define _VERBOSE_TAG(x,y) { #x, VERBOSE_##x, y },
355 static const struct { const char* name; int flag; const char* text; }
356 verbose_options[] = {
357 VERBOSE_TAG_LIST
358 { 0, 0, 0 }
359 };
360#undef _VERBOSE_TAG
361
362 PRINTF(
363 " the '-debug <tags>' option can be used to enable or disable debug\n"
364 " messages from specific parts of the emulator. <tags> must be a list\n"
365 " (separated by space/comma/column) of <component> names, which can be one of:\n\n"
366 );
367
368 for (n = 0; n < VERBOSE_MAX; n++)
369 PRINTF( " %-12s %s\n", verbose_options[n].name, verbose_options[n].text );
370 PRINTF( " %-12s %s\n", "all", "all components together\n" );
371
372 PRINTF(
373 "\n"
374 " each <component> can be prefixed with a single '-' to indicate the disabling\n"
375 " of its debug messages. for example:\n\n"
376
377 " -debug all,-socket,-keys\n\n"
378
379 " enables all debug messages, except the ones related to network sockets\n"
380 " and key bindings/presses\n\n"
381 );
382}
383
384static void
385help_char_devices(stralloc_t* out)
386{
387 PRINTF(
388 " various emulation options take a <device> specification that can be used to\n"
389 " specify something to hook to an emulated device or communication channel.\n"
390 " here is the list of supported <device> specifications:\n\n"
391
392 " stdio\n"
393 " standard input/output. this may be subject to character\n"
394 " translation (e.g. LN <=> CR/LF)\n\n"
395
396 " COM<n> [Windows only]\n"
397 " where <n> is a digit. host serial communication port.\n\n"
398
399 " pipe:<filename>\n"
400 " named pipe <filename>\n\n"
401
402 " file:<filename>\n"
403 " write output to <filename>, no input can be read\n\n"
404
405 " pty [Linux only]\n"
406 " pseudo TTY (a new PTY is automatically allocated)\n\n"
407
408 " /dev/<file> [Unix only]\n"
409 " host char device file, e.g. /dev/ttyS0. may require root access\n\n"
410
411 " /dev/parport<N> [Linux only]\n"
412 " use host parallel port. may require root access\n\n"
413
414 " unix:<path>[,server][,nowait]] [Unix only]\n"
415 " use a Unix domain socket. if you use the 'server' option, then\n"
416 " the emulator will create the socket and wait for a client to\n"
417 " connect before continuing, unless you also use 'nowait'\n\n"
418
419 " tcp:[<host>]:<port>[,server][,nowait][,nodelay]\n"
420 " use a TCP socket. 'host' is set to localhost by default. if you\n"
421 " use the 'server' option will bind the port and wait for a client\n"
422 " to connect before continuing, unless you also use 'nowait'. the\n"
423 " 'nodelay' option disables the TCP Nagle algorithm\n\n"
424
425 " telnet:[<host>]:<port>[,server][,nowait][,nodelay]\n"
426 " similar to 'tcp:' but uses the telnet protocol instead of raw TCP\n\n"
427
428 " udp:[<remote_host>]:<remote_port>[@[<src_ip>]:<src_port>]\n"
429 " send output to a remote UDP server. if 'remote_host' is no\n"
430 " specified it will default to '0.0.0.0'. you can also receive input\n"
431 " through UDP by specifying a source address after the optional '@'.\n\n"
432
433 " fdpair:<fd1>,<fd2> [Unix only]\n"
434 " redirection input and output to a pair of pre-opened file\n"
435 " descriptors. this is mostly useful for scripts and other\n"
436 " programmatic launches of the emulator.\n\n"
437
438 " none\n"
439 " no device connected\n\n"
440
441 " null\n"
442 " the null device (a.k.a /dev/null on Unix, or NUL on Win32)\n\n"
443
444 " NOTE: these correspond to the <device> parameter of the QEMU -serial option\n"
445 " as described on http://bellard.org/qemu/qemu-doc.html#SEC10\n\n"
446 );
447}
448
449static void
450help_avd(stralloc_t* out)
451{
452 PRINTF(
David Turnerb58c44e2009-03-25 02:42:45 -0700453 " use '-avd <name>' to start the emulator program with a given Android\n"
454 " Virtual Device (a.k.a. AVD), where <name> must correspond to the name\n"
455 " of one of the existing AVDs available on your host machine.\n\n"
456
457 "See -help-virtual-device to learn how to create/list/manage AVDs.\n\n"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800458
459 " As a special convenience, using '@<name>' is equivalent to using\n"
460 " '-avd <name>'.\n\n"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800461 );
462}
463
464static void
465help_sysdir(stralloc_t* out)
466{
467 char systemdir[MAX_PATH];
468 char *p = systemdir, *end = p + sizeof(systemdir);
469
470 p = bufprint_app_dir( p, end );
471 p = bufprint( p, end, PATH_SEP "lib" PATH_SEP "images" );
472
473 PRINTF(
474 " use '-sysdir <dir>' to specify a directory where system read-only\n"
475 " image files will be searched. on this system, the default directory is:\n\n"
476 " %s\n\n", systemdir );
477
478 PRINTF(
479 " see '-help-disk-images' for more information about disk image files\n\n" );
480}
481
482static void
483help_datadir(stralloc_t* out)
484{
485 char datadir[MAX_PATH];
486
487 bufprint_config_path(datadir, datadir + sizeof(datadir));
488
489 PRINTF(
490 " use '-datadir <dir>' to specify a directory where writable image files\n"
491 " will be searched. on this system, the default directory is:\n\n"
492 " %s\n\n", datadir );
493
494 PRINTF(
495 " see '-help-disk-images' for more information about disk image files\n\n" );
496}
497
498static void
499help_kernel(stralloc_t* out)
500{
501 PRINTF(
502 " use '-kernel <file>' to specify a Linux kernel image to be run.\n"
503 " the default image is 'kernel-qemu' from the system directory.\n\n"
504
505 " you can use '-debug-kernel' to see debug messages from the kernel\n"
506 " to the terminal\n\n"
507
508 " see '-help-disk-images' for more information about disk image files\n\n"
509 );
510}
511
512static void
513help_ramdisk(stralloc_t* out)
514{
515 PRINTF(
516 " use '-ramdisk <file>' to specify a Linux ramdisk boot image to be run in\n"
517 " the emulator. the default image is 'ramdisk.img' from the system directory.\n\n"
518
519 " see '-help-disk-images' for more information about disk image files\n\n"
520 );
521}
522
523static void
524help_system(stralloc_t* out)
525{
526 PRINTF(
527 " use '-system <file>' to specify the intial system image that will be loaded.\n"
528 " the default image is 'system.img' from the system directory.\n\n"
529
530 " NOTE: In previous releases of the Android SDK, this option was named '-image'.\n"
531 " And using '-system <path>' was equivalent to using '-sysdir <path>' now.\n\n"
532
533 " see '-help-disk-images' for more information about disk image files\n\n"
534 );
535}
536
537static void
538help_image(stralloc_t* out)
539{
540 PRINTF(
541 " This option is obsolete, you should use '-system <file>' instead to point\n"
542 " to the initial system image.\n\n"
543
544 " see '-help-disk-images' for more information about disk image files\n\n"
545 );
546}
547
548static void
549help_init_data(stralloc_t* out)
550{
551 PRINTF(
552 " use '-init-data <file>' to specify an *init* /data partition file.\n"
553 " it is only used when creating a new writable /data image file, or\n"
554 " when you use '-wipe-data' to reset it. the default is 'userdata.img'\n"
555 " from the system directory.\n\n"
556
557 " see '-help-disk-images' for more information about disk image files\n\n"
558 );
559}
560
561static void
562help_data(stralloc_t* out)
563{
564 PRINTF(
565 " use '-data <file>' to specify a different /data partition image file.\n\n"
566
567 " see '-help-disk-images' for more information about disk image files\n\n"
568 );
569}
570
571static void
572help_wipe_data(stralloc_t* out)
573{
574 PRINTF(
575 " use '-wipe-data' to reset your /data partition image to its factory\n"
576 " defaults. this removes all installed applications and settings.\n\n"
577
578 " see '-help-disk-images' for more information about disk image files\n\n"
579 );
580}
581
582static void
583help_cache(stralloc_t* out)
584{
585 PRINTF(
586 " use '-cache <file>' to specify a /cache partition image. if <file> does\n"
587 " not exist, it will be created empty. by default, the cache partition is\n"
588 " backed by a temporary file that is deleted when the emulator exits.\n"
589 " using the -cache option allows it to be persistent.\n\n"
590
591 " the '-no-cache' option can be used to disable the cache partition.\n\n"
592
593 " see '-help-disk-images' for more information about disk image files\n\n"
594 );
595}
596
597static void
598help_no_cache(stralloc_t* out)
599{
600 PRINTF(
601 " use '-no-cache' to disable the cache partition in the emulated system.\n"
602 " the cache partition is optional, but when available, is used by the browser\n"
603 " to cache web pages and images\n\n"
604
605 " see '-help-disk-images' for more information about disk image files\n\n"
606 );
607}
608
609static void
610help_sdcard(stralloc_t* out)
611{
612 PRINTF(
613 " use '-sdcard <file>' to specify a SD Card image file that will be attached\n"
614 " to the emulator. By default, the 'sdcard.img' file is searched in the data\n"
615 " directory.\n\n"
616
617 " if the file does not exist, the emulator will still start, but without an\n"
618 " attached SD Card.\n\n"
619
620 " see '-help-disk-images' for more information about disk image files\n\n"
621 );
622}
623
624static void
San Mehat68a8f7b2009-12-05 09:54:44 -0800625help_sdcard2(stralloc_t* out)
626{
627 PRINTF(
628 " use '-sdcard2 <file>' to specify a second SD Card image file that will be attached\n"
629 " to the emulator. By default, the 'sdcard.img' file is searched in the data\n"
630 " directory.\n\n"
631
632 " if the file does not exist, the emulator will still start, but without a\n"
633 " second SD Card attached.\n\n"
634
635 " see '-help-disk-images' for more information about disk image files\n\n"
636 );
637}
638
639static void
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800640help_skindir(stralloc_t* out)
641{
642 PRINTF(
643 " use '-skindir <dir>' to specify a directory that will be used to search\n"
644 " for emulator skins. each skin must be a subdirectory of <dir>. by default\n"
645 " the emulator will look in the 'skins' sub-directory of the system directory\n\n"
646
647 " the '-skin <name>' option is required when -skindir is used.\n"
648 );
649}
650
651static void
652help_skin(stralloc_t* out)
653{
654 PRINTF(
655 " use '-skin <skin>' to specify an emulator skin, each skin corresponds to\n"
656 " the visual appearance of a given device, including buttons and keyboards,\n"
657 " and is stored as subdirectory <skin> of the skin root directory\n"
658 " (see '-help-skindir')\n\n" );
659
660 PRINTF(
661 " note that <skin> can also be '<width>x<height>' (e.g. '320x480') to\n"
662 " specify an exact framebuffer size, without any visual ornaments.\n\n" );
663}
664
665/* default network settings for emulator */
666#define DEFAULT_NETSPEED "full"
667#define DEFAULT_NETDELAY "none"
668
669static void
670help_shaper(stralloc_t* out)
671{
672 int n;
673
674 PRINTF(
675 " the Android emulator supports network throttling, i.e. slower network\n"
676 " bandwidth as well as higher connection latencies. this is done either through\n"
677 " skin configuration, or with '-netspeed <speed>' and '-netdelay <delay>'.\n\n"
678
679 " the format of -netspeed is one of the following (numbers are kbits/s):\n\n" );
680
681 for (n = 0; android_netspeeds[n].name != NULL; n++) {
682 PRINTF( " -netspeed %-12s %-15s (up: %.1f, down: %.1f)\n",
683 android_netspeeds[n].name,
684 android_netspeeds[n].display,
685 android_netspeeds[n].upload/1000.,
686 android_netspeeds[n].download/1000. );
687 }
688 PRINTF( "\n" );
689 PRINTF( " -netspeed %-12s %s", "<num>", "select both upload and download speed\n");
690 PRINTF( " -netspeed %-12s %s", "<up>:<down>", "select individual up and down speed\n");
691
692 PRINTF( "\n The format of -netdelay is one of the following (numbers are msec):\n\n" );
693 for (n = 0; android_netdelays[n].name != NULL; n++) {
694 PRINTF( " -netdelay %-10s %-15s (min %d, max %d)\n",
695 android_netdelays[n].name, android_netdelays[n].display,
696 android_netdelays[n].min_ms, android_netdelays[n].max_ms );
697 }
698 PRINTF( " -netdelay %-10s %s", "<num>", "select exact latency\n");
699 PRINTF( " -netdelay %-10s %s", "<min>:<max>", "select min and max latencies\n\n");
700
701 PRINTF( " the emulator uses the following defaults:\n\n" );
702 PRINTF( " Default network speed is '%s'\n", DEFAULT_NETSPEED);
703 PRINTF( " Default network latency is '%s'\n\n", DEFAULT_NETDELAY);
704}
705
706static void
707help_http_proxy(stralloc_t* out)
708{
709 PRINTF(
710 " the Android emulator allows you to redirect all TCP connections through\n"
711 " a HTTP/HTTPS proxy. this can be enabled by using the '-http-proxy <proxy>'\n"
712 " option, or by defining the 'http_proxy' environment variable.\n\n"
713
714 " <proxy> can be one of the following:\n\n"
715 " http://<server>:<port>\n"
716 " http://<username>:<password>@<server>:<port>\n\n"
717
718 " the 'http://' prefix can be omitted. If '-http-proxy <proxy>' is not used,\n"
719 " the 'http_proxy' environment variable is looked up and any value matching\n"
720 " the <proxy> format will be used automatically\n\n" );
721}
722
723static void
724help_report_console(stralloc_t* out)
725{
726 PRINTF(
727 " the '-report-console <socket>' option can be used to report the\n"
728 " automatically-assigned console port number to a remote third-party\n"
729 " before starting the emulation. <socket> must be in one of these\n"
730 " formats:\n\n"
731
732 " tcp:<port>[,server][,max=<seconds>]\n"
733 " unix:<path>[,server][,max=<seconds>]\n"
734 "\n"
735 " if the 'server' option is used, the emulator opens a server socket\n"
736 " and waits for an incoming connection to it. by default, it will instead\n"
737 " try to make a normal client connection to the socket, and, in case of\n"
738 " failure, will repeat this operation every second for 10 seconds.\n"
739 " the 'max=<seconds>' option can be used to modify the timeout\n\n"
740
741 " when the connection is established, the emulator sends its console port\n"
742 " number as text to the remote third-party, then closes the connection and\n"
743 " starts the emulation as usual. *any* failure in the process described here\n"
744 " will result in the emulator aborting immediately\n\n"
745
746 " as an example, here's a small Unix shell script that starts the emulator in\n"
747 " the background and waits for its port number with the help of the 'netcat'\n"
748 " utility:\n\n"
749
750 " MYPORT=5000\n"
751 " emulator -no-window -report-console tcp:$MYPORT &\n"
752 " CONSOLEPORT=`nc -l localhost $MYPORT`\n"
753 "\n"
754 );
755}
756
757static void
758help_dpi_device(stralloc_t* out)
759{
760 PRINTF(
761 " use '-dpi-device <dpi>' to specify the screen resolution of the emulated\n"
762 " device. <dpi> must be an integer between 72 and 1000. the default is taken\n"
763 " from the skin, if available, or uses the contant value %d (an average of\n"
764 " several prototypes used during Android development).\n\n", DEFAULT_DEVICE_DPI );
765
766 PRINTF(
767 " the device resolution can also used to rescale the emulator window with\n"
768 " the '-scale' option (see -help-scale)\n\n"
769 );
770}
771
772static void
773help_audio(stralloc_t* out)
774{
775 PRINTF(
776 " the '-audio <backend>' option allows you to select a specific backend\n"
777 " to be used to both play and record audio in the Android emulator.\n\n"
778
779 " this is equivalent to calling both '-audio-in <backend>' and\n"
780 " '-audio-out <backend>' at the same time.\n\n"
781
782 " use '-help-audio-out' to see a list of valid output <backend> values.\n"
783 " use '-help-audio-in' to see a list of valid input <backend> values.\n"
784 " use '-audio none' to disable audio completely.\n\n"
785 );
786}
787
788static void
789help_audio_out(stralloc_t* out)
790{
791 int nn;
792
793 PRINTF(
794 " the '-audio-out <backend>' option allows you to select a specific\n"
795 " backend to play audio in the Android emulator. this is mostly useful\n"
796 " on Linux\n\n"
797
798 " on this system, output <backend> can be one of the following:\n\n"
799 );
800 for ( nn = 0; ; nn++ ) {
801 const char* descr;
802 const char* name = audio_get_backend_name( 0, nn, &descr );
803 if (name == NULL)
804 break;
805 PRINTF( " %-10s %s\n", name, descr );
806 }
807 PRINTF( "\n" );
808}
809
810static void
811help_audio_in(stralloc_t* out)
812{
813 int nn;
814
815 PRINTF(
816 " the '-audio-in <backend>' option allows you to select a specific\n"
817 " backend to play audio in the Android emulator. this is mostly useful\n"
818 " on Linux\n\n"
819
820 " IMPORTANT NOTE:\n"
821 " on some Linux systems, broken Esd/ALSA/driver implementations will\n"
822 " make your emulator freeze and become totally unresponsive when\n"
823 " using audio recording. the only way to avoid this is to use\n"
824 " '-audio-in none' to disable it\n\n"
825
826 " on this system, input <backend> can be one of:\n\n"
827 );
828 for ( nn = 0; ; nn++ ) {
829 const char* descr;
830 const char* name = audio_get_backend_name( 1, nn, &descr );
831 if (name == NULL)
832 break;
833 PRINTF( " %-10s %s\n", name, descr );
834 }
835 PRINTF( "\n" );
836}
837
838
839static void
840help_scale(stralloc_t* out)
841{
842 PRINTF(
843 " the '-scale <scale>' option is used to scale the emulator window to\n"
844 " something that better fits the physical dimensions of a real device. this\n"
845 " can be *very* useful to check that your UI isn't too small to be usable\n"
846 " on a real device.\n\n"
847
848 " there are three supported formats for <scale>:\n\n"
849
850 " * if <scale> is a real number (between 0.1 and 3.0) it is used as a\n"
851 " scaling factor for the emulator's window.\n\n"
852
853 " * if <scale> is an integer followed by the suffix 'dpi' (e.g. '110dpi'),\n"
854 " then it is interpreted as the resolution of your monitor screen. this\n"
855 " will be divided by the emulated device's resolution to get an absolute\n"
856 " scale. (see -help-dpi-device for details).\n\n"
857
858 " * finally, if <scale> is the keyword 'auto', the emulator tries to guess\n"
859 " your monitor's resolution and automatically adjusts its window\n"
860 " accordingly\n\n"
861
862 " NOTE: this process is *very* unreliable, depending on your OS, video\n"
863 " driver issues and other random system parameters\n\n"
864
865 " the emulator's scale can be changed anytime at runtime through the control\n"
866 " console. see the help for the 'window scale' command for details\n\n" );
867}
868
869static void
870help_trace(stralloc_t* out)
871{
872 PRINTF(
873 " use '-trace <name>' to start the emulator with runtime code profiling support\n"
874 " profiling itself will not be enabled unless you press F9 to activate it, or\n"
875 " the executed code turns it on programmatically.\n\n"
876
877 " trace information is stored in directory <name>, several files are created\n"
878 " there, that can later be used with the 'traceview' program that comes with\n"
879 " the Android SDK for analysis.\n\n"
880
881 " note that execution will be slightly slower when enabling code profiling,\n"
882 " this is a necessary requirement of the operations being performed to record\n"
883 " the execution trace. this slowdown should not affect your system until you\n"
884 " enable the profiling though...\n\n"
885 );
886}
887
888static void
889help_show_kernel(stralloc_t* out)
890{
891 PRINTF(
892 " use '-show-kernel' to redirect debug messages from the kernel to the current\n"
893 " terminal. this is useful to check that the boot process works correctly.\n\n"
894 );
895}
896
897static void
898help_shell(stralloc_t* out)
899{
900 PRINTF(
901 " use '-shell' to create a root shell console on the current terminal.\n"
902 " this is unlike the 'adb shell' command for the following reasons:\n\n"
903
904 " * this is a *root* shell that allows you to modify many parts of the system\n"
905 " * this works even if the ADB daemon in the emulated system is broken\n"
906 " * pressing Ctrl-C will stop the emulator, instead of the shell.\n\n"
907 " See also '-shell-serial'.\n\n" );
908}
909
910static void
911help_shell_serial(stralloc_t* out)
912{
913 PRINTF(
914 " use '-shell-serial <device>' instead of '-shell' to open a root shell\n"
915 " to the emulated system, while specifying an external communication\n"
916 " channel / host device.\n\n"
917
918 " '-shell-serial stdio' is identical to '-shell', while you can use\n"
919 " '-shell-serial tcp::4444,server,nowait' to talk to the shell over local\n"
920 " TCP port 4444. '-shell-serial fdpair:3:6' would let a parent process\n"
921 " talk to the shell using fds 3 and 6.\n\n"
922
923 " see -help-char-devices for a list of available <device> specifications.\n\n"
924 " NOTE: you can have only one shell per emulator instance at the moment\n\n"
925 );
926}
927
928static void
929help_logcat(stralloc_t* out)
930{
931 PRINTF(
932 " use '-logcat <tags>' to redirect log messages from the emulated system to\n"
933 " the current terminal. <tags> is a list of space/comma-separated log filters\n"
934 " where each filter has the following format:\n\n"
935
936 " <componentName>:<logLevel>\n\n"
937
938 " where <componentName> is either '*' or the name of a given component,\n"
939 " and <logLevel> is one of the following letters:\n\n"
940
941 " v verbose level\n"
942 " d debug level\n"
943 " i informative log level\n"
944 " w warning log level\n"
945 " e error log level\n"
946 " s silent log level\n\n"
947
948 " for example, the following only displays messages from the 'GSM' component\n"
949 " that are at least at the informative level:\n\n"
950
951 " -logcat '*:s GSM:i'\n\n"
952
953 " if '-logcat <tags>' is not used, the emulator looks for ANDROID_LOG_TAGS\n"
954 " in the environment. if it is defined, its value must match the <tags>\n"
955 " format and will be used to redirect log messages to the terminal.\n\n"
956
957 " note that this doesn't prevent you from redirecting the same, or other,\n"
958 " log messages through the ADB or DDMS tools too.\n\n");
959}
960
961static void
962help_no_audio(stralloc_t* out)
963{
964 PRINTF(
965 " use '-no-audio' to disable all audio support in the emulator. this may be\n"
966 " unfortunately be necessary in some cases:\n\n"
967
968 " * at least two users have reported that their Windows machine rebooted\n"
969 " instantly unless they used this option when starting the emulator.\n"
970 " it is very likely that the problem comes from buggy audio drivers.\n\n"
971
972 " * on some Linux machines, the emulator might get stuck at startup with\n"
973 " audio support enabled. this problem is hard to reproduce, but seems to\n"
974 " be related too to flaky ALSA / audio driver support.\n\n"
975
976 " on Linux, another option is to try to change the default audio backend\n"
977 " used by the emulator. you can do that by setting the QEMU_AUDIO_DRV\n"
978 " environment variables to one of the following values:\n\n"
979
980 " alsa (use the ALSA backend)\n"
981 " esd (use the EsounD backend)\n"
982 " sdl (use the SDL audio backend, no audio input supported)\n"
983 " oss (use the OSS backend)\n"
984 " none (do not support audio)\n"
985 "\n"
986 " the very brave can also try to use distinct backends for audio input\n"
987 " and audio outputs, this is possible by selecting one of the above values\n"
988 " into the QEMU_AUDIO_OUT_DRV and QEMU_AUDIO_IN_DRV environment variables.\n\n"
989 );
990}
991
992static void
993help_raw_keys(stralloc_t* out)
994{
995 PRINTF(
996 " this option is deprecated because one can do the same using Ctrl-K\n"
997 " at runtime (this keypress toggles between unicode/raw keyboard modes)\n\n"
998
999 " by default, the emulator tries to reverse-map the characters you type on\n"
1000 " your keyboard to device-specific key presses whenever possible. this is\n"
1001 " done to make the emulator usable with a non-QWERTY keyboard.\n\n"
1002
1003 " however, this also means that single keypresses like Shift or Alt are not\n"
1004 " passed to the emulated device. the '-raw-keys' option disables the reverse\n"
1005 " mapping. it should only be used when using a QWERTY keyboard on your machine\n"
1006
1007 " (should only be useful to Android system hackers, e.g. when implementing a\n"
1008 " new input method).\n\n"
1009 );
1010}
1011
1012static void
1013help_radio(stralloc_t* out)
1014{
1015 PRINTF(
1016 " use '-radio <device>' to redirect the GSM modem emulation to an external\n"
1017 " character device or program. this bypasses the emulator's internal modem\n"
1018 " and should only be used for testing.\n\n"
1019
1020 " see '-help-char-devices' for the format of <device>\n\n"
1021
1022 " the data exchanged with the external device/program are GSM AT commands\n\n"
1023
1024 " note that, when running in the emulator, the Android GSM stack only supports\n"
1025 " a *very* basic subset of the GSM protocol. trying to link the emulator to\n"
1026 " a real GSM modem is very likely to not work properly.\n\n"
1027 );
1028}
1029
1030
1031static void
1032help_port(stralloc_t* out)
1033{
1034 PRINTF(
1035 " at startup, the emulator tries to bind its control console at a free port\n"
1036 " starting from 5554, in increments of two (i.e. 5554, then 5556, 5558, etc..)\n"
1037 " this allows several emulator instances to run concurrently on the same\n"
1038 " machine, each one using a different console port number.\n\n"
1039
1040 " use '-port <port>' to force an emulator instance to use a given console port\n\n"
1041
1042 " note that <port> must be an *even* integer between 5554 and 5584 included.\n"
1043 " <port>+1 must also be free and will be reserved for ADB. if any of these\n"
1044 " ports is already used, the emulator will fail to start.\n\n" );
1045}
1046
1047static void
1048help_ports(stralloc_t* out)
1049{
1050 PRINTF(
1051 " the '-ports <consoleport>,<adbport>' option allows you to explicitely set\n"
1052 " the TCP ports used by the emulator to implement its control console and\n"
1053 " communicate with the ADB tool.\n\n"
1054
1055 " This is a very special option that should probably *not* be used by typical\n"
1056 " developers using the Android SDK (use '-port <port>' instead), because the\n"
1057 " corresponding instance is probably not going to be seen from adb/DDMS. Its\n"
1058 " purpose is to use the emulator in very specific network configurations.\n\n"
1059
1060 " <consoleport> is the TCP port used to bind the control console\n"
1061 " <adbport> is the TCP port used to bind the ADB local transport/tunnel.\n\n"
1062
1063 " If both ports aren't available on startup, the emulator will exit.\n\n");
1064}
1065
1066
1067static void
1068help_onion(stralloc_t* out)
1069{
1070 PRINTF(
1071 " use '-onion <file>' to specify a PNG image file that will be displayed on\n"
1072 " top of the emulated framebuffer with translucency. this can be useful to\n"
1073 " check that UI elements are correctly positioned with regards to a reference\n"
1074 " graphics specification.\n\n"
1075
1076 " the default translucency is 50%%, but you can use '-onion-alpha <%%age>' to\n"
1077 " select a different one, or even use keypresses at runtime to alter it\n"
1078 " (see -help-keys for details)\n\n"
1079
1080 " finally, the onion image can be rotated (see -help-onion-rotate)\n\n"
1081 );
1082}
1083
1084static void
1085help_onion_alpha(stralloc_t* out)
1086{
1087 PRINTF(
1088 " use '-onion-alpha <percent>' to change the translucency level of the onion\n"
1089 " image that is going to be displayed on top of the framebuffer (see also\n"
1090 " -help-onion). the default is 50%%.\n\n"
1091
1092 " <percent> must be an integer between 0 and 100.\n\n"
1093
1094 " you can also change the translucency dynamically (see -help-keys)\n\n"
1095 );
1096}
1097
1098static void
1099help_onion_rotation(stralloc_t* out)
1100{
1101 PRINTF(
1102 " use '-onion-rotation <rotation>' to change the rotation of the onion\n"
1103 " image loaded through '-onion <file>'. valid values for <rotation> are:\n\n"
1104
1105 " 0 no rotation\n"
1106 " 1 90 degrees clockwise\n"
1107 " 2 180 degrees\n"
1108 " 3 270 degrees clockwise\n\n"
1109 );
1110}
1111
1112
1113static void
1114help_timezone(stralloc_t* out)
1115{
1116 PRINTF(
1117 " by default, the emulator tries to detect your current timezone to report\n"
1118 " it to the emulated system. use the '-timezone <timezone>' option to choose\n"
1119 " a different timezone, or if the automatic detection doesn't work correctly.\n\n"
1120
1121 " VERY IMPORTANT NOTE:\n\n"
1122 " the <timezone> value must be in zoneinfo format, i.e. it should look like\n"
1123 " Area/Location or even Area/SubArea/Location. valid examples are:\n\n"
1124
1125 " America/Los_Angeles\n"
1126 " Europe/Paris\n\n"
1127
1128 " using a human-friendly abbreviation like 'PST' or 'CET' will not work, as\n"
1129 " well as using values that are not defined by the zoneinfo database.\n\n"
1130
1131 " NOTE: unfortunately, this will not work on M5 and older SDK releases\n\n"
1132 );
1133}
1134
1135
1136static void
1137help_dns_server(stralloc_t* out)
1138{
1139 PRINTF(
1140 " by default, the emulator tries to detect the DNS servers you're using and\n"
1141 " will setup special aliases in the emulated firewall network to allow the\n"
1142 " Android system to connect directly to them. use '-dns-server <servers>' to\n"
1143 " select a different list of DNS servers to be used.\n\n"
1144
1145 " <servers> must be a comma-separated list of up to 4 DNS server names or\n"
1146 " IP addresses.\n\n"
1147
1148 " NOTE: on M5 and older SDK releases, only the first server in the list will\n"
1149 " be used.\n\n"
1150 );
1151}
1152
1153
1154static void
1155help_cpu_delay(stralloc_t* out)
1156{
1157 PRINTF(
1158 " this option is purely experimental, probably doesn't work as you would\n"
1159 " expect, and may even disappear in a later emulator release.\n\n"
1160
1161 " use '-cpu-delay <delay>' to throttle CPU emulation. this may be useful\n"
1162 " to detect weird race conditions that only happen on 'lower' CPUs. note\n"
1163 " that <delay> is a unit-less integer that doesn't even scale linearly\n"
1164 " to observable slowdowns. use trial and error to find something that\n"
1165 " suits you, the 'correct' machine is very probably dependent on your\n"
1166 " host CPU and memory anyway...\n\n"
1167 );
1168}
1169
1170
1171static void
1172help_no_boot_anim(stralloc_t* out)
1173{
1174 PRINTF(
1175 " use '-no-boot-anim' to disable the boot animation (red bouncing ball) when\n"
1176 " starting the emulator. on slow machines, this can surprisingly speed up the\n"
1177 " boot sequence in tremendous ways.\n\n"
1178
1179 " NOTE: unfortunately, this will not work on M5 and older SDK releases\n\n"
1180 );
1181}
1182
1183
1184static void
1185help_gps(stralloc_t* out)
1186{
1187 PRINTF(
1188 " use '-gps <device>' to emulate an NMEA-compatible GPS unit connected to\n"
1189 " an external character device or socket. the format of <device> is the same\n"
1190 " than the one used for '-radio <device>' (see -help-char-devices for details)\n\n"
1191 );
1192}
1193
1194
1195static void
1196help_keyset(stralloc_t* out)
1197{
1198 char temp[256];
1199
1200 PRINTF(
1201 " use '-keyset <name>' to specify a different keyset file name to use when\n"
1202 " starting the emulator. a keyset file contains a list of key bindings used\n"
1203 " to control the emulator with the host keyboard.\n\n"
1204
1205 " by default, the emulator looks for the following file:\n\n"
1206 );
1207
1208 bufprint_config_file(temp, temp+sizeof(temp), KEYSET_FILE);
1209 PRINTF(
1210 " %s\n\n", temp );
1211
1212 bufprint_config_path(temp, temp+sizeof(temp));
1213 PRINTF(
1214 " however, if -keyset is used, then the emulator does the following:\n\n"
1215
1216 " - first, if <name> doesn't have an extension, then the '.keyset' suffix\n"
1217 " is appended to it (e.g. \"foo\" => \"foo.keyset\"),\n\n"
1218
1219 " - then, the emulator searches for a file named <name> in the following\n"
1220 " directories:\n\n"
1221
1222 " * the emulator configuration directory: %s\n"
1223 " * the 'keysets' subdirectory of <systemdir>, if any\n"
1224 " * the 'keysets' subdirectory of the program location, if any\n\n",
1225 temp );
1226
1227 PRINTF(
1228 " if no corresponding file is found, a default set of key bindings is used.\n\n"
1229 " use '-help-keys' to list the default key bindings.\n"
1230 " use '-help-keyset-file' to learn more about the format of keyset files.\n"
1231 "\n"
1232 );
1233}
1234
1235static void
1236help_old_system(stralloc_t* out)
1237{
1238 PRINTF(
1239 " use '-old-system' if you want to use a recent emulator binary to run\n"
1240 " an old version of the Android SDK system images. Here, 'old' means anything\n"
1241 " older than version 1.4 of the emulator.\n\n"
1242
1243 " NOTE: using '-old-system' with recent system images is likely to not work\n"
1244 " properly, though you may not notice it immediately (e.g. failure to\n"
1245 " start the emulated GPS hardware)\n\n"
1246 );
1247}
1248
1249#ifdef CONFIG_NAND_LIMITS
1250static void
1251help_nand_limits(stralloc_t* out)
1252{
1253 PRINTF(
1254 " use '-nand-limits <limits>' to enable a debugging feature that sends a\n"
1255 " signal to an external process once a read and/or write limit is achieved\n"
1256 " in the emulated system. the format of <limits> is the following:\n\n"
1257
1258 " pid=<number>,signal=<number>,[reads=<threshold>][,writes=<threshold>]\n\n"
1259
1260 " where 'pid' is the target process identifier, 'signal' the number of the\n"
1261 " target signal. the read and/or write threshold'reads' are a number optionally\n"
1262 " followed by a K, M or G suffix, corresponding to the number of bytes to be\n"
1263 " read or written before the signal is sent.\n\n"
1264 );
1265}
1266#endif /* CONFIG_NAND_LIMITS */
1267
1268static void
1269help_bootchart(stralloc_t *out)
1270{
1271 PRINTF(
1272 " some Android system images have a modified 'init' system that integrates\n"
1273 " a bootcharting facility (see http://www.bootchart.org/). You can pass a\n"
1274 " bootcharting period to the system with the following:\n\n"
1275
1276 " -bootchart <timeout>\n\n"
1277
1278 " where 'timeout' is a period expressed in seconds. Note that this won't do\n"
1279 " anything if your init doesn't have bootcharting activated.\n\n"
1280 );
1281}
1282
1283static void
1284help_tcpdump(stralloc_t *out)
1285{
1286 PRINTF(
1287 " use the -tcpdump <file> option to start capturing all network packets\n"
1288 " that are sent through the emulator's virtual Ethernet LAN. You can later\n"
1289 " use tools like WireShark to analyze the traffic and understand what\n"
1290 " really happens.\n\n"
1291
1292 " note that this captures all Ethernet packets, and is not limited to TCP\n"
1293 " connections.\n\n"
1294
1295 " you can also start/stop the packet capture dynamically through the console;\n"
1296 " see the 'network capture start' and 'network capture stop' commands for\n"
1297 " details.\n\n"
1298 );
1299}
1300
David 'Digit' Turner318e4f22009-05-25 18:01:03 +02001301static void
vchtchetkine9085a282009-09-14 15:29:20 -07001302help_charmap(stralloc_t *out)
1303{
1304 PRINTF(
1305 " use '-charmap <file>' to use key character map specified in that file.\n"
1306 " <file> must be a full path to a kcm file, containing desired character map.\n\n"
1307 );
1308}
1309
1310static void
David 'Digit' Turner318e4f22009-05-25 18:01:03 +02001311help_prop(stralloc_t *out)
1312{
1313 PRINTF(
1314 " use '-prop <name>=<value>' to set a boot-time system property.\n"
1315 " <name> must be a property name of at most %d characters, without any\n"
1316 " space in it, and <value> must be a string of at most %d characters.\n\n",
1317 PROPERTY_MAX_NAME, PROPERTY_MAX_VALUE );
1318
1319 PRINTF(
1320 " the corresponding system property will be set at boot time in the\n"
1321 " emulated system. This can be useful for debugging purposes.\n\n"
1322
1323 " note that you can use several -prop options to define more than one\n"
1324 " boot property.\n\n"
1325 );
1326}
1327
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001328#define help_no_skin NULL
1329#define help_netspeed help_shaper
1330#define help_netdelay help_shaper
1331#define help_netfast help_shaper
1332
1333#define help_noaudio NULL
1334#define help_noskin NULL
1335#define help_nocache NULL
1336#define help_no_jni NULL
1337#define help_nojni NULL
1338#define help_initdata NULL
1339#define help_no_window NULL
1340#define help_version NULL
1341#define help_memory NULL
The Android Open Source Projectb3ee93a2009-03-13 13:04:21 -07001342#define help_partition_size NULL
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001343
1344typedef struct {
1345 const char* name;
1346 const char* template;
1347 const char* descr;
1348 void (*func)(stralloc_t*);
1349} OptionHelp;
1350
1351static const OptionHelp option_help[] = {
1352#define OPT_FLAG(_name,_descr) { STRINGIFY(_name), NULL, _descr, help_##_name },
1353#define OPT_PARAM(_name,_template,_descr) { STRINGIFY(_name), _template, _descr, help_##_name },
David 'Digit' Turner318e4f22009-05-25 18:01:03 +02001354#define OPT_LIST OPT_PARAM
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001355#include "android/cmdline-options.h"
1356 { NULL, NULL, NULL, NULL }
1357};
1358
1359typedef struct {
1360 const char* name;
1361 const char* desc;
1362 void (*func)(stralloc_t*);
1363} TopicHelp;
1364
1365
1366static const TopicHelp topic_help[] = {
1367 { "disk-images", "about disk images", help_disk_images },
1368 { "keys", "supported key bindings", help_keys },
1369 { "debug-tags", "debug tags for -debug <tags>", help_debug_tags },
1370 { "char-devices", "character <device> specification", help_char_devices },
1371 { "environment", "environment variables", help_environment },
1372 { "keyset-file", "key bindings configuration file", help_keyset_file },
1373 { "virtual-device", "virtual device management", help_virtual_device },
1374 { "sdk-images", "about disk images when using the SDK", help_sdk_images },
1375 { "build-images", "about disk images when building Android", help_build_images },
1376 { NULL, NULL, NULL }
1377};
1378
1379int
1380android_help_for_option( const char* option, stralloc_t* out )
1381{
1382 OptionHelp const* oo;
1383 char temp[32];
1384
1385 /* the names in the option_help table use underscore instead
1386 * of dashes, so create a tranlated copy of the option name
1387 * before scanning the table for matches
1388 */
1389 buffer_translate_char( temp, sizeof temp, option, '-', '_' );
1390
1391 for ( oo = option_help; oo->name != NULL; oo++ ) {
1392 if ( !strcmp(oo->name, temp) ) {
1393 if (oo->func)
1394 oo->func(out);
1395 else
1396 stralloc_add_str(out, oo->descr);
1397 return 0;
1398 }
1399 }
1400 return -1;
1401}
1402
1403
1404int
1405android_help_for_topic( const char* topic, stralloc_t* out )
1406{
1407 const TopicHelp* tt;
1408
1409 for ( tt = topic_help; tt->name != NULL; tt++ ) {
1410 if ( !strcmp(tt->name, topic) ) {
1411 tt->func(out);
1412 return 0;
1413 }
1414 }
1415 return -1;
1416}
1417
1418
1419extern void
1420android_help_list_options( stralloc_t* out )
1421{
1422 const OptionHelp* oo;
1423 const TopicHelp* tt;
1424 int maxwidth = 0;
1425
1426 for ( oo = option_help; oo->name != NULL; oo++ ) {
1427 int width = strlen(oo->name);
1428 if (oo->template != NULL)
1429 width += strlen(oo->template);
1430 if (width > maxwidth)
1431 maxwidth = width;
1432 }
1433
1434 for (oo = option_help; oo->name != NULL; oo++) {
1435 char temp[32];
1436 /* the names in the option_help table use underscores instead
1437 * of dashes, so create a translated copy of the option's name
1438 */
1439 buffer_translate_char(temp, sizeof temp, oo->name, '_', '-');
1440
1441 stralloc_add_format( out, " -%s %-*s %s\n",
1442 temp,
1443 (int)(maxwidth - strlen(oo->name)),
1444 oo->template ? oo->template : "",
1445 oo->descr );
1446 }
1447
1448 PRINTF( "\n" );
1449 PRINTF( " %-*s %s\n", maxwidth, "-qemu args...", "pass arguments to qemu");
1450 PRINTF( " %-*s %s\n", maxwidth, "-qemu -h", "display qemu help");
1451 PRINTF( "\n" );
1452 PRINTF( " %-*s %s\n", maxwidth, "-verbose", "same as '-debug-init'");
1453 PRINTF( " %-*s %s\n", maxwidth, "-debug <tags>", "enable/disable debug messages");
1454 PRINTF( " %-*s %s\n", maxwidth, "-debug-<tag>", "enable specific debug messages");
1455 PRINTF( " %-*s %s\n", maxwidth, "-debug-no-<tag>","disable specific debug messages");
1456 PRINTF( "\n" );
1457 PRINTF( " %-*s %s\n", maxwidth, "-help", "print this help");
1458 PRINTF( " %-*s %s\n", maxwidth, "-help-<option>", "print option-specific help");
1459 PRINTF( "\n" );
1460
1461 for (tt = topic_help; tt->name != NULL; tt += 1) {
1462 char help[32];
1463 snprintf(help, sizeof(help), "-help-%s", tt->name);
1464 PRINTF( " %-*s %s\n", maxwidth, help, tt->desc );
1465 }
1466 PRINTF( " %-*s %s\n", maxwidth, "-help-all", "prints all help content");
1467 PRINTF( "\n");
1468}
1469
1470
1471void
1472android_help_main( stralloc_t* out )
1473{
1474 stralloc_add_str(out, "Android Emulator usage: emulator [options] [-qemu args]\n");
1475 stralloc_add_str(out, " options:\n" );
1476
1477 android_help_list_options(out);
1478
1479 /*printf( "%.*s", out->n, out->s );*/
1480}
1481
1482
1483void
1484android_help_all( stralloc_t* out )
1485{
1486 const OptionHelp* oo;
1487 const TopicHelp* tt;
1488
1489 for (oo = option_help; oo->name != NULL; oo++) {
1490 PRINTF( "========= help for option -%s:\n\n", oo->name );
1491 android_help_for_option( oo->name, out );
1492 }
1493
1494 for (tt = topic_help; tt->name != NULL; tt++) {
1495 PRINTF( "========= help for -help-%s\n\n", tt->name );
1496 android_help_for_topic( tt->name, out );
1497 }
1498 PRINTF( "========= top-level help\n\n" );
1499 android_help_main(out);
1500}