forked from kevinkong/Emmagee
-
Notifications
You must be signed in to change notification settings - Fork 715
Closed
Description
public long getTrafficInfo() {
RandomAccessFile rafTaffic = null;
long traffic = 0;
try {
rafTaffic = new RandomAccessFile("/proc/net/xt_qtaguid/stats", "r");
Log.i(LOG_TAG, "get traffic information");
String line = "";
while ((line = rafTaffic.readLine()) != null) {
Log.d(LOG_TAG, "line===" + line);
String[] linesplits = line.split(" ");
Log.d(LOG_TAG, "uid===" + uid);
Log.d(LOG_TAG, linesplits[3]);
if (linesplits[3].endsWith(uid)) {
traffic = traffic + Long.parseLong(linesplits[5])
+ Long.parseLong(linesplits[7]);
}
}
} catch (FileNotFoundException e) {
traffic = -1;
} catch (NumberFormatException e) {
Log.e(LOG_TAG, "NumberFormatException: " + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
Log.e(LOG_TAG, "IOException: " + e.getMessage());
e.printStackTrace();
} finally {
try {
if (rafTaffic != null)
rafTaffic.close();
} catch (IOException e) {
Log.i(LOG_TAG,
"close randomAccessFile exception: " + e.getMessage());
}
}
Log.d(LOG_TAG, "Traffic===" + traffic);
return traffic;
}
Metadata
Metadata
Assignees
Labels
No labels