Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server.connectivity; |
| 18 | |
Paul Jensen | ca8f16a | 2014-05-09 12:47:55 -0400 | [diff] [blame] | 19 | import android.content.Context; |
Lorenzo Colitti | 9307ca2 | 2019-01-12 01:54:23 +0900 | [diff] [blame] | 20 | import android.net.INetd; |
Remi NGUYEN VAN | e67b0c3 | 2018-12-27 16:43:56 +0900 | [diff] [blame] | 21 | import android.net.INetworkMonitor; |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 22 | import android.net.LinkProperties; |
| 23 | import android.net.Network; |
| 24 | import android.net.NetworkCapabilities; |
| 25 | import android.net.NetworkInfo; |
Sreeram Ramachandran | 8cd33ed | 2014-07-23 15:23:15 -0700 | [diff] [blame] | 26 | import android.net.NetworkMisc; |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 27 | import android.net.NetworkRequest; |
Jeff Sharkey | f07c7b9 | 2016-04-22 09:50:16 -0600 | [diff] [blame] | 28 | import android.net.NetworkState; |
Paul Jensen | ca8f16a | 2014-05-09 12:47:55 -0400 | [diff] [blame] | 29 | import android.os.Handler; |
Hugo Benichi | ef50288 | 2017-09-01 01:23:32 +0000 | [diff] [blame] | 30 | import android.os.INetworkManagementService; |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 31 | import android.os.Messenger; |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 32 | import android.os.SystemClock; |
| 33 | import android.util.Log; |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 34 | import android.util.SparseArray; |
| 35 | |
| 36 | import com.android.internal.util.AsyncChannel; |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 37 | import com.android.internal.util.WakeupMessage; |
Paul Jensen | cf4c2c6 | 2015-07-01 14:16:32 -0400 | [diff] [blame] | 38 | import com.android.server.ConnectivityService; |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 39 | |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 40 | import java.io.PrintWriter; |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 41 | import java.util.Objects; |
| 42 | import java.util.SortedSet; |
| 43 | import java.util.TreeSet; |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 44 | |
| 45 | /** |
| 46 | * A bag class used by ConnectivityService for holding a collection of most recent |
| 47 | * information published by a particular NetworkAgent as well as the |
| 48 | * AsyncChannel/messenger for reaching that NetworkAgent and lists of NetworkRequests |
Paul Jensen | 85cf78e | 2015-06-25 13:25:07 -0400 | [diff] [blame] | 49 | * interested in using it. Default sort order is descending by score. |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 50 | */ |
Paul Jensen | e098854 | 2015-06-25 15:30:08 -0400 | [diff] [blame] | 51 | // States of a network: |
| 52 | // -------------------- |
| 53 | // 1. registered, uncreated, disconnected, unvalidated |
| 54 | // This state is entered when a NetworkFactory registers a NetworkAgent in any state except |
| 55 | // the CONNECTED state. |
Robin Lee | 585e248 | 2016-05-01 23:00:00 +0100 | [diff] [blame] | 56 | // 2. registered, uncreated, connecting, unvalidated |
| 57 | // This state is entered when a registered NetworkAgent for a VPN network transitions to the |
| 58 | // CONNECTING state (TODO: go through this state for every network, not just VPNs). |
| 59 | // ConnectivityService will tell netd to create the network early in order to add extra UID |
| 60 | // routing rules referencing the netID. These rules need to be in place before the network is |
| 61 | // connected to avoid racing against client apps trying to connect to a half-setup network. |
| 62 | // 3. registered, uncreated, connected, unvalidated |
| 63 | // This state is entered when a registered NetworkAgent transitions to the CONNECTED state. |
| 64 | // ConnectivityService will tell netd to create the network if it was not already created, and |
| 65 | // immediately transition to state #4. |
| 66 | // 4. registered, created, connected, unvalidated |
Paul Jensen | cf4c2c6 | 2015-07-01 14:16:32 -0400 | [diff] [blame] | 67 | // If this network can satisfy the default NetworkRequest, then NetworkMonitor will |
Paul Jensen | e098854 | 2015-06-25 15:30:08 -0400 | [diff] [blame] | 68 | // probe for Internet connectivity. |
| 69 | // If this network cannot satisfy the default NetworkRequest, it will immediately be |
Robin Lee | 585e248 | 2016-05-01 23:00:00 +0100 | [diff] [blame] | 70 | // transitioned to state #5. |
Paul Jensen | e098854 | 2015-06-25 15:30:08 -0400 | [diff] [blame] | 71 | // A network may remain in this state if NetworkMonitor fails to find Internet connectivity, |
| 72 | // for example: |
| 73 | // a. a captive portal is present, or |
| 74 | // b. a WiFi router whose Internet backhaul is down, or |
| 75 | // c. a wireless connection stops transfering packets temporarily (e.g. device is in elevator |
| 76 | // or tunnel) but does not disconnect from the AP/cell tower, or |
| 77 | // d. a stand-alone device offering a WiFi AP without an uplink for configuration purposes. |
Robin Lee | 585e248 | 2016-05-01 23:00:00 +0100 | [diff] [blame] | 78 | // 5. registered, created, connected, validated |
Paul Jensen | e098854 | 2015-06-25 15:30:08 -0400 | [diff] [blame] | 79 | // |
| 80 | // The device's default network connection: |
| 81 | // ---------------------------------------- |
Robin Lee | 585e248 | 2016-05-01 23:00:00 +0100 | [diff] [blame] | 82 | // Networks in states #4 and #5 may be used as a device's default network connection if they |
Paul Jensen | e098854 | 2015-06-25 15:30:08 -0400 | [diff] [blame] | 83 | // satisfy the default NetworkRequest. |
Robin Lee | 585e248 | 2016-05-01 23:00:00 +0100 | [diff] [blame] | 84 | // A network, that satisfies the default NetworkRequest, in state #5 should always be chosen |
| 85 | // in favor of a network, that satisfies the default NetworkRequest, in state #4. |
Paul Jensen | e098854 | 2015-06-25 15:30:08 -0400 | [diff] [blame] | 86 | // When deciding between two networks, that both satisfy the default NetworkRequest, to select |
| 87 | // for the default network connection, the one with the higher score should be chosen. |
| 88 | // |
| 89 | // When a network disconnects: |
| 90 | // --------------------------- |
| 91 | // If a network's transport disappears, for example: |
| 92 | // a. WiFi turned off, or |
| 93 | // b. cellular data turned off, or |
| 94 | // c. airplane mode is turned on, or |
| 95 | // d. a wireless connection disconnects from AP/cell tower entirely (e.g. device is out of range |
| 96 | // of AP for an extended period of time, or switches to another AP without roaming) |
Robin Lee | 585e248 | 2016-05-01 23:00:00 +0100 | [diff] [blame] | 97 | // then that network can transition from any state (#1-#5) to unregistered. This happens by |
Paul Jensen | e098854 | 2015-06-25 15:30:08 -0400 | [diff] [blame] | 98 | // the transport disconnecting their NetworkAgent's AsyncChannel with ConnectivityManager. |
| 99 | // ConnectivityService also tells netd to destroy the network. |
| 100 | // |
| 101 | // When ConnectivityService disconnects a network: |
| 102 | // ----------------------------------------------- |
| 103 | // If a network has no chance of satisfying any requests (even if it were to become validated |
Robin Lee | 585e248 | 2016-05-01 23:00:00 +0100 | [diff] [blame] | 104 | // and enter state #5), ConnectivityService will disconnect the NetworkAgent's AsyncChannel. |
Lorenzo Colitti | 3d4a106 | 2016-09-09 18:48:56 +0900 | [diff] [blame] | 105 | // |
| 106 | // If the network was satisfying a foreground NetworkRequest (i.e. had been the highest scoring that |
| 107 | // satisfied the NetworkRequest's constraints), but is no longer the highest scoring network for any |
| 108 | // foreground NetworkRequest, then there will be a 30s pause to allow network communication to be |
| 109 | // wrapped up rather than abruptly terminated. During this pause the network is said to be |
| 110 | // "lingering". During this pause if the network begins satisfying a foreground NetworkRequest, |
| 111 | // ConnectivityService will cancel the future disconnection of the NetworkAgent's AsyncChannel, and |
| 112 | // the network is no longer considered "lingering". After the linger timer expires, if the network |
| 113 | // is satisfying one or more background NetworkRequests it is kept up in the background. If it is |
| 114 | // not, ConnectivityService disconnects the NetworkAgent's AsyncChannel. |
Paul Jensen | 85cf78e | 2015-06-25 13:25:07 -0400 | [diff] [blame] | 115 | public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> { |
Hugo Benichi | c8e9e12 | 2016-09-14 23:23:08 +0000 | [diff] [blame] | 116 | |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 117 | public NetworkInfo networkInfo; |
Paul Jensen | 31a94f4 | 2015-02-13 14:18:39 -0500 | [diff] [blame] | 118 | // This Network object should always be used if possible, so as to encourage reuse of the |
| 119 | // enclosed socket factory and connection pool. Avoid creating other Network objects. |
| 120 | // This Network object is always valid. |
| 121 | public final Network network; |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 122 | public LinkProperties linkProperties; |
Paul Jensen | 1c7ba02 | 2015-06-16 14:27:36 -0400 | [diff] [blame] | 123 | // This should only be modified via ConnectivityService.updateCapabilities(). |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 124 | public NetworkCapabilities networkCapabilities; |
Sreeram Ramachandran | 8cd33ed | 2014-07-23 15:23:15 -0700 | [diff] [blame] | 125 | public final NetworkMisc networkMisc; |
Robin Lee | 585e248 | 2016-05-01 23:00:00 +0100 | [diff] [blame] | 126 | // Indicates if netd has been told to create this Network. From this point on the appropriate |
| 127 | // routing rules are setup and routes are added so packets can begin flowing over the Network. |
Lorenzo Colitti | d49159f | 2015-05-14 23:15:10 +0900 | [diff] [blame] | 128 | // This is a sticky bit; once set it is never cleared. |
Paul Jensen | eec7541 | 2014-08-04 12:21:19 -0400 | [diff] [blame] | 129 | public boolean created; |
Robin Lee | 585e248 | 2016-05-01 23:00:00 +0100 | [diff] [blame] | 130 | // Set to true after the first time this network is marked as CONNECTED. Once set, the network |
| 131 | // shows up in API calls, is able to satisfy NetworkRequests and can become the default network. |
| 132 | // This is a sticky bit; once set it is never cleared. |
| 133 | public boolean everConnected; |
Paul Jensen | 71b645f | 2014-10-13 14:13:07 -0400 | [diff] [blame] | 134 | // Set to true if this Network successfully passed validation or if it did not satisfy the |
| 135 | // default NetworkRequest in which case validation will not be attempted. |
Lorenzo Colitti | d49159f | 2015-05-14 23:15:10 +0900 | [diff] [blame] | 136 | // This is a sticky bit; once set it is never cleared even if future validation attempts fail. |
Lorenzo Colitti | d3b8a3e | 2014-12-17 11:14:42 +0900 | [diff] [blame] | 137 | public boolean everValidated; |
Paul Jensen | ca8f16a | 2014-05-09 12:47:55 -0400 | [diff] [blame] | 138 | |
Lorenzo Colitti | 7b42f39 | 2014-12-17 11:26:49 +0900 | [diff] [blame] | 139 | // The result of the last validation attempt on this network (true if validated, false if not). |
Lorenzo Colitti | 7b42f39 | 2014-12-17 11:26:49 +0900 | [diff] [blame] | 140 | public boolean lastValidated; |
| 141 | |
Lorenzo Colitti | 165c51c | 2016-09-19 01:00:19 +0900 | [diff] [blame] | 142 | // If true, becoming unvalidated will lower the network's score. This is only meaningful if the |
| 143 | // system is configured not to do this for certain networks, e.g., if the |
| 144 | // config_networkAvoidBadWifi option is set to 0 and the user has not overridden that via |
| 145 | // Settings.Global.NETWORK_AVOID_BAD_WIFI. |
| 146 | public boolean avoidUnvalidated; |
| 147 | |
Lorenzo Colitti | d49159f | 2015-05-14 23:15:10 +0900 | [diff] [blame] | 148 | // Whether a captive portal was ever detected on this network. |
| 149 | // This is a sticky bit; once set it is never cleared. |
Paul Jensen | 3d194ea | 2015-06-16 14:27:36 -0400 | [diff] [blame] | 150 | public boolean everCaptivePortalDetected; |
| 151 | |
| 152 | // Whether a captive portal was found during the last network validation attempt. |
| 153 | public boolean lastCaptivePortalDetected; |
Lorenzo Colitti | d49159f | 2015-05-14 23:15:10 +0900 | [diff] [blame] | 154 | |
lucaslin | d2e045e0 | 2019-01-24 15:55:30 +0800 | [diff] [blame] | 155 | // Indicates the user was notified of a successful captive portal login since a portal was |
| 156 | // last detected. |
| 157 | public boolean captivePortalLoginNotified; |
| 158 | |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 159 | // Networks are lingered when they become unneeded as a result of their NetworkRequests being |
| 160 | // satisfied by a higher-scoring network. so as to allow communication to wrap up before the |
| 161 | // network is taken down. This usually only happens to the default network. Lingering ends with |
| 162 | // either the linger timeout expiring and the network being taken down, or the network |
| 163 | // satisfying a request again. |
| 164 | public static class LingerTimer implements Comparable<LingerTimer> { |
| 165 | public final NetworkRequest request; |
| 166 | public final long expiryMs; |
| 167 | |
| 168 | public LingerTimer(NetworkRequest request, long expiryMs) { |
| 169 | this.request = request; |
| 170 | this.expiryMs = expiryMs; |
| 171 | } |
| 172 | public boolean equals(Object o) { |
| 173 | if (!(o instanceof LingerTimer)) return false; |
| 174 | LingerTimer other = (LingerTimer) o; |
| 175 | return (request.requestId == other.request.requestId) && (expiryMs == other.expiryMs); |
| 176 | } |
| 177 | public int hashCode() { |
| 178 | return Objects.hash(request.requestId, expiryMs); |
| 179 | } |
| 180 | public int compareTo(LingerTimer other) { |
| 181 | return (expiryMs != other.expiryMs) ? |
| 182 | Long.compare(expiryMs, other.expiryMs) : |
| 183 | Integer.compare(request.requestId, other.request.requestId); |
| 184 | } |
| 185 | public String toString() { |
| 186 | return String.format("%s, expires %dms", request.toString(), |
| 187 | expiryMs - SystemClock.elapsedRealtime()); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Inform ConnectivityService that the network LINGER period has |
| 193 | * expired. |
| 194 | * obj = this NetworkAgentInfo |
| 195 | */ |
| 196 | public static final int EVENT_NETWORK_LINGER_COMPLETE = 1001; |
| 197 | |
| 198 | // All linger timers for this network, sorted by expiry time. A linger timer is added whenever |
| 199 | // a request is moved to a network with a better score, regardless of whether the network is or |
| 200 | // was lingering or not. |
| 201 | // TODO: determine if we can replace this with a smaller or unsorted data structure. (e.g., |
| 202 | // SparseLongArray) combined with the timestamp of when the last timer is scheduled to fire. |
| 203 | private final SortedSet<LingerTimer> mLingerTimers = new TreeSet<>(); |
| 204 | |
| 205 | // For fast lookups. Indexes into mLingerTimers by request ID. |
| 206 | private final SparseArray<LingerTimer> mLingerTimerForRequest = new SparseArray<>(); |
| 207 | |
| 208 | // Linger expiry timer. Armed whenever mLingerTimers is non-empty, regardless of whether the |
| 209 | // network is lingering or not. Always set to the expiry of the LingerTimer that expires last. |
| 210 | // When the timer fires, all linger state is cleared, and if the network has no requests, it is |
| 211 | // torn down. |
| 212 | private WakeupMessage mLingerMessage; |
| 213 | |
| 214 | // Linger expiry. Holds the expiry time of the linger timer, or 0 if the timer is not armed. |
| 215 | private long mLingerExpiryMs; |
| 216 | |
| 217 | // Whether the network is lingering or not. Must be maintained separately from the above because |
| 218 | // it depends on the state of other networks and requests, which only ConnectivityService knows. |
| 219 | // (Example: we don't linger a network if it would become the best for a NetworkRequest if it |
| 220 | // validated). |
| 221 | private boolean mLingering; |
Paul Jensen | 85cf78e | 2015-06-25 13:25:07 -0400 | [diff] [blame] | 222 | |
Paul Jensen | 2161a8e | 2014-09-11 11:00:39 -0400 | [diff] [blame] | 223 | // This represents the last score received from the NetworkAgent. |
| 224 | private int currentScore; |
Robert Greenwalt | e73cc46 | 2014-09-07 16:50:01 -0700 | [diff] [blame] | 225 | |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 226 | // The list of NetworkRequests being satisfied by this Network. |
Lorenzo Colitti | 767708d | 2016-07-01 01:37:11 +0900 | [diff] [blame] | 227 | private final SparseArray<NetworkRequest> mNetworkRequests = new SparseArray<>(); |
Lorenzo Colitti | 3d4a106 | 2016-09-09 18:48:56 +0900 | [diff] [blame] | 228 | |
Lorenzo Colitti | 767708d | 2016-07-01 01:37:11 +0900 | [diff] [blame] | 229 | // How many of the satisfied requests are actual requests and not listens. |
| 230 | private int mNumRequestNetworkRequests = 0; |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 231 | |
Lorenzo Colitti | 3d4a106 | 2016-09-09 18:48:56 +0900 | [diff] [blame] | 232 | // How many of the satisfied requests are of type BACKGROUND_REQUEST. |
| 233 | private int mNumBackgroundNetworkRequests = 0; |
| 234 | |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 235 | public final Messenger messenger; |
| 236 | public final AsyncChannel asyncChannel; |
| 237 | |
Chalard Jean | 08577fc | 2018-05-02 21:14:54 +0900 | [diff] [blame] | 238 | public final int factorySerialNumber; |
| 239 | |
Lorenzo Colitti | 9543946 | 2014-10-09 13:44:48 +0900 | [diff] [blame] | 240 | // Used by ConnectivityService to keep track of 464xlat. |
Lorenzo Colitti | df59563 | 2019-01-08 14:43:37 +0900 | [diff] [blame] | 241 | public final Nat464Xlat clatd; |
Lorenzo Colitti | 9543946 | 2014-10-09 13:44:48 +0900 | [diff] [blame] | 242 | |
Remi NGUYEN VAN | e67b0c3 | 2018-12-27 16:43:56 +0900 | [diff] [blame] | 243 | // Set after asynchronous creation of the NetworkMonitor. |
| 244 | private volatile INetworkMonitor mNetworkMonitor; |
| 245 | |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 246 | private static final String TAG = ConnectivityService.class.getSimpleName(); |
| 247 | private static final boolean VDBG = false; |
Hugo Benichi | 50d46a4 | 2017-08-31 14:29:51 +0000 | [diff] [blame] | 248 | private final ConnectivityService mConnService; |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 249 | private final Context mContext; |
Hugo Benichi | 50d46a4 | 2017-08-31 14:29:51 +0000 | [diff] [blame] | 250 | private final Handler mHandler; |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 251 | |
Paul Jensen | 31a94f4 | 2015-02-13 14:18:39 -0500 | [diff] [blame] | 252 | public NetworkAgentInfo(Messenger messenger, AsyncChannel ac, Network net, NetworkInfo info, |
Sreeram Ramachandran | 8cd33ed | 2014-07-23 15:23:15 -0700 | [diff] [blame] | 253 | LinkProperties lp, NetworkCapabilities nc, int score, Context context, Handler handler, |
Lorenzo Colitti | 9307ca2 | 2019-01-12 01:54:23 +0900 | [diff] [blame] | 254 | NetworkMisc misc, ConnectivityService connService, INetd netd, |
Chalard Jean | 08577fc | 2018-05-02 21:14:54 +0900 | [diff] [blame] | 255 | INetworkManagementService nms, int factorySerialNumber) { |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 256 | this.messenger = messenger; |
| 257 | asyncChannel = ac; |
Paul Jensen | 31a94f4 | 2015-02-13 14:18:39 -0500 | [diff] [blame] | 258 | network = net; |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 259 | networkInfo = info; |
| 260 | linkProperties = lp; |
| 261 | networkCapabilities = nc; |
| 262 | currentScore = score; |
Lorenzo Colitti | df59563 | 2019-01-08 14:43:37 +0900 | [diff] [blame] | 263 | clatd = new Nat464Xlat(this, netd, nms); |
Hugo Benichi | 50d46a4 | 2017-08-31 14:29:51 +0000 | [diff] [blame] | 264 | mConnService = connService; |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 265 | mContext = context; |
Hugo Benichi | 50d46a4 | 2017-08-31 14:29:51 +0000 | [diff] [blame] | 266 | mHandler = handler; |
Sreeram Ramachandran | 8cd33ed | 2014-07-23 15:23:15 -0700 | [diff] [blame] | 267 | networkMisc = misc; |
Chalard Jean | 08577fc | 2018-05-02 21:14:54 +0900 | [diff] [blame] | 268 | this.factorySerialNumber = factorySerialNumber; |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 269 | } |
| 270 | |
Remi NGUYEN VAN | e67b0c3 | 2018-12-27 16:43:56 +0900 | [diff] [blame] | 271 | /** |
| 272 | * Inform NetworkAgentInfo that a new NetworkMonitor was created. |
| 273 | */ |
| 274 | public void onNetworkMonitorCreated(INetworkMonitor networkMonitor) { |
| 275 | mNetworkMonitor = networkMonitor; |
| 276 | } |
| 277 | |
Hugo Benichi | ef50288 | 2017-09-01 01:23:32 +0000 | [diff] [blame] | 278 | public ConnectivityService connService() { |
| 279 | return mConnService; |
| 280 | } |
| 281 | |
soma, kawata | 88b8f63 | 2018-10-23 21:10:02 +0900 | [diff] [blame] | 282 | public NetworkMisc netMisc() { |
| 283 | return networkMisc; |
| 284 | } |
| 285 | |
Hugo Benichi | ef50288 | 2017-09-01 01:23:32 +0000 | [diff] [blame] | 286 | public Handler handler() { |
| 287 | return mHandler; |
| 288 | } |
| 289 | |
Hugo Benichi | c894b12 | 2017-07-31 12:58:20 +0900 | [diff] [blame] | 290 | public Network network() { |
| 291 | return network; |
| 292 | } |
| 293 | |
Remi NGUYEN VAN | e67b0c3 | 2018-12-27 16:43:56 +0900 | [diff] [blame] | 294 | /** |
| 295 | * Get the INetworkMonitor in this NetworkAgentInfo. |
| 296 | * |
| 297 | * <p>This will be null before {@link #onNetworkMonitorCreated(INetworkMonitor)} is called. |
| 298 | */ |
| 299 | public INetworkMonitor networkMonitor() { |
| 300 | return mNetworkMonitor; |
| 301 | } |
| 302 | |
Lorenzo Colitti | 767708d | 2016-07-01 01:37:11 +0900 | [diff] [blame] | 303 | // Functions for manipulating the requests satisfied by this network. |
| 304 | // |
| 305 | // These functions must only called on ConnectivityService's main thread. |
| 306 | |
Lorenzo Colitti | 3d4a106 | 2016-09-09 18:48:56 +0900 | [diff] [blame] | 307 | private static final boolean ADD = true; |
| 308 | private static final boolean REMOVE = false; |
| 309 | |
| 310 | private void updateRequestCounts(boolean add, NetworkRequest request) { |
| 311 | int delta = add ? +1 : -1; |
| 312 | switch (request.type) { |
| 313 | case REQUEST: |
Lorenzo Colitti | 3d4a106 | 2016-09-09 18:48:56 +0900 | [diff] [blame] | 314 | mNumRequestNetworkRequests += delta; |
| 315 | break; |
| 316 | |
| 317 | case BACKGROUND_REQUEST: |
| 318 | mNumRequestNetworkRequests += delta; |
| 319 | mNumBackgroundNetworkRequests += delta; |
| 320 | break; |
| 321 | |
Chalard Jean | 715d39b | 2018-02-16 17:59:29 +0900 | [diff] [blame] | 322 | case TRACK_DEFAULT: |
Lorenzo Colitti | 3d4a106 | 2016-09-09 18:48:56 +0900 | [diff] [blame] | 323 | case LISTEN: |
| 324 | break; |
| 325 | |
| 326 | case NONE: |
| 327 | default: |
| 328 | Log.wtf(TAG, "Unhandled request type " + request.type); |
| 329 | break; |
| 330 | } |
| 331 | } |
| 332 | |
Paul Jensen | 3d91146 | 2015-06-12 06:40:24 -0400 | [diff] [blame] | 333 | /** |
| 334 | * Add {@code networkRequest} to this network as it's satisfied by this network. |
Paul Jensen | 3d91146 | 2015-06-12 06:40:24 -0400 | [diff] [blame] | 335 | * @return true if {@code networkRequest} was added or false if {@code networkRequest} was |
| 336 | * already present. |
| 337 | */ |
| 338 | public boolean addRequest(NetworkRequest networkRequest) { |
Lorenzo Colitti | 767708d | 2016-07-01 01:37:11 +0900 | [diff] [blame] | 339 | NetworkRequest existing = mNetworkRequests.get(networkRequest.requestId); |
| 340 | if (existing == networkRequest) return false; |
Lorenzo Colitti | 3d4a106 | 2016-09-09 18:48:56 +0900 | [diff] [blame] | 341 | if (existing != null) { |
| 342 | // Should only happen if the requestId wraps. If that happens lots of other things will |
| 343 | // be broken as well. |
| 344 | Log.wtf(TAG, String.format("Duplicate requestId for %s and %s on %s", |
| 345 | networkRequest, existing, name())); |
| 346 | updateRequestCounts(REMOVE, existing); |
| 347 | } |
Lorenzo Colitti | 767708d | 2016-07-01 01:37:11 +0900 | [diff] [blame] | 348 | mNetworkRequests.put(networkRequest.requestId, networkRequest); |
Lorenzo Colitti | 3d4a106 | 2016-09-09 18:48:56 +0900 | [diff] [blame] | 349 | updateRequestCounts(ADD, networkRequest); |
Paul Jensen | 3d91146 | 2015-06-12 06:40:24 -0400 | [diff] [blame] | 350 | return true; |
Robert Greenwalt | 71bf33a | 2014-05-15 18:07:26 -0700 | [diff] [blame] | 351 | } |
| 352 | |
Lorenzo Colitti | 767708d | 2016-07-01 01:37:11 +0900 | [diff] [blame] | 353 | /** |
| 354 | * Remove the specified request from this network. |
| 355 | */ |
| 356 | public void removeRequest(int requestId) { |
| 357 | NetworkRequest existing = mNetworkRequests.get(requestId); |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 358 | if (existing == null) return; |
Lorenzo Colitti | 3d4a106 | 2016-09-09 18:48:56 +0900 | [diff] [blame] | 359 | updateRequestCounts(REMOVE, existing); |
Lorenzo Colitti | 767708d | 2016-07-01 01:37:11 +0900 | [diff] [blame] | 360 | mNetworkRequests.remove(requestId); |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 361 | if (existing.isRequest()) { |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 362 | unlingerRequest(existing); |
| 363 | } |
Lorenzo Colitti | 767708d | 2016-07-01 01:37:11 +0900 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | /** |
| 367 | * Returns whether this network is currently satisfying the request with the specified ID. |
| 368 | */ |
| 369 | public boolean isSatisfyingRequest(int id) { |
| 370 | return mNetworkRequests.get(id) != null; |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * Returns the request at the specified position in the list of requests satisfied by this |
| 375 | * network. |
| 376 | */ |
| 377 | public NetworkRequest requestAt(int index) { |
| 378 | return mNetworkRequests.valueAt(index); |
| 379 | } |
| 380 | |
| 381 | /** |
| 382 | * Returns the number of requests currently satisfied by this network for which |
| 383 | * {@link android.net.NetworkRequest#isRequest} returns {@code true}. |
| 384 | */ |
| 385 | public int numRequestNetworkRequests() { |
| 386 | return mNumRequestNetworkRequests; |
| 387 | } |
| 388 | |
| 389 | /** |
Lorenzo Colitti | 3d4a106 | 2016-09-09 18:48:56 +0900 | [diff] [blame] | 390 | * Returns the number of requests currently satisfied by this network of type |
| 391 | * {@link android.net.NetworkRequest.Type.BACKGROUND_REQUEST}. |
| 392 | */ |
| 393 | public int numBackgroundNetworkRequests() { |
| 394 | return mNumBackgroundNetworkRequests; |
| 395 | } |
| 396 | |
| 397 | /** |
| 398 | * Returns the number of foreground requests currently satisfied by this network. |
| 399 | */ |
| 400 | public int numForegroundNetworkRequests() { |
| 401 | return mNumRequestNetworkRequests - mNumBackgroundNetworkRequests; |
| 402 | } |
| 403 | |
| 404 | /** |
Lorenzo Colitti | 767708d | 2016-07-01 01:37:11 +0900 | [diff] [blame] | 405 | * Returns the number of requests of any type currently satisfied by this network. |
| 406 | */ |
| 407 | public int numNetworkRequests() { |
| 408 | return mNetworkRequests.size(); |
| 409 | } |
| 410 | |
Lorenzo Colitti | 3d4a106 | 2016-09-09 18:48:56 +0900 | [diff] [blame] | 411 | /** |
| 412 | * Returns whether the network is a background network. A network is a background network if it |
Chalard Jean | b72b62d | 2018-02-16 16:08:35 +0900 | [diff] [blame] | 413 | * does not have the NET_CAPABILITY_FOREGROUND capability, which implies it is satisfying no |
| 414 | * foreground request, is not lingering (i.e. kept for a while after being outscored), and is |
| 415 | * not a speculative network (i.e. kept pending validation when validation would have it |
| 416 | * outscore another foreground network). That implies it is being kept up by some background |
| 417 | * request (otherwise it would be torn down), maybe the mobile always-on request. |
Lorenzo Colitti | 3d4a106 | 2016-09-09 18:48:56 +0900 | [diff] [blame] | 418 | */ |
| 419 | public boolean isBackgroundNetwork() { |
Chalard Jean | b72b62d | 2018-02-16 16:08:35 +0900 | [diff] [blame] | 420 | return !isVPN() && numForegroundNetworkRequests() == 0 && mNumBackgroundNetworkRequests > 0 |
| 421 | && !isLingering(); |
Lorenzo Colitti | 3d4a106 | 2016-09-09 18:48:56 +0900 | [diff] [blame] | 422 | } |
| 423 | |
Chalard Jean | 804b8fb | 2018-01-30 22:41:41 +0900 | [diff] [blame] | 424 | /** |
| 425 | * Returns whether this network is currently suspended. A network is suspended if it is still |
| 426 | * connected but data temporarily fails to transfer. See {@link NetworkInfo.State#SUSPENDED} |
| 427 | * and {@link NetworkCapabilities#NET_CAPABILITY_NOT_SUSPENDED}. |
| 428 | */ |
| 429 | public boolean isSuspended() { |
| 430 | return networkInfo.getState() == NetworkInfo.State.SUSPENDED; |
| 431 | } |
| 432 | |
Paul Jensen | 0cc1732 | 2014-11-25 15:26:53 -0500 | [diff] [blame] | 433 | // Does this network satisfy request? |
| 434 | public boolean satisfies(NetworkRequest request) { |
| 435 | return created && |
| 436 | request.networkCapabilities.satisfiedByNetworkCapabilities(networkCapabilities); |
| 437 | } |
| 438 | |
Lorenzo Colitti | c3f21f3 | 2015-07-06 23:50:27 +0900 | [diff] [blame] | 439 | public boolean satisfiesImmutableCapabilitiesOf(NetworkRequest request) { |
| 440 | return created && |
| 441 | request.networkCapabilities.satisfiedByImmutableNetworkCapabilities( |
| 442 | networkCapabilities); |
| 443 | } |
| 444 | |
Paul Jensen | 6bc2c2c | 2014-05-07 15:27:40 -0400 | [diff] [blame] | 445 | public boolean isVPN() { |
| 446 | return networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN); |
| 447 | } |
| 448 | |
Paul Jensen | b10e37f | 2014-11-25 12:33:08 -0500 | [diff] [blame] | 449 | private int getCurrentScore(boolean pretendValidated) { |
Paul Jensen | 2161a8e | 2014-09-11 11:00:39 -0400 | [diff] [blame] | 450 | // TODO: We may want to refactor this into a NetworkScore class that takes a base score from |
| 451 | // the NetworkAgent and signals from the NetworkAgent and uses those signals to modify the |
| 452 | // score. The NetworkScore class would provide a nice place to centralize score constants |
| 453 | // so they are not scattered about the transports. |
| 454 | |
Lorenzo Colitti | e03c3c7 | 2015-04-03 16:38:52 +0900 | [diff] [blame] | 455 | // If this network is explicitly selected and the user has decided to use it even if it's |
| 456 | // unvalidated, give it the maximum score. Also give it the maximum score if it's explicitly |
| 457 | // selected and we're trying to see what its score could be. This ensures that we don't tear |
| 458 | // down an explicitly selected network before the user gets a chance to prefer it when |
| 459 | // a higher-scoring network (e.g., Ethernet) is available. |
| 460 | if (networkMisc.explicitlySelected && (networkMisc.acceptUnvalidated || pretendValidated)) { |
Chalard Jean | 918a68b | 2018-01-19 17:00:47 +0900 | [diff] [blame] | 461 | return ConnectivityConstants.MAXIMUM_NETWORK_SCORE; |
Lorenzo Colitti | e03c3c7 | 2015-04-03 16:38:52 +0900 | [diff] [blame] | 462 | } |
Paul Jensen | 2161a8e | 2014-09-11 11:00:39 -0400 | [diff] [blame] | 463 | |
Lorenzo Colitti | e03c3c7 | 2015-04-03 16:38:52 +0900 | [diff] [blame] | 464 | int score = currentScore; |
Hugo Benichi | c8e9e12 | 2016-09-14 23:23:08 +0000 | [diff] [blame] | 465 | if (!lastValidated && !pretendValidated && !ignoreWifiUnvalidationPenalty()) { |
Chalard Jean | 918a68b | 2018-01-19 17:00:47 +0900 | [diff] [blame] | 466 | score -= ConnectivityConstants.UNVALIDATED_SCORE_PENALTY; |
Paul Jensen | e098854 | 2015-06-25 15:30:08 -0400 | [diff] [blame] | 467 | } |
Paul Jensen | 2161a8e | 2014-09-11 11:00:39 -0400 | [diff] [blame] | 468 | if (score < 0) score = 0; |
Paul Jensen | 2161a8e | 2014-09-11 11:00:39 -0400 | [diff] [blame] | 469 | return score; |
| 470 | } |
| 471 | |
Hugo Benichi | c8e9e12 | 2016-09-14 23:23:08 +0000 | [diff] [blame] | 472 | // Return true on devices configured to ignore score penalty for wifi networks |
| 473 | // that become unvalidated (b/31075769). |
| 474 | private boolean ignoreWifiUnvalidationPenalty() { |
Lorenzo Colitti | 165c51c | 2016-09-19 01:00:19 +0900 | [diff] [blame] | 475 | boolean isWifi = networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) && |
| 476 | networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); |
Hugo Benichi | 50d46a4 | 2017-08-31 14:29:51 +0000 | [diff] [blame] | 477 | boolean avoidBadWifi = mConnService.avoidBadWifi() || avoidUnvalidated; |
Lorenzo Colitti | 165c51c | 2016-09-19 01:00:19 +0900 | [diff] [blame] | 478 | return isWifi && !avoidBadWifi && everValidated; |
Hugo Benichi | c8e9e12 | 2016-09-14 23:23:08 +0000 | [diff] [blame] | 479 | } |
| 480 | |
Paul Jensen | b10e37f | 2014-11-25 12:33:08 -0500 | [diff] [blame] | 481 | // Get the current score for this Network. This may be modified from what the |
| 482 | // NetworkAgent sent, as it has modifiers applied to it. |
| 483 | public int getCurrentScore() { |
| 484 | return getCurrentScore(false); |
| 485 | } |
| 486 | |
| 487 | // Get the current score for this Network as if it was validated. This may be modified from |
| 488 | // what the NetworkAgent sent, as it has modifiers applied to it. |
| 489 | public int getCurrentScoreAsValidated() { |
| 490 | return getCurrentScore(true); |
| 491 | } |
| 492 | |
Paul Jensen | 2161a8e | 2014-09-11 11:00:39 -0400 | [diff] [blame] | 493 | public void setCurrentScore(int newScore) { |
| 494 | currentScore = newScore; |
| 495 | } |
| 496 | |
Jeff Sharkey | f07c7b9 | 2016-04-22 09:50:16 -0600 | [diff] [blame] | 497 | public NetworkState getNetworkState() { |
| 498 | synchronized (this) { |
Chalard Jean | 804b8fb | 2018-01-30 22:41:41 +0900 | [diff] [blame] | 499 | // Network objects are outwardly immutable so there is no point in duplicating. |
Jeff Sharkey | f07c7b9 | 2016-04-22 09:50:16 -0600 | [diff] [blame] | 500 | // Duplicating also precludes sharing socket factories and connection pools. |
| 501 | final String subscriberId = (networkMisc != null) ? networkMisc.subscriberId : null; |
| 502 | return new NetworkState(new NetworkInfo(networkInfo), |
| 503 | new LinkProperties(linkProperties), |
| 504 | new NetworkCapabilities(networkCapabilities), network, subscriberId, null); |
| 505 | } |
| 506 | } |
| 507 | |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 508 | /** |
| 509 | * Sets the specified request to linger on this network for the specified time. Called by |
| 510 | * ConnectivityService when the request is moved to another network with a higher score. |
| 511 | */ |
| 512 | public void lingerRequest(NetworkRequest request, long now, long duration) { |
| 513 | if (mLingerTimerForRequest.get(request.requestId) != null) { |
| 514 | // Cannot happen. Once a request is lingering on a particular network, we cannot |
| 515 | // re-linger it unless that network becomes the best for that request again, in which |
| 516 | // case we should have unlingered it. |
| 517 | Log.wtf(TAG, this.name() + ": request " + request.requestId + " already lingered"); |
| 518 | } |
| 519 | final long expiryMs = now + duration; |
| 520 | LingerTimer timer = new LingerTimer(request, expiryMs); |
| 521 | if (VDBG) Log.d(TAG, "Adding LingerTimer " + timer + " to " + this.name()); |
| 522 | mLingerTimers.add(timer); |
| 523 | mLingerTimerForRequest.put(request.requestId, timer); |
| 524 | } |
| 525 | |
| 526 | /** |
| 527 | * Cancel lingering. Called by ConnectivityService when a request is added to this network. |
Lorenzo Colitti | 5526f9c | 2016-08-22 16:46:40 +0900 | [diff] [blame] | 528 | * Returns true if the given request was lingering on this network, false otherwise. |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 529 | */ |
Lorenzo Colitti | 5526f9c | 2016-08-22 16:46:40 +0900 | [diff] [blame] | 530 | public boolean unlingerRequest(NetworkRequest request) { |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 531 | LingerTimer timer = mLingerTimerForRequest.get(request.requestId); |
| 532 | if (timer != null) { |
| 533 | if (VDBG) Log.d(TAG, "Removing LingerTimer " + timer + " from " + this.name()); |
| 534 | mLingerTimers.remove(timer); |
| 535 | mLingerTimerForRequest.remove(request.requestId); |
Lorenzo Colitti | 5526f9c | 2016-08-22 16:46:40 +0900 | [diff] [blame] | 536 | return true; |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 537 | } |
Lorenzo Colitti | 5526f9c | 2016-08-22 16:46:40 +0900 | [diff] [blame] | 538 | return false; |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | public long getLingerExpiry() { |
| 542 | return mLingerExpiryMs; |
| 543 | } |
| 544 | |
| 545 | public void updateLingerTimer() { |
| 546 | long newExpiry = mLingerTimers.isEmpty() ? 0 : mLingerTimers.last().expiryMs; |
| 547 | if (newExpiry == mLingerExpiryMs) return; |
| 548 | |
| 549 | // Even if we're going to reschedule the timer, cancel it first. This is because the |
| 550 | // semantics of WakeupMessage guarantee that if cancel is called then the alarm will |
| 551 | // never call its callback (handleLingerComplete), even if it has already fired. |
| 552 | // WakeupMessage makes no such guarantees about rescheduling a message, so if mLingerMessage |
| 553 | // has already been dispatched, rescheduling to some time in the future it won't stop it |
| 554 | // from calling its callback immediately. |
| 555 | if (mLingerMessage != null) { |
| 556 | mLingerMessage.cancel(); |
| 557 | mLingerMessage = null; |
| 558 | } |
| 559 | |
| 560 | if (newExpiry > 0) { |
Hugo Benichi | 50d46a4 | 2017-08-31 14:29:51 +0000 | [diff] [blame] | 561 | mLingerMessage = mConnService.makeWakeupMessage( |
| 562 | mContext, mHandler, |
Lorenzo Colitti | b57578ca | 2016-07-01 01:53:25 +0900 | [diff] [blame] | 563 | "NETWORK_LINGER_COMPLETE." + network.netId, |
| 564 | EVENT_NETWORK_LINGER_COMPLETE, this); |
| 565 | mLingerMessage.schedule(newExpiry); |
| 566 | } |
| 567 | |
| 568 | mLingerExpiryMs = newExpiry; |
| 569 | } |
| 570 | |
| 571 | public void linger() { |
| 572 | mLingering = true; |
| 573 | } |
| 574 | |
| 575 | public void unlinger() { |
| 576 | mLingering = false; |
| 577 | } |
| 578 | |
| 579 | public boolean isLingering() { |
| 580 | return mLingering; |
| 581 | } |
| 582 | |
| 583 | public void clearLingerState() { |
| 584 | if (mLingerMessage != null) { |
| 585 | mLingerMessage.cancel(); |
| 586 | mLingerMessage = null; |
| 587 | } |
| 588 | mLingerTimers.clear(); |
| 589 | mLingerTimerForRequest.clear(); |
| 590 | updateLingerTimer(); // Sets mLingerExpiryMs, cancels and nulls out mLingerMessage. |
| 591 | mLingering = false; |
| 592 | } |
| 593 | |
| 594 | public void dumpLingerTimers(PrintWriter pw) { |
| 595 | for (LingerTimer timer : mLingerTimers) { pw.println(timer); } |
| 596 | } |
| 597 | |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 598 | public String toString() { |
lucaslin | d2e045e0 | 2019-01-24 15:55:30 +0800 | [diff] [blame] | 599 | return "NetworkAgentInfo{ ni{" + networkInfo + "} " |
| 600 | + "network{" + network + "} nethandle{" + network.getNetworkHandle() + "} " |
| 601 | + "lp{" + linkProperties + "} " |
| 602 | + "nc{" + networkCapabilities + "} Score{" + getCurrentScore() + "} " |
| 603 | + "everValidated{" + everValidated + "} lastValidated{" + lastValidated + "} " |
| 604 | + "created{" + created + "} lingering{" + isLingering() + "} " |
| 605 | + "explicitlySelected{" + networkMisc.explicitlySelected + "} " |
| 606 | + "acceptUnvalidated{" + networkMisc.acceptUnvalidated + "} " |
| 607 | + "everCaptivePortalDetected{" + everCaptivePortalDetected + "} " |
| 608 | + "lastCaptivePortalDetected{" + lastCaptivePortalDetected + "} " |
| 609 | + "captivePortalLoginNotified{" + captivePortalLoginNotified + "} " |
| 610 | + "clat{" + clatd + "} " |
| 611 | + "}"; |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | public String name() { |
| 615 | return "NetworkAgentInfo [" + networkInfo.getTypeName() + " (" + |
Hugo Benichi | b577d65 | 2017-06-27 15:13:20 +0900 | [diff] [blame] | 616 | networkInfo.getSubtypeName() + ") - " + Objects.toString(network) + "]"; |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 617 | } |
Paul Jensen | 85cf78e | 2015-06-25 13:25:07 -0400 | [diff] [blame] | 618 | |
| 619 | // Enables sorting in descending order of score. |
| 620 | @Override |
| 621 | public int compareTo(NetworkAgentInfo other) { |
| 622 | return other.getCurrentScore() - getCurrentScore(); |
| 623 | } |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 624 | } |