diff --git a/core/java/android/net/NetworkStats.java b/core/java/android/net/NetworkStats.java index 5b883a0741..e5f32735b0 100644 --- a/core/java/android/net/NetworkStats.java +++ b/core/java/android/net/NetworkStats.java @@ -19,6 +19,7 @@ package android.net; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; +import android.util.Log; import android.util.SparseBooleanArray; import com.android.internal.util.Objects; @@ -38,6 +39,8 @@ import java.util.HashSet; * @hide */ public class NetworkStats implements Parcelable { + private static final String TAG = "NetworkStats"; + /** {@link #iface} value when interface details unavailable. */ public static final String IFACE_ALL = null; /** {@link #uid} value when UID details unavailable. */ @@ -397,7 +400,10 @@ public class NetworkStats implements Parcelable { if (enforceMonotonic && (entry.rxBytes < 0 || entry.rxPackets < 0 || entry.txBytes < 0 || entry.txPackets < 0 || entry.operations < 0)) { - throw new IllegalArgumentException("found non-monotonic values"); + Log.v(TAG, "lhs=" + this); + Log.v(TAG, "rhs=" + value); + throw new IllegalArgumentException( + "found non-monotonic values at lhs[" + i + "] - rhs[" + j + "]"); } if (clampNegative) { entry.rxBytes = Math.max(0, entry.rxBytes); diff --git a/core/java/android/net/NetworkStatsHistory.java b/core/java/android/net/NetworkStatsHistory.java index b19949e39d..d07d8990d7 100644 --- a/core/java/android/net/NetworkStatsHistory.java +++ b/core/java/android/net/NetworkStatsHistory.java @@ -482,12 +482,12 @@ public class NetworkStatsHistory implements Parcelable { for (int i = start; i < bucketCount; i++) { pw.print(prefix); pw.print(" bucketStart="); pw.print(bucketStart[i]); - if (activeTime != null) pw.print(" activeTime="); pw.print(activeTime[i]); - if (rxBytes != null) pw.print(" rxBytes="); pw.print(rxBytes[i]); - if (rxPackets != null) pw.print(" rxPackets="); pw.print(rxPackets[i]); - if (txBytes != null) pw.print(" txBytes="); pw.print(txBytes[i]); - if (txPackets != null) pw.print(" txPackets="); pw.print(txPackets[i]); - if (operations != null) pw.print(" operations="); pw.print(operations[i]); + if (activeTime != null) { pw.print(" activeTime="); pw.print(activeTime[i]); } + if (rxBytes != null) { pw.print(" rxBytes="); pw.print(rxBytes[i]); } + if (rxPackets != null) { pw.print(" rxPackets="); pw.print(rxPackets[i]); } + if (txBytes != null) { pw.print(" txBytes="); pw.print(txBytes[i]); } + if (txPackets != null) { pw.print(" txPackets="); pw.print(txPackets[i]); } + if (operations != null) { pw.print(" operations="); pw.print(operations[i]); } pw.println(); } } diff --git a/services/java/com/android/server/net/NetworkStatsService.java b/services/java/com/android/server/net/NetworkStatsService.java index 80ae9bc6cb..bb0a0d132b 100644 --- a/services/java/com/android/server/net/NetworkStatsService.java +++ b/services/java/com/android/server/net/NetworkStatsService.java @@ -707,7 +707,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { mLastPersistUidSnapshot, uidSnapshot, true); if (forcePersist || persistUidDelta.getTotalBytes() > persistThreshold) { writeUidStatsLocked(); - mLastPersistNetworkSnapshot = networkSnapshot; + mLastPersistUidSnapshot = networkSnapshot; } }