Merge "DefaultNetworkEvent: fix two bugs with validation times" am: c0d951c3e0
am: 144d9e9f83
Change-Id: Iad5a7cda8b73f638aa7db8ae38bdccef1cbeae85
This commit is contained in:
@@ -74,7 +74,7 @@ public class DefaultNetworkEvent {
|
|||||||
j.add("final_score=" + finalScore);
|
j.add("final_score=" + finalScore);
|
||||||
}
|
}
|
||||||
j.add(String.format("duration=%.0fs", durationMs / 1000.0));
|
j.add(String.format("duration=%.0fs", durationMs / 1000.0));
|
||||||
j.add(String.format("validation=%4.1f%%", (validatedMs * 100.0) / durationMs));
|
j.add(String.format("validation=%04.1f%%", (validatedMs * 100.0) / durationMs));
|
||||||
return j.toString();
|
return j.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public class DefaultNetworkMetrics {
|
|||||||
// Information about the current status of the default network.
|
// Information about the current status of the default network.
|
||||||
@GuardedBy("this")
|
@GuardedBy("this")
|
||||||
private DefaultNetworkEvent mCurrentDefaultNetwork;
|
private DefaultNetworkEvent mCurrentDefaultNetwork;
|
||||||
|
// True if the current default network has been validated.
|
||||||
@GuardedBy("this")
|
@GuardedBy("this")
|
||||||
private boolean mIsCurrentlyValid;
|
private boolean mIsCurrentlyValid;
|
||||||
@GuardedBy("this")
|
@GuardedBy("this")
|
||||||
@@ -71,6 +72,8 @@ public class DefaultNetworkMetrics {
|
|||||||
printEvent(localTimeMs, pw, ev);
|
printEvent(localTimeMs, pw, ev);
|
||||||
}
|
}
|
||||||
mCurrentDefaultNetwork.updateDuration(timeMs);
|
mCurrentDefaultNetwork.updateDuration(timeMs);
|
||||||
|
// When printing default network events for bug reports, update validation time
|
||||||
|
// and refresh the last validation timestmap for future validation time updates.
|
||||||
if (mIsCurrentlyValid) {
|
if (mIsCurrentlyValid) {
|
||||||
updateValidationTime(timeMs);
|
updateValidationTime(timeMs);
|
||||||
mLastValidationTimeMs = timeMs;
|
mLastValidationTimeMs = timeMs;
|
||||||
@@ -92,11 +95,13 @@ public class DefaultNetworkMetrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void logDefaultNetworkValidity(long timeMs, boolean isValid) {
|
public synchronized void logDefaultNetworkValidity(long timeMs, boolean isValid) {
|
||||||
|
// Transition from valid to invalid: update validity duration since last update
|
||||||
if (!isValid && mIsCurrentlyValid) {
|
if (!isValid && mIsCurrentlyValid) {
|
||||||
mIsCurrentlyValid = false;
|
mIsCurrentlyValid = false;
|
||||||
updateValidationTime(timeMs);
|
updateValidationTime(timeMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Transition from invalid to valid: simply mark the validation timestamp.
|
||||||
if (isValid && !mIsCurrentlyValid) {
|
if (isValid && !mIsCurrentlyValid) {
|
||||||
mIsCurrentlyValid = true;
|
mIsCurrentlyValid = true;
|
||||||
mLastValidationTimeMs = timeMs;
|
mLastValidationTimeMs = timeMs;
|
||||||
@@ -114,6 +119,9 @@ public class DefaultNetworkMetrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void logCurrentDefaultNetwork(long timeMs, NetworkAgentInfo oldNai) {
|
private void logCurrentDefaultNetwork(long timeMs, NetworkAgentInfo oldNai) {
|
||||||
|
if (mIsCurrentlyValid) {
|
||||||
|
updateValidationTime(timeMs);
|
||||||
|
}
|
||||||
DefaultNetworkEvent ev = mCurrentDefaultNetwork;
|
DefaultNetworkEvent ev = mCurrentDefaultNetwork;
|
||||||
ev.updateDuration(timeMs);
|
ev.updateDuration(timeMs);
|
||||||
ev.previousTransports = mLastTransports;
|
ev.previousTransports = mLastTransports;
|
||||||
@@ -122,7 +130,6 @@ public class DefaultNetworkMetrics {
|
|||||||
// The system acquired a new default network.
|
// The system acquired a new default network.
|
||||||
fillLinkInfo(ev, oldNai);
|
fillLinkInfo(ev, oldNai);
|
||||||
ev.finalScore = oldNai.getCurrentScore();
|
ev.finalScore = oldNai.getCurrentScore();
|
||||||
ev.validatedMs = ev.durationMs;
|
|
||||||
}
|
}
|
||||||
// Only change transport of the previous default network if the event currently logged
|
// Only change transport of the previous default network if the event currently logged
|
||||||
// corresponds to an existing default network, and not to the absence of a default network.
|
// corresponds to an existing default network, and not to the absence of a default network.
|
||||||
@@ -143,9 +150,10 @@ public class DefaultNetworkMetrics {
|
|||||||
fillLinkInfo(ev, newNai);
|
fillLinkInfo(ev, newNai);
|
||||||
ev.initialScore = newNai.getCurrentScore();
|
ev.initialScore = newNai.getCurrentScore();
|
||||||
if (newNai.lastValidated) {
|
if (newNai.lastValidated) {
|
||||||
mIsCurrentlyValid = true;
|
logDefaultNetworkValidity(timeMs, true);
|
||||||
mLastValidationTimeMs = timeMs;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
mIsCurrentlyValid = false;
|
||||||
}
|
}
|
||||||
mCurrentDefaultNetwork = ev;
|
mCurrentDefaultNetwork = ev;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user