Bootstrap stats before registering listeners.

Also move ISE to handled NonMonotonicException.

Bug: 5570872
Change-Id: I793f349287ef5589185f117dfbec6f1fad73a661
This commit is contained in:
Jeff Sharkey
2011-11-08 18:08:48 -08:00
parent cd5559a856
commit 29f15bb4b3
2 changed files with 18 additions and 17 deletions

View File

@@ -455,7 +455,7 @@ public class NetworkStats implements Parcelable {
public NetworkStats subtract(NetworkStats value) throws NonMonotonicException {
final long deltaRealtime = this.elapsedRealtime - value.elapsedRealtime;
if (deltaRealtime < 0) {
throw new IllegalArgumentException("found non-monotonic realtime");
throw new NonMonotonicException(this, value);
}
// result will have our rows, and elapsed time between snapshots
@@ -575,7 +575,8 @@ public class NetworkStats implements Parcelable {
pw.print("NetworkStats: elapsedRealtime="); pw.println(elapsedRealtime);
for (int i = 0; i < size; i++) {
pw.print(prefix);
pw.print(" iface="); pw.print(iface[i]);
pw.print(" ["); pw.print(i); pw.print("]");
pw.print(" iface="); pw.print(iface[i]);
pw.print(" uid="); pw.print(uid[i]);
pw.print(" set="); pw.print(setToString(set[i]));
pw.print(" tag="); pw.print(tagToString(tag[i]));
@@ -638,6 +639,10 @@ public class NetworkStats implements Parcelable {
public final int leftIndex;
public final int rightIndex;
public NonMonotonicException(NetworkStats left, NetworkStats right) {
this(left, -1, right, -1);
}
public NonMonotonicException(
NetworkStats left, int leftIndex, NetworkStats right, int rightIndex) {
this.left = checkNotNull(left, "missing left");