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