Report unavailable data usage.
- when showing the data usage graph, if the first data point is equal to the first available data, insert a 0 usage point on the first day of available data, so that it will show a flat line for the days that do not have available data instead of showing a non-zero slope. Change-Id: Ibf305e292a65ab3310ea12efbb575e3a7e1b6012 Fixes: 76155147 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -18,6 +18,7 @@ import android.content.Context;
|
||||
import android.net.NetworkPolicy;
|
||||
import android.net.NetworkStatsHistory;
|
||||
import android.net.TrafficStats;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.text.SpannableStringBuilder;
|
||||
@@ -88,7 +89,8 @@ public class ChartDataUsagePreference extends Preference {
|
||||
return (int) (Math.max(totalData, policyMax) / RESOLUTION);
|
||||
}
|
||||
|
||||
private void calcPoints(UsageView chart) {
|
||||
@VisibleForTesting
|
||||
void calcPoints(UsageView chart) {
|
||||
SparseIntArray points = new SparseIntArray();
|
||||
NetworkStatsHistory.Entry entry = null;
|
||||
|
||||
@@ -108,6 +110,9 @@ public class ChartDataUsagePreference extends Preference {
|
||||
// increment by current bucket total
|
||||
totalData += entry.rxBytes + entry.txBytes;
|
||||
|
||||
if (i == 0) {
|
||||
points.put(toInt(startTime - mStart) - 1, -1);
|
||||
}
|
||||
points.put(toInt(startTime - mStart + 1), (int) (totalData / RESOLUTION));
|
||||
points.put(toInt(endTime - mStart), (int) (totalData / RESOLUTION));
|
||||
}
|
||||
|
Reference in New Issue
Block a user