指令 | 解释 |
---|---|
adb root | 获取root |
adb remount | 挂载 |
adb push 电脑文件 设备路径 | 将电脑文件弄到设备上 |
adb pull 设备路劲 [电脑路径] | 将设备上文件弄到电脑上 |
adb reboot | 重启 |
adb reboot recovery | 重启到recovery模式 |
adb reboot bootloader | 重启到bootloader模式 |
adb install -r | 替换系统中已经存在的apk reboot 之后失效 |
adb install xxx.apk | 安装 apk |
adb uninstall 包名 | 卸载 apk |
adb connect 192.168.xxx.xxx | 通过 网络连接adb 前提条件是在同一局域网中 |
adb devices | 查看 当前连接在电脑上的设备 |
adb -s aaaa xxxx | 当连接多个设备的时候,通过-s指定特定的设备 来操作对应的设备 |
adb forward local remote | 网络重定向 |
adb forward tcp:5901 tcp:5901 | 把PC端5901端口的数据, 转发到Android端的5901端口上 |
在shell环境下才能执行的命令
作用:调试按键的时候比较有用,这个是代表从内核传上来的值
getprop xxx 系统系统设置的属性
setprop xxx xxx 设置系统的属性
watchprops 动态查看属性的变化
##setting
1. 用法 settings [–user NUM] get namespace key
settings [–user NUM] put namespace key value
2 例子
+ 获取系统默认输入法
C:\Users\Administrator>adb shell settings get secure default_input_method
com.sohu.inputmethod.sogouoem/.SogouIME
+ put命令更改默认输入法(将io.appium.android.ime/.UnicodeIME改为com.sohu.inputmethod.sogouoem/.SogouIME)
C:\Users\Administrator>adb shell settings put secure default_input_method com.sohu.inputmethod.sogouoem/.SogouIME
+ 获取屏幕休眠时间
C:\Users\Administrator>adb shell settings get system screen_off_timeout
15000
+ 更改该状态,从1改为0
C:\Users\Administrator>adb shell settings put global auto_time 0
##input
1.用法
text (Default: touchscreen)
keyevent [–longpress] … (Default: keyboard)
tap (Default: touchscreen)
swipe [duration(ms)] (Default: touchscreen)
press (Default: trackball)
roll (Default: trackball)
2.例子
+ 模拟按下power键:adb shell input keyevent 26
+ 模拟按下返回键:adb shell input keyevent 4
作用:打印系统环境变量
作用:调试Android应用
##reboot
reboot 重启
reboot -p 关机
#其他常用命令
1. 查看当前应用程序的包名类名:dumpsys activity | grep Resume*
2. 获取截屏:adb shell /system/bin/screencap -p /sdcard/screenshot.png(保存到SDCard)
adb pull /sdcard/screenshot.png d:/screenshot.png(保存到电脑)
3. 不重启杀进程的方法,找到相应进程的pid 之后kill:
adb shell “ps |grep com.android.systemui |busybox awk ‘{print $2}’|busybox xargs kill -9”
adb shell “ps |grep zygote|busybox awk ‘{print $2}’|busybox xargs kill -9”
4. 自动填满内存的方法:adb shell dd if=/dev/zero of=/mnt/sdcard/bigfile
5. 应用对应的apk文件在手机上的安装位置: adb shell pm list packages -f
6. 启动activity方法:adb shell am start -n 包名/类名
7. 模拟广播发送的:
adb shell am broadcast -a com.android.test --es test_string “this is test string” --ei test_int 100 --ez test_boolean true
8. 实时查看各service状态:
1. adb shell
2. dumpsys | grep "DUMP OF SERVICE"看哪些service可以dump
3. dumpsys相应服务 如 battery
9. 修改文件权限:adb shell chmod 777 system/bin/bootanimation
10. 打印对应标签的log(5.0以上):
adb shell setprop log.tag.InCall D
adb shell stop
adb shell start
11. 电池电量模拟广播:
adb shell am broadcast -a android.intent.action.BATTERY_CHANGED --es technology Li-ion --ei level 50 --ei temperature 700
adb shell am broadcast -a android.intent.action.BATTERY_CHANGED --es technology Li-ion --ei icon-small 17303283 --ei max_charging_voltage 0 --ei health 2 --ei max_charging_current 0 --ei status 2 --ei plugged 2 --ez present true --ei charge_counter 0 --ei level 39 --ei scale 100 --ei temperature 9000 --ei voltage 4398 --ei invalid_charger 0
12. 查看当前的input设备: adb shell getevent -i
13. 清除apk缓存:adb shell pm clear
14. 查看systemui dump中的信息:adb shell dumpsys activity -p com.android.systemui service com.android.systemui/.SystemUIService
15. 通过adb 命令的方式,预置recovery指令:adb shell “echo “–update_package=/sdcard/update.zip” > /cache/recovery/command”