Merge changes If8c8d1f3,I3a804a9f am: 49c185e487 am: dff0d295a9

Change-Id: I1a0085ad35ca95cab4086d4779ee15322094c2f6
This commit is contained in:
Automerger Merge Worker
2020-02-03 15:12:20 +00:00

View File

@@ -6347,12 +6347,34 @@ 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,20 +6450,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
changes.addRematchedNetwork(new NetworkReassignment.NetworkBgStatePair(newNetwork,
newNetwork.isBackgroundNetwork()));
final int score = newNetwork.getCurrentScore();
if (VDBG || DDBG) log("rematching " + newNetwork.name());
final ArrayMap<NetworkRequestInfo, NetworkAgentInfo> reassignedRequests =
computeRequestReassignmentForNetwork(newNetwork);
NetworkCapabilities nc = newNetwork.networkCapabilities;
if (VDBG) log(" network has: " + nc);
// 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();
@@ -6455,7 +6470,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
previousSatisfier.removeRequest(nri.request.requestId);
previousSatisfier.lingerRequest(nri.request, now, mLingerDelayMs);
removedRequests.add(previousSatisfier);
} else {
if (VDBG || DDBG) log(" accepting network in place of null");
}
@@ -6464,7 +6478,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (!newSatisfier.addRequest(nri.request)) {
Slog.wtf(TAG, "BUG: " + newSatisfier.name() + " already has " + nri.request);
}
addedRequests.add(nri);
changes.addRequestReassignment(new NetworkReassignment.RequestReassignment(
nri, previousSatisfier, newSatisfier));
// Tell NetworkProviders 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
@@ -6521,21 +6536,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
// Have a new default network, release the transition wakelock in
scheduleReleaseNetworkTransitionWakelock();
}
if (!newNetwork.networkCapabilities.equalRequestableCapabilities(nc)) {
Slog.wtf(TAG, String.format(
"BUG: %s changed requestable capabilities during rematch: %s -> %s",
newNetwork.name(), nc, newNetwork.networkCapabilities));
}
if (newNetwork.getCurrentScore() != score) {
Slog.wtf(TAG, String.format(
"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);
}
/**
@@ -6564,6 +6564,15 @@ 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