Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么我能';Android ICS中的FileReader无法正确读取/proc/net/xt_qtaguid/stats_Android_Bufferedreader_Filereader_Proc - Fatal编程技术网

为什么我能';Android ICS中的FileReader无法正确读取/proc/net/xt_qtaguid/stats

为什么我能';Android ICS中的FileReader无法正确读取/proc/net/xt_qtaguid/stats,android,bufferedreader,filereader,proc,Android,Bufferedreader,Filereader,Proc,我想在Android ICS中读取/proc/net/xt_qtaguid/stats,它记录所有接口和应用程序的流量统计。以下是代码片段: 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 corr

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

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_字节rx_数据包tx_字节tx_数据包rx_tcp_数据包rx_udp_字节rx_udp_数据包rx_其他字节rx_其他数据包tx_tcp_数据包tx_udp_字节tx_udp_数据包tx_其他字节tx_其他数据包

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

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

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

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

6 rmnet0 0x0 10004 0 1000 0 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 0 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,每个应用程序只能读取头和它自己的行