adb常用命令

通过adb获取页面信息

adb shell uiautomator dump /sdcard/ui.xml

将页面文件上传到电脑

adb pull /sdcard/ui.xml

在电脑上把文件上传到手机

adb push fileName /sdcard/fileName

另外可以使用AndroidSDK/tools/bin/目录下uiautomatoriviewer.bat工具获取页面信息

1.如果碰到
ERROR: could not get idle state.
可以断网试试
2.如果有动态部分则不支持dump

adb使用wifi调试

使用数据线连接成功后
adb tcpip 5555
adb connect 手机ip:5555

adb查看已连接设备

adb devices

adb控制手机

  1. 电源键(锁屏/亮屏)
adb shell input keyevent 26
  1. 输入密码
# 输入0-9 对应7-16
adb shell input keyevent 7   
adb shell input keyevent 8
adb shell input keyevent 9 
  1. 向上滑动
adb shell input swipe 500 500 500 200
  1. 向下滑动
adb shell input swipe 500 200 500 500
  1. 音量加/减
adb shell input keyevent 24
adb shell input keyevent 25
  1. 返回
adb shell input keyevent 4
  1. 运行app
adb shell am start -n com.miui.player/.ui.MusicBrowserActivity
  1. 获取当前最前面的app包名
adb shell am monitor
  1. 播放音乐
adb shell input keyevent 126
  1. 停止音乐
adb shell input keyevent 86
  1. 暂停音乐
adb shell input keyevent 127
  1. 播放/暂停
adb shell input keyevent 85
  1. 查看屏幕状态
adb shell dumpsys window policy
  1. 获取手机状态
adb shell dumpsys power
  1. 获取屏幕大小
adb shell wm size
  1. 获取全局设置信息
adb shell settings list global
  1. 修改WiFi休眠模式
- 在睡眠期间保持 WiFi 开启:始终 = 2
- 在睡眠期间保持 WiFi 开启:仅在插入时 = 1
- 在睡眠期间保持 WiFi 开启:从不 = 0
adb shell settings put global wifi_sleep_policy 1
  1. 挂载/system文件夹
adb shell
su 
mount -o rw,remount -t auto /system
# 改回去
mount -o ro,remount -t auto /system
  1. adb shell 中修改wifi连接
# 进入adb shell后
stop adbd
setprop service.adb.tcp.port 5555
start adbd
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值