Merge "Fix listening NetworkRequests to listen for all networks." into lmp-dev

This commit is contained in:
Robert Greenwalt
2014-08-21 01:01:22 +00:00
committed by Android (Google) Code Review

View File

@@ -2109,13 +2109,21 @@ public class ConnectivityService extends IConnectivityManager.Stub {
if (newCap.satisfiedByNetworkCapabilities(network.networkCapabilities)) {
if (VDBG) log("apparently satisfied. currentScore=" + network.currentScore);
if ((bestNetwork == null) || bestNetwork.currentScore < network.currentScore) {
if (!nri.isRequest) {
// Not setting bestNetwork here as a listening NetworkRequest may be
// satisfied by multiple Networks. Instead the request is added to
// each satisfying Network and notified about each.
network.addRequest(nri.request);
notifyNetworkCallback(network, nri);
} else {
bestNetwork = network;
}
}
}
}
if (bestNetwork != null) {
if (VDBG) log("using " + bestNetwork.name());
if (nri.isRequest && bestNetwork.networkInfo.isConnected()) {
if (bestNetwork.networkInfo.isConnected()) {
// Cancel any lingering so the linger timeout doesn't teardown this network
// even though we have a request for it.
bestNetwork.networkLingered.clear();
@@ -2125,7 +2133,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
mNetworkForRequestId.put(nri.request.requestId, bestNetwork);
notifyNetworkCallback(bestNetwork, nri);
score = bestNetwork.currentScore;
if (nri.isRequest && nri.request.legacyType != TYPE_NONE) {
if (nri.request.legacyType != TYPE_NONE) {
mLegacyTypeTracker.add(nri.request.legacyType, bestNetwork);
}
}
@@ -4423,6 +4431,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
if (VDBG) log(" checking if request is satisfied: " + nri.request);
if (nri.request.networkCapabilities.satisfiedByNetworkCapabilities(
newNetwork.networkCapabilities)) {
if (!nri.isRequest) {
newNetwork.addRequest(nri.request);
continue;
}
// next check if it's better than any current network we're using for
// this request
if (VDBG) {