am 630a13bd
: Merge "Bootstrap stats before registering listeners." into ics-mr1
* commit '630a13bdd88723599a7617ca4df20ab923e7ffbb': Bootstrap stats before registering listeners.
This commit is contained in:
@ -466,7 +466,7 @@ public class NetworkStats implements Parcelable {
|
|||||||
public NetworkStats subtract(NetworkStats value) throws NonMonotonicException {
|
public NetworkStats subtract(NetworkStats value) throws NonMonotonicException {
|
||||||
final long deltaRealtime = this.elapsedRealtime - value.elapsedRealtime;
|
final long deltaRealtime = this.elapsedRealtime - value.elapsedRealtime;
|
||||||
if (deltaRealtime < 0) {
|
if (deltaRealtime < 0) {
|
||||||
throw new IllegalArgumentException("found non-monotonic realtime");
|
throw new NonMonotonicException(this, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// result will have our rows, and elapsed time between snapshots
|
// result will have our rows, and elapsed time between snapshots
|
||||||
@ -586,7 +586,8 @@ public class NetworkStats implements Parcelable {
|
|||||||
pw.print("NetworkStats: elapsedRealtime="); pw.println(elapsedRealtime);
|
pw.print("NetworkStats: elapsedRealtime="); pw.println(elapsedRealtime);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
pw.print(prefix);
|
pw.print(prefix);
|
||||||
pw.print(" iface="); pw.print(iface[i]);
|
pw.print(" ["); pw.print(i); pw.print("]");
|
||||||
|
pw.print(" iface="); pw.print(iface[i]);
|
||||||
pw.print(" uid="); pw.print(uid[i]);
|
pw.print(" uid="); pw.print(uid[i]);
|
||||||
pw.print(" set="); pw.print(setToString(set[i]));
|
pw.print(" set="); pw.print(setToString(set[i]));
|
||||||
pw.print(" tag="); pw.print(tagToString(tag[i]));
|
pw.print(" tag="); pw.print(tagToString(tag[i]));
|
||||||
@ -649,6 +650,10 @@ public class NetworkStats implements Parcelable {
|
|||||||
public final int leftIndex;
|
public final int leftIndex;
|
||||||
public final int rightIndex;
|
public final int rightIndex;
|
||||||
|
|
||||||
|
public NonMonotonicException(NetworkStats left, NetworkStats right) {
|
||||||
|
this(left, -1, right, -1);
|
||||||
|
}
|
||||||
|
|
||||||
public NonMonotonicException(
|
public NonMonotonicException(
|
||||||
NetworkStats left, int leftIndex, NetworkStats right, int rightIndex) {
|
NetworkStats left, int leftIndex, NetworkStats right, int rightIndex) {
|
||||||
this.left = checkNotNull(left, "missing left");
|
this.left = checkNotNull(left, "missing left");
|
||||||
|
@ -152,10 +152,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
|
|
||||||
private static final String TAG_NETSTATS_ERROR = "netstats_error";
|
private static final String TAG_NETSTATS_ERROR = "netstats_error";
|
||||||
|
|
||||||
private static final String DEV = "dev";
|
|
||||||
private static final String XT = "xt";
|
|
||||||
private static final String UID = "uid";
|
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final INetworkManagementService mNetworkManager;
|
private final INetworkManagementService mNetworkManager;
|
||||||
private final IAlarmManager mAlarmManager;
|
private final IAlarmManager mAlarmManager;
|
||||||
@ -278,6 +274,9 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
readNetworkXtStatsLocked();
|
readNetworkXtStatsLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bootstrap initial stats to prevent double-counting later
|
||||||
|
bootstrapStats();
|
||||||
|
|
||||||
// watch for network interfaces to be claimed
|
// watch for network interfaces to be claimed
|
||||||
final IntentFilter connFilter = new IntentFilter(CONNECTIVITY_ACTION_IMMEDIATE);
|
final IntentFilter connFilter = new IntentFilter(CONNECTIVITY_ACTION_IMMEDIATE);
|
||||||
mContext.registerReceiver(mConnReceiver, connFilter, CONNECTIVITY_INTERNAL, mHandler);
|
mContext.registerReceiver(mConnReceiver, connFilter, CONNECTIVITY_INTERNAL, mHandler);
|
||||||
@ -311,9 +310,6 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
registerPollAlarmLocked();
|
registerPollAlarmLocked();
|
||||||
registerGlobalAlert();
|
registerGlobalAlert();
|
||||||
|
|
||||||
// bootstrap initial stats to prevent double-counting later
|
|
||||||
bootstrapStats();
|
|
||||||
|
|
||||||
mDropBox = (DropBoxManager) mContext.getSystemService(Context.DROPBOX_SERVICE);
|
mDropBox = (DropBoxManager) mContext.getSystemService(Context.DROPBOX_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -837,9 +833,9 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
|
|
||||||
// persist when enough network data has occurred
|
// persist when enough network data has occurred
|
||||||
final long persistNetworkDevDelta = computeStatsDelta(
|
final long persistNetworkDevDelta = computeStatsDelta(
|
||||||
mLastPersistNetworkDevSnapshot, networkDevSnapshot, true, DEV).getTotalBytes();
|
mLastPersistNetworkDevSnapshot, networkDevSnapshot, true, "devp").getTotalBytes();
|
||||||
final long persistNetworkXtDelta = computeStatsDelta(
|
final long persistNetworkXtDelta = computeStatsDelta(
|
||||||
mLastPersistNetworkXtSnapshot, networkXtSnapshot, true, XT).getTotalBytes();
|
mLastPersistNetworkXtSnapshot, networkXtSnapshot, true, "xtp").getTotalBytes();
|
||||||
final boolean networkOverThreshold = persistNetworkDevDelta > threshold
|
final boolean networkOverThreshold = persistNetworkDevDelta > threshold
|
||||||
|| persistNetworkXtDelta > threshold;
|
|| persistNetworkXtDelta > threshold;
|
||||||
if (persistForce || (persistNetwork && networkOverThreshold)) {
|
if (persistForce || (persistNetwork && networkOverThreshold)) {
|
||||||
@ -851,7 +847,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
|
|
||||||
// persist when enough uid data has occurred
|
// persist when enough uid data has occurred
|
||||||
final long persistUidDelta = computeStatsDelta(
|
final long persistUidDelta = computeStatsDelta(
|
||||||
mLastPersistUidSnapshot, uidSnapshot, true, UID).getTotalBytes();
|
mLastPersistUidSnapshot, uidSnapshot, true, "uidp").getTotalBytes();
|
||||||
if (persistForce || (persistUid && persistUidDelta > threshold)) {
|
if (persistForce || (persistUid && persistUidDelta > threshold)) {
|
||||||
writeUidStatsLocked();
|
writeUidStatsLocked();
|
||||||
mLastPersistUidSnapshot = uidSnapshot;
|
mLastPersistUidSnapshot = uidSnapshot;
|
||||||
@ -880,7 +876,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
final HashSet<String> unknownIface = Sets.newHashSet();
|
final HashSet<String> unknownIface = Sets.newHashSet();
|
||||||
|
|
||||||
final NetworkStats delta = computeStatsDelta(
|
final NetworkStats delta = computeStatsDelta(
|
||||||
mLastPollNetworkDevSnapshot, networkDevSnapshot, false, DEV);
|
mLastPollNetworkDevSnapshot, networkDevSnapshot, false, "dev");
|
||||||
final long timeStart = currentTime - delta.getElapsedRealtime();
|
final long timeStart = currentTime - delta.getElapsedRealtime();
|
||||||
|
|
||||||
NetworkStats.Entry entry = null;
|
NetworkStats.Entry entry = null;
|
||||||
@ -910,7 +906,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
final HashSet<String> unknownIface = Sets.newHashSet();
|
final HashSet<String> unknownIface = Sets.newHashSet();
|
||||||
|
|
||||||
final NetworkStats delta = computeStatsDelta(
|
final NetworkStats delta = computeStatsDelta(
|
||||||
mLastPollNetworkXtSnapshot, networkXtSnapshot, false, XT);
|
mLastPollNetworkXtSnapshot, networkXtSnapshot, false, "xt");
|
||||||
final long timeStart = currentTime - delta.getElapsedRealtime();
|
final long timeStart = currentTime - delta.getElapsedRealtime();
|
||||||
|
|
||||||
NetworkStats.Entry entry = null;
|
NetworkStats.Entry entry = null;
|
||||||
@ -940,9 +936,9 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
ensureUidStatsLoadedLocked();
|
ensureUidStatsLoadedLocked();
|
||||||
|
|
||||||
final NetworkStats delta = computeStatsDelta(
|
final NetworkStats delta = computeStatsDelta(
|
||||||
mLastPollUidSnapshot, uidSnapshot, false, UID);
|
mLastPollUidSnapshot, uidSnapshot, false, "uid");
|
||||||
final NetworkStats operationsDelta = computeStatsDelta(
|
final NetworkStats operationsDelta = computeStatsDelta(
|
||||||
mLastPollOperationsSnapshot, mOperations, false, UID);
|
mLastPollOperationsSnapshot, mOperations, false, "uidop");
|
||||||
final long timeStart = currentTime - delta.getElapsedRealtime();
|
final long timeStart = currentTime - delta.getElapsedRealtime();
|
||||||
|
|
||||||
NetworkStats.Entry entry = null;
|
NetworkStats.Entry entry = null;
|
||||||
@ -1515,7 +1511,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
|||||||
|
|
||||||
// record error for debugging
|
// record error for debugging
|
||||||
final StringBuilder builder = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
builder.append("found non-monotonic " + type + "values at left[" + e.leftIndex
|
builder.append("found non-monotonic " + type + " values at left[" + e.leftIndex
|
||||||
+ "] - right[" + e.rightIndex + "]\n");
|
+ "] - right[" + e.rightIndex + "]\n");
|
||||||
builder.append("left=").append(e.left).append('\n');
|
builder.append("left=").append(e.left).append('\n');
|
||||||
builder.append("right=").append(e.right).append('\n');
|
builder.append("right=").append(e.right).append('\n');
|
||||||
|
Reference in New Issue
Block a user