我想实现一个扩展
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)
我读了android.net.TrafficStats.java,它在android_net_TrafficStats.cpp中调用native方法,本机方法从某些文件读取流量统计信息:
>总流量统计文件在文件夹/ 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流量统计信息的每个应用?