summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChalard Jean <jchalard@google.com>2019-11-19 19:23:38 +0900
committerChalard Jean <jchalard@google.com>2019-12-02 13:02:41 +0900
commit0147c90f1645c255942bfddd6a260156b0e3c192 (patch)
tree6beee74fd2a4871bb9646d26dc71baecba7c368e
parent18ee53f90bfac67c6b5d272869333229bb9dde97 (diff)
downloadbase-0147c90f1645c255942bfddd6a260156b0e3c192.tar.gz
[NS A16] Cleanup
Move LegacyTypeTracker work into a function for readability. Test: FrameworksNetTests NetworkStackTests Change-Id: I9539b8cc4422b3a0cc1d3d9b3a44d59dc1905b44
-rw-r--r--services/core/java/com/android/server/ConnectivityService.java51
1 files changed, 31 insertions, 20 deletions
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 1bbd96a093e5..1d5016e9d52a 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -6522,7 +6522,32 @@ public class ConnectivityService extends IConnectivityManager.Stub
final NetworkAgentInfo newDefaultNetwork = getDefaultNetwork();
- // TODO : move the LegacyTypeTracker-related code to a separate function.
+ updateLegacyTypeTrackerAndVpnLockdownForRematch(oldDefaultNetwork, newDefaultNetwork, nais);
+
+ // Tear down all unneeded networks.
+ for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
+ if (unneeded(nai, UnneededFor.TEARDOWN)) {
+ if (nai.getLingerExpiry() > 0) {
+ // This network has active linger timers and no requests, but is not
+ // lingering. Linger it.
+ //
+ // One way (the only way?) this can happen if this network is unvalidated
+ // and became unneeded due to another network improving its score to the
+ // point where this network will no longer be able to satisfy any requests
+ // even if it validates.
+ updateLingerState(nai, now);
+ } else {
+ if (DBG) log("Reaping " + nai.name());
+ teardownUnneededNetwork(nai);
+ }
+ }
+ }
+ }
+
+ private void updateLegacyTypeTrackerAndVpnLockdownForRematch(
+ @Nullable final NetworkAgentInfo oldDefaultNetwork,
+ @Nullable final NetworkAgentInfo newDefaultNetwork,
+ @NonNull final NetworkAgentInfo[] nais) {
if (oldDefaultNetwork != newDefaultNetwork) {
// Maintain the illusion : since the legacy API only understands one network at a time,
// if the default network changed, apps should see a disconnected broadcast for the
@@ -6537,6 +6562,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
// capability.
mDefaultInetConditionPublished = newDefaultNetwork.lastValidated ? 100 : 0;
mLegacyTypeTracker.add(newDefaultNetwork.networkInfo.getType(), newDefaultNetwork);
+ // If the legacy VPN is connected, notifyLockdownVpn may end up sending a broadcast
+ // to reflect the NetworkInfo of this new network. This broadcast has to be sent
+ // after the disconnect broadcasts above, but before the broadcasts sent by the
+ // legacy type tracker below.
+ // TODO : refactor this, it's too complex
notifyLockdownVpn(newDefaultNetwork);
}
}
@@ -6558,25 +6588,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
for (NetworkAgentInfo nai : nais) {
addNetworkToLegacyTypeTracker(nai);
}
-
- // Tear down all unneeded networks.
- for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
- if (unneeded(nai, UnneededFor.TEARDOWN)) {
- if (nai.getLingerExpiry() > 0) {
- // This network has active linger timers and no requests, but is not
- // lingering. Linger it.
- //
- // One way (the only way?) this can happen if this network is unvalidated
- // and became unneeded due to another network improving its score to the
- // point where this network will no longer be able to satisfy any requests
- // even if it validates.
- updateLingerState(nai, now);
- } else {
- if (DBG) log("Reaping " + nai.name());
- teardownUnneededNetwork(nai);
- }
- }
- }
}
private void addNetworkToLegacyTypeTracker(@NonNull final NetworkAgentInfo nai) {