一次连接即可告别adb有线模式
- 使用有线连接手机,执行以下命令:adb tcpip 5555
> adb tcpip 5555
restarting in TCP mode port: 5555
- 接着执行adb connect (手机ip地址):5555,这时候应该就能连接成功了
> adb connect 172.25.64.62:5555
connected to 172.25.64.62:5555
调试完成之后,输入如下的命令断开连接:
> adb disconnect
disconnected everything
说明代码:
static void help() {
fprintf(stdout, "%s\n", adb_version().c_str());
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 TCP/IP device (error if multiple TCP/IP devices available)\n"
" -s SERIAL use device with given serial (overrides $ANDROID_SERIAL)\n"
" -t ID use device with given transport id\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"
"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"
" 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:<port> (<local> may be \"tcp:0\" to pick any open port)\n"
" localabstract:<unix domain socket name>\n"
" localreserved:<unix domain socket name>\n"
" localfilesystem:<unix domain socket name>\n"
" dev:<character device name>\n"
" jdwp:<process pid> (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:<port> (<remote> may be \"tcp:0\" to pick any open port)\n"
" localabstract:<unix domain socket name>\n"
" localreserved:<unix domain socket name>\n"
" localfilesystem:<unix domain socket name>\n"
" reverse --remove REMOTE remove specific reverse socket connection\n"
" reverse --remove-all remove all reverse socket connections from device\n"
"\n"
"file transfer:\n"
" push [--sync] LOCAL... REMOTE\n"
" copy local files/directories to device\n"
" --sync: only push files that are newer on the host than the device\n"
" pull [-a] REMOTE... LOCAL\n"
" copy files/dirs from device\n"
" -a: preserve file timestamp and mode\n"
" sync [all|data|odm|oem|product|system|vendor]\n"
" sync a local build from $ANDROID_PRODUCT_OUT to the device (default all)\n"
" -l: list but don't copy\n"
"\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"
"app installation:\n"
" install [-lrtsdg] [--instant] PACKAGE\n"
" install-multiple [-lrtsdpg] [--instant] 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"
" --instant: cause the app to be installed as an ephemeral install app\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"
" to show usage run \"adb shell bu help\"\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 <serial-number>\n"
" get-devpath print <device-path>\n"
" remount remount 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"
" 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"
" reconnect offline reset offline/unauthorized devices to force reconnect\n"
"\n"
"environment variables:\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");
}
附上adb源码说明地址: adb source code
|