diff options
| author | 2014-12-19 10:51:18 +0000 | |
|---|---|---|
| committer | 2014-12-19 10:51:18 +0000 | |
| commit | 3c125575b63aedc16ca63fdf378217d1c61fd39c (patch) | |
| tree | 2e1477e8df6203283854fbaf25726587b2dcdadb | |
| parent | f895c8c5c6abb140b9d0ffa6bbf5664cacdc774c (diff) | |
| parent | 8af8f1f71e05355d890206517b5518c961a247d4 (diff) | |
am 7e81cdef: am 7b42f399: Add a lastValidated bit and use it when reporting capabilities.
automerge: 8af8f1f7
* commit '8af8f1f71e05355d890206517b5518c961a247d4':
Add a lastValidated bit and use it when reporting capabilities.
| -rw-r--r-- | services/core/java/com/android/server/ConnectivityService.java | 9 | ||||
| -rw-r--r-- | services/core/java/com/android/server/connectivity/NetworkAgentInfo.java | 13 |
2 files changed, 16 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 3387c0f19000..b1f14a913795 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -1048,7 +1048,7 @@ public class ConnectivityService extends IConnectivityManager.Stub synchronized (nai) { if (nai.created) { NetworkCapabilities nc = new NetworkCapabilities(nai.networkCapabilities); - if (nai.everValidated) { + if (nai.lastValidated) { nc.addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED); } else { nc.removeCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED); @@ -1954,6 +1954,7 @@ public class ConnectivityService extends IConnectivityManager.Stub NetworkAgentInfo nai = (NetworkAgentInfo)msg.obj; if (isLiveNetworkAgent(nai, "EVENT_NETWORK_VALIDATED")) { boolean valid = (msg.arg1 == NetworkMonitor.NETWORK_TEST_RESULT_VALID); + nai.lastValidated = valid; if (valid) { if (DBG) log("Validated " + nai.name()); if (!nai.everValidated) { @@ -1964,7 +1965,7 @@ public class ConnectivityService extends IConnectivityManager.Stub sendUpdatedScoreToFactories(nai); } } - updateInetCondition(nai, valid); + updateInetCondition(nai); // Let the NetworkAgent know the state of its network nai.asyncChannel.sendMessage( 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. if (!nai.everValidated) return; // For now only update icons for default connection. // TODO: Update WiFi and cellular icons separately. b/17237507 if (!isDefaultNetwork(nai)) return; - int newInetCondition = valid ? 100 : 0; + int newInetCondition = nai.lastValidated ? 100 : 0; // Don't repeat publish. if (newInetCondition == mDefaultInetConditionPublished) return; diff --git a/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java b/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java index 94a8c0f215d0..f3e0bbc573d8 100644 --- a/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java +++ b/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java @@ -55,6 +55,13 @@ public class NetworkAgentInfo { // fail. 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. private int currentScore; // Penalty applied to scores of Networks that have not been validated. @@ -90,6 +97,7 @@ public class NetworkAgentInfo { networkMisc = misc; created = false; everValidated = false; + lastValidated = false; } public void addRequest(NetworkRequest networkRequest) { @@ -142,8 +150,9 @@ public class NetworkAgentInfo { return "NetworkAgentInfo{ ni{" + networkInfo + "} network{" + network + "} lp{" + linkProperties + "} nc{" + - networkCapabilities + "} Score{" + getCurrentScore() + "} " + - "everValidated{" + everValidated + "} created{" + created + "} " + + networkCapabilities + "} Score{" + getCurrentScore() + "} " + + "everValidated{" + everValidated + "} lastValidated{" + lastValidated + "} " + + "created{" + created + "} " + "explicitlySelected{" + networkMisc.explicitlySelected + "} }"; } |