From 4bf9bc1ac70fb0856d6ec5ae1b8dc02402e6d7c5 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 28 Sep 2016 15:25:47 -0700 Subject: [PATCH] Improve "adb help" output. The specific request was to document $ADB_VENDOR_KEYS, but since I'm here, let's try to make the help output shorter but more useful... Bug: http://b/18437888 Test: adb help Change-Id: I77135d4e666f19524f880228d27d87ba881672b5 --- adb/commandline.cpp | 298 ++++++++++++++++++++------------------------ 1 file changed, 133 insertions(+), 165 deletions(-) diff --git a/adb/commandline.cpp b/adb/commandline.cpp index a9185a0b1..54e254a1c 100644 --- a/adb/commandline.cpp +++ b/adb/commandline.cpp @@ -83,181 +83,149 @@ static std::string product_file(const char *extra) { } static void help() { - fprintf(stderr, "%s\n", adb_version().c_str()); + fprintf(stdout, "%s\n", adb_version().c_str()); // clang-format off - fprintf(stderr, - " -a - directs adb to listen on all interfaces for a connection\n" - " -d - directs command to the only connected USB device\n" - " returns an error if more than one USB device is present.\n" - " -e - directs command to the only running emulator.\n" - " returns an error if more than one emulator is running.\n" - " -s - directs command to the device or emulator with the given\n" - " serial number or qualifier. Overrides ANDROID_SERIAL\n" - " environment variable.\n" - " -p - simple product name like 'sooner', or\n" - " a relative/absolute path to a product\n" - " out directory like 'out/target/product/sooner'.\n" - " If -p is not specified, the ANDROID_PRODUCT_OUT\n" - " environment variable is used, which must\n" - " be an absolute path.\n" - " -H - Name of adb server host (default: localhost)\n" - " -P - Port of adb server (default: 5037)\n" - " -L - listen on socket specifier for the adb server\n" - " (default: tcp:localhost:5037)\n" - " devices [-l] - list all connected devices\n" - " ('-l' will also list device qualifiers)\n" - " connect [:] - connect to a device via TCP/IP\n" - " Port 5555 is used by default if no port number is specified.\n" - " disconnect [[:]] - disconnect from a TCP/IP device.\n" - " Port 5555 is used by default if no port number is specified.\n" - " Using this command with no additional arguments\n" - " will disconnect from all connected TCP/IP devices.\n" + fprintf(stdout, + "global options:\n" + " -a listen on all network interfaces, not just localhost\n" + " -d use USB device (error if multiple devices connected)\n" + " -e use emulator (error if multiple emulators running)\n" + " -s SERIAL\n" + " use device/emulator with given serial number (overrides $ANDROID_SERIAL)\n" + " -p PRODUCT\n" + " name or path ('angler'/'out/target/product/angler');\n" + " default $ANDROID_PRODUCT_OUT\n" + " -H name of adb server host [default=localhost]\n" + " -P port of adb server [default=5037]\n" + " -L SOCKET listen on given socket for adb server [default=tcp:localhost:5037]\n" "\n" - "device commands:\n" - " adb push ... \n" - " - copy files/dirs to device\n" - " adb pull [-a] ... \n" - " - copy files/dirs from device\n" - " (-a preserves file timestamp and mode)\n" - " adb sync [ ] - copy host->device only if changed\n" - " (-l means list but don't copy)\n" - " adb shell [-e escape] [-n] [-Tt] [-x] [command]\n" - " - run remote shell command (interactive shell if no command given)\n" - " (-e: choose escape character, or \"none\"; default '~')\n" - " (-n: don't read from stdin)\n" - " (-T: disable PTY allocation)\n" - " (-t: force PTY allocation)\n" - " (-x: disable remote exit codes and stdout/stderr separation)\n" - " adb emu - run emulator console command\n" - " adb logcat [ ] - View device log\n" - " adb forward --list - list all forward socket connections.\n" - " the format is a list of lines with the following format:\n" - " \" \" \" \" \"\\n\"\n" - " adb forward - forward socket connections\n" - " forward specs are one of: \n" - " tcp: ( may be \"tcp:0\" to pick any open port)\n" - " localabstract:\n" - " localreserved:\n" - " localfilesystem:\n" - " dev:\n" - " jdwp: (remote only)\n" - " adb forward --no-rebind \n" - " - same as 'adb forward ' but fails\n" - " if is already forwarded\n" - " adb forward --remove - remove a specific forward socket connection\n" - " adb forward --remove-all - remove all forward socket connections\n" - " adb reverse --list - list all reverse socket connections from device\n" - " adb reverse - reverse socket connections\n" - " reverse specs are one of:\n" - " tcp: ( may be \"tcp:0\" to pick any open port)\n" - " localabstract:\n" - " localreserved:\n" - " localfilesystem:\n" - " adb reverse --no-rebind \n" - " - same as 'adb reverse ' but fails\n" - " if is already reversed.\n" - " adb reverse --remove \n" - " - remove a specific reversed socket connection\n" - " adb reverse --remove-all - remove all reversed socket connections from device\n" - " adb jdwp - list PIDs of processes hosting a JDWP transport\n" - " adb install [-lrtsdg] \n" - " - push this package file to the device and install it\n" - " (-l: forward lock application)\n" - " (-r: replace existing application)\n" - " (-t: allow test packages)\n" - " (-s: install application on sdcard)\n" - " (-d: allow version code downgrade (debuggable packages only))\n" - " (-g: grant all runtime permissions)\n" - " adb install-multiple [-lrtsdpg] \n" - " - push this package file to the device and install it\n" - " (-l: forward lock application)\n" - " (-r: replace existing application)\n" - " (-t: allow test packages)\n" - " (-s: install application on sdcard)\n" - " (-d: allow version code downgrade (debuggable packages only))\n" - " (-p: partial application install)\n" - " (-g: grant all runtime permissions)\n" - " adb uninstall [-k] - remove this app package from the device\n" - " ('-k' means keep the data and cache directories)\n" - " adb bugreport [] - return all information from the device that should be included in a zipped bug report.\n" - " If is a file, the bug report will be saved as that file.\n" - " If is a directory, the bug report will be saved in that directory with the name provided by the device.\n" - " If is omitted, the bug report will be saved in the current directory with the name provided by the device.\n" - " NOTE: if the device does not support zipped bug reports, the bug report will be output on stdout.\n" - " adb backup [-f ] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] []\n" - " - write an archive of the device's data to .\n" - " If no -f option is supplied then the data is written\n" - " to \"backup.ab\" in the current directory.\n" - " (-apk|-noapk enable/disable backup of the .apks themselves\n" - " in the archive; the default is noapk.)\n" - " (-obb|-noobb enable/disable backup of any installed apk expansion\n" - " (aka .obb) files associated with each application; the default\n" - " is noobb.)\n" - " (-shared|-noshared enable/disable backup of the device's\n" - " shared storage / SD card contents; the default is noshared.)\n" - " (-all means to back up all installed applications)\n" - " (-system|-nosystem toggles whether -all automatically includes\n" - " system applications; the default is to include system apps)\n" - " ( is the list of applications to be backed up. If\n" - " the -all or -shared flags are passed, then the package\n" - " list is optional. Applications explicitly given on the\n" - " command line will be included even if -nosystem would\n" - " ordinarily cause them to be omitted.)\n" - "\n" - " adb restore - restore device contents from the backup archive\n" - "\n" - " adb disable-verity - disable dm-verity checking on USERDEBUG builds\n" - " adb enable-verity - re-enable dm-verity checking on USERDEBUG builds\n" - " adb keygen - generate adb public/private key. The private key is stored in ,\n" - " and the public key is stored in .pub. Any existing files\n" - " are overwritten.\n" - " adb help - show this help message\n" - " adb version - show version num\n" - "\n" - "scripting:\n" - " adb wait-for[-]-\n" - " - wait for device to be in the given state:\n" - " device, recovery, sideload, or bootloader\n" - " Transport is: usb, local or any [default=any]\n" - " adb start-server - ensure that there is a server running\n" - " adb kill-server - kill the server if it is running\n" - " adb get-state - prints: offline | bootloader | device\n" - " adb get-serialno - prints: \n" - " adb get-devpath - prints: \n" - " adb remount - remounts the /system, /vendor (if present) and /oem (if present) partitions on the device read-write\n" - " adb reboot [bootloader|recovery]\n" - " - reboots the device, optionally into the bootloader or recovery program.\n" - " adb reboot sideload - reboots the device into the sideload mode in recovery program (adb root required).\n" - " adb reboot sideload-auto-reboot\n" - " - reboots into the sideload mode, then reboots automatically after the sideload regardless of the result.\n" - " adb sideload - sideloads the given package\n" - " adb root - restarts the adbd daemon with root permissions\n" - " adb unroot - restarts the adbd daemon without root permissions\n" - " adb usb - restarts the adbd daemon listening on USB\n" - " adb tcpip - restarts the adbd daemon listening on TCP on the specified port\n" + "general commands:\n" + " devices [-l] list connected devices (-l for long output)\n" + " help show this help message\n" + " version show version num\n" "\n" "networking:\n" - " adb ppp [parameters] - Run PPP over USB.\n" - " Note: you should not automatically start a PPP connection.\n" - " refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1\n" - " [parameters] - Eg. defaultroute debug dump local notty usepeerdns\n" + " connect HOST[:PORT] connect to a device via TCP/IP [default port=5555]\n" + " disconnect [HOST[:PORT]]\n" + " disconnect from given TCP/IP device [default port=5555], or all\n" + " forward --list list all forward socket connections\n" + " forward [--no-rebind] LOCAL REMOTE\n" + " forward socket connection using:\n" + " tcp: ( may be \"tcp:0\" to pick any open port)\n" + " localabstract:\n" + " localreserved:\n" + " localfilesystem:\n" + " dev:\n" + " jdwp: (remote only)\n" + " forward --remove LOCAL remove specific forward socket connection\n" + " forward --remove-all remove all forward socket connections\n" + " ppp TTY [PARAMETER...] run PPP over USB\n" + " reverse --list list all reverse socket connections from device\n" + " reverse [--no-rebind] REMOTE LOCAL\n" + " reverse socket connection using:\n" + " tcp: ( may be \"tcp:0\" to pick any open port)\n" + " localabstract:\n" + " localreserved:\n" + " localfilesystem:\n" + " reverse --remove REMOTE remove specific reverse socket connection\n" + " reverse --remove-all remove all reverse socket connections from device\n" "\n" - "adb sync notes: adb sync [ ]\n" - " can be interpreted in several ways:\n" + "file transfer:\n" + " push LOCAL... REMOTE\n" + " copy local files/directories to device\n" + " pull [-a] REMOTE... LOCAL\n" + " copy files/dirs from device\n" + " -a: preserve file timestamp and mode\n" + " sync [DIR]\n" + " copy all changed files to device; if DIR is \"system\", \"vendor\", \"oem\",\n" + " or \"data\", only sync that partition (default all)\n" + " -l: list but don't copy\n" "\n" - " - If is not specified, /system, /vendor (if present), /oem (if present) and /data partitions will be updated.\n" + "shell:\n" + " shell [-e ESCAPE] [-n] [-Tt] [-x] [COMMAND...]\n" + " run remote shell command (interactive shell if no command given)\n" + " -e: choose escape character, or \"none\"; default '~'\n" + " -n: don't read from stdin\n" + " -T: disable PTY allocation\n" + " -t: force PTY allocation\n" + " -x: disable remote exit codes and stdout/stderr separation\n" + " emu COMMAND run emulator console command\n" "\n" - " - If it is \"system\", \"vendor\", \"oem\" or \"data\", only the corresponding partition\n" - " is updated.\n" + "app installation:\n" + " install [-lrtsdg] PACKAGE\n" + " install-multiple [-lrtsdpg] PACKAGE...\n" + " push package(s) to the device and install them\n" + " -l: forward lock application\n" + " -r: replace existing application\n" + " -t: allow test packages\n" + " -s: install application on sdcard\n" + " -d: allow version code downgrade (debuggable packages only)\n" + " -p: partial application install (install-multiple only)\n" + " -g: grant all runtime permissions\n" + " uninstall [-k] PACKAGE\n" + " remove this app package from the device\n" + " '-k': keep the data and cache directories\n" + "\n" + "backup/restore:\n" + " backup [-f FILE] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] [PACKAGE...]\n" + " write an archive of the device's data to FILE [default=backup.adb]\n" + " package list optional if -all/-shared are supplied\n" + " -apk/-noapk: do/don't back up .apk files (default -noapk)\n" + " -obb/-noobb: do/don't back up .obb files (default -noobb)\n" + " -shared|-noshared: do/don't back up shared storage (default -noshared)\n" + " -all: back up all installed applications\n" + " -system|-nosystem: include system apps in -all (default -system)\n" + " restore FILE restore device contents from FILE\n" + "\n" + "debugging:\n" + " bugreport [PATH]\n" + " write bugreport to given PATH [default=bugreport.zip];\n" + " if PATH is a directory, the bug report is saved in that directory.\n" + " devices that don't support zipped bug reports output to stdout.\n" + " jdwp list pids of processes hosting a JDWP transport\n" + " logcat show device log (logcat --help for more)\n" + "\n" + "security:\n" + " disable-verity disable dm-verity checking on userdebug builds\n" + " enable-verity re-enable dm-verity checking on userdebug builds\n" + " keygen FILE\n" + " generate adb public/private key; private key stored in FILE,\n" + " public key stored in FILE.pub (existing files overwritten)\n" + "\n" + "scripting:\n" + " wait-for[-TRANSPORT]-STATE\n" + " wait for device to be in the given state\n" + " State: device, recovery, sideload, or bootloader\n" + " Transport: usb, local, or any [default=any]\n" + " get-state print offline | bootloader | device\n" + " get-serialno print \n" + " get-devpath print \n" + " remount\n" + " remount /system, /vendor, and /oem partitions read-write\n" + " reboot [bootloader|recovery|sideload|sideload-auto-reboot]\n" + " reboot the device; defaults to booting system image but\n" + " supports bootloader and recovery too. sideload reboots\n" + " into recovery and automatically starts sideload mode,\n" + " sideload-auto-reboot is the same but reboots after sideloading.\n" + " sideload OTAPACKAGE sideload the given full OTA package\n" + " root restart adbd with root permissions\n" + " unroot restart adbd without root permissions\n" + " usb restart adb server listening on USB\n" + " tcpip PORT restart adb server listening on TCP on PORT\n" "\n" "internal debugging:\n" - " adb reconnect Kick current connection from host side and make it reconnect.\n" - " adb reconnect device Kick current connection from device side and make it reconnect.\n" + " start-server ensure that there is a server running\n" + " kill-server kill the server if it is running\n" + " reconnect kick connection from host side to force reconnect\n" + " reconnect device kick connection from device side to force reconnect\n" + "\n" "environment variables:\n" - " ADB_TRACE - Print debug information. A comma separated list of the following values\n" - " 1 or all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp\n" - " ANDROID_SERIAL - The serial number to connect to. -s takes priority over this if given.\n" - " ANDROID_LOG_TAGS - When used with the logcat option, only these debug tags are printed.\n"); + " $ADB_TRACE\n" + " comma-separated list of debug info to log:\n" + " all,adb,sockets,packets,rwx,usb,sync,sysdeps,transport,jdwp\n" + " $ADB_VENDOR_KEYS colon-separated list of keys (files or directories)\n" + " $ANDROID_SERIAL serial number to connect to (see -s)\n" + " $ANDROID_LOG_TAGS tags to be used by logcat (see logcat --help)\n"); // clang-format on }