常用adb shell命令大全

一、adb相关命令。

1. 关闭adb服务:adb kill-server

2. 开启adb服务:adb start-server

3. 查看当前连接的手机设备:adb devices

4. 多设设备操作,< -s 虚拟设备名称 >

5. 重启设备 adb reboot --指定虚拟设备 adb -s 设备名称 reboot

6. 查看日志 adb logcat 清除日志 adb logcat -c

7. 进入linux shell下 adb shell 其中常用的linux命令 cd cat 等等 输入su可以获取超级管理员名称了 要确定是否有哪些命令 进入 system/bin目录 就知道了

8. adb connect [ip:post] #代理链接

9. adb shell cat /sys/class/net/wlan0/address #获取MAC地址

10. adb install <name.apk>  #安装应用

11. adb uninstall <name.apk>  #卸载安装包

12. adb install -r <name.apk>  #保存缓存文件重新安装apk

13.adb disconnect <设备名>  #断开连接

14. adb push filename /sdcard/ #文件复制到移动设备 ,后面跟设备目录

15. adb shell input tap  #模拟位置点击(x,y)

16. adb shell input swipe   #模拟滑动( x,yx1,y1 ),还可传入滑动缓冲

17. uiautomator dump dump: creates an XML dump of current UI hierarchy  #获取当前页面的UI层 次,保存为xml文件
  
18.adb shell input text <输入任意内容> #模式实现输入

二:adb模拟按键对照表

keycode 含义
3 HOME 键
4 返回键
5 打开拨号应用
6 挂断电话
24 增加音量
25 降低音量
26 电源键
27 拍照(需要在相机应用里)
64 打开浏览器
82 菜单键
85 播放/暂停
86 停止播放
87 播放下一首
88 播放上一首
122 移动光标到行首或列表顶部
123 移动光标到行末或列表底部
126 恢复播放
127 暂停播放
164 静音
176 打开系统设置
187 切换应用
207 打开联系人
208 打开日历
209 打开音乐
210 打开计算器
220 降低屏幕亮度
221 提高屏幕亮度
223 系统休眠
224 点亮屏幕
231 打开语音助手
276 如果没有 wakelock 则让系统休眠

调用实例说明:

命令: adb shell input keyevent <keycode>
  1. 示例,点击电源键:
 adb shell input keyevent 26  #执行效果相当于按电源键。
  1. 示例,输入"你好啊中国":
 adb shell input text "你好啊中国"  #执行效果相当于用户输入"你好啊中国"。
  1. 示例,模拟点击任何位置:
adb shell input tap x y (x和y表示点击的坐标)

当然,有很多,这里不一一列举了。

发布了49 篇原创文章 · 获赞 66 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/ljx1400052550/article/details/103835482