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

最新文章

  1. 使用js脚本批量下载慕课网视频
  2. asp.net读写配置文件方法
  3. jquery总结02-样式和属性
  4. 发送消息执行记事本的“另存为”菜单功能(通过WM_COMMAND控制使用别的程序的菜单命令)
  5. chown
  6. freeCMS学习网站
  7. .call()和.apply()相同点与不同点
  8. Determine whether an integer is a palindrome. Do this without extra space.
  9. Xamarin android SwipeRefreshLayout入门实例
  10. Python 下载win32api 模块
  11. Mac 装机必备软件推荐
  12. pl/sql Devloper 关键字转为大写
  13. css 元素居中
  14. ArcGis连接oracle、oracle配置
  15. JAVA的SPI简单应用
  16. [2017BUAA软工助教]学期总结
  17. JSONP 劫持漏洞实例
  18. 【delphi】delphi的TAdoQuery读取Excel数据
  19. 2018/04/01 每日一个Linux命令 之 sleep
  20. Android ImageResizer:inSampleSize

热门文章

  1. S03_CH10_DMA_4_Video_Stitch视频拼接系统
  2. k8s基础环境搭建
  3. nodejs 对 png 图片的像素级别处理
  4. AtCoder Grand Contest 040 C - Neither AB nor BA
  5. 解决GitHub下载速度缓慢的问题
  6. 关于C#7 新语法糖
  7. vue-cli中eslint配置
  8. mysql 添加省市编码表
  9. Vue2.0+elementUI使用echarts插件
  10. InnoDB全文索引