Sample network statistics for sanity check.
After detailed poll events, sample high-level network statistics to sanity check iface totals against UID totals. Bug: 5248382 Change-Id: I1c1fbb7c094c9ff0c9dde416467c563dda68f478
This commit is contained in:
@@ -320,15 +320,36 @@ public class NetworkStats implements Parcelable {
|
||||
* checking if a {@link #subtract(NetworkStats)} delta passes a threshold.
|
||||
*/
|
||||
public long getTotalBytes() {
|
||||
long totalBytes = 0;
|
||||
final Entry entry = getTotal(null);
|
||||
return entry.rxBytes + entry.txBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return total of all fields represented by this snapshot object.
|
||||
*/
|
||||
public Entry getTotal(Entry recycle) {
|
||||
final Entry entry = recycle != null ? recycle : new Entry();
|
||||
|
||||
entry.iface = IFACE_ALL;
|
||||
entry.uid = UID_ALL;
|
||||
entry.set = SET_ALL;
|
||||
entry.tag = TAG_NONE;
|
||||
entry.rxBytes = 0;
|
||||
entry.rxPackets = 0;
|
||||
entry.txBytes = 0;
|
||||
entry.txPackets = 0;
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
// skip specific tags, since already counted in TAG_NONE
|
||||
if (tag[i] != TAG_NONE) continue;
|
||||
|
||||
totalBytes += rxBytes[i];
|
||||
totalBytes += txBytes[i];
|
||||
entry.rxBytes += rxBytes[i];
|
||||
entry.rxPackets += rxPackets[i];
|
||||
entry.txBytes += txBytes[i];
|
||||
entry.txPackets += txPackets[i];
|
||||
entry.operations += operations[i];
|
||||
}
|
||||
return totalBytes;
|
||||
return entry;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user