Track xtables summary, move tether stats, time.

Begin tracking xtables summary of data usage to compare with values
reported from /proc/net/dev.  Roll tethering directly into UID stats
to trigger UID stats persisting when crossing threshold.

Include xtables summary and authoritative time in samples.

Bug: 5373561, 5397882, 5381980
Change-Id: Ib7945522caadfbe0864fdf391582dc820f4f371e
This commit is contained in:
Jeff Sharkey
2011-09-30 15:19:49 -07:00
parent 8cddd4a5c7
commit f1369459ed
2 changed files with 254 additions and 116 deletions

View File

@@ -271,6 +271,17 @@ public class NetworkStats implements Parcelable {
return this;
}
/**
* Combine all values from another {@link NetworkStats} into this object.
*/
public void combineAllValues(NetworkStats another) {
NetworkStats.Entry entry = null;
for (int i = 0; i < another.size; i++) {
entry = another.getValues(i, entry);
combineValues(entry);
}
}
/**
* Find first stats index that matches the requested parameters.
*/
@@ -456,6 +467,34 @@ public class NetworkStats implements Parcelable {
return result;
}
/**
* Return total statistics grouped by {@link #iface}; doesn't mutate the
* original structure.
*/
public NetworkStats groupedByIface() {
final NetworkStats stats = new NetworkStats(elapsedRealtime, 10);
final Entry entry = new Entry();
entry.uid = UID_ALL;
entry.set = SET_ALL;
entry.tag = TAG_NONE;
entry.operations = 0L;
for (int i = 0; i < size; i++) {
// skip specific tags, since already counted in TAG_NONE
if (tag[i] != TAG_NONE) continue;
entry.iface = iface[i];
entry.rxBytes = rxBytes[i];
entry.rxPackets = rxPackets[i];
entry.txBytes = txBytes[i];
entry.txPackets = txPackets[i];
stats.combineValues(entry);
}
return stats;
}
public void dump(String prefix, PrintWriter pw) {
pw.print(prefix);
pw.print("NetworkStats: elapsedRealtime="); pw.println(elapsedRealtime);