gpt4 book ai didi

android - 为什么我无法通过 Android ICS 中的 FileReader 正确读取/proc/net/xt_qtaguid/stats

转载 作者:太空狗 更新时间:2023-10-29 16:08:15 26 4
gpt4 key购买 nike

我想在 Android ICS 中读取/proc/net/xt_qtaguid/stats,它记录了所有接口(interface)和应用程序的流量统计信息。以下是代码 fragment :

String line = null;
BufferReader reader = new BufferedReader(new FileReader(new File("/proc/net/xt_qtaguid/stats")));

line = reader.readLine();/*Here I can read the 1st line correctly, it return "idx iface acct_tag_hex..."*/
splitLine(line, keys);
line = reader.readLine();//!!!!!Read next line, it returns null!!!!!!

如果我 cat 这个文件,它会显示:

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

2 rmnet0 0x0 0 0 6266 105 8882 121 1428 30 4838 75 0 0 208 4 2552 44 6122 73

3 rmnet0 0x0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

4 rmnet0 0x0 1000 0 0 0 2262 39 0 0 0 0 0 0 0 0 2262 39 0 0

5 rmnet0 0x0 1000 1 0 0 290 5 0 0 0 0 0 0 0 0 290 5 0 0

6 rmnet0 0x0 10004 0 1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

7 rmnet0 0x0 10004 1 20177 36 7037 81 20177 36 0 0 0 0 7037 81 0 0 0 0

而且我发现NetworkStatsFactory.java(Android原类)也读取了这个文件,使用了同样的方法。我尝试使用这个类,它也无法正确读取:

try{
NetworkStats stats = new NetworkStatsFactory().readNetworkStatsDetail(10004);
stats.size();//size is ZERO!
}
catch(IllegalStateException e){
//Do nothing
}

谷歌工程师犯过同样的错误吗? :)

最佳答案

我得到了答案,这个虚拟文件的read_proc函数限制了uid,每个应用程序只能读取文件头和它自己的行。

关于android - 为什么我无法通过 Android ICS 中的 FileReader 正确读取/proc/net/xt_qtaguid/stats,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9080229/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com