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