Fix legacy request removal.
Don't say we're disconnected from a legacy type until there are no outstanding requests for it. bug:18946574 Change-Id: I8e45c4a7558f7ced0840b71c50081989ba13c1c7
This commit is contained in:
@@ -2324,6 +2324,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
if (nri.isRequest) {
|
if (nri.isRequest) {
|
||||||
// Find all networks that are satisfying this request and remove the request
|
// Find all networks that are satisfying this request and remove the request
|
||||||
// from their request lists.
|
// from their request lists.
|
||||||
|
// TODO - it's my understanding that for a request there is only a single
|
||||||
|
// network satisfying it, so this loop is wasteful
|
||||||
|
boolean wasKept = false;
|
||||||
for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
|
for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
|
||||||
if (nai.networkRequests.get(nri.request.requestId) != null) {
|
if (nai.networkRequests.get(nri.request.requestId) != null) {
|
||||||
nai.networkRequests.remove(nri.request.requestId);
|
nai.networkRequests.remove(nri.request.requestId);
|
||||||
@@ -2335,19 +2338,39 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
if (unneeded(nai)) {
|
if (unneeded(nai)) {
|
||||||
if (DBG) log("no live requests for " + nai.name() + "; disconnecting");
|
if (DBG) log("no live requests for " + nai.name() + "; disconnecting");
|
||||||
teardownUnneededNetwork(nai);
|
teardownUnneededNetwork(nai);
|
||||||
|
} else {
|
||||||
|
// suspect there should only be one pass through here
|
||||||
|
// but if any were kept do the check below
|
||||||
|
wasKept |= true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetworkAgentInfo nai = mNetworkForRequestId.get(nri.request.requestId);
|
||||||
|
if (nai != null) {
|
||||||
|
mNetworkForRequestId.remove(nri.request.requestId);
|
||||||
|
}
|
||||||
// Maintain the illusion. When this request arrived, we might have pretended
|
// Maintain the illusion. When this request arrived, we might have pretended
|
||||||
// that a network connected to serve it, even though the network was already
|
// that a network connected to serve it, even though the network was already
|
||||||
// connected. Now that this request has gone away, we might have to pretend
|
// connected. Now that this request has gone away, we might have to pretend
|
||||||
// that the network disconnected. LegacyTypeTracker will generate that
|
// that the network disconnected. LegacyTypeTracker will generate that
|
||||||
// phantom disconnect for this type.
|
// phantom disconnect for this type.
|
||||||
NetworkAgentInfo nai = mNetworkForRequestId.get(nri.request.requestId);
|
if (nri.request.legacyType != TYPE_NONE && nai != null) {
|
||||||
if (nai != null) {
|
boolean doRemove = true;
|
||||||
mNetworkForRequestId.remove(nri.request.requestId);
|
if (wasKept) {
|
||||||
if (nri.request.legacyType != TYPE_NONE) {
|
// check if any of the remaining requests for this network are for the
|
||||||
|
// same legacy type - if so, don't remove the nai
|
||||||
|
for (int i = 0; i < nai.networkRequests.size(); i++) {
|
||||||
|
NetworkRequest otherRequest = nai.networkRequests.valueAt(i);
|
||||||
|
if (otherRequest.legacyType == nri.request.legacyType &&
|
||||||
|
isRequest(otherRequest)) {
|
||||||
|
if (DBG) log(" still have other legacy request - leaving");
|
||||||
|
doRemove = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doRemove) {
|
||||||
mLegacyTypeTracker.remove(nri.request.legacyType, nai);
|
mLegacyTypeTracker.remove(nri.request.legacyType, nai);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user