summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2015-10-19 17:22:05 -0700
committerJeff Sharkey <jsharkey@android.com>2015-10-19 17:28:04 -0700
commit02551ecd2e31e597144e7d194b772aa4b1a7a750 (patch)
tree4acc7fbcb8a1e8dfd86129c3db19542e12e75418 /src
parent3105ea30d47d35848951cda0cc4b18750e5166ea (diff)
downloadpackages_apps_Settings-02551ecd2e31e597144e7d194b772aa4b1a7a750.zip
packages_apps_Settings-02551ecd2e31e597144e7d194b772aa4b1a7a750.tar.gz
packages_apps_Settings-02551ecd2e31e597144e7d194b772aa4b1a7a750.tar.bz2
Hide empty data usage cycles.
When building list of historical data usage cycles, omit cycles that don't contain any data usage. A bad NITZ or NTP fix may have caused us to record some usage in 1970 or 2038, which would have shown all the cycles in between. Now we hide empty cycles to keep things clean. Bug: 18282691 Change-Id: Ib04c95d1411400ba9967d311b59402a26d39cfe3
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/DataUsageSummary.java29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index e014465..135328b 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -1166,6 +1166,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
mCycleAdapter.clear();
final Context context = mCycleSpinner.getContext();
+ NetworkStatsHistory.Entry entry = null;
long historyStart = Long.MAX_VALUE;
long historyEnd = Long.MIN_VALUE;
@@ -1188,9 +1189,20 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
final long cycleStart = computeLastCycleBoundary(cycleEnd, policy);
Log.d(TAG, "generating cs=" + cycleStart + " to ce=" + cycleEnd + " waiting for hs="
+ historyStart);
- mCycleAdapter.add(new CycleItem(context, cycleStart, cycleEnd));
+
+ final boolean includeCycle;
+ if (mChartData != null) {
+ entry = mChartData.network.getValues(cycleStart, cycleEnd, entry);
+ includeCycle = (entry.rxBytes + entry.txBytes) > 0;
+ } else {
+ includeCycle = true;
+ }
+
+ if (includeCycle) {
+ mCycleAdapter.add(new CycleItem(context, cycleStart, cycleEnd));
+ hasCycles = true;
+ }
cycleEnd = cycleStart;
- hasCycles = true;
}
// one last cycle entry to modify policy cycle day
@@ -1202,7 +1214,18 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
long cycleEnd = historyEnd;
while (cycleEnd > historyStart) {
final long cycleStart = cycleEnd - (DateUtils.WEEK_IN_MILLIS * 4);
- mCycleAdapter.add(new CycleItem(context, cycleStart, cycleEnd));
+
+ final boolean includeCycle;
+ if (mChartData != null) {
+ entry = mChartData.network.getValues(cycleStart, cycleEnd, entry);
+ includeCycle = (entry.rxBytes + entry.txBytes) > 0;
+ } else {
+ includeCycle = true;
+ }
+
+ if (includeCycle) {
+ mCycleAdapter.add(new CycleItem(context, cycleStart, cycleEnd));
+ }
cycleEnd = cycleStart;
}