Merge "Report unavailable data usage." into pi-dev am: a673f714c4

am: 4395decf14

Change-Id: I713f1fc8a1025087b8dfc775e45c63c0ff037c9c
This commit is contained in:
Doris Ling
2018-03-29 20:45:42 +00:00
committed by android-build-merger
4 changed files with 171 additions and 5 deletions

View File

@@ -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));
}

View File

@@ -185,6 +185,10 @@ public class UsageGraph extends View {
int x = paths.keyAt(i);
int y = paths.valueAt(i);
if (y == PATH_DELIM) {
if (i == 1) {
localPaths.put(getX(x+1) - 1, getY(0));
continue;
}
if (i == paths.size() - 1 && skippedLastPoint) {
// Add back skipped point to complete the path.
localPaths.put(lx, ly);