When adding a NetworkRequest, cancel linger for satisfying Network.

This fixes a problem where a requested network can later suddenly disappear if
it was lingering when the request arrived and later the linger timeout expired.

bug:15927234
Change-Id: Ib3fae45820ce4421e3bc5b623937a16d5f1efa0f
This commit is contained in:
Paul Jensen
2014-07-02 12:02:59 -04:00
parent b20d886bce
commit 7ba4d03c1c

View File

@@ -3332,6 +3332,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
if (bestNetwork != null) {
if (VDBG) log("using " + bestNetwork.name());
if (nri.isRequest && 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();
bestNetwork.networkMonitor.sendMessage(NetworkMonitor.CMD_NETWORK_CONNECTED);
}
bestNetwork.addRequest(nri.request);
mNetworkForRequestId.put(nri.request.requestId, bestNetwork);
int legacyType = nri.request.legacyType;