I want to implement an extention to android.net.TrafficStats to measure the data traffic per APN or per APN per application. the methods prototype looks like:
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)
I read the android.net.TrafficStats.java, it call the native methods in android_net_TrafficStats.cpp, and the native methods read the traffic statistics from some files:
the total traffic statistic files are in folder
/sys/class/net/, in this folder there are some sub folders like: eth0, ip6tnl0, rmnet0, rmnet1, rmnet2, rmnet3., the detailed statistic files are saved in these folders.the per application traffic statistic files are in
/proc/uid_stat/[uid]/
My questions:
Do the folder
rmnet0, rmnet1, rmnet2, rmnet3... match each APN? If do, what's the match rule? if don't, how can I get each APN traffic statistic?In folder
/proc/uid_stat/[uid]/,there are only two files:tcp_rcvandtcp_snd, how can I get each applicaton on each APN traffic stats?