From d4a4a30aef54eec7339e7c4d88d5f9ee50c55d48 Mon Sep 17 00:00:00 2001 From: Chalard Jean Date: Tue, 10 Dec 2019 19:01:29 +0900 Subject: [PATCH] [NS B02] Split out a function to apply a NetworkReassignment This makes the rematchAllNetworksAndRequests function, which is the nexus of the rematching code, very straightforward and easy to read. Bug: 113554781 Test: FrameworksNetTests Change-Id: I5cea4ed7e06439494700d88ab202b696402fa360 --- .../java/com/android/server/ConnectivityService.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 30419aebd0..ea6fe2b918 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -6723,12 +6723,15 @@ public class ConnectivityService extends IConnectivityManager.Stub // be optimized to only do the processing needed. final long now = SystemClock.elapsedRealtime(); final NetworkAgentInfo oldDefaultNetwork = getDefaultNetwork(); - final NetworkReassignment changes = computeNetworkReassignment(); + applyNetworkReassignment(changes, oldDefaultNetwork, now); + } - // Now that the entire rematch is computed, update the lists of satisfied requests in - // the network agents. This is necessary because some code later depends on this state - // to be correct, most prominently computing the linger status. + private void applyNetworkReassignment(@NonNull final NetworkReassignment changes, + @Nullable final NetworkAgentInfo oldDefaultNetwork, final long now) { + // First, update the lists of satisfied requests in the network agents. This is necessary + // because some code later depends on this state to be correct, most prominently computing + // the linger status. for (final NetworkReassignment.RequestReassignment event : changes.getRequestReassignments()) { // The rematch is seeded with an entry for each request, and requests that don't