diff options
author | Jeff Sharkey <jsharkey@android.com> | 2011-07-12 13:53:11 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2011-07-12 13:53:11 -0700 |
commit | ebae659fc786a14a0dc6ceda2af80fc48e46e123 (patch) | |
tree | 32b269adbd357f0cd8c4280f5c3e87ea49129874 /src/com | |
parent | 078b435743bf7f42feb140de287b70685cfcb7a8 (diff) | |
download | packages_apps_Settings-ebae659fc786a14a0dc6ceda2af80fc48e46e123.zip packages_apps_Settings-ebae659fc786a14a0dc6ceda2af80fc48e46e123.tar.gz packages_apps_Settings-ebae659fc786a14a0dc6ceda2af80fc48e46e123.tar.bz2 |
Migrate to refactored NetworkStats API.
Change-Id: I76452a67b74df873c88cb9092188e5e4ba83b991
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/settings/DataUsageSummary.java | 19 | ||||
-rw-r--r-- | src/com/android/settings/widget/ChartNetworkSeriesView.java | 11 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java index bed3be5..4edda7d 100644 --- a/src/com/android/settings/DataUsageSummary.java +++ b/src/com/android/settings/DataUsageSummary.java @@ -745,9 +745,13 @@ public class DataUsageSummary extends Fragment { long start = currentTime; long end = currentTime; - if (history.bucketCount > 0) { - start = history.bucketStart[0]; - end = history.bucketStart[history.bucketCount - 1]; + + NetworkStatsHistory.Entry entry = null; + if (history.size() > 0) { + entry = history.getValues(0, entry); + start = entry.bucketStart; + entry = history.getValues(history.size() - 1, entry); + end = entry.bucketStart + entry.bucketDuration; } return new long[] { start, end }; @@ -1081,11 +1085,12 @@ public class DataUsageSummary extends Fragment { mItems.clear(); if (stats != null) { - for (int i = 0; i < stats.size; i++) { - final long total = stats.rx[i] + stats.tx[i]; + NetworkStats.Entry entry = null; + for (int i = 0; i < stats.size(); i++) { + entry = stats.getValues(i, entry); final AppUsageItem item = new AppUsageItem(); - item.uid = stats.uid[i]; - item.total = total; + item.uid = entry.uid; + item.total = entry.rxBytes + entry.txBytes; mItems.add(item); } } diff --git a/src/com/android/settings/widget/ChartNetworkSeriesView.java b/src/com/android/settings/widget/ChartNetworkSeriesView.java index 83c10cd..10d8976 100644 --- a/src/com/android/settings/widget/ChartNetworkSeriesView.java +++ b/src/com/android/settings/widget/ChartNetworkSeriesView.java @@ -140,7 +140,7 @@ public class ChartNetworkSeriesView extends View { mPathFill.reset(); // bail when not enough stats to render - if (mStats == null || mStats.bucketCount < 2) return; + if (mStats == null || mStats.size() < 2) return; final int width = getWidth(); final int height = getHeight(); @@ -155,8 +155,11 @@ public class ChartNetworkSeriesView extends View { long totalData = 0; - for (int i = 0; i < mStats.bucketCount; i++) { - final float x = mHoriz.convertToPoint(mStats.bucketStart[i]); + NetworkStatsHistory.Entry entry = null; + for (int i = 0; i < mStats.size(); i++) { + entry = mStats.getValues(i, entry); + + final float x = mHoriz.convertToPoint(entry.bucketStart); final float y = mVert.convertToPoint(totalData); // skip until we find first stats on screen @@ -170,7 +173,7 @@ public class ChartNetworkSeriesView extends View { if (started) { mPathStroke.lineTo(x, y); mPathFill.lineTo(x, y); - totalData += mStats.rx[i] + mStats.tx[i]; + totalData += entry.rxBytes + entry.txBytes; } // skip if beyond view |