吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 11128|回复: 17
收起左侧

[Android 分享] ADB(Android Debug Bridge) 命令详解

  [复制链接]
loadbxh 发表于 2018-1-20 17:49
本帖最后由 loadbxh 于 2018-1-20 17:54 编辑

ADB(Android Debug Bridge)命令详解
1.介绍
Android设备与PC主机通过USB/TYPE-C And 网络连接,并与PC主机进行通讯/调试工具.
1.1源文档Doc:
Android Debug Bridge version 1.0.39
Version 0.0.1-4500957
Installed as C:\Windows\system32\adb.exe

global options:
-a         listen on all network interfaces, not just localhost
-d         use USB device (error if multiple devices connected)
-e         use TCP/IP device (error if multiple TCP/IP devices available)
-s SERIAL  use device with given serial (overrides $ANDROID_SERIAL)
-t ID      use device with given transport id
-H         name of adb server host [default=localhost]
-P         port of adb server [default=5037]
-L SOCKET  listen on given socket for adb server [default=tcp:localhost:5037]

general commands:
devices [-l]             list connected devices (-l for long output)
help                     show this help message
version                  show version num

networking:
connect HOST[:PORT]      connect to a device via TCP/IP [default port=5555]
disconnect [HOST[:PORT]]
     disconnect from given TCP/IP device [default port=5555], or all
forward --list           list all forward socket connections
forward [--no-rebind] LOCAL REMOTE
     forward socket connection using:
       tcp:<port> (<local> may be "tcp:0" to pick any open port)
       localabstract:<unix domain socket name>
       localreserved:<unix domain socket name>
       localfilesystem:<unix domain socket name>
       dev:<character device name>
       jdwp:<process pid> (remote only)
forward --remove LOCAL   remove specific forward socket connection
forward --remove-all     remove all forward socket connections
ppp TTY [PARAMETER...]   run PPP over USB
reverse --list           list all reverse socket connections from device
reverse [--no-rebind] REMOTE LOCAL
     reverse socket connection using:
       tcp:<port> (<remote> may be "tcp:0" to pick any open port)
       localabstract:<unix domain socket name>
       localreserved:<unix domain socket name>
       localfilesystem:<unix domain socket name>
reverse --remove REMOTE  remove specific reverse socket connection
reverse --remove-all     remove all reverse socket connections from device

file transfer:
push [--sync] LOCAL... REMOTE
     copy local files/directories to device
     --sync: only push files that are newer on the host than the device
pull [-a] REMOTE... LOCAL
     copy files/dirs from device
     -a: preserve file timestamp and mode
sync [system|vendor|oem|data|all]
     sync a local build from $ANDROID_PRODUCT_OUT to the device (default all)
     -l: list but don't copy

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

app installation:
install [-lrtsdg] PACKAGE
install-multiple [-lrtsdpg] PACKAGE...
     push package(s) to the device and install them
     -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:
   to show usage run "adb shell bu help"

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
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
reconnect offline        reset offline/unauthorized devices 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)

2.基础信息解释:
Android Debug Bridge version 1.0.39                        
# 使用版本为1.0.39 的 Android Debug Bridge
Version 0.0.1-4500957
# 内部版本为 0.0.1-4500957
Installed as C:\Windows\system32\adb.exe
# 安装路径为 C:\Windows\system32\adb.exe
# 此处说明:
# 1.从https://dl.google.com/android/repository/platform-tools-latest-平台.zip,下载Google开放ADB工具到合适你的运行平台.
# 2.解压platform-tools-latest-平台.zip,释放出ADB相关文件到路径: C:\Windows\system32\
# 3.打开系统path配置.修改系统PATH,在PATH最后一个分号后添加C:\Windows\system32\adb并保存.重启!
# 4.测试ADB PATH,打开CMD输入 adb version

3.基础操作:
adb 参数
# 参数:a 监听所有网络端口,d USB连接,e TCP连接,s 序列号连接,t ID连接,usb 监听USB连接,tcpip 监听TCP连接
# 作用:连接主机
connect 或disconnect
# 参数: 主机IP:端口
# 作用:从网络连接设备
reconnect
# 参数:device 设备端强制重连,offline 重置ADB授权请求
# 作用:强制重连
wait-for[-参数]-STATE
# 参数:device,bootloader,recovery,sideload(后面STATE不用理会)
# 作用:等待'参数'设备接入
get-state
# 参数:null
# 作用:获取设备名称
get-serialno
# 参数:null
# 作用:获取设备序列号
get-devpath
# 参数:null
# 作用:获取开发版本
start-server
# 参数:null
# 作用:开启ABD
kill-server
# 参数:null
# 作用:关闭ADB
reboot
# 参数:bootloader,recovery,sideload,sideload-auto-reboot
# 作用:重启设备到状态

