am 7e81cdef: am 5f82daec: Add a lastValidated bit and use it when reporting capabilities.

automerge: 71860bbb

* commit '71860bbba756c618e0c8e19191b6d829e51d7f0a':
  Add a lastValidated bit and use it when reporting capabilities.
This commit is contained in:
Lorenzo Colitti
2014-12-19 10:51:18 +00:00
committed by android-build-merger
2 changed files with 16 additions and 6 deletions

View File

@@ -1048,7 +1048,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
synchronized (nai) { synchronized (nai) {
if (nai.created) { if (nai.created) {
NetworkCapabilities nc = new NetworkCapabilities(nai.networkCapabilities); NetworkCapabilities nc = new NetworkCapabilities(nai.networkCapabilities);
if (nai.everValidated) { if (nai.lastValidated) {
nc.addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED); nc.addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
} else { } else {
nc.removeCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED); nc.removeCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
@@ -1954,6 +1954,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
NetworkAgentInfo nai = (NetworkAgentInfo)msg.obj; NetworkAgentInfo nai = (NetworkAgentInfo)msg.obj;
if (isLiveNetworkAgent(nai, "EVENT_NETWORK_VALIDATED")) { if (isLiveNetworkAgent(nai, "EVENT_NETWORK_VALIDATED")) {
boolean valid = (msg.arg1 == NetworkMonitor.NETWORK_TEST_RESULT_VALID); boolean valid = (msg.arg1 == NetworkMonitor.NETWORK_TEST_RESULT_VALID);
nai.lastValidated = valid;
if (valid) { if (valid) {
if (DBG) log("Validated " + nai.name()); if (DBG) log("Validated " + nai.name());
if (!nai.everValidated) { if (!nai.everValidated) {
@@ -1964,7 +1965,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
sendUpdatedScoreToFactories(nai); sendUpdatedScoreToFactories(nai);
} }
} }
updateInetCondition(nai, valid); updateInetCondition(nai);
// Let the NetworkAgent know the state of its network // Let the NetworkAgent know the state of its network
nai.asyncChannel.sendMessage( nai.asyncChannel.sendMessage(
android.net.NetworkAgent.CMD_REPORT_NETWORK_STATUS, android.net.NetworkAgent.CMD_REPORT_NETWORK_STATUS,
@@ -4200,14 +4201,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
} }
private void updateInetCondition(NetworkAgentInfo nai, boolean valid) { private void updateInetCondition(NetworkAgentInfo nai) {
// Don't bother updating until we've graduated to validated at least once. // Don't bother updating until we've graduated to validated at least once.
if (!nai.everValidated) return; if (!nai.everValidated) return;
// For now only update icons for default connection. // For now only update icons for default connection.
// TODO: Update WiFi and cellular icons separately. b/17237507 // TODO: Update WiFi and cellular icons separately. b/17237507
if (!isDefaultNetwork(nai)) return; if (!isDefaultNetwork(nai)) return;
int newInetCondition = valid ? 100 : 0; int newInetCondition = nai.lastValidated ? 100 : 0;
// Don't repeat publish. // Don't repeat publish.
if (newInetCondition == mDefaultInetConditionPublished) return; if (newInetCondition == mDefaultInetConditionPublished) return;

View File

@@ -55,6 +55,13 @@ public class NetworkAgentInfo {
// fail. // fail.
public boolean everValidated; public boolean everValidated;
// The result of the last validation attempt on this network (true if validated, false if not).
// This bit exists only because we never unvalidate a network once it's been validated, and that
// is because the network scoring and revalidation code does not (may not?) deal properly with
// networks becoming unvalidated.
// TODO: Fix the network scoring code, remove this, and rename everValidated to validated.
public boolean lastValidated;
// This represents the last score received from the NetworkAgent. // This represents the last score received from the NetworkAgent.
private int currentScore; private int currentScore;
// Penalty applied to scores of Networks that have not been validated. // Penalty applied to scores of Networks that have not been validated.
@@ -90,6 +97,7 @@ public class NetworkAgentInfo {
networkMisc = misc; networkMisc = misc;
created = false; created = false;
everValidated = false; everValidated = false;
lastValidated = false;
} }
public void addRequest(NetworkRequest networkRequest) { public void addRequest(NetworkRequest networkRequest) {
@@ -143,7 +151,8 @@ public class NetworkAgentInfo {
network + "} lp{" + network + "} lp{" +
linkProperties + "} nc{" + linkProperties + "} nc{" +
networkCapabilities + "} Score{" + getCurrentScore() + "} " + networkCapabilities + "} Score{" + getCurrentScore() + "} " +
"everValidated{" + everValidated + "} created{" + created + "} " + "everValidated{" + everValidated + "} lastValidated{" + lastValidated + "} " +
"created{" + created + "} " +
"explicitlySelected{" + networkMisc.explicitlySelected + "} }"; "explicitlySelected{" + networkMisc.explicitlySelected + "} }";
} }