blob: f226cf6850f4a39a3ed84ff64b80cad34d62ac9c [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>
Vladimir Chtchetkine318f17a2010-08-27 09:09:45 -070013#include "android/ui-core-protocol.h"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080014
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"
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -080081 " directories for system image files, in the following order:\n\n"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080082
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"
David 'Digit' Turner92568952010-04-15 15:04:16 -0700123 " also use the -cache and -sdcard options to indicate specific cache partition\n"
124 " 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"
Ot ten Thije353b3b12010-10-05 17:53:30 +0100169#if CONFIG_ANDROID_SNAPSHOTS
170 " snapshots.img an *optional* state snapshots image\n\n"
171#endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800172
173 " If you use a virtual device, its content directory should store\n"
174 " all writable images, and read-only ones will be found from the\n"
175 " corresponding platform/add-on directories. See -help-sdk-images\n"
176 " for more details.\n\n"
177
178 " If you are building from the Android build system, you should\n"
179 " have ANDROID_PRODUCT_OUT defined in your environment, and the\n"
180 " emulator shall be able to pick-up the right image files automatically.\n"
181 " See -help-build-images for more details.\n\n"
182
183 " If you're neither using the SDK or the Android build system, you\n"
184 " can still run the emulator by explicitely providing the paths to\n"
185 " *all* required disk images through a combination of the following\n"
186 " options: -sysdir, -datadir, -kernel, -ramdisk, -system, -data, -cache\n"
Ot ten Thije353b3b12010-10-05 17:53:30 +0100187#if CONFIG_ANDROID_SNAPSHOTS
188 " -sdcard and -snapstorage.\n\n"
189#else
190 " and -sdcard.\n\n"
191#endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800192
193 " The actual logic being that the emulator should be able to find all\n"
194 " images from the options you give it.\n\n"
195
196 " For more detail, see the corresponding -help-<option> entry.\n\n"
197
198 " Other related options are:\n\n"
199
Ot ten Thije353b3b12010-10-05 17:53:30 +0100200 " -init-data Specify an alternative *initial* user data image\n\n"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800201
Ot ten Thije353b3b12010-10-05 17:53:30 +0100202 " -wipe-data Copy the content of the *initial* user data image\n"
203" (userdata.img) into the writable one (userdata-qemu.img)\n\n"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800204
Ot ten Thije353b3b12010-10-05 17:53:30 +0100205 " -no-cache do not use a cache partition, even if one is\n"
206 " available.\n\n"
207
208#if CONFIG_ANDROID_SNAPSHOTS
209 " -no-snapstorage do not use a state snapshot image, even if one is\n"
210 " available.\n\n"
211#endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800212 ,
213 datadir );
214}
215
216static void
217help_keys(stralloc_t* out)
218{
219 int pass, maxw = 0;
220
221 stralloc_add_str( out, " When running the emulator, use the following keypresses:\n\n");
222
223 if (!android_keyset)
224 android_keyset = skin_keyset_new_from_text( skin_keyset_get_default() );
225
226 for (pass = 0; pass < 2; pass++) {
227 SkinKeyCommand cmd;
228
229 for (cmd = SKIN_KEY_COMMAND_NONE+1; cmd < SKIN_KEY_COMMAND_MAX; cmd++)
230 {
231 SkinKeyBinding bindings[ SKIN_KEY_COMMAND_MAX_BINDINGS ];
232 int n, count, len;
233 char temp[32], *p = temp, *end = p + sizeof(temp);
234
235 count = skin_keyset_get_bindings( android_keyset, cmd, bindings );
236 if (count <= 0)
237 continue;
238
239 for (n = 0; n < count; n++) {
240 p = bufprint(p, end, "%s%s", (n == 0) ? "" : ", ",
241 skin_key_symmod_to_str( bindings[n].sym, bindings[n].mod ) );
242 }
243
244 if (pass == 0) {
245 len = strlen(temp);
246 if (len > maxw)
247 maxw = len;
248 } else {
249 PRINTF( " %-*s %s\n", maxw, temp, skin_key_command_description(cmd) );
250 }
251 }
252 }
253 PRINTF( "\n" );
254 PRINTF( " note that NumLock must be deactivated for keypad keys to work\n\n" );
255}
256
257
258static void
259help_environment(stralloc_t* out)
260{
261 PRINTF(
262 " The Android emulator looks at various environment variables when it starts:\n\n"
263
264 " If ANDROID_LOG_TAGS is defined, it will be used as in '-logcat <tags>'.\n\n"
265
266 " If 'http_proxy' is defined, it will be used as in '-http-proxy <proxy>'.\n\n"
267
268 " If ANDROID_VERBOSE is defined, it can contain a comma-separated list of\n"
269 " verbose items. for example:\n\n"
270
271 " ANDROID_VERBOSE=socket,radio\n\n"
272
273 " is equivalent to using the '-verbose -verbose-socket -verbose-radio'\n"
274 " options together. unsupported items will be ignored.\n\n"
275
276 " If ANDROID_LOG_TAGS is defined, it will be used as in '-logcat <tags>'.\n\n"
277
278 " If ANDROID_SDK_HOME is defined, it indicates the path of the '.android'\n"
279 " directory which contains the SDK user data (Android Virtual Devices,\n"
280 " DDMS preferences, key stores, etc.).\n\n"
281
282 " If ANDROID_SDK_ROOT is defined, it indicates the path of the SDK\n"
283 " installation directory.\n\n"
284
285 );
286}
287
288
289static void
290help_keyset_file(stralloc_t* out)
291{
292 int n, count;
293 const char** strings;
294 char temp[MAX_PATH];
295
296 PRINTF(
297 " on startup, the emulator looks for 'keyset' file that contains the\n"
298 " configuration of key-bindings to use. the default location on this\n"
299 " system is:\n\n"
300 );
301
302 bufprint_config_file( temp, temp+sizeof(temp), KEYSET_FILE );
303 PRINTF( " %s\n\n", temp );
304
305 PRINTF(
306 " if the file doesn't exist, the emulator writes one containing factory\n"
307 " defaults. you are then free to modify it to suit specific needs.\n\n"
308 " this file shall contain a list of text lines in the following format:\n\n"
309
310 " <command> [<modifiers>]<key>\n\n"
311
312 " where <command> is an emulator-specific command name, i.e. one of:\n\n"
313 );
314
315 count = SKIN_KEY_COMMAND_MAX-1;
316 strings = calloc( count, sizeof(char*) );
317 for (n = 0; n < count; n++)
318 strings[n] = skin_key_command_to_str(n+1);
319
320 stralloc_tabular( out, strings, count, " ", 80-8 );
321 free(strings);
322
323 PRINTF(
324 "\n"
325 " <modifers> is an optional list of <modifier> elements (without separators)\n"
326 " which can be one of:\n\n"
327
328 " Ctrl- Left Control Key\n"
329 " Shift- Left Shift Key\n"
330 " Alt- Left Alt key\n"
331 " RCtrl- Right Control Key\n"
332 " RShift- Right Shift Key\n"
333 " RAlt- Right Alt key (a.k.a AltGr)\n"
334 "\n"
335 " finally <key> is a QWERTY-specific keyboard symbol which can be one of:\n\n"
336 );
337 count = skin_keysym_str_count();
338 strings = calloc( count, sizeof(char*) );
339 for (n = 0; n < count; n++)
340 strings[n] = skin_keysym_str(n);
341
342 stralloc_tabular( out, strings, count, " ", 80-8 );
343 free(strings);
344
345 PRINTF(
346 "\n"
347 " case is not significant, and a single command can be associated to up\n"
348 " to %d different keys. to bind a command to multiple keys, use commas to\n"
349 " separate them. here are some examples:\n\n",
350 SKIN_KEY_COMMAND_MAX_BINDINGS );
351
352 PRINTF(
353 " TOGGLE_NETWORK F8 # toggle the network on/off\n"
354 " CHANGE_LAYOUT_PREV Keypad_7,Ctrl-J # switch to a previous skin layout\n"
355 "\n"
356 );
357}
358
359
360static void
361help_debug_tags(stralloc_t* out)
362{
363 int n;
364
365#define _VERBOSE_TAG(x,y) { #x, VERBOSE_##x, y },
366 static const struct { const char* name; int flag; const char* text; }
367 verbose_options[] = {
368 VERBOSE_TAG_LIST
369 { 0, 0, 0 }
370 };
371#undef _VERBOSE_TAG
372
373 PRINTF(
374 " the '-debug <tags>' option can be used to enable or disable debug\n"
375 " messages from specific parts of the emulator. <tags> must be a list\n"
376 " (separated by space/comma/column) of <component> names, which can be one of:\n\n"
377 );
378
379 for (n = 0; n < VERBOSE_MAX; n++)
380 PRINTF( " %-12s %s\n", verbose_options[n].name, verbose_options[n].text );
381 PRINTF( " %-12s %s\n", "all", "all components together\n" );
382
383 PRINTF(
384 "\n"
385 " each <component> can be prefixed with a single '-' to indicate the disabling\n"
386 " of its debug messages. for example:\n\n"
387
388 " -debug all,-socket,-keys\n\n"
389
390 " enables all debug messages, except the ones related to network sockets\n"
391 " and key bindings/presses\n\n"
392 );
393}
394
395static void
396help_char_devices(stralloc_t* out)
397{
398 PRINTF(
399 " various emulation options take a <device> specification that can be used to\n"
400 " specify something to hook to an emulated device or communication channel.\n"
401 " here is the list of supported <device> specifications:\n\n"
402
403 " stdio\n"
404 " standard input/output. this may be subject to character\n"
405 " translation (e.g. LN <=> CR/LF)\n\n"
406
407 " COM<n> [Windows only]\n"
408 " where <n> is a digit. host serial communication port.\n\n"
409
410 " pipe:<filename>\n"
411 " named pipe <filename>\n\n"
412
413 " file:<filename>\n"
414 " write output to <filename>, no input can be read\n\n"
415
416 " pty [Linux only]\n"
417 " pseudo TTY (a new PTY is automatically allocated)\n\n"
418
419 " /dev/<file> [Unix only]\n"
420 " host char device file, e.g. /dev/ttyS0. may require root access\n\n"
421
422 " /dev/parport<N> [Linux only]\n"
423 " use host parallel port. may require root access\n\n"
424
425 " unix:<path>[,server][,nowait]] [Unix only]\n"
426 " use a Unix domain socket. if you use the 'server' option, then\n"
427 " the emulator will create the socket and wait for a client to\n"
428 " connect before continuing, unless you also use 'nowait'\n\n"
429
430 " tcp:[<host>]:<port>[,server][,nowait][,nodelay]\n"
431 " use a TCP socket. 'host' is set to localhost by default. if you\n"
432 " use the 'server' option will bind the port and wait for a client\n"
433 " to connect before continuing, unless you also use 'nowait'. the\n"
434 " 'nodelay' option disables the TCP Nagle algorithm\n\n"
435
436 " telnet:[<host>]:<port>[,server][,nowait][,nodelay]\n"
437 " similar to 'tcp:' but uses the telnet protocol instead of raw TCP\n\n"
438
439 " udp:[<remote_host>]:<remote_port>[@[<src_ip>]:<src_port>]\n"
440 " send output to a remote UDP server. if 'remote_host' is no\n"
441 " specified it will default to '0.0.0.0'. you can also receive input\n"
442 " through UDP by specifying a source address after the optional '@'.\n\n"
443
444 " fdpair:<fd1>,<fd2> [Unix only]\n"
445 " redirection input and output to a pair of pre-opened file\n"
446 " descriptors. this is mostly useful for scripts and other\n"
447 " programmatic launches of the emulator.\n\n"
448
449 " none\n"
450 " no device connected\n\n"
451
452 " null\n"
453 " the null device (a.k.a /dev/null on Unix, or NUL on Win32)\n\n"
454
455 " NOTE: these correspond to the <device> parameter of the QEMU -serial option\n"
456 " as described on http://bellard.org/qemu/qemu-doc.html#SEC10\n\n"
457 );
458}
459
460static void
461help_avd(stralloc_t* out)
462{
463 PRINTF(
David Turnerb58c44e2009-03-25 02:42:45 -0700464 " use '-avd <name>' to start the emulator program with a given Android\n"
465 " Virtual Device (a.k.a. AVD), where <name> must correspond to the name\n"
466 " of one of the existing AVDs available on your host machine.\n\n"
467
468 "See -help-virtual-device to learn how to create/list/manage AVDs.\n\n"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800469
470 " As a special convenience, using '@<name>' is equivalent to using\n"
471 " '-avd <name>'.\n\n"
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800472 );
473}
474
475static void
476help_sysdir(stralloc_t* out)
477{
478 char systemdir[MAX_PATH];
479 char *p = systemdir, *end = p + sizeof(systemdir);
480
481 p = bufprint_app_dir( p, end );
482 p = bufprint( p, end, PATH_SEP "lib" PATH_SEP "images" );
483
484 PRINTF(
485 " use '-sysdir <dir>' to specify a directory where system read-only\n"
486 " image files will be searched. on this system, the default directory is:\n\n"
487 " %s\n\n", systemdir );
488
489 PRINTF(
490 " see '-help-disk-images' for more information about disk image files\n\n" );
491}
492
493static void
494help_datadir(stralloc_t* out)
495{
496 char datadir[MAX_PATH];
497
498 bufprint_config_path(datadir, datadir + sizeof(datadir));
499
500 PRINTF(
501 " use '-datadir <dir>' to specify a directory where writable image files\n"
502 " will be searched. on this system, the default directory is:\n\n"
503 " %s\n\n", datadir );
504
505 PRINTF(
506 " see '-help-disk-images' for more information about disk image files\n\n" );
507}
508
509static void
510help_kernel(stralloc_t* out)
511{
512 PRINTF(
513 " use '-kernel <file>' to specify a Linux kernel image to be run.\n"
514 " the default image is 'kernel-qemu' from the system directory.\n\n"
515
516 " you can use '-debug-kernel' to see debug messages from the kernel\n"
517 " to the terminal\n\n"
518
519 " see '-help-disk-images' for more information about disk image files\n\n"
520 );
521}
522
523static void
524help_ramdisk(stralloc_t* out)
525{
526 PRINTF(
527 " use '-ramdisk <file>' to specify a Linux ramdisk boot image to be run in\n"
528 " the emulator. the default image is 'ramdisk.img' from the system directory.\n\n"
529
530 " see '-help-disk-images' for more information about disk image files\n\n"
531 );
532}
533
534static void
535help_system(stralloc_t* out)
536{
537 PRINTF(
538 " use '-system <file>' to specify the intial system image that will be loaded.\n"
539 " the default image is 'system.img' from the system directory.\n\n"
540
541 " NOTE: In previous releases of the Android SDK, this option was named '-image'.\n"
542 " And using '-system <path>' was equivalent to using '-sysdir <path>' now.\n\n"
543
544 " see '-help-disk-images' for more information about disk image files\n\n"
545 );
546}
547
548static void
549help_image(stralloc_t* out)
550{
551 PRINTF(
552 " This option is obsolete, you should use '-system <file>' instead to point\n"
553 " to the initial system image.\n\n"
554
555 " see '-help-disk-images' for more information about disk image files\n\n"
556 );
557}
558
559static void
560help_init_data(stralloc_t* out)
561{
562 PRINTF(
563 " use '-init-data <file>' to specify an *init* /data partition file.\n"
564 " it is only used when creating a new writable /data image file, or\n"
565 " when you use '-wipe-data' to reset it. the default is 'userdata.img'\n"
566 " from the system directory.\n\n"
567
568 " see '-help-disk-images' for more information about disk image files\n\n"
569 );
570}
571
572static void
573help_data(stralloc_t* out)
574{
575 PRINTF(
576 " use '-data <file>' to specify a different /data partition image file.\n\n"
577
578 " see '-help-disk-images' for more information about disk image files\n\n"
579 );
580}
581
582static void
583help_wipe_data(stralloc_t* out)
584{
585 PRINTF(
586 " use '-wipe-data' to reset your /data partition image to its factory\n"
587 " defaults. this removes all installed applications and settings.\n\n"
588
589 " see '-help-disk-images' for more information about disk image files\n\n"
590 );
591}
592
593static void
594help_cache(stralloc_t* out)
595{
596 PRINTF(
597 " use '-cache <file>' to specify a /cache partition image. if <file> does\n"
598 " not exist, it will be created empty. by default, the cache partition is\n"
599 " backed by a temporary file that is deleted when the emulator exits.\n"
600 " using the -cache option allows it to be persistent.\n\n"
601
602 " the '-no-cache' option can be used to disable the cache partition.\n\n"
603
604 " see '-help-disk-images' for more information about disk image files\n\n"
605 );
606}
607
608static void
609help_no_cache(stralloc_t* out)
610{
611 PRINTF(
612 " use '-no-cache' to disable the cache partition in the emulated system.\n"
613 " the cache partition is optional, but when available, is used by the browser\n"
614 " to cache web pages and images\n\n"
615
616 " see '-help-disk-images' for more information about disk image files\n\n"
617 );
618}
619
620static void
621help_sdcard(stralloc_t* out)
622{
623 PRINTF(
624 " use '-sdcard <file>' to specify a SD Card image file that will be attached\n"
625 " to the emulator. By default, the 'sdcard.img' file is searched in the data\n"
626 " directory.\n\n"
627
628 " if the file does not exist, the emulator will still start, but without an\n"
629 " attached SD Card.\n\n"
630
631 " see '-help-disk-images' for more information about disk image files\n\n"
632 );
633}
634
Ot ten Thije353b3b12010-10-05 17:53:30 +0100635#if CONFIG_ANDROID_SNAPSHOTS
636static void
637help_snapstorage(stralloc_t* out)
638{
639 PRINTF(
640 " Use '-snapstorage <file>' to specify a repository file for snapshots.\n"
641 " All snapshots made during execution will be saved in this file, and only\n"
642 " snapshots in this file can be restored during the emulator run.\n\n"
643
644 " If the option is not specified, it defaults to 'snapshots.img' in the\n"
645 " data directory. If the specified file does not exist, the emulator will\n"
646 " start, but without support for saving or loading state snapshots.\n\n"
647
648 " see '-help-disk-images' for more information about disk image files\n"
649 " see '-help-snapshot' for more information about snapshots\n\n"
650 );
651}
652
653static void
654help_no_snapstorage(stralloc_t* out)
655{
656 PRINTF(
657 " This starts the emulator without mounting a file to store or load state\n"
658 " snapshots, forcing a full boot and disabling state snapshot functionality.\n\n"
659 ""
660 " This command overrides the configuration specified by the parameters\n"
661 " '-snapstorage' and '-snapshot'. A warning will be raised if either\n"
662 " of those parameters was specified anyway.\n\n"
663 );
664 }
665
666static void
667help_snapshot(stralloc_t* out)
668{
669 PRINTF(
670 " Rather than executing a full boot sequence, the Android emulator can\n"
671 " resume execution from an earlier state snapshot (which is usually\n"
672 " significantly faster). When the parameter '-snapshot <name>' is given,\n"
Tim Baverstock53d8a5c2010-12-02 14:21:39 +0000673 " the emulator loads the snapshot of that name from the snapshot image,\n"
674 " and saves it back under the same name on exit.\n\n"
Ot ten Thije353b3b12010-10-05 17:53:30 +0100675
676 " If the option is not specified, it defaults to 'default-boot'. If the\n"
677 " specified snapshot does not exist, the emulator will perform a full boot\n"
Tim Baverstock53d8a5c2010-12-02 14:21:39 +0000678 " sequence instead, but will still save.\n\n"
Ot ten Thije353b3b12010-10-05 17:53:30 +0100679
680 " WARNING: In the process of loading, all contents of the system, userdata\n"
681 " and SD card images will be OVERWRITTEN with the contents they\n"
682 " held when the snapshot was made. Unless saved in a different\n"
683 " snapshot, any changes since will be lost!\n\n"
684
Tim Baverstock53d8a5c2010-12-02 14:21:39 +0000685 " If you want to create a snapshot manually, connect to the emulator console:\n\n"
Ot ten Thije353b3b12010-10-05 17:53:30 +0100686
687 " telnet localhost <port>\n\n"
688
689 " Then execute the command 'avd snapshot save <name>'. See '-help-port' for\n"
690 " information on obtaining <port>.\n\n"
691 );
692}
693
694static void
695help_no_snapshot(stralloc_t* out)
696{
697 PRINTF(
Tim Baverstock53d8a5c2010-12-02 14:21:39 +0000698 " This inhibits both the autoload and autosave operations, forcing\n"
699 " emulator to perform a full boot sequence and losing state on close.\n"
700 " It overrides the '-snapshot' parameter.\n"
Ot ten Thije353b3b12010-10-05 17:53:30 +0100701 " If '-snapshot' was specified anyway, a warning is raised.\n\n"
702 );
703}
704
Ot ten Thijeae835ac2010-10-18 13:37:37 +0100705static void
Tim Baverstock53d8a5c2010-12-02 14:21:39 +0000706help_no_snapshot_load(stralloc_t* out)
707{
708 PRINTF(
709 " Prevents the emulator from loading the AVD's state from the snapshot\n"
710 " storage on start.\n\n"
711 );
712}
713
714static void
Tim Baverstock24204cc2010-11-25 11:37:43 +0000715help_no_snapshot_save(stralloc_t* out)
716{
717 PRINTF(
718 " Prevents the emulator from saving the AVD's state to the snapshot\n"
719 " storage on exit, meaning that all changes will be lost.\n\n"
720 );
721}
722
723static void
Tim Baverstock622b8f42010-12-07 11:36:59 +0000724help_no_snapshot_update_time(stralloc_t* out)
725{
726 PRINTF(
727 " Prevent the emulator from sending an unsolicited time update\n"
728 " in response to the first signal strength query after loadvm,\n"
729 " to avoid a sudden time jump that might upset testing. (Signal\n"
730 " strength is queried approximately every 15 seconds)\n\n"
731 );
732}
733
734static void
Ot ten Thijeae835ac2010-10-18 13:37:37 +0100735help_snapshot_list(stralloc_t* out)
736{
737 PRINTF(
738 " This prints a table of snapshots that are stored in the snapshot storage\n"
739 " file that the emulator was started with, then exits. Values from the 'ID'\n"
740 " and 'TAG' columns can be used as arguments for the '-snapshot' parameter.\n\n"
741
742 " If '-snapstorage <file>' was specified as well, this command prints a "
743 " table of the snapshots stored in <file>.\n\n"
744
745 " See '-help-snapshot' for more information on snapshots.\n\n"
746 );
747}
748
Ot ten Thije353b3b12010-10-05 17:53:30 +0100749#endif
750
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800751static void
752help_skindir(stralloc_t* out)
753{
754 PRINTF(
755 " use '-skindir <dir>' to specify a directory that will be used to search\n"
756 " for emulator skins. each skin must be a subdirectory of <dir>. by default\n"
757 " the emulator will look in the 'skins' sub-directory of the system directory\n\n"
758
759 " the '-skin <name>' option is required when -skindir is used.\n"
760 );
761}
762
763static void
764help_skin(stralloc_t* out)
765{
766 PRINTF(
767 " use '-skin <skin>' to specify an emulator skin, each skin corresponds to\n"
768 " the visual appearance of a given device, including buttons and keyboards,\n"
769 " and is stored as subdirectory <skin> of the skin root directory\n"
770 " (see '-help-skindir')\n\n" );
771
772 PRINTF(
773 " note that <skin> can also be '<width>x<height>' (e.g. '320x480') to\n"
774 " specify an exact framebuffer size, without any visual ornaments.\n\n" );
775}
776
777/* default network settings for emulator */
778#define DEFAULT_NETSPEED "full"
779#define DEFAULT_NETDELAY "none"
780
781static void
782help_shaper(stralloc_t* out)
783{
784 int n;
Vladimir Chtchetkine318f17a2010-08-27 09:09:45 -0700785 NetworkSpeed android_netspeed;
786 NetworkLatency android_netdelay;
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800787 PRINTF(
788 " the Android emulator supports network throttling, i.e. slower network\n"
789 " bandwidth as well as higher connection latencies. this is done either through\n"
790 " skin configuration, or with '-netspeed <speed>' and '-netdelay <delay>'.\n\n"
791
792 " the format of -netspeed is one of the following (numbers are kbits/s):\n\n" );
793
Vladimir Chtchetkine318f17a2010-08-27 09:09:45 -0700794 for (n = 0; !android_core_get_android_netspeed(n, &android_netspeed); n++) {
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800795 PRINTF( " -netspeed %-12s %-15s (up: %.1f, down: %.1f)\n",
Vladimir Chtchetkine318f17a2010-08-27 09:09:45 -0700796 android_netspeed.name,
797 android_netspeed.display,
798 android_netspeed.upload/1000.,
799 android_netspeed.download/1000. );
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800800 }
801 PRINTF( "\n" );
802 PRINTF( " -netspeed %-12s %s", "<num>", "select both upload and download speed\n");
803 PRINTF( " -netspeed %-12s %s", "<up>:<down>", "select individual up and down speed\n");
804
805 PRINTF( "\n The format of -netdelay is one of the following (numbers are msec):\n\n" );
Vladimir Chtchetkine318f17a2010-08-27 09:09:45 -0700806 for (n = 0; !android_core_get_android_netdelay(n, &android_netdelay); n++) {
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800807 PRINTF( " -netdelay %-10s %-15s (min %d, max %d)\n",
Vladimir Chtchetkine318f17a2010-08-27 09:09:45 -0700808 android_netdelay.name, android_netdelay.display,
809 android_netdelay.min_ms, android_netdelay.max_ms );
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800810 }
811 PRINTF( " -netdelay %-10s %s", "<num>", "select exact latency\n");
812 PRINTF( " -netdelay %-10s %s", "<min>:<max>", "select min and max latencies\n\n");
813
814 PRINTF( " the emulator uses the following defaults:\n\n" );
815 PRINTF( " Default network speed is '%s'\n", DEFAULT_NETSPEED);
816 PRINTF( " Default network latency is '%s'\n\n", DEFAULT_NETDELAY);
817}
818
819static void
820help_http_proxy(stralloc_t* out)
821{
822 PRINTF(
823 " the Android emulator allows you to redirect all TCP connections through\n"
824 " a HTTP/HTTPS proxy. this can be enabled by using the '-http-proxy <proxy>'\n"
825 " option, or by defining the 'http_proxy' environment variable.\n\n"
826
827 " <proxy> can be one of the following:\n\n"
828 " http://<server>:<port>\n"
829 " http://<username>:<password>@<server>:<port>\n\n"
830
831 " the 'http://' prefix can be omitted. If '-http-proxy <proxy>' is not used,\n"
832 " the 'http_proxy' environment variable is looked up and any value matching\n"
833 " the <proxy> format will be used automatically\n\n" );
834}
835
836static void
837help_report_console(stralloc_t* out)
838{
839 PRINTF(
840 " the '-report-console <socket>' option can be used to report the\n"
841 " automatically-assigned console port number to a remote third-party\n"
842 " before starting the emulation. <socket> must be in one of these\n"
843 " formats:\n\n"
844
845 " tcp:<port>[,server][,max=<seconds>]\n"
846 " unix:<path>[,server][,max=<seconds>]\n"
847 "\n"
848 " if the 'server' option is used, the emulator opens a server socket\n"
849 " and waits for an incoming connection to it. by default, it will instead\n"
850 " try to make a normal client connection to the socket, and, in case of\n"
851 " failure, will repeat this operation every second for 10 seconds.\n"
852 " the 'max=<seconds>' option can be used to modify the timeout\n\n"
853
854 " when the connection is established, the emulator sends its console port\n"
855 " number as text to the remote third-party, then closes the connection and\n"
856 " starts the emulation as usual. *any* failure in the process described here\n"
857 " will result in the emulator aborting immediately\n\n"
858
859 " as an example, here's a small Unix shell script that starts the emulator in\n"
860 " the background and waits for its port number with the help of the 'netcat'\n"
861 " utility:\n\n"
862
863 " MYPORT=5000\n"
864 " emulator -no-window -report-console tcp:$MYPORT &\n"
865 " CONSOLEPORT=`nc -l localhost $MYPORT`\n"
866 "\n"
867 );
868}
869
870static void
871help_dpi_device(stralloc_t* out)
872{
873 PRINTF(
874 " use '-dpi-device <dpi>' to specify the screen resolution of the emulated\n"
875 " device. <dpi> must be an integer between 72 and 1000. the default is taken\n"
876 " from the skin, if available, or uses the contant value %d (an average of\n"
877 " several prototypes used during Android development).\n\n", DEFAULT_DEVICE_DPI );
878
879 PRINTF(
880 " the device resolution can also used to rescale the emulator window with\n"
881 " the '-scale' option (see -help-scale)\n\n"
882 );
883}
884
885static void
886help_audio(stralloc_t* out)
887{
888 PRINTF(
889 " the '-audio <backend>' option allows you to select a specific backend\n"
890 " to be used to both play and record audio in the Android emulator.\n\n"
891
892 " this is equivalent to calling both '-audio-in <backend>' and\n"
893 " '-audio-out <backend>' at the same time.\n\n"
894
895 " use '-help-audio-out' to see a list of valid output <backend> values.\n"
896 " use '-help-audio-in' to see a list of valid input <backend> values.\n"
897 " use '-audio none' to disable audio completely.\n\n"
898 );
899}
900
901static void
902help_audio_out(stralloc_t* out)
903{
904 int nn;
905
906 PRINTF(
907 " the '-audio-out <backend>' option allows you to select a specific\n"
908 " backend to play audio in the Android emulator. this is mostly useful\n"
909 " on Linux\n\n"
910
911 " on this system, output <backend> can be one of the following:\n\n"
912 );
913 for ( nn = 0; ; nn++ ) {
Vladimir Chtchetkine318f17a2010-08-27 09:09:45 -0700914 char name[512];
915 char descr[4096];
916 if (android_core_audio_get_backend_name(0, nn, name, sizeof(name),
917 descr, sizeof(descr))) {
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800918 break;
Vladimir Chtchetkine318f17a2010-08-27 09:09:45 -0700919 }
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800920 PRINTF( " %-10s %s\n", name, descr );
921 }
922 PRINTF( "\n" );
923}
924
925static void
926help_audio_in(stralloc_t* out)
927{
928 int nn;
929
930 PRINTF(
931 " the '-audio-in <backend>' option allows you to select a specific\n"
932 " backend to play audio in the Android emulator. this is mostly useful\n"
933 " on Linux\n\n"
934
935 " IMPORTANT NOTE:\n"
936 " on some Linux systems, broken Esd/ALSA/driver implementations will\n"
937 " make your emulator freeze and become totally unresponsive when\n"
938 " using audio recording. the only way to avoid this is to use\n"
939 " '-audio-in none' to disable it\n\n"
940
941 " on this system, input <backend> can be one of:\n\n"
942 );
943 for ( nn = 0; ; nn++ ) {
Vladimir Chtchetkine318f17a2010-08-27 09:09:45 -0700944 char name[512];
945 char descr[4096];
946 if (android_core_audio_get_backend_name(1, nn, name, sizeof(name),
947 descr, sizeof(descr))) {
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800948 break;
Vladimir Chtchetkine318f17a2010-08-27 09:09:45 -0700949 }
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800950 PRINTF( " %-10s %s\n", name, descr );
951 }
952 PRINTF( "\n" );
953}
954
955
956static void
957help_scale(stralloc_t* out)
958{
959 PRINTF(
960 " the '-scale <scale>' option is used to scale the emulator window to\n"
961 " something that better fits the physical dimensions of a real device. this\n"
962 " can be *very* useful to check that your UI isn't too small to be usable\n"
963 " on a real device.\n\n"
964
965 " there are three supported formats for <scale>:\n\n"
966
967 " * if <scale> is a real number (between 0.1 and 3.0) it is used as a\n"
968 " scaling factor for the emulator's window.\n\n"
969
970 " * if <scale> is an integer followed by the suffix 'dpi' (e.g. '110dpi'),\n"
971 " then it is interpreted as the resolution of your monitor screen. this\n"
972 " will be divided by the emulated device's resolution to get an absolute\n"
973 " scale. (see -help-dpi-device for details).\n\n"
974
975 " * finally, if <scale> is the keyword 'auto', the emulator tries to guess\n"
976 " your monitor's resolution and automatically adjusts its window\n"
977 " accordingly\n\n"
978
979 " NOTE: this process is *very* unreliable, depending on your OS, video\n"
980 " driver issues and other random system parameters\n\n"
981
982 " the emulator's scale can be changed anytime at runtime through the control\n"
983 " console. see the help for the 'window scale' command for details\n\n" );
984}
985
986static void
987help_trace(stralloc_t* out)
988{
989 PRINTF(
990 " use '-trace <name>' to start the emulator with runtime code profiling support\n"
991 " profiling itself will not be enabled unless you press F9 to activate it, or\n"
992 " the executed code turns it on programmatically.\n\n"
993
994 " trace information is stored in directory <name>, several files are created\n"
995 " there, that can later be used with the 'traceview' program that comes with\n"
996 " the Android SDK for analysis.\n\n"
997
998 " note that execution will be slightly slower when enabling code profiling,\n"
999 " this is a necessary requirement of the operations being performed to record\n"
1000 " the execution trace. this slowdown should not affect your system until you\n"
1001 " enable the profiling though...\n\n"
1002 );
1003}
1004
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -08001005#ifdef CONFIG_MEMCHECK
1006static void
1007help_memcheck(stralloc_t* out)
1008{
1009 PRINTF(
1010 " use '-memcheck <flags>' to start the emulator with memory access checking\n"
1011 " support.\n\n"
1012
1013 " <flags> enables, or disables memory access checking, and also controls\n"
1014 " what events are going to be logged by the memory access checker.\n"
1015 " <flags> can be one of the following:\n"
1016 " 1 - Enables memory access checking with default logging (\"LIRW\"), or\n"
1017 " 0 - Disables memory access checking, or\n"
1018 " A combination (in no particular order) of the following:\n"
1019 " L - Logs memory leaks on process exit.\n"
1020 " I - Logs attempts to use invalid pointers in free, or realloc routines.\n"
1021 " R - Logs memory access violation on read operations.\n"
1022 " W - Logs memory access violation on write operations.\n"
1023 " N - Logs new process ID allocation.\n"
1024 " F - Logs guest's process forking.\n"
1025 " S - Logs guest's process starting.\n"
1026 " E - Logs guest's process exiting.\n"
1027 " C - Logs guest's thread creation (clone).\n"
1028 " B - Logs libc.so initialization in the guest system.\n"
1029 " M - Logs module mapping and unmapping in the guest system.\n"
1030 " A - Logs all emulator events. Equala to \"LIRWFSECANBM\" combination.\n"
1031 " e - Logs error messages, received from the guest system.\n"
1032 " d - Logs debug messages, received from the guest system.\n"
1033 " i - Logs information messages, received from the guest system.\n"
1034 " a - Logs all messages, received from the guest system.\n"
1035 " This is equal to \"edi\" combination.\n\n"
1036
1037 " note that execution might be significantly slower when enabling memory access\n"
1038 " checking, this is a necessary requirement of the operations being performed\n"
1039 " to analyze memory allocations and memory access.\n\n"
1040 );
1041}
1042#endif // CONFIG_MEMCHECK
1043
Vladimir Chtchetkine9a33e852010-11-08 16:52:04 -08001044#ifdef CONFIG_STANDALONE_UI
1045static void
1046help_list_cores(stralloc_t* out)
1047{
1048 PRINTF(
1049 " use '-list-cores localhost to list emulator core processes running on this machine.\n"
1050 " use '-list-cores host_name, or IP address to list emulator core processes running on\n"
1051 " a remote machine.\n"
1052 );
1053}
Vladimir Chtchetkined87b0802010-12-06 10:55:11 -08001054
1055static void
1056help_attach_core(stralloc_t* out)
1057{
1058 PRINTF(
1059 " the -attach-core <console socket> options attaches the UI to a running emulator core process.\n\n"
1060
1061 " the <console socket> parameter must be in the form [host:]port, where 'host' addresses the\n"
1062 " machine on which the core process is running, and 'port' addresses the console port number for\n"
1063 " the running core process. Note that 'host' value must be in the form that can be resolved\n"
1064 " into an IP address.\n\n"
1065
1066 " Use -list-cores to enumerate console ports for all currently running core processes.\n"
1067 );
1068}
Vladimir Chtchetkine9a33e852010-11-08 16:52:04 -08001069#endif // CONFIG_STANDALONE_UI
1070
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001071static void
1072help_show_kernel(stralloc_t* out)
1073{
1074 PRINTF(
1075 " use '-show-kernel' to redirect debug messages from the kernel to the current\n"
1076 " terminal. this is useful to check that the boot process works correctly.\n\n"
1077 );
1078}
1079
1080static void
1081help_shell(stralloc_t* out)
1082{
1083 PRINTF(
1084 " use '-shell' to create a root shell console on the current terminal.\n"
1085 " this is unlike the 'adb shell' command for the following reasons:\n\n"
1086
1087 " * this is a *root* shell that allows you to modify many parts of the system\n"
1088 " * this works even if the ADB daemon in the emulated system is broken\n"
1089 " * pressing Ctrl-C will stop the emulator, instead of the shell.\n\n"
1090 " See also '-shell-serial'.\n\n" );
1091}
1092
1093static void
1094help_shell_serial(stralloc_t* out)
1095{
1096 PRINTF(
1097 " use '-shell-serial <device>' instead of '-shell' to open a root shell\n"
1098 " to the emulated system, while specifying an external communication\n"
1099 " channel / host device.\n\n"
1100
1101 " '-shell-serial stdio' is identical to '-shell', while you can use\n"
1102 " '-shell-serial tcp::4444,server,nowait' to talk to the shell over local\n"
1103 " TCP port 4444. '-shell-serial fdpair:3:6' would let a parent process\n"
1104 " talk to the shell using fds 3 and 6.\n\n"
1105
1106 " see -help-char-devices for a list of available <device> specifications.\n\n"
1107 " NOTE: you can have only one shell per emulator instance at the moment\n\n"
1108 );
1109}
1110
1111static void
1112help_logcat(stralloc_t* out)
1113{
1114 PRINTF(
1115 " use '-logcat <tags>' to redirect log messages from the emulated system to\n"
1116 " the current terminal. <tags> is a list of space/comma-separated log filters\n"
1117 " where each filter has the following format:\n\n"
1118
1119 " <componentName>:<logLevel>\n\n"
1120
1121 " where <componentName> is either '*' or the name of a given component,\n"
1122 " and <logLevel> is one of the following letters:\n\n"
1123
1124 " v verbose level\n"
1125 " d debug level\n"
1126 " i informative log level\n"
1127 " w warning log level\n"
1128 " e error log level\n"
1129 " s silent log level\n\n"
1130
1131 " for example, the following only displays messages from the 'GSM' component\n"
1132 " that are at least at the informative level:\n\n"
1133
1134 " -logcat '*:s GSM:i'\n\n"
1135
1136 " if '-logcat <tags>' is not used, the emulator looks for ANDROID_LOG_TAGS\n"
1137 " in the environment. if it is defined, its value must match the <tags>\n"
1138 " format and will be used to redirect log messages to the terminal.\n\n"
1139
1140 " note that this doesn't prevent you from redirecting the same, or other,\n"
1141 " log messages through the ADB or DDMS tools too.\n\n");
1142}
1143
1144static void
1145help_no_audio(stralloc_t* out)
1146{
1147 PRINTF(
1148 " use '-no-audio' to disable all audio support in the emulator. this may be\n"
1149 " unfortunately be necessary in some cases:\n\n"
1150
1151 " * at least two users have reported that their Windows machine rebooted\n"
1152 " instantly unless they used this option when starting the emulator.\n"
1153 " it is very likely that the problem comes from buggy audio drivers.\n\n"
1154
1155 " * on some Linux machines, the emulator might get stuck at startup with\n"
1156 " audio support enabled. this problem is hard to reproduce, but seems to\n"
1157 " be related too to flaky ALSA / audio driver support.\n\n"
1158
1159 " on Linux, another option is to try to change the default audio backend\n"
1160 " used by the emulator. you can do that by setting the QEMU_AUDIO_DRV\n"
1161 " environment variables to one of the following values:\n\n"
1162
1163 " alsa (use the ALSA backend)\n"
1164 " esd (use the EsounD backend)\n"
1165 " sdl (use the SDL audio backend, no audio input supported)\n"
1166 " oss (use the OSS backend)\n"
1167 " none (do not support audio)\n"
1168 "\n"
1169 " the very brave can also try to use distinct backends for audio input\n"
1170 " and audio outputs, this is possible by selecting one of the above values\n"
1171 " into the QEMU_AUDIO_OUT_DRV and QEMU_AUDIO_IN_DRV environment variables.\n\n"
1172 );
1173}
1174
1175static void
1176help_raw_keys(stralloc_t* out)
1177{
1178 PRINTF(
1179 " this option is deprecated because one can do the same using Ctrl-K\n"
1180 " at runtime (this keypress toggles between unicode/raw keyboard modes)\n\n"
1181
1182 " by default, the emulator tries to reverse-map the characters you type on\n"
1183 " your keyboard to device-specific key presses whenever possible. this is\n"
1184 " done to make the emulator usable with a non-QWERTY keyboard.\n\n"
1185
1186 " however, this also means that single keypresses like Shift or Alt are not\n"
1187 " passed to the emulated device. the '-raw-keys' option disables the reverse\n"
1188 " mapping. it should only be used when using a QWERTY keyboard on your machine\n"
1189
1190 " (should only be useful to Android system hackers, e.g. when implementing a\n"
1191 " new input method).\n\n"
1192 );
1193}
1194
1195static void
1196help_radio(stralloc_t* out)
1197{
1198 PRINTF(
1199 " use '-radio <device>' to redirect the GSM modem emulation to an external\n"
1200 " character device or program. this bypasses the emulator's internal modem\n"
1201 " and should only be used for testing.\n\n"
1202
1203 " see '-help-char-devices' for the format of <device>\n\n"
1204
1205 " the data exchanged with the external device/program are GSM AT commands\n\n"
1206
1207 " note that, when running in the emulator, the Android GSM stack only supports\n"
1208 " a *very* basic subset of the GSM protocol. trying to link the emulator to\n"
1209 " a real GSM modem is very likely to not work properly.\n\n"
1210 );
1211}
1212
1213
1214static void
1215help_port(stralloc_t* out)
1216{
1217 PRINTF(
1218 " at startup, the emulator tries to bind its control console at a free port\n"
1219 " starting from 5554, in increments of two (i.e. 5554, then 5556, 5558, etc..)\n"
1220 " this allows several emulator instances to run concurrently on the same\n"
1221 " machine, each one using a different console port number.\n\n"
1222
1223 " use '-port <port>' to force an emulator instance to use a given console port\n\n"
1224
1225 " note that <port> must be an *even* integer between 5554 and 5584 included.\n"
1226 " <port>+1 must also be free and will be reserved for ADB. if any of these\n"
1227 " ports is already used, the emulator will fail to start.\n\n" );
1228}
1229
1230static void
1231help_ports(stralloc_t* out)
1232{
1233 PRINTF(
1234 " the '-ports <consoleport>,<adbport>' option allows you to explicitely set\n"
1235 " the TCP ports used by the emulator to implement its control console and\n"
1236 " communicate with the ADB tool.\n\n"
1237
1238 " This is a very special option that should probably *not* be used by typical\n"
1239 " developers using the Android SDK (use '-port <port>' instead), because the\n"
1240 " corresponding instance is probably not going to be seen from adb/DDMS. Its\n"
1241 " purpose is to use the emulator in very specific network configurations.\n\n"
1242
1243 " <consoleport> is the TCP port used to bind the control console\n"
1244 " <adbport> is the TCP port used to bind the ADB local transport/tunnel.\n\n"
1245
1246 " If both ports aren't available on startup, the emulator will exit.\n\n");
1247}
1248
1249
1250static void
1251help_onion(stralloc_t* out)
1252{
1253 PRINTF(
1254 " use '-onion <file>' to specify a PNG image file that will be displayed on\n"
1255 " top of the emulated framebuffer with translucency. this can be useful to\n"
1256 " check that UI elements are correctly positioned with regards to a reference\n"
1257 " graphics specification.\n\n"
1258
1259 " the default translucency is 50%%, but you can use '-onion-alpha <%%age>' to\n"
1260 " select a different one, or even use keypresses at runtime to alter it\n"
1261 " (see -help-keys for details)\n\n"
1262
1263 " finally, the onion image can be rotated (see -help-onion-rotate)\n\n"
1264 );
1265}
1266
1267static void
1268help_onion_alpha(stralloc_t* out)
1269{
1270 PRINTF(
1271 " use '-onion-alpha <percent>' to change the translucency level of the onion\n"
1272 " image that is going to be displayed on top of the framebuffer (see also\n"
1273 " -help-onion). the default is 50%%.\n\n"
1274
1275 " <percent> must be an integer between 0 and 100.\n\n"
1276
1277 " you can also change the translucency dynamically (see -help-keys)\n\n"
1278 );
1279}
1280
1281static void
1282help_onion_rotation(stralloc_t* out)
1283{
1284 PRINTF(
1285 " use '-onion-rotation <rotation>' to change the rotation of the onion\n"
1286 " image loaded through '-onion <file>'. valid values for <rotation> are:\n\n"
1287
1288 " 0 no rotation\n"
1289 " 1 90 degrees clockwise\n"
1290 " 2 180 degrees\n"
1291 " 3 270 degrees clockwise\n\n"
1292 );
1293}
1294
1295
1296static void
1297help_timezone(stralloc_t* out)
1298{
1299 PRINTF(
1300 " by default, the emulator tries to detect your current timezone to report\n"
1301 " it to the emulated system. use the '-timezone <timezone>' option to choose\n"
1302 " a different timezone, or if the automatic detection doesn't work correctly.\n\n"
1303
1304 " VERY IMPORTANT NOTE:\n\n"
1305 " the <timezone> value must be in zoneinfo format, i.e. it should look like\n"
1306 " Area/Location or even Area/SubArea/Location. valid examples are:\n\n"
1307
1308 " America/Los_Angeles\n"
1309 " Europe/Paris\n\n"
1310
1311 " using a human-friendly abbreviation like 'PST' or 'CET' will not work, as\n"
1312 " well as using values that are not defined by the zoneinfo database.\n\n"
1313
1314 " NOTE: unfortunately, this will not work on M5 and older SDK releases\n\n"
1315 );
1316}
1317
1318
1319static void
1320help_dns_server(stralloc_t* out)
1321{
1322 PRINTF(
1323 " by default, the emulator tries to detect the DNS servers you're using and\n"
1324 " will setup special aliases in the emulated firewall network to allow the\n"
1325 " Android system to connect directly to them. use '-dns-server <servers>' to\n"
1326 " select a different list of DNS servers to be used.\n\n"
1327
1328 " <servers> must be a comma-separated list of up to 4 DNS server names or\n"
1329 " IP addresses.\n\n"
1330
1331 " NOTE: on M5 and older SDK releases, only the first server in the list will\n"
1332 " be used.\n\n"
1333 );
1334}
1335
1336
1337static void
1338help_cpu_delay(stralloc_t* out)
1339{
1340 PRINTF(
1341 " this option is purely experimental, probably doesn't work as you would\n"
1342 " expect, and may even disappear in a later emulator release.\n\n"
1343
1344 " use '-cpu-delay <delay>' to throttle CPU emulation. this may be useful\n"
1345 " to detect weird race conditions that only happen on 'lower' CPUs. note\n"
1346 " that <delay> is a unit-less integer that doesn't even scale linearly\n"
1347 " to observable slowdowns. use trial and error to find something that\n"
1348 " suits you, the 'correct' machine is very probably dependent on your\n"
1349 " host CPU and memory anyway...\n\n"
1350 );
1351}
1352
1353
1354static void
1355help_no_boot_anim(stralloc_t* out)
1356{
1357 PRINTF(
1358 " use '-no-boot-anim' to disable the boot animation (red bouncing ball) when\n"
1359 " starting the emulator. on slow machines, this can surprisingly speed up the\n"
1360 " boot sequence in tremendous ways.\n\n"
1361
1362 " NOTE: unfortunately, this will not work on M5 and older SDK releases\n\n"
1363 );
1364}
1365
1366
1367static void
1368help_gps(stralloc_t* out)
1369{
1370 PRINTF(
1371 " use '-gps <device>' to emulate an NMEA-compatible GPS unit connected to\n"
1372 " an external character device or socket. the format of <device> is the same\n"
1373 " than the one used for '-radio <device>' (see -help-char-devices for details)\n\n"
1374 );
1375}
1376
1377
1378static void
1379help_keyset(stralloc_t* out)
1380{
1381 char temp[256];
1382
1383 PRINTF(
1384 " use '-keyset <name>' to specify a different keyset file name to use when\n"
1385 " starting the emulator. a keyset file contains a list of key bindings used\n"
1386 " to control the emulator with the host keyboard.\n\n"
1387
1388 " by default, the emulator looks for the following file:\n\n"
1389 );
1390
1391 bufprint_config_file(temp, temp+sizeof(temp), KEYSET_FILE);
1392 PRINTF(
1393 " %s\n\n", temp );
1394
1395 bufprint_config_path(temp, temp+sizeof(temp));
1396 PRINTF(
1397 " however, if -keyset is used, then the emulator does the following:\n\n"
1398
1399 " - first, if <name> doesn't have an extension, then the '.keyset' suffix\n"
1400 " is appended to it (e.g. \"foo\" => \"foo.keyset\"),\n\n"
1401
1402 " - then, the emulator searches for a file named <name> in the following\n"
1403 " directories:\n\n"
1404
1405 " * the emulator configuration directory: %s\n"
1406 " * the 'keysets' subdirectory of <systemdir>, if any\n"
1407 " * the 'keysets' subdirectory of the program location, if any\n\n",
1408 temp );
1409
1410 PRINTF(
1411 " if no corresponding file is found, a default set of key bindings is used.\n\n"
1412 " use '-help-keys' to list the default key bindings.\n"
1413 " use '-help-keyset-file' to learn more about the format of keyset files.\n"
1414 "\n"
1415 );
1416}
1417
1418static void
1419help_old_system(stralloc_t* out)
1420{
1421 PRINTF(
1422 " use '-old-system' if you want to use a recent emulator binary to run\n"
1423 " an old version of the Android SDK system images. Here, 'old' means anything\n"
1424 " older than version 1.4 of the emulator.\n\n"
1425
1426 " NOTE: using '-old-system' with recent system images is likely to not work\n"
1427 " properly, though you may not notice it immediately (e.g. failure to\n"
1428 " start the emulated GPS hardware)\n\n"
1429 );
1430}
1431
1432#ifdef CONFIG_NAND_LIMITS
1433static void
1434help_nand_limits(stralloc_t* out)
1435{
1436 PRINTF(
1437 " use '-nand-limits <limits>' to enable a debugging feature that sends a\n"
1438 " signal to an external process once a read and/or write limit is achieved\n"
1439 " in the emulated system. the format of <limits> is the following:\n\n"
1440
1441 " pid=<number>,signal=<number>,[reads=<threshold>][,writes=<threshold>]\n\n"
1442
1443 " where 'pid' is the target process identifier, 'signal' the number of the\n"
1444 " target signal. the read and/or write threshold'reads' are a number optionally\n"
1445 " followed by a K, M or G suffix, corresponding to the number of bytes to be\n"
1446 " read or written before the signal is sent.\n\n"
1447 );
1448}
1449#endif /* CONFIG_NAND_LIMITS */
1450
1451static void
1452help_bootchart(stralloc_t *out)
1453{
1454 PRINTF(
1455 " some Android system images have a modified 'init' system that integrates\n"
1456 " a bootcharting facility (see http://www.bootchart.org/). You can pass a\n"
1457 " bootcharting period to the system with the following:\n\n"
1458
1459 " -bootchart <timeout>\n\n"
1460
1461 " where 'timeout' is a period expressed in seconds. Note that this won't do\n"
1462 " anything if your init doesn't have bootcharting activated.\n\n"
1463 );
1464}
1465
1466static void
1467help_tcpdump(stralloc_t *out)
1468{
1469 PRINTF(
1470 " use the -tcpdump <file> option to start capturing all network packets\n"
1471 " that are sent through the emulator's virtual Ethernet LAN. You can later\n"
1472 " use tools like WireShark to analyze the traffic and understand what\n"
1473 " really happens.\n\n"
1474
1475 " note that this captures all Ethernet packets, and is not limited to TCP\n"
1476 " connections.\n\n"
1477
1478 " you can also start/stop the packet capture dynamically through the console;\n"
1479 " see the 'network capture start' and 'network capture stop' commands for\n"
1480 " details.\n\n"
1481 );
1482}
1483
David 'Digit' Turner318e4f22009-05-25 18:01:03 +02001484static void
vchtchetkine9085a282009-09-14 15:29:20 -07001485help_charmap(stralloc_t *out)
1486{
1487 PRINTF(
1488 " use '-charmap <file>' to use key character map specified in that file.\n"
1489 " <file> must be a full path to a kcm file, containing desired character map.\n\n"
1490 );
1491}
1492
1493static void
David 'Digit' Turner318e4f22009-05-25 18:01:03 +02001494help_prop(stralloc_t *out)
1495{
1496 PRINTF(
1497 " use '-prop <name>=<value>' to set a boot-time system property.\n"
1498 " <name> must be a property name of at most %d characters, without any\n"
1499 " space in it, and <value> must be a string of at most %d characters.\n\n",
Vladimir Chtchetkine45d921a2010-07-08 11:05:31 -07001500 BOOT_PROPERTY_MAX_NAME, BOOT_PROPERTY_MAX_VALUE );
David 'Digit' Turner318e4f22009-05-25 18:01:03 +02001501
1502 PRINTF(
1503 " the corresponding system property will be set at boot time in the\n"
1504 " emulated system. This can be useful for debugging purposes.\n\n"
1505
1506 " note that you can use several -prop options to define more than one\n"
1507 " boot property.\n\n"
1508 );
1509}
1510
Dries Harnie40beab42010-05-15 17:04:47 +02001511static void
1512help_shared_net_id(stralloc_t* out)
1513{
1514 PRINTF(
1515 " Normally, Android instances running in the emulator cannot talk to each other\n"
1516 " directly, because each instance is behind a virtual router. However, sometimes\n"
1517 " it is necessary to test the behaviour of applications if they are directly\n"
1518 " exposed to the network.\n\n"
1519
1520 " This option instructs the emulator to join a virtual network shared with\n"
1521 " emulators also using this option. The number given is used to construct\n"
1522 " the IP address 10.1.2.<number>, which is bound to a second interface on\n"
1523 " the emulator. Each emulator must use a different number.\n\n"
1524 );
1525}
1526
1527
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001528#define help_no_skin NULL
1529#define help_netspeed help_shaper
1530#define help_netdelay help_shaper
1531#define help_netfast help_shaper
1532
1533#define help_noaudio NULL
1534#define help_noskin NULL
1535#define help_nocache NULL
1536#define help_no_jni NULL
1537#define help_nojni NULL
1538#define help_initdata NULL
1539#define help_no_window NULL
1540#define help_version NULL
1541#define help_memory NULL
The Android Open Source Projectb3ee93a2009-03-13 13:04:21 -07001542#define help_partition_size NULL
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001543
1544typedef struct {
1545 const char* name;
1546 const char* template;
1547 const char* descr;
1548 void (*func)(stralloc_t*);
1549} OptionHelp;
1550
1551static const OptionHelp option_help[] = {
1552#define OPT_FLAG(_name,_descr) { STRINGIFY(_name), NULL, _descr, help_##_name },
1553#define OPT_PARAM(_name,_template,_descr) { STRINGIFY(_name), _template, _descr, help_##_name },
David 'Digit' Turner318e4f22009-05-25 18:01:03 +02001554#define OPT_LIST OPT_PARAM
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001555#include "android/cmdline-options.h"
1556 { NULL, NULL, NULL, NULL }
1557};
1558
1559typedef struct {
1560 const char* name;
1561 const char* desc;
1562 void (*func)(stralloc_t*);
1563} TopicHelp;
1564
1565
1566static const TopicHelp topic_help[] = {
1567 { "disk-images", "about disk images", help_disk_images },
1568 { "keys", "supported key bindings", help_keys },
1569 { "debug-tags", "debug tags for -debug <tags>", help_debug_tags },
1570 { "char-devices", "character <device> specification", help_char_devices },
1571 { "environment", "environment variables", help_environment },
1572 { "keyset-file", "key bindings configuration file", help_keyset_file },
1573 { "virtual-device", "virtual device management", help_virtual_device },
1574 { "sdk-images", "about disk images when using the SDK", help_sdk_images },
1575 { "build-images", "about disk images when building Android", help_build_images },
1576 { NULL, NULL, NULL }
1577};
1578
1579int
1580android_help_for_option( const char* option, stralloc_t* out )
1581{
1582 OptionHelp const* oo;
1583 char temp[32];
1584
1585 /* the names in the option_help table use underscore instead
1586 * of dashes, so create a tranlated copy of the option name
1587 * before scanning the table for matches
1588 */
1589 buffer_translate_char( temp, sizeof temp, option, '-', '_' );
1590
1591 for ( oo = option_help; oo->name != NULL; oo++ ) {
1592 if ( !strcmp(oo->name, temp) ) {
1593 if (oo->func)
1594 oo->func(out);
1595 else
1596 stralloc_add_str(out, oo->descr);
1597 return 0;
1598 }
1599 }
1600 return -1;
1601}
1602
1603
1604int
1605android_help_for_topic( const char* topic, stralloc_t* out )
1606{
1607 const TopicHelp* tt;
1608
1609 for ( tt = topic_help; tt->name != NULL; tt++ ) {
1610 if ( !strcmp(tt->name, topic) ) {
1611 tt->func(out);
1612 return 0;
1613 }
1614 }
1615 return -1;
1616}
1617
1618
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -08001619extern void
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001620android_help_list_options( stralloc_t* out )
1621{
1622 const OptionHelp* oo;
1623 const TopicHelp* tt;
1624 int maxwidth = 0;
1625
1626 for ( oo = option_help; oo->name != NULL; oo++ ) {
1627 int width = strlen(oo->name);
1628 if (oo->template != NULL)
1629 width += strlen(oo->template);
1630 if (width > maxwidth)
1631 maxwidth = width;
1632 }
1633
1634 for (oo = option_help; oo->name != NULL; oo++) {
1635 char temp[32];
1636 /* the names in the option_help table use underscores instead
1637 * of dashes, so create a translated copy of the option's name
1638 */
1639 buffer_translate_char(temp, sizeof temp, oo->name, '_', '-');
1640
1641 stralloc_add_format( out, " -%s %-*s %s\n",
1642 temp,
1643 (int)(maxwidth - strlen(oo->name)),
1644 oo->template ? oo->template : "",
1645 oo->descr );
1646 }
1647
1648 PRINTF( "\n" );
1649 PRINTF( " %-*s %s\n", maxwidth, "-qemu args...", "pass arguments to qemu");
1650 PRINTF( " %-*s %s\n", maxwidth, "-qemu -h", "display qemu help");
1651 PRINTF( "\n" );
1652 PRINTF( " %-*s %s\n", maxwidth, "-verbose", "same as '-debug-init'");
1653 PRINTF( " %-*s %s\n", maxwidth, "-debug <tags>", "enable/disable debug messages");
1654 PRINTF( " %-*s %s\n", maxwidth, "-debug-<tag>", "enable specific debug messages");
1655 PRINTF( " %-*s %s\n", maxwidth, "-debug-no-<tag>","disable specific debug messages");
1656 PRINTF( "\n" );
1657 PRINTF( " %-*s %s\n", maxwidth, "-help", "print this help");
1658 PRINTF( " %-*s %s\n", maxwidth, "-help-<option>", "print option-specific help");
1659 PRINTF( "\n" );
1660
1661 for (tt = topic_help; tt->name != NULL; tt += 1) {
1662 char help[32];
1663 snprintf(help, sizeof(help), "-help-%s", tt->name);
1664 PRINTF( " %-*s %s\n", maxwidth, help, tt->desc );
1665 }
1666 PRINTF( " %-*s %s\n", maxwidth, "-help-all", "prints all help content");
1667 PRINTF( "\n");
1668}
1669
1670
1671void
1672android_help_main( stralloc_t* out )
1673{
1674 stralloc_add_str(out, "Android Emulator usage: emulator [options] [-qemu args]\n");
1675 stralloc_add_str(out, " options:\n" );
1676
1677 android_help_list_options(out);
1678
1679 /*printf( "%.*s", out->n, out->s );*/
1680}
1681
1682
1683void
1684android_help_all( stralloc_t* out )
1685{
1686 const OptionHelp* oo;
1687 const TopicHelp* tt;
1688
1689 for (oo = option_help; oo->name != NULL; oo++) {
1690 PRINTF( "========= help for option -%s:\n\n", oo->name );
1691 android_help_for_option( oo->name, out );
1692 }
1693
1694 for (tt = topic_help; tt->name != NULL; tt++) {
1695 PRINTF( "========= help for -help-%s\n\n", tt->name );
1696 android_help_for_topic( tt->name, out );
1697 }
1698 PRINTF( "========= top-level help\n\n" );
1699 android_help_main(out);
1700}