Last-ditch clamping of negative NetworkStats.

We've seen reports of negative values flowing through to attempt
being recorded, which will outright crash.  This change does one
last-ditch check to see if we're about to work with negative values,
reporting any trouble and clamping them to zero so we don't crash.

This gives us the data we need to continue investigating without
triggering runtime restarts in the field.

Bug: 80057433
Test: atest android.net.NetworkStatsTest
Change-Id: I8174391c6cf5dadc2c2c10a8d841ee07e1f7d934
This commit is contained in:
Jeff Sharkey
2018-05-22 11:35:29 -06:00
parent 89005ff73e
commit d631c5836d
3 changed files with 32 additions and 4 deletions

View File

@@ -1100,6 +1100,8 @@ public class NetworkStats implements Parcelable {
public interface NonMonotonicObserver<C> {
public void foundNonMonotonic(
NetworkStats left, int leftIndex, NetworkStats right, int rightIndex, C cookie);
public void foundNonMonotonic(
NetworkStats stats, int statsIndex, C cookie);
}
/**