[NS A17] Update linger state after rematching.
Test: FrameworksNetTests NetworkStackTests Change-Id: I720a1feb89088aa123201ef5867de444234343e8
This commit is contained in:
@@ -6486,15 +6486,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
// do this after the default net is switched, but
|
||||
// before LegacyTypeTracker sends legacy broadcasts
|
||||
for (NetworkRequestInfo nri : addedRequests) notifyNetworkAvailable(newNetwork, nri);
|
||||
|
||||
// Linger any networks that are no longer needed. This should be done after sending the
|
||||
// available callback for newNetwork.
|
||||
for (NetworkAgentInfo nai : removedRequests) {
|
||||
updateLingerState(nai, now);
|
||||
}
|
||||
// Possibly unlinger newNetwork. Unlingering a network does not send any callbacks so it
|
||||
// does not need to be done in any particular order.
|
||||
updateLingerState(newNetwork, now);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6514,14 +6505,23 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
new NetworkAgentInfo[mNetworkAgentInfos.size()]);
|
||||
// Rematch higher scoring networks first to prevent requests first matching a lower
|
||||
// scoring network and then a higher scoring network, which could produce multiple
|
||||
// callbacks and inadvertently unlinger networks.
|
||||
// callbacks.
|
||||
Arrays.sort(nais);
|
||||
for (NetworkAgentInfo nai : nais) {
|
||||
for (final NetworkAgentInfo nai : nais) {
|
||||
rematchNetworkAndRequests(nai, now);
|
||||
}
|
||||
|
||||
final NetworkAgentInfo newDefaultNetwork = getDefaultNetwork();
|
||||
|
||||
for (final NetworkAgentInfo nai : nais) {
|
||||
// Rematching may have altered the linger state of some networks, so update all linger
|
||||
// timers. updateLingerState reads the state from the network agent and does nothing
|
||||
// if the state has not changed : the source of truth is controlled with
|
||||
// NetworkAgentInfo#lingerRequest and NetworkAgentInfo#unlingerRequest, which have been
|
||||
// called while rematching the individual networks above.
|
||||
updateLingerState(nai, now);
|
||||
}
|
||||
|
||||
updateLegacyTypeTrackerAndVpnLockdownForRematch(oldDefaultNetwork, newDefaultNetwork, nais);
|
||||
|
||||
// Tear down all unneeded networks.
|
||||
|
||||
@@ -580,7 +580,7 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> {
|
||||
// semantics of WakeupMessage guarantee that if cancel is called then the alarm will
|
||||
// never call its callback (handleLingerComplete), even if it has already fired.
|
||||
// WakeupMessage makes no such guarantees about rescheduling a message, so if mLingerMessage
|
||||
// has already been dispatched, rescheduling to some time in the future it won't stop it
|
||||
// has already been dispatched, rescheduling to some time in the future won't stop it
|
||||
// from calling its callback immediately.
|
||||
if (mLingerMessage != null) {
|
||||
mLingerMessage.cancel();
|
||||
|
||||
Reference in New Issue
Block a user