4.常用操作
logcat
# 参数:配合shell符号参数
# 作用:输出设备日志
bugreport
# 参数: PATH
# 作用:输出设备日志文件
push 参数1 参数2 --sync
# 参数:本地路径 远程路径 !注意权限
# 作用:将本地文件拷贝至远程设备,sync参数为更新文件
pull 参数1 参数2 -a
# 参数:远程路径 本地路径
# 作用:将设备文件拷贝至本地路径,a参数保留文件时间戳等信息.
shell 参数
# 参数:e 转义字符,n 禁止读取,x 仿真控制台
# 作用:远程shell仿真
remount
# 参数: 分区
# 作用:重载分区
install
# 参数:l 锁定应用,r 取代应用,t 允许测试包,s 安装在外部存储,d 允许版本降级,p 批量安装,g 授予所有运行时权限
# 作用:安装/调试应用
uninstall
# 参数: k 保留数据
# 作用:卸载应用


论坛编辑器不会用,暂时就写这木多吧,手打翻译.实机测试.如果觉得辛苦请点赞收藏.

嗯,想起一件事,前几天看到有人问Fastboot.我这里也发一点吧,fastboot太接近核心.随便乱用我不负责的哦!
手机重启到Fastboot模式下.连接手机.输入Fastboot确认状态OK

fastboot flash boot xxx.img
这个命令可以给设备刷入BOOT分区,常用.但是注意你的Recovery和设备处理器平台.(OEM可不喜欢你这样,给你下套的多了去,自己注意)

根据这个命令,你可以结合ADB shell mount结果,对任何分区进行提取 修改 刷写操作.
fastboot erase boot
这个命令,可以擦除Mount出来的各个分区数据.这个擦除不是覆写.只是Clear.会让分区归零.所以用过后不做写入操作,基本设备都不会开机.如果你直接擦出了BOOT  那么恭喜你.制造黑砖一块.Fastboot,recovery统统报废.

还有一个不是Fastboot的方式,就是ADB sideload.这个命令也是可以刷机的,而且相对更安全.但是时间长,具体的怎么操作自己找找资料吧,我要去煮晚饭了...


斑竹,帖子位置不对帮忙移动一下.看我ID信息就知道,我不常来论坛的.但是我是一个灰常热心的人.

Py for ADB 演示 .rar

1.81 KB, 下载次数: 52, 下载积分: 吾爱币 -1 CB

使用PY3.6制作的android温度读取工具

免费评分

参与人数 5吾爱币 +7 热心值 +5 收起 理由
qilelejia + 1 + 1 谢谢@Thanks!
qtfreet00 + 3 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
殇丶浮生若夢 + 1 + 1 热心回复!
hejialong + 2 + 1 谢谢@Thanks!
秒针 + 1 看不懂,支持一个吧

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

smile 发表于 2018-1-20 18:00
看不懂,大神级别
 楼主| loadbxh 发表于 2018-1-22 01:56
寒尘丶Coldust 发表于 2018-1-22 00:15
感觉像是从官网上扒下来的...adb很强大 不过最好希望有人能做一份chm手册就最好了

是的,就是扒的官方文档.ADB其实也只是个调试通道而已,别想太多,真正强悍的是Android的Linux特性.
675550115 发表于 2018-1-20 18:23
kingswb 发表于 2018-1-20 19:04 来自手机
留个脚印
onemoretc 发表于 2018-1-20 20:27
很详细了,过去玩安卓的时候一直搞不懂,现在懂了却已经退烧了
新手小K 发表于 2018-1-20 20:40
学习学习,感谢分享
秒针 发表于 2018-1-20 22:08
看的那么多,就几个回复的,诶
当红灬依赖 发表于 2018-1-21 08:57
费心了,楼主!
殇丶浮生若夢 发表于 2018-1-21 10:36
感谢分享
Xdragon 发表于 2018-1-21 16:34
好像没必要发吧?Android官网就有技术文档
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-26 01:19

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表