Don't allow an uncreated Network to satsify requests.

This could happen when another Network changes its capabilities and
updateCapabilities() calls rematchAllNetworksAndRequests() which
calls rematchNetworkAndRequests() on all Networks, even those that
are uncreated.
Allowing uncreated Networks to satisfy requests can lead to bugs
where ConnectivityService instructs netd to perform actions
(e.g. set default Network) on uncreated Networks which netd doesn't
know about yet.

bug:18446301
Change-Id: I857262ac66d1d3af4c264ce128f0a4bee95655de
This commit is contained in:
Paul Jensen
2014-11-19 13:01:46 -05:00
parent c52ae42e2f
commit 262b462786

View File

@@ -3973,7 +3973,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// another higher scoring network by another call to rematchNetworkAndRequests()
// and this other call also lingered newNetwork.
private void rematchNetworkAndRequests(NetworkAgentInfo newNetwork, boolean nascent) {
if (!newNetwork.created) loge("ERROR: uncreated network being rematched.");
if (!newNetwork.created) return;
if (nascent && !newNetwork.validated) loge("ERROR: nascent network not validated.");
boolean keep = newNetwork.isVPN();
boolean isNewDefault = false;
@@ -4272,7 +4272,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
final int oldScore = nai.getCurrentScore();
nai.setCurrentScore(score);
if (nai.created) rematchAllNetworksAndRequests(nai, oldScore);
rematchAllNetworksAndRequests(nai, oldScore);
sendUpdatedScoreToFactories(nai);
}