I have developed an app to manage the amount of traffic. I'm using the TrafficStats API. getUidRx/TxBytes() returns traffic amount includes the loopback traffic. But, information of loopback traffic is not required.
So, I have examined the method of measuring the loopback traffic amount for each app.
Information of the traffic amount in the following file.
/proc/net/xt_qtaguid/stats
However, it is not possible to read from my app.
[Reference] read /proc/net/xt_qtaguid/stats in my user application and caused java.lang.nullpointerexception
I can get total loopback traffic amount.
Method getRxBytesMethod = TrafficStats.class
.getDeclaredMethod("getRxBytes", new Class[]{String.class});
long loopbackRxBytes = (Long) getRxBytesMethod.invoke(null, "lo");
Is it possible to know the uid that is currently communication?
0 comments:
Post a Comment