zoukankan      html  css  js  c++  java
  • 五、ADB进阶

    一、传输文件

    image

    • push

      • adb push 电脑路径 设备路径
    • pull

      • adb pull 设备路径 电脑路径

    二、查看日志

    日志的级别

    • V — 明细 verbose(最低优先级)
    • D — 调试 debug
    • I — 信息 info
    • W — 警告 warn
    • E — 错误 error
    • F — 严重错误 fatal
    • S — 无记载 silent(最高优先级,绝不会输出任何内容)

    查看命令

    • adb logcat 查看近期所有日志
    • adb logcat --help 查看帮命令
    • adb logcat 打印默认日志数据
    • adb logcat -v time 打印时间
    • adb logcat -v color 使用不同的颜色来显示每个优先级
    • adb logcat -f <filename> 将日志输出到文件,地址为手机端路径
    • adb logcat > log.log 保存日志到PC上
    • adb logcat -c 清理已存在的日志

    根据条件过滤日志

    • adb logcat -v time "*:W" 打印 Warning 及以上级别的日志*
    • *adb logcat ActivityManager:D '*:S' 过滤tag 为ActivityManager,level为Debug及以上级别的日志

    常见错误日志查询

    三、ADB模拟按键操作

    提示:为了方便查看操作效果,先打开开发者选项—>指针位置

    • adb shell input 查看帮助命令提示

    • adb shell tap x坐标 y坐标 模拟点击事件,如:adb shell tap 630 630

    • adb shell input text <输入内容> 模拟输入文本事件,只支持英文输入,提示:首先光标先聚焦到输入框

      如:adb shell input text hello

    • adb shell swipe <起点x> <起点y> <终点x> <终点y> <滑动时长>

    如:adb shell swipe 200 250 300 250 2000

    • adb shell input keyevent 4 返回键
    • adb shell input keyevent 3 Home键(置应用于后台运行)
    • adb shell input keyevent 24 音量放大
    • adb shell input keyevent 25 音量缩小

    参考文档:https://developer.android.com/reference/android/view/KeyEvent

    四、查看性能指标

    dumpsys 是一种在 Android 设备上运行的工具,可提供有关系统服务的信息。您可以使用 Android 调试桥 (ADB) 从命令行调用 dumpsys,获取在连接的设备上运行的所有系统服务的诊断输出。此输出通常比您想要的更详细。

    查看CPU指标(均值)

    • adb shell dumpsys cpuinfo 查看当前系统 CPU 使用情况

    查看内存使用情况

    • 查看当前系统的内存:adb shell dumpsys meminfo
    • 查看某个应用的内存:adb shell dumpsys meminfo <应用名>

    TOP命令(实时值)

    相当于Windows系统的任务管理器

    • adb shell top

    • MAC:adb shell top |grep ”包名“ 查看某个包的一些性能指标

    Windows:shell top |findstr ”包名“查看某个包的一些性能指标

    • MAC:adb shell top -d 1 |grep “包名"每隔1秒打印出一次

      Windows:adb shell top -d 1 |findstr “包名"

    电池电量

    adb shell dumpsys battery

    Hogwarts $ adb shell dumpsys battery
    Current Battery Service state:
      AC powered: true
      USB powered: false
      Wireless powered: false
      Max charging current: 2000000   # 最大充电电流; mA
      status: 2    #电池状态:2:充电状态 ,其他数字为非充电状态 
      health: 2    #电池健康状态:只有数字2表示good
      present: true   #电池是否安装在机身
      level: 81    #电量: 百分比
      scale: 100
      voltage: 4108    #电池电压
      temperature: 353   #电池温度,单位是0.1摄氏度
      technology: Li-poly   #电池种类
    

    参考文档: https://developer.android.com/docs

    本文来自博客园,作者:農碼一生,转载请注明原文链接:https://www.cnblogs.com/wml-it/p/15721513.html


    技术的发展日新月异,随着时间推移,无法保证本博客所有内容的正确性。如有误导,请大家见谅,欢迎评论区指正!
    个人开源代码链接:
    GitHub:https://github.com/ITMingliang
    Gitee:https://gitee.com/mingliang_it
    GitLab:https://gitlab.com/ITMingliang
    进开发学习交流群:

  • 相关阅读:
    [cf553C]Love Triangles
    Unix目录结构的来历
    debian学习笔记9, putty连接debian的字体乱码修改设置。
    【转】Dictionary排序
    debian学习笔记9, putty连接debian的字体乱码修改设置。
    【转】可以用圆形的钻头钻出方孔吗
    【转】Dictionary排序
    关于设置sftp 指定端口
    【转】可以用圆形的钻头钻出方孔吗
    Unix目录结构的来历
  • 原文地址:https://www.cnblogs.com/wml-it/p/15721513.html
Copyright © 2011-2022 走看看