Update Inet state when NetworkMonitor re-evaluates a network.
Previously the Inet state (the little exclamation mark beside the WiFi and Cellular bars) only transitioned from bad to good once. With this change it can transition back to bad (and later to good again) if a network re-evaluation is triggered, say by ConnectivityManager.reportBadNetwork. Also, avoid triggering re-evaluation in two unwanted cases. bug:16214361 Change-Id: I7856724249ffcbb0945276dcf45019876231fdaf
This commit is contained in:
committed by
Robert Greenwalt
parent
05e85ee7a6
commit
39fc7d5e8e
@@ -1785,6 +1785,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
}
|
||||
|
||||
private boolean isLiveNetworkAgent(NetworkAgentInfo nai, String msg) {
|
||||
if (nai.network == null) return false;
|
||||
final NetworkAgentInfo officialNai;
|
||||
synchronized (mNetworkForNetId) {
|
||||
officialNai = mNetworkForNetId.get(nai.network.netId);
|
||||
@@ -1924,12 +1925,16 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NetworkMonitor.EVENT_NETWORK_VALIDATED: {
|
||||
case NetworkMonitor.EVENT_NETWORK_TESTED: {
|
||||
NetworkAgentInfo nai = (NetworkAgentInfo)msg.obj;
|
||||
if (isLiveNetworkAgent(nai, "EVENT_NETWORK_VALIDATED")) {
|
||||
if (DBG) log("Validated " + nai.name());
|
||||
nai.validated = true;
|
||||
rematchNetworkAndRequests(nai);
|
||||
boolean valid = (msg.arg1 == NetworkMonitor.NETWORK_TEST_RESULT_VALID);
|
||||
if (valid) {
|
||||
if (DBG) log("Validated " + nai.name());
|
||||
nai.validated = true;
|
||||
rematchNetworkAndRequests(nai);
|
||||
}
|
||||
updateInetCondition(nai, valid);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -4716,6 +4721,21 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateInetCondition(NetworkAgentInfo nai, boolean valid) {
|
||||
// Don't bother updating until we've graduated to validated at least once.
|
||||
if (!nai.validated) 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;
|
||||
// Don't repeat publish.
|
||||
if (newInetCondition == mDefaultInetConditionPublished) return;
|
||||
|
||||
mDefaultInetConditionPublished = newInetCondition;
|
||||
sendInetConditionBroadcast(nai.networkInfo);
|
||||
}
|
||||
|
||||
private void updateNetworkInfo(NetworkAgentInfo networkAgent, NetworkInfo newInfo) {
|
||||
NetworkInfo.State state = newInfo.getState();
|
||||
NetworkInfo oldInfo = null;
|
||||
|
||||
Reference in New Issue
Block a user