diff options
author | Jeff Sharkey <jsharkey@android.com> | 2015-10-19 16:41:53 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2015-10-19 16:41:53 -0700 |
commit | 3105ea30d47d35848951cda0cc4b18750e5166ea (patch) | |
tree | 719493ec3cfa01dbe96009a4a5112bc9a3163ce1 /src/com | |
parent | cdcba9ce5f44cf4cad9e308919272db4e15e9717 (diff) | |
download | packages_apps_Settings-3105ea30d47d35848951cda0cc4b18750e5166ea.zip packages_apps_Settings-3105ea30d47d35848951cda0cc4b18750e5166ea.tar.gz packages_apps_Settings-3105ea30d47d35848951cda0cc4b18750e5166ea.tar.bz2 |
Clamp large data usage values.
Without clamping, they can wrap around to negative values and cause
all sorts of havok. 1TB ought to be enough for anyone: that's 3Mbps
for a solid month.
Bug: 24555152
Change-Id: If92c87f9920c3f05cd3ff2cc6630b1bbb65335b8
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/settings/widget/ChartDataUsageView.java | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/com/android/settings/widget/ChartDataUsageView.java b/src/com/android/settings/widget/ChartDataUsageView.java index cc9acd6..6fb805b 100644 --- a/src/com/android/settings/widget/ChartDataUsageView.java +++ b/src/com/android/settings/widget/ChartDataUsageView.java @@ -22,6 +22,7 @@ import android.content.Context; import android.content.res.Resources; import android.net.NetworkPolicy; import android.net.NetworkStatsHistory; +import android.net.TrafficStats; import android.os.Handler; import android.os.Message; import android.text.Spannable; @@ -33,6 +34,7 @@ import android.text.format.Formatter.BytesResult; import android.text.format.Time; import android.util.AttributeSet; import android.util.Log; +import android.util.MathUtils; import android.view.MotionEvent; import android.view.View; @@ -535,6 +537,7 @@ public class ChartDataUsageView extends ChartView { @Override public long buildLabel(Resources res, SpannableStringBuilder builder, long value) { + value = MathUtils.constrain(value, 0, TrafficStats.TB_IN_BYTES); final BytesResult result = Formatter.formatBytes(res, value, Formatter.FLAG_SHORTER | Formatter.FLAG_CALCULATE_ROUNDED); setText(builder, sSpanSize, result.value, "^1"); |