微信跳一跳高分系列一:解读 adb 工具

版权声明:本文为大事龙原创文章,未经允许不得转载。 https://blog.csdn.net/w_yunlong/article/details/79105561

adb

常用命令

general commands: // 常用命令
 devices [-l]             list connected devices (-l for long output) // 列出当前链接到 adb-server 的设备
 help                     show this help message // 查看帮助
 version                  show version num // 显示当前版本号

文件传输

file transfer: // 文件传输
 push LOCAL... REMOTE // 推送PC文件到手机: push d://demo.txt /sdcard/
     copy local files/directories to device
 pull [-a] REMOTE... LOCAL // 拉取手机文件到PC: pull /sdcard/demo.txt d://mobile
     copy files/dirs from device
     -a: preserve file timestamp and mode
 sync [DIR] // 同步目录到手机
     copy all changed files to device; if DIR is "system", "vendor", "oem",
     or "data", only sync that partition (default all)
     -l: list but don't copy

shell 命令

shell: // shell 命令(常用于模拟点击、输入、截屏、录屏等事件)
 shell [-e ESCAPE] [-n] [-Tt] [-x] [COMMAND...]
     run remote shell command (interactive shell if no command given)
     -e: choose escape character, or "none"; default '~'
     -n: don't read from stdin
     -T: disable PTY allocation
     -t: force PTY allocation
     -x: disable remote exit codes and stdout/stderr separation
 emu COMMAND              run emulator console command

安装 apk

app installation: // 安装 apk
 install [-lrtsdg] PACKAGE
 install-multiple [-lrtsdpg] PACKAGE...
     push package(s) to the device and install them // 先将安装包推送到手机端,然后安装: install com.youhua
     -l: forward lock application
     -r: replace existing application
     -t: allow test packages
     -s: install application on sdcard
     -d: allow version code downgrade (debuggable packages only)
     -p: partial application install (install-multiple only)
     -g: grant all runtime permissions
 uninstall [-k] PACKAGE
     remove this app package from the device
     '-k': keep the data and cache directories

备份和还原

backup/restore: // 备份和还原
 backup [-f FILE] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] [PACKAGE...]
     write an archive of the device's data to FILE [default=backup.adb]
     package list optional if -all/-shared are supplied
     -apk/-noapk: do/don't back up .apk files (default -noapk)
     -obb/-noobb: do/don't back up .obb files (default -noobb)
     -shared|-noshared: do/don't back up shared storage (default -noshared)
     -all: back up all installed applications
     -system|-nosystem: include system apps in -all (default -system)
 restore FILE             restore device contents from FILE

调试

debugging: // 调试
 bugreport [PATH]
     write bugreport to given PATH [default=bugreport.zip];
     if PATH is a directory, the bug report is saved in that directory.
     devices that don't support zipped bug reports output to stdout.
 jdwp                     list pids of processes hosting a JDWP transport
 logcat                   show device log (logcat --help for more)

安全

security:// 安全
 disable-verity           disable dm-verity checking on userdebug builds
 enable-verity            re-enable dm-verity checking on userdebug builds
 keygen FILE
     generate adb public/private key; private key stored in FILE,
     public key stored in FILE.pub (existing files overwritten)

脚本

scripting:
 wait-for[-TRANSPORT]-STATE
     wait for device to be in the given state
     State: device, recovery, sideload, or bootloader
     Transport: usb, local, or any [default=any]
 get-state                print offline | bootloader | device
 get-serialno             print <serial-number>
 get-devpath              print <device-path>
 remount
     remount /system, /vendor, and /oem partitions read-write
 reboot [bootloader|recovery|sideload|sideload-auto-reboot]
     reboot the device; defaults to booting system image but
     supports bootloader and recovery too. sideload reboots
     into recovery and automatically starts sideload mode,
     sideload-auto-reboot is the same but reboots after sideloading.
 sideload OTAPACKAGE      sideload the given full OTA package
 root                     restart adbd with root permissions
 unroot                   restart adbd without root permissions
 usb                      restart adb server listening on USB // 重新启动 正在监听 usbadb-server
 tcpip PORT               restart adb server listening on TCP on PORT
internal debugging:
 start-server             ensure that there is a server running
 kill-server              kill the server if it is running
 reconnect                kick connection from host side to force reconnect
 reconnect device         kick connection from device side to force reconnect

环境变量

environment variables: // 环境变量
 $ADB_TRACE
     comma-separated list of debug info to log:
     all,adb,sockets,packets,rwx,usb,sync,sysdeps,transport,jdwp
 $ADB_VENDOR_KEYS         colon-separated list of keys (files or directories)
 $ANDROID_SERIAL          serial number to connect to (see -s)
 $ANDROID_LOG_TAGS        tags to be used by logcat (see logcat --help)

猜你喜欢

转载自blog.csdn.net/w_yunlong/article/details/79105561
今日推荐