fre*_*man 13 android traffic-measurement
我想实现一个扩展来android.net.TrafficStats测量每个应用程序的每个APN或每个APN的数据流量.方法原型看起来像:
getInterfaceTxPackets(String interface)
getInterfaceRxPackets(String interface)
getInterfaceTxBytes(String interface)
getInterfaceRxBytes(String interface)
getUidInterfaceTxPackets(int uid,String interface)
getUidInterfaceRxPackets(int uid,String interface)
getUidInterfaceTxBytes(int uid,String interface)
getUidInterfaceRxBytes(int uid,String interface)
Run Code Online (Sandbox Code Playgroud)
我读了android.net.TrafficStats.java,它调用了本机方法android_net_TrafficStats.cpp,本机方法从一些文件中读取流量统计信息:
总流量统计文件在文件夹中/sys/class/net/,在此文件夹中有一些子文件夹,如:eth0,ip6tnl0,rmnet0,rmnet1,rmnet2,rmnet3.,详细的统计文件保存在这些文件夹中.
每个应用程序流量统计文件都在 /proc/uid_stat/[uid]/
我的问题:
做文件夹rmnet0, rmnet1, rmnet2, rmnet3...匹配每个APN?如果这样做,匹配规则是什么?如果没有,我怎样才能得到每个APN流量统计数据?
在文件夹/proc/uid_stat/[uid]/,中只有两个文件:tcp_rcv并且tcp_snd,如何在每个APN流量统计数据上获得每个应用程序?
请切换到 Android 4.0,其中数据使用监控已得到加强。这些 API 现在位于一个更加复杂的服务之上,该服务收集每个接口每个 uid 的流量信息。
请注意,每个接口名称都没有关联的含义,因此您不能假设在一台设备上找到的特定名称在另一台设备上具有相同的含义。
| 归档时间: |
|
| 查看次数: |
3165 次 |
| 最近记录: |