• adb命令积累


    1. 模拟事件全部是通过input命令来实现的,首先看一下input命令的使用: (原文:http://blog.csdn.net/huiguixian/article/details/11925389)

     usage: input ...

           input text <string>
           input keyevent <key code number or name>
           input tap <x> <y>
           input swipe <x1> <y1> <x2> <y2>

    1. keyevent指的是android对应的keycode,比如home键的keycode=3,back键的keycode=4.

    具体请查阅 <android keycode详解> http://blog.csdn.net/huiguixian/article/details/8550170

    然后使用的话比较简单,比如想模拟home按键:

    adb shell input keyevent 3

    请查阅上述文章,根据具体keycode编辑即可。

    2. 关于tap的话,他模拟的是touch屏幕的事件,只需给出x、y坐标即可。

    此x、y坐标对应的是真实的屏幕分辨率,所以要根据具体手机具体看,比如你想点击屏幕(x, y) = (250, 250)位置:

    adb shell input tap 250 250

    3. 关于swipe同tap是一样的,只是他是模拟滑动的事件,给出起点和终点的坐标即可。例如从屏幕(250, 250), 到屏幕(300, 300)即

    adb shell input swipe 250 250 300 300

    2. 使用adb命令对手机进行截屏保存到电脑,SDCard : (原文:http://blog.csdn.net/huangyabin001/article/details/29198367)

    adb shell /system/bin/screencap -p /sdcard/screenshot.png(保存到SDCard)
    adb pull /sdcard/screenshot.png d:/screenshot.png(保存到电脑)

    3. 获取某个应用的uid:

    adb shell dumpsys package 包名 | grep userId

    4. 查看某个应用消耗的流量:(参考资料:http://testerhome.com/topics/2068)

    1、 之前统计是cat proc/uid_stat/(uid#)/tcp_rcv路径下

    adb shell cat proc/uid_stat/(uid#)/tcp_rcv
    adb shell cat proc/uid_stat/(uid#)/tcp_snd
    

    对二者求和,劣势是只针对tcp协议网络的消耗统计,且在某些机型上不存在该路径。
    故进行了优化。

    2、 经调查/proc/net/xt_qtaguid/stats 基本覆盖目前所有机型且统计流量全面

    adb shell cat /proc/net/xt_qtaguid/stats | grep (uid#)

    如: adb shell cat /proc/net/xt_qtaguid/stats | grep 10127

    48 wlan0 0x0 10127 0 316574 2279 472562 3651 316574 2279 0 0 0 0 472562 3651 0 0 0 0
    49 wlan0 0x0 10127 1 6172960 4936 415951 5215 6172960 4936 0 0 0 0 415951 5215 0 0 0 0
    50 wlan0 0x3792d5b400000000 10127 0 29678 208 32168 296 29678 208 0 0 0 0 32168 296 0 0 0 0
    51 wlan0 0x3792d5b400000000 10127 1 226170 222 25745 265 226170 222 0 0 0 0 25745 265 0 0 0 0
    56 wlan0 0xfa1dcc4b00000000 10127 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    57 wlan0 0xfa1dcc4b00000000 10127 1 3014885 2127 139857 2117 3014885 2127 0 0 0 0 139857 2117 0 0 0 0

    其中第6和8列为 rx_bytes(接收数据)和tx_bytes(传输数据)包含tcp,udp等所有网络流量传输的统计。
    [具体参考url:​http://stackoverflow.com/questions/12904809/tracking-an-applications-network-statistics-netstats-using-adb]

    备注:

    adb shell cat /proc/net/xt_qtaguid/stats | grep (uid#) 每一列对应的含义:

    idx
    iface
    acct_tag_hex
    uid_tag_int
    cnt_set
    rx_bytes
    rx_packets
    tx_bytes
    tx_packets
    rx_tcp_bytes
    rx_tcp_packets
    rx_udp_bytes
    rx_udp_packets
    rx_other_bytes
    rx_other_packets
    tx_tcp_bytes
    tx_tcp_packets
    tx_udp_bytes
    tx_udp_packets
    tx_other_bytes
    tx_other_packets

  • 相关阅读:
    WPF listbox 实现动态滚轮下拉定位
    VS的安装和入门使用
    pyqt5学习之菜单栏,工具栏,状态栏
    pyqt5学习之QSpinBox
    pyqt5环境安装
    pyqt5学习之QKeySequeueEdit
    pyqt5学习之QPainTextEditer
    pyqt5学习之QTextEditer
    pyqt5学习之QABstractScrollArea
    pyqt5学习之QFrame
  • 原文地址:https://www.cnblogs.com/LittleRedPoint/p/4389300.html
Copyright © 2020-2023  润新知