Revert "[NS A26] Move available callbacks out of the rematch computation"

This reverts commit be083a195f.

Reason for revert: Toggling wifi on/off causes networking to
 stop working with these four patches applied.
Bug: 146230156

Change-Id: I9af7f8b9af1a6279f2b9f1249824da705164c6b5
This commit is contained in:
Andrew Chant
2019-12-14 03:32:04 +00:00
parent 06a8edd342
commit 6f9f854916

View File

@@ -6312,34 +6312,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
}
static class RequestReassignment {
@NonNull public final NetworkRequestInfo mRequest;
@Nullable public final NetworkAgentInfo mOldNetwork;
@Nullable public final NetworkAgentInfo mNewNetwork;
RequestReassignment(@NonNull final NetworkRequestInfo request,
@Nullable final NetworkAgentInfo oldNetwork,
@Nullable final NetworkAgentInfo newNetwork) {
mRequest = request;
mOldNetwork = oldNetwork;
mNewNetwork = newNetwork;
}
}
@NonNull private final Set<NetworkBgStatePair> mRematchedNetworks = new ArraySet<>();
@NonNull private final List<RequestReassignment> mReassignments = new ArrayList<>();
@NonNull Iterable<NetworkBgStatePair> getRematchedNetworks() {
return mRematchedNetworks;
}
@NonNull Iterable<RequestReassignment> getRequestReassignments() {
return mReassignments;
}
void addRequestReassignment(@NonNull final RequestReassignment reassignment) {
mReassignments.add(reassignment);
}
void addRematchedNetwork(@NonNull final NetworkBgStatePair network) {
mRematchedNetworks.add(network);
}
@@ -6428,6 +6406,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// Find and migrate to this Network any NetworkRequests for
// which this network is now the best.
final ArrayList<NetworkAgentInfo> removedRequests = new ArrayList<>();
final ArrayList<NetworkRequestInfo> addedRequests = new ArrayList<>();
for (final Map.Entry<NetworkRequestInfo, NetworkAgentInfo> entry :
reassignedRequests.entrySet()) {
final NetworkRequestInfo nri = entry.getKey();
@@ -6450,8 +6429,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (!newSatisfier.addRequest(nri.request)) {
Slog.wtf(TAG, "BUG: " + newSatisfier.name() + " already has " + nri.request);
}
changes.addRequestReassignment(new NetworkReassignment.RequestReassignment(
nri, previousSatisfier, newSatisfier));
addedRequests.add(nri);
// Tell NetworkFactories about the new score, so they can stop
// trying to connect if they know they cannot match it.
// TODO - this could get expensive if we have a lot of requests for this
@@ -6519,6 +6497,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
"BUG: %s changed score during rematch: %d -> %d",
newNetwork.name(), score, newNetwork.getCurrentScore()));
}
// Notify requested networks are available after the default net is switched, but
// before LegacyTypeTracker sends legacy broadcasts
for (NetworkRequestInfo nri : addedRequests) notifyNetworkAvailable(newNetwork, nri);
}
/**
@@ -6547,15 +6529,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
final NetworkAgentInfo newDefaultNetwork = getDefaultNetwork();
// Notify requested networks are available after the default net is switched, but
// before LegacyTypeTracker sends legacy broadcasts
for (final NetworkReassignment.RequestReassignment event :
changes.getRequestReassignments()) {
if (null != event.mNewNetwork) {
notifyNetworkAvailable(event.mNewNetwork, event.mRequest);
}
}
for (final NetworkReassignment.NetworkBgStatePair event : changes.getRematchedNetworks()) {
// Process listen requests and update capabilities if the background state has
// changed for this network. For consistency with previous behavior, send onLost