blob: aae9fd4725b4e3063c553e31728c0878a21600a8 [file] [log] [blame]
Robert Greenwalt7b816022014-04-18 15:25:25 -07001/*
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
17package android.net;
18
lucaslinc2bac512019-11-07 16:47:56 +080019import android.annotation.NonNull;
Lorenzo Colitti631f33a2020-01-15 00:13:37 +090020import android.annotation.Nullable;
21import android.annotation.SystemApi;
Artur Satayev33f92172019-12-10 17:47:52 +000022import android.compat.annotation.UnsupportedAppUsage;
Robert Greenwalt7b816022014-04-18 15:25:25 -070023import android.content.Context;
Mathew Inwood31755f92018-12-20 13:53:36 +000024import android.os.Build;
Erik Kline9d598e12015-07-13 16:37:51 +090025import android.os.Bundle;
Robert Greenwalt7b816022014-04-18 15:25:25 -070026import android.os.Handler;
27import android.os.Looper;
28import android.os.Message;
29import android.os.Messenger;
Robert Greenwalt7b816022014-04-18 15:25:25 -070030import android.util.Log;
Robert Greenwalt7b816022014-04-18 15:25:25 -070031
32import com.android.internal.util.AsyncChannel;
33import com.android.internal.util.Protocol;
34
Robert Greenwalt3192dec2014-05-27 13:20:24 -070035import java.util.ArrayList;
fenglu95ce8032015-05-01 17:04:36 -070036import java.util.concurrent.atomic.AtomicBoolean;
Robert Greenwalt7b816022014-04-18 15:25:25 -070037
38/**
Robert Greenwalt3192dec2014-05-27 13:20:24 -070039 * A Utility class for handling for communicating between bearer-specific
40 * code and ConnectivityService.
Robert Greenwalt7b816022014-04-18 15:25:25 -070041 *
42 * A bearer may have more than one NetworkAgent if it can simultaneously
43 * support separate networks (IMS / Internet / MMS Apns on cellular, or
Robert Greenwalt3192dec2014-05-27 13:20:24 -070044 * perhaps connections with different SSID or P2P for Wi-Fi).
Robert Greenwalt7b816022014-04-18 15:25:25 -070045 *
Robert Greenwalt7b816022014-04-18 15:25:25 -070046 * @hide
47 */
Lorenzo Colitti631f33a2020-01-15 00:13:37 +090048@SystemApi
Lorenzo Colitti782b48d52020-01-12 20:27:32 +090049public abstract class NetworkAgent {
Lorenzo Colitti631f33a2020-01-15 00:13:37 +090050 /**
51 * The {@link Network} corresponding to this object.
52 */
Chalard Jeana0e2aa122019-12-13 19:47:12 +090053 @NonNull
54 public final Network network;
Paul Jensen31a94f42015-02-13 14:18:39 -050055
Lorenzo Colitti782b48d52020-01-12 20:27:32 +090056 private final Handler mHandler;
Robert Greenwalt3192dec2014-05-27 13:20:24 -070057 private volatile AsyncChannel mAsyncChannel;
Robert Greenwalt7b816022014-04-18 15:25:25 -070058 private final String LOG_TAG;
59 private static final boolean DBG = true;
Robert Greenwaltfc0c6892014-08-27 14:34:02 -070060 private static final boolean VDBG = false;
Robert Greenwalt7b816022014-04-18 15:25:25 -070061 private final Context mContext;
Robert Greenwalt3192dec2014-05-27 13:20:24 -070062 private final ArrayList<Message>mPreConnectedQueue = new ArrayList<Message>();
fenglub15e72b2015-03-20 11:29:56 -070063 private volatile long mLastBwRefreshTime = 0;
64 private static final long BW_REFRESH_MIN_WIN_MS = 500;
Lorenzo Colitti631f33a2020-01-15 00:13:37 +090065 private boolean mBandwidthUpdateScheduled = false;
66 private AtomicBoolean mBandwidthUpdatePending = new AtomicBoolean(false);
67
68 /**
69 * The ID of the {@link NetworkProvider} that created this object, or
70 * {@link NetworkProvider#ID_NONE} if unknown.
71 */
72 public final int providerId;
Robert Greenwalt7b816022014-04-18 15:25:25 -070073
74 private static final int BASE = Protocol.BASE_NETWORK_AGENT;
75
76 /**
Robert Greenwalt7b816022014-04-18 15:25:25 -070077 * Sent by ConnectivityService to the NetworkAgent to inform it of
78 * suspected connectivity problems on its network. The NetworkAgent
79 * should take steps to verify and correct connectivity.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +090080 * @hide
Robert Greenwalt7b816022014-04-18 15:25:25 -070081 */
Robert Greenwalt3192dec2014-05-27 13:20:24 -070082 public static final int CMD_SUSPECT_BAD = BASE;
Robert Greenwalt7b816022014-04-18 15:25:25 -070083
84 /**
85 * Sent by the NetworkAgent (note the EVENT vs CMD prefix) to
86 * ConnectivityService to pass the current NetworkInfo (connection state).
87 * Sent when the NetworkInfo changes, mainly due to change of state.
88 * obj = NetworkInfo
Lorenzo Colitti631f33a2020-01-15 00:13:37 +090089 * @hide
Robert Greenwalt7b816022014-04-18 15:25:25 -070090 */
Robert Greenwalt3192dec2014-05-27 13:20:24 -070091 public static final int EVENT_NETWORK_INFO_CHANGED = BASE + 1;
Robert Greenwalt7b816022014-04-18 15:25:25 -070092
93 /**
94 * Sent by the NetworkAgent to ConnectivityService to pass the current
95 * NetworkCapabilties.
96 * obj = NetworkCapabilities
Lorenzo Colitti631f33a2020-01-15 00:13:37 +090097 * @hide
Robert Greenwalt7b816022014-04-18 15:25:25 -070098 */
Robert Greenwalt3192dec2014-05-27 13:20:24 -070099 public static final int EVENT_NETWORK_CAPABILITIES_CHANGED = BASE + 2;
Robert Greenwalt7b816022014-04-18 15:25:25 -0700100
101 /**
102 * Sent by the NetworkAgent to ConnectivityService to pass the current
103 * NetworkProperties.
104 * obj = NetworkProperties
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900105 * @hide
Robert Greenwalt7b816022014-04-18 15:25:25 -0700106 */
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700107 public static final int EVENT_NETWORK_PROPERTIES_CHANGED = BASE + 3;
Robert Greenwalt7b816022014-04-18 15:25:25 -0700108
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900109 /**
110 * Centralize the place where base network score, and network score scaling, will be
vandwalle2ab90892014-06-02 15:30:39 -0700111 * stored, so as we can consistently compare apple and oranges, or wifi, ethernet and LTE
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900112 * @hide
vandwalle2ab90892014-06-02 15:30:39 -0700113 */
114 public static final int WIFI_BASE_SCORE = 60;
115
Robert Greenwalt7b816022014-04-18 15:25:25 -0700116 /**
117 * Sent by the NetworkAgent to ConnectivityService to pass the current
118 * network score.
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700119 * obj = network score Integer
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900120 * @hide
Robert Greenwalt7b816022014-04-18 15:25:25 -0700121 */
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700122 public static final int EVENT_NETWORK_SCORE_CHANGED = BASE + 4;
Robert Greenwalt7b816022014-04-18 15:25:25 -0700123
Paul Jensen6bc2c2c2014-05-07 15:27:40 -0400124 /**
Lorenzo Colittie03c3c72015-04-03 16:38:52 +0900125 * Sent by ConnectivityService to the NetworkAgent to inform the agent of the
Robert Greenwalt49f63fb2014-09-13 12:04:12 -0700126 * networks status - whether we could use the network or could not, due to
127 * either a bad network configuration (no internet link) or captive portal.
128 *
129 * arg1 = either {@code VALID_NETWORK} or {@code INVALID_NETWORK}
Paul Jensen232437312016-04-06 09:51:26 -0400130 * obj = Bundle containing map from {@code REDIRECT_URL_KEY} to {@code String}
131 * representing URL that Internet probe was redirect to, if it was redirected,
132 * or mapping to {@code null} otherwise.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900133 * @hide
Robert Greenwalt49f63fb2014-09-13 12:04:12 -0700134 */
Lorenzo Colitti60446162014-09-20 00:14:31 +0900135 public static final int CMD_REPORT_NETWORK_STATUS = BASE + 7;
Robert Greenwalt49f63fb2014-09-13 12:04:12 -0700136
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900137
138 /**
139 * Network validation suceeded.
140 * Corresponds to {@link NetworkCapabilities.NET_CAPABILITY_VALIDATED}.
141 */
142 public static final int VALIDATION_STATUS_VALID = 1;
143
144 /**
145 * Network validation was attempted and failed. This may be received more than once as
146 * subsequent validation attempts are made.
147 */
148 public static final int VALIDATION_STATUS_NOT_VALID = 2;
149
150 // TODO: remove.
151 /** @hide */
Robert Greenwalt49f63fb2014-09-13 12:04:12 -0700152 public static final int VALID_NETWORK = 1;
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900153 /** @hide */
Robert Greenwalt49f63fb2014-09-13 12:04:12 -0700154 public static final int INVALID_NETWORK = 2;
155
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900156 /**
157 * The key for the redirect URL in the Bundle argument of {@code CMD_REPORT_NETWORK_STATUS}.
158 * @hide
159 */
Paul Jensen232437312016-04-06 09:51:26 -0400160 public static String REDIRECT_URL_KEY = "redirect URL";
161
Robert Greenwalte73cc462014-09-07 16:50:01 -0700162 /**
163 * Sent by the NetworkAgent to ConnectivityService to indicate this network was
164 * explicitly selected. This should be sent before the NetworkInfo is marked
165 * CONNECTED so it can be given special treatment at that time.
Lorenzo Colittie03c3c72015-04-03 16:38:52 +0900166 *
167 * obj = boolean indicating whether to use this network even if unvalidated
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900168 * @hide
Robert Greenwalte73cc462014-09-07 16:50:01 -0700169 */
Lorenzo Colitti60446162014-09-20 00:14:31 +0900170 public static final int EVENT_SET_EXPLICITLY_SELECTED = BASE + 8;
Robert Greenwalte73cc462014-09-07 16:50:01 -0700171
Lorenzo Colittie03c3c72015-04-03 16:38:52 +0900172 /**
173 * Sent by ConnectivityService to the NetworkAgent to inform the agent of
174 * whether the network should in the future be used even if not validated.
175 * This decision is made by the user, but it is the network transport's
176 * responsibility to remember it.
177 *
178 * arg1 = 1 if true, 0 if false
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900179 * @hide
Lorenzo Colittie03c3c72015-04-03 16:38:52 +0900180 */
181 public static final int CMD_SAVE_ACCEPT_UNVALIDATED = BASE + 9;
182
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900183 /**
184 * Sent by ConnectivityService to the NetworkAgent to inform the agent to pull
fenglub15e72b2015-03-20 11:29:56 -0700185 * the underlying network connection for updated bandwidth information.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900186 * @hide
fenglub15e72b2015-03-20 11:29:56 -0700187 */
188 public static final int CMD_REQUEST_BANDWIDTH_UPDATE = BASE + 10;
189
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900190 /**
191 * Sent by ConnectivityService to the NetworkAgent to request that the specified packet be sent
192 * periodically on the given interval.
193 *
194 * arg1 = the slot number of the keepalive to start
195 * arg2 = interval in seconds
196 * obj = KeepalivePacketData object describing the data to be sent
197 *
198 * Also used internally by ConnectivityService / KeepaliveTracker, with different semantics.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900199 * @hide
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900200 */
junyulaie4135282019-01-03 18:50:15 +0800201 public static final int CMD_START_SOCKET_KEEPALIVE = BASE + 11;
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900202
203 /**
204 * Requests that the specified keepalive packet be stopped.
205 *
206 * arg1 = slot number of the keepalive to stop.
207 *
208 * Also used internally by ConnectivityService / KeepaliveTracker, with different semantics.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900209 * @hide
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900210 */
junyulaie4135282019-01-03 18:50:15 +0800211 public static final int CMD_STOP_SOCKET_KEEPALIVE = BASE + 12;
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900212
213 /**
junyulaie4135282019-01-03 18:50:15 +0800214 * Sent by the NetworkAgent to ConnectivityService to provide status on a socket keepalive
215 * request. This may either be the reply to a CMD_START_SOCKET_KEEPALIVE, or an asynchronous
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900216 * error notification.
217 *
junyulaie4135282019-01-03 18:50:15 +0800218 * This is also sent by KeepaliveTracker to the app's {@link SocketKeepalive},
219 * so that the app's {@link SocketKeepalive.Callback} methods can be called.
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900220 *
221 * arg1 = slot number of the keepalive
222 * arg2 = error code
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900223 * @hide
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900224 */
junyulaie4135282019-01-03 18:50:15 +0800225 public static final int EVENT_SOCKET_KEEPALIVE = BASE + 13;
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900226
junyulai76baf5f2019-05-17 22:13:02 +0800227 /**
228 * Sent by ConnectivityService to inform this network transport of signal strength thresholds
229 * that when crossed should trigger a system wakeup and a NetworkCapabilities update.
230 *
231 * obj = int[] describing signal strength thresholds.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900232 * @hide
junyulai76baf5f2019-05-17 22:13:02 +0800233 */
234 public static final int CMD_SET_SIGNAL_STRENGTH_THRESHOLDS = BASE + 14;
235
236 /**
237 * Sent by ConnectivityService to the NeworkAgent to inform the agent to avoid
238 * automatically reconnecting to this network (e.g. via autojoin). Happens
239 * when user selects "No" option on the "Stay connected?" dialog box.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900240 * @hide
junyulai76baf5f2019-05-17 22:13:02 +0800241 */
242 public static final int CMD_PREVENT_AUTOMATIC_RECONNECT = BASE + 15;
243
junyulai352dc2f2019-01-08 20:04:33 +0800244 /**
245 * Sent by the KeepaliveTracker to NetworkAgent to add a packet filter.
246 *
247 * For TCP keepalive offloads, keepalive packets are sent by the firmware. However, because the
248 * remote site will send ACK packets in response to the keepalive packets, the firmware also
249 * needs to be configured to properly filter the ACKs to prevent the system from waking up.
250 * This does not happen with UDP, so this message is TCP-specific.
251 * arg1 = slot number of the keepalive to filter for.
252 * obj = the keepalive packet to send repeatedly.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900253 * @hide
junyulai352dc2f2019-01-08 20:04:33 +0800254 */
255 public static final int CMD_ADD_KEEPALIVE_PACKET_FILTER = BASE + 16;
256
257 /**
258 * Sent by the KeepaliveTracker to NetworkAgent to remove a packet filter. See
259 * {@link #CMD_ADD_KEEPALIVE_PACKET_FILTER}.
260 * arg1 = slot number of the keepalive packet filter to remove.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900261 * @hide
junyulai352dc2f2019-01-08 20:04:33 +0800262 */
263 public static final int CMD_REMOVE_KEEPALIVE_PACKET_FILTER = BASE + 17;
264
Chalard Jean08577fc2018-05-02 21:14:54 +0900265 // TODO : remove these two constructors. They are a stopgap measure to help sheperding a number
266 // of dependent changes that would conflict throughout the automerger graph. Having these
267 // temporarily helps with the process of going through with all these dependent changes across
268 // the entire tree.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900269 /** @hide TODO: decide which of these to expose. */
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700270 public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni,
271 NetworkCapabilities nc, LinkProperties lp, int score) {
Lorenzo Colitti6654b082020-01-10 00:40:28 +0900272 this(looper, context, logTag, ni, nc, lp, score, null, NetworkProvider.ID_NONE);
Chalard Jean08577fc2018-05-02 21:14:54 +0900273 }
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900274
275 /** @hide TODO: decide which of these to expose. */
Chalard Jean08577fc2018-05-02 21:14:54 +0900276 public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni,
Lorenzo Colittid9696562020-01-12 22:28:37 +0900277 NetworkCapabilities nc, LinkProperties lp, int score, NetworkAgentConfig config) {
278 this(looper, context, logTag, ni, nc, lp, score, config, NetworkProvider.ID_NONE);
Sreeram Ramachandran8cd33ed2014-07-23 15:23:15 -0700279 }
280
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900281 /** @hide TODO: decide which of these to expose. */
Sreeram Ramachandran8cd33ed2014-07-23 15:23:15 -0700282 public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni,
Lorenzo Colitti6654b082020-01-10 00:40:28 +0900283 NetworkCapabilities nc, LinkProperties lp, int score, int providerId) {
284 this(looper, context, logTag, ni, nc, lp, score, null, providerId);
Chalard Jean08577fc2018-05-02 21:14:54 +0900285 }
286
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900287 /** @hide TODO: decide which of these to expose. */
Chalard Jean08577fc2018-05-02 21:14:54 +0900288 public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni,
Lorenzo Colittid9696562020-01-12 22:28:37 +0900289 NetworkCapabilities nc, LinkProperties lp, int score, NetworkAgentConfig config,
Lorenzo Colitti6654b082020-01-10 00:40:28 +0900290 int providerId) {
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900291 mHandler = new NetworkAgentHandler(looper);
Robert Greenwalt7b816022014-04-18 15:25:25 -0700292 LOG_TAG = logTag;
293 mContext = context;
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900294 this.providerId = providerId;
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700295 if (ni == null || nc == null || lp == null) {
296 throw new IllegalArgumentException();
Robert Greenwalt7b816022014-04-18 15:25:25 -0700297 }
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700298
Robert Greenwaltfc0c6892014-08-27 14:34:02 -0700299 if (VDBG) log("Registering NetworkAgent");
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700300 ConnectivityManager cm = (ConnectivityManager)mContext.getSystemService(
301 Context.CONNECTIVITY_SERVICE);
Chalard Jeana0e2aa122019-12-13 19:47:12 +0900302 network = cm.registerNetworkAgent(new Messenger(mHandler), new NetworkInfo(ni),
Lorenzo Colittid9696562020-01-12 22:28:37 +0900303 new LinkProperties(lp), new NetworkCapabilities(nc), score, config,
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900304 providerId);
Robert Greenwalt7b816022014-04-18 15:25:25 -0700305 }
306
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900307 private class NetworkAgentHandler extends Handler {
308 NetworkAgentHandler(Looper looper) {
309 super(looper);
310 }
Lorenzo Colittic3f21f32015-07-06 23:50:27 +0900311
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900312 @Override
313 public void handleMessage(Message msg) {
314 switch (msg.what) {
315 case AsyncChannel.CMD_CHANNEL_FULL_CONNECTION: {
316 if (mAsyncChannel != null) {
317 log("Received new connection while already connected!");
318 } else {
319 if (VDBG) log("NetworkAgent fully connected");
320 AsyncChannel ac = new AsyncChannel();
321 ac.connected(null, this, msg.replyTo);
322 ac.replyToMessage(msg, AsyncChannel.CMD_CHANNEL_FULLY_CONNECTED,
323 AsyncChannel.STATUS_SUCCESSFUL);
324 synchronized (mPreConnectedQueue) {
325 mAsyncChannel = ac;
326 for (Message m : mPreConnectedQueue) {
327 ac.sendMessage(m);
328 }
329 mPreConnectedQueue.clear();
330 }
331 }
332 break;
Erik Kline9d598e12015-07-13 16:37:51 +0900333 }
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900334 case AsyncChannel.CMD_CHANNEL_DISCONNECT: {
335 if (VDBG) log("CMD_CHANNEL_DISCONNECT");
336 if (mAsyncChannel != null) mAsyncChannel.disconnect();
337 break;
338 }
339 case AsyncChannel.CMD_CHANNEL_DISCONNECTED: {
340 if (DBG) log("NetworkAgent channel lost");
341 // let the client know CS is done with us.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900342 onNetworkUnwanted();
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900343 synchronized (mPreConnectedQueue) {
344 mAsyncChannel = null;
345 }
346 break;
347 }
348 case CMD_SUSPECT_BAD: {
349 log("Unhandled Message " + msg);
350 break;
351 }
352 case CMD_REQUEST_BANDWIDTH_UPDATE: {
353 long currentTimeMs = System.currentTimeMillis();
354 if (VDBG) {
355 log("CMD_REQUEST_BANDWIDTH_UPDATE request received.");
356 }
357 if (currentTimeMs >= (mLastBwRefreshTime + BW_REFRESH_MIN_WIN_MS)) {
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900358 mBandwidthUpdateScheduled = false;
359 if (!mBandwidthUpdatePending.getAndSet(true)) {
360 onBandwidthUpdateRequested();
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900361 }
362 } else {
363 // deliver the request at a later time rather than discard it completely.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900364 if (!mBandwidthUpdateScheduled) {
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900365 long waitTime = mLastBwRefreshTime + BW_REFRESH_MIN_WIN_MS
366 - currentTimeMs + 1;
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900367 mBandwidthUpdateScheduled = sendEmptyMessageDelayed(
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900368 CMD_REQUEST_BANDWIDTH_UPDATE, waitTime);
369 }
370 }
371 break;
372 }
373 case CMD_REPORT_NETWORK_STATUS: {
374 String redirectUrl = ((Bundle) msg.obj).getString(REDIRECT_URL_KEY);
375 if (VDBG) {
376 log("CMD_REPORT_NETWORK_STATUS("
377 + (msg.arg1 == VALID_NETWORK ? "VALID, " : "INVALID, ")
378 + redirectUrl);
379 }
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900380 onValidationStatus(msg.arg1 /* status */, redirectUrl);
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900381 break;
382 }
383 case CMD_SAVE_ACCEPT_UNVALIDATED: {
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900384 onSaveAcceptUnvalidated(msg.arg1 != 0);
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900385 break;
386 }
387 case CMD_START_SOCKET_KEEPALIVE: {
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900388 onStartSocketKeepalive(msg.arg1 /* slot */, msg.arg2 /* interval */,
389 (KeepalivePacketData) msg.obj /* packet */);
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900390 break;
391 }
392 case CMD_STOP_SOCKET_KEEPALIVE: {
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900393 onStopSocketKeepalive(msg.arg1 /* slot */);
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900394 break;
395 }
396
397 case CMD_SET_SIGNAL_STRENGTH_THRESHOLDS: {
398 ArrayList<Integer> thresholds =
399 ((Bundle) msg.obj).getIntegerArrayList("thresholds");
400 // TODO: Change signal strength thresholds API to use an ArrayList<Integer>
401 // rather than convert to int[].
402 int[] intThresholds = new int[(thresholds != null) ? thresholds.size() : 0];
403 for (int i = 0; i < intThresholds.length; i++) {
404 intThresholds[i] = thresholds.get(i);
405 }
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900406 onSignalStrengthThresholdsUpdated(intThresholds);
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900407 break;
408 }
409 case CMD_PREVENT_AUTOMATIC_RECONNECT: {
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900410 onAutomaticReconnectDisabled();
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900411 break;
412 }
413 case CMD_ADD_KEEPALIVE_PACKET_FILTER: {
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900414 onAddKeepalivePacketFilter(msg.arg1 /* slot */,
415 (KeepalivePacketData) msg.obj /* packet */);
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900416 break;
417 }
418 case CMD_REMOVE_KEEPALIVE_PACKET_FILTER: {
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900419 onRemoveKeepalivePacketFilter(msg.arg1 /* slot */);
Lorenzo Colitti782b48d52020-01-12 20:27:32 +0900420 break;
421 }
junyulai352dc2f2019-01-08 20:04:33 +0800422 }
Robert Greenwalt7b816022014-04-18 15:25:25 -0700423 }
424 }
425
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700426 private void queueOrSendMessage(int what, Object obj) {
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900427 queueOrSendMessage(what, 0, 0, obj);
428 }
429
430 private void queueOrSendMessage(int what, int arg1, int arg2) {
431 queueOrSendMessage(what, arg1, arg2, null);
432 }
433
434 private void queueOrSendMessage(int what, int arg1, int arg2, Object obj) {
435 Message msg = Message.obtain();
436 msg.what = what;
437 msg.arg1 = arg1;
438 msg.arg2 = arg2;
439 msg.obj = obj;
440 queueOrSendMessage(msg);
441 }
442
443 private void queueOrSendMessage(Message msg) {
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700444 synchronized (mPreConnectedQueue) {
445 if (mAsyncChannel != null) {
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900446 mAsyncChannel.sendMessage(msg);
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700447 } else {
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700448 mPreConnectedQueue.add(msg);
Lorenzo Colitti9a6a11a2014-05-24 02:25:55 +0900449 }
Robert Greenwalt7b816022014-04-18 15:25:25 -0700450 }
451 }
452
Robert Greenwalt7b816022014-04-18 15:25:25 -0700453 /**
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900454 * Must be called by the agent when the network's {@link LinkProperties} change.
455 * @param linkProperties the new LinkProperties.
Robert Greenwalt7b816022014-04-18 15:25:25 -0700456 */
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900457 public void sendLinkProperties(@NonNull LinkProperties linkProperties) {
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700458 queueOrSendMessage(EVENT_NETWORK_PROPERTIES_CHANGED, new LinkProperties(linkProperties));
Robert Greenwalt7b816022014-04-18 15:25:25 -0700459 }
460
461 /**
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900462 * Must be called by the agent when it has a new NetworkInfo object.
463 * @hide TODO: expose something better.
Robert Greenwalt7b816022014-04-18 15:25:25 -0700464 */
Mathew Inwood31755f92018-12-20 13:53:36 +0000465 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
Robert Greenwalt7b816022014-04-18 15:25:25 -0700466 public void sendNetworkInfo(NetworkInfo networkInfo) {
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700467 queueOrSendMessage(EVENT_NETWORK_INFO_CHANGED, new NetworkInfo(networkInfo));
Robert Greenwalt7b816022014-04-18 15:25:25 -0700468 }
469
470 /**
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900471 * Must be called by the agent when the network's {@link NetworkCapabilities} change.
472 * @param networkCapabilities the new NetworkCapabilities.
Robert Greenwalt7b816022014-04-18 15:25:25 -0700473 */
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900474 public void sendNetworkCapabilities(@NonNull NetworkCapabilities networkCapabilities) {
475 mBandwidthUpdatePending.set(false);
fenglub15e72b2015-03-20 11:29:56 -0700476 mLastBwRefreshTime = System.currentTimeMillis();
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700477 queueOrSendMessage(EVENT_NETWORK_CAPABILITIES_CHANGED,
478 new NetworkCapabilities(networkCapabilities));
Robert Greenwalt7b816022014-04-18 15:25:25 -0700479 }
480
481 /**
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900482 * Must be called by the agent to update the score of this network.
483 * @param score the new score.
Robert Greenwalt7b816022014-04-18 15:25:25 -0700484 */
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700485 public void sendNetworkScore(int score) {
Robert Greenwalt35f7a942014-09-09 14:46:37 -0700486 if (score < 0) {
487 throw new IllegalArgumentException("Score must be >= 0");
488 }
lucaslinc2bac512019-11-07 16:47:56 +0800489 final NetworkScore ns = new NetworkScore();
490 ns.putIntExtension(NetworkScore.LEGACY_SCORE, score);
491 updateScore(ns);
492 }
493
494 /**
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900495 * Must be called by the agent when it has a new {@link NetworkScore} for this network.
496 * @param ns the new score.
497 * @hide TODO: unhide the NetworkScore class, and rename to sendNetworkScore.
lucaslinc2bac512019-11-07 16:47:56 +0800498 */
499 public void updateScore(@NonNull NetworkScore ns) {
500 queueOrSendMessage(EVENT_NETWORK_SCORE_CHANGED, new NetworkScore(ns));
Robert Greenwalt7b816022014-04-18 15:25:25 -0700501 }
502
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700503 /**
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900504 * Must be called by the agent to indicate this network was manually selected by the user.
Robert Greenwalte73cc462014-09-07 16:50:01 -0700505 * This should be called before the NetworkInfo is marked CONNECTED so that this
Lorenzo Colittie03c3c72015-04-03 16:38:52 +0900506 * Network can be given special treatment at that time. If {@code acceptUnvalidated} is
507 * {@code true}, then the system will switch to this network. If it is {@code false} and the
508 * network cannot be validated, the system will ask the user whether to switch to this network.
509 * If the user confirms and selects "don't ask again", then the system will call
510 * {@link #saveAcceptUnvalidated} to persist the user's choice. Thus, if the transport ever
511 * calls this method with {@code acceptUnvalidated} set to {@code false}, it must also implement
512 * {@link #saveAcceptUnvalidated} to respect the user's choice.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900513 * @hide should move to NetworkAgentConfig.
Robert Greenwalte73cc462014-09-07 16:50:01 -0700514 */
Lorenzo Colittie03c3c72015-04-03 16:38:52 +0900515 public void explicitlySelected(boolean acceptUnvalidated) {
Lorenzo Colitti0e33bd12019-06-04 14:37:26 +0900516 explicitlySelected(true /* explicitlySelected */, acceptUnvalidated);
517 }
518
519 /**
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900520 * Must be called by the agent to indicate whether the network was manually selected by the
521 * user. This should be called before the network becomes connected, so it can be given
522 * special treatment when it does.
Lorenzo Colittib5ad6132019-06-04 22:15:33 +0900523 *
524 * If {@code explicitlySelected} is {@code true}, and {@code acceptUnvalidated} is {@code true},
525 * then the system will switch to this network. If {@code explicitlySelected} is {@code true}
526 * and {@code acceptUnvalidated} is {@code false}, and the network cannot be validated, the
527 * system will ask the user whether to switch to this network. If the user confirms and selects
528 * "don't ask again", then the system will call {@link #saveAcceptUnvalidated} to persist the
529 * user's choice. Thus, if the transport ever calls this method with {@code explicitlySelected}
530 * set to {@code true} and {@code acceptUnvalidated} set to {@code false}, it must also
531 * implement {@link #saveAcceptUnvalidated} to respect the user's choice.
532 *
533 * If {@code explicitlySelected} is {@code false} and {@code acceptUnvalidated} is
534 * {@code true}, the system will interpret this as the user having accepted partial connectivity
535 * on this network. Thus, the system will switch to the network and consider it validated even
536 * if it only provides partial connectivity, but the network is not otherwise treated specially.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900537 * @hide should move to NetworkAgentConfig.
Lorenzo Colitti0e33bd12019-06-04 14:37:26 +0900538 */
539 public void explicitlySelected(boolean explicitlySelected, boolean acceptUnvalidated) {
540 queueOrSendMessage(EVENT_SET_EXPLICITLY_SELECTED,
541 explicitlySelected ? 1 : 0,
542 acceptUnvalidated ? 1 : 0);
Robert Greenwalte73cc462014-09-07 16:50:01 -0700543 }
544
545 /**
Robert Greenwalt3192dec2014-05-27 13:20:24 -0700546 * Called when ConnectivityService has indicated they no longer want this network.
547 * The parent factory should (previously) have received indication of the change
548 * as well, either canceling NetworkRequests or altering their score such that this
549 * network won't be immediately requested again.
550 */
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900551 public void onNetworkUnwanted() {
552 unwanted();
553 }
554 /** @hide TODO delete once subclasses have moved to onNetworkUnwanted. */
555 protected void unwanted() {
556 }
Robert Greenwalt7b816022014-04-18 15:25:25 -0700557
Robert Greenwalt49f63fb2014-09-13 12:04:12 -0700558 /**
fenglub15e72b2015-03-20 11:29:56 -0700559 * Called when ConnectivityService request a bandwidth update. The parent factory
560 * shall try to overwrite this method and produce a bandwidth update if capable.
561 */
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900562 public void onBandwidthUpdateRequested() {
563 pollLceData();
564 }
565 /** @hide TODO delete once subclasses have moved to onBandwidthUpdateRequested. */
fenglub15e72b2015-03-20 11:29:56 -0700566 protected void pollLceData() {
567 }
568
569 /**
Robert Greenwalt49f63fb2014-09-13 12:04:12 -0700570 * Called when the system determines the usefulness of this network.
571 *
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900572 * The system attempts to validate Internet connectivity on networks that provide the
markchien06b9dfb2020-01-15 20:41:31 +0800573 * {@link NetworkCapabilities#NET_CAPABILITY_INTERNET} capability.
Robert Greenwalt49f63fb2014-09-13 12:04:12 -0700574 *
575 * Currently there are two possible values:
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900576 * {@code VALIDATION_STATUS_VALID} if Internet connectivity was validated,
577 * {@code VALIDATION_STATUS_NOT_VALID} if Internet connectivity was not validated.
Robert Greenwalt49f63fb2014-09-13 12:04:12 -0700578 *
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900579 * This may be called multiple times as network status changes, or if there are multiple
580 * subsequent attempts to validate connectivity that fail.
Paul Jensen232437312016-04-06 09:51:26 -0400581 *
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900582 * @param status one of {@code VALIDATION_STATUS_VALID} or {@code VALIDATION_STATUS_NOT_VALID}.
583 * @param redirectUrl If Internet connectivity is being redirected (e.g., on a captive portal),
584 * this is the destination the probes are being redirected to, otherwise {@code null}.
Robert Greenwalt49f63fb2014-09-13 12:04:12 -0700585 */
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900586 public void onValidationStatus(int status, @Nullable String redirectUrl) {
587 networkStatus(status, redirectUrl);
588 }
589 /** @hide TODO delete once subclasses have moved to onValidationStatus */
Paul Jensen232437312016-04-06 09:51:26 -0400590 protected void networkStatus(int status, String redirectUrl) {
Robert Greenwalt49f63fb2014-09-13 12:04:12 -0700591 }
592
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900593
Lorenzo Colittie03c3c72015-04-03 16:38:52 +0900594 /**
595 * Called when the user asks to remember the choice to use this network even if unvalidated.
596 * The transport is responsible for remembering the choice, and the next time the user connects
597 * to the network, should explicitlySelected with {@code acceptUnvalidated} set to {@code true}.
598 * This method will only be called if {@link #explicitlySelected} was called with
599 * {@code acceptUnvalidated} set to {@code false}.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900600 * @param accept whether the user wants to use the network even if unvalidated.
Lorenzo Colittie03c3c72015-04-03 16:38:52 +0900601 */
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900602 public void onSaveAcceptUnvalidated(boolean accept) {
603 saveAcceptUnvalidated(accept);
604 }
605 /** @hide TODO delete once subclasses have moved to onSaveAcceptUnvalidated */
Lorenzo Colittie03c3c72015-04-03 16:38:52 +0900606 protected void saveAcceptUnvalidated(boolean accept) {
607 }
608
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900609 /**
610 * Requests that the network hardware send the specified packet at the specified interval.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900611 *
612 * @param slot the hardware slot on which to start the keepalive.
613 * @param intervalSeconds the interval between packets
614 * @param packet the packet to send.
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900615 */
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900616 public void onStartSocketKeepalive(int slot, int intervalSeconds,
617 @NonNull KeepalivePacketData packet) {
618 Message msg = mHandler.obtainMessage(CMD_START_SOCKET_KEEPALIVE, slot, intervalSeconds,
619 packet);
620 startSocketKeepalive(msg);
621 msg.recycle();
622 }
623 /** @hide TODO delete once subclasses have moved to onStartSocketKeepalive */
junyulaie4135282019-01-03 18:50:15 +0800624 protected void startSocketKeepalive(Message msg) {
junyulai0c666972019-03-04 22:45:36 +0800625 onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_UNSUPPORTED);
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900626 }
627
628 /**
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900629 * Requests that the network hardware stop a previously-started keepalive.
630 *
631 * @param slot the hardware slot on which to stop the keepalive.
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900632 */
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900633 public void onStopSocketKeepalive(int slot) {
634 Message msg = mHandler.obtainMessage(CMD_STOP_SOCKET_KEEPALIVE, slot, 0, null);
635 stopSocketKeepalive(msg);
636 msg.recycle();
637 }
638 /** @hide TODO delete once subclasses have moved to onStopSocketKeepalive */
junyulaie4135282019-01-03 18:50:15 +0800639 protected void stopSocketKeepalive(Message msg) {
junyulai0c666972019-03-04 22:45:36 +0800640 onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_UNSUPPORTED);
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900641 }
642
643 /**
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900644 * Must be called by the agent when a socket keepalive event occurs.
645 *
646 * @param slot the hardware slot on which the event occurred.
647 * @param event the event that occurred.
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900648 */
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900649 public void sendSocketKeepaliveEvent(int slot, int event) {
650 queueOrSendMessage(EVENT_SOCKET_KEEPALIVE, slot, event);
651 }
652 /** @hide TODO delete once callers have moved to sendSocketKeepaliveEvent */
junyulaie4135282019-01-03 18:50:15 +0800653 public void onSocketKeepaliveEvent(int slot, int reason) {
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900654 sendSocketKeepaliveEvent(slot, reason);
Lorenzo Colitti8bf977d2015-06-15 14:29:22 +0900655 }
656
Lorenzo Colittic3f21f32015-07-06 23:50:27 +0900657 /**
junyulai352dc2f2019-01-08 20:04:33 +0800658 * Called by ConnectivityService to add specific packet filter to network hardware to block
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900659 * replies (e.g., TCP ACKs) matching the sent keepalive packets. Implementations that support
660 * this feature must override this method.
661 *
662 * @param slot the hardware slot on which the keepalive should be sent.
663 * @param packet the packet that is being sent.
junyulai352dc2f2019-01-08 20:04:33 +0800664 */
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900665 public void onAddKeepalivePacketFilter(int slot, @NonNull KeepalivePacketData packet) {
666 Message msg = mHandler.obtainMessage(CMD_ADD_KEEPALIVE_PACKET_FILTER, slot, 0, packet);
667 addKeepalivePacketFilter(msg);
668 msg.recycle();
669 }
670 /** @hide TODO delete once subclasses have moved to onAddKeepalivePacketFilter */
junyulai352dc2f2019-01-08 20:04:33 +0800671 protected void addKeepalivePacketFilter(Message msg) {
junyulai352dc2f2019-01-08 20:04:33 +0800672 }
673
674 /**
675 * Called by ConnectivityService to remove a packet filter installed with
676 * {@link #addKeepalivePacketFilter(Message)}. Implementations that support this feature
677 * must override this method.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900678 *
679 * @param slot the hardware slot on which the keepalive is being sent.
junyulai352dc2f2019-01-08 20:04:33 +0800680 */
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900681 public void onRemoveKeepalivePacketFilter(int slot) {
682 Message msg = mHandler.obtainMessage(CMD_REMOVE_KEEPALIVE_PACKET_FILTER, slot, 0, null);
683 removeKeepalivePacketFilter(msg);
684 msg.recycle();
685 }
686 /** @hide TODO delete once subclasses have moved to onRemoveKeepalivePacketFilter */
junyulai352dc2f2019-01-08 20:04:33 +0800687 protected void removeKeepalivePacketFilter(Message msg) {
junyulai352dc2f2019-01-08 20:04:33 +0800688 }
689
690 /**
Lorenzo Colittic3f21f32015-07-06 23:50:27 +0900691 * Called by ConnectivityService to inform this network transport of signal strength thresholds
692 * that when crossed should trigger a system wakeup and a NetworkCapabilities update.
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900693 *
694 * @param thresholds the array of thresholds that should trigger wakeups.
Lorenzo Colittic3f21f32015-07-06 23:50:27 +0900695 */
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900696 public void onSignalStrengthThresholdsUpdated(@NonNull int[] thresholds) {
697 setSignalStrengthThresholds(thresholds);
698 }
699 /** @hide TODO delete once subclasses have moved to onSetSignalStrengthThresholds */
Lorenzo Colittic3f21f32015-07-06 23:50:27 +0900700 protected void setSignalStrengthThresholds(int[] thresholds) {
701 }
702
Paul Jensenbf109912015-07-29 11:31:53 -0400703 /**
Paul Jensenf95d2202015-07-13 15:19:51 -0400704 * Called when the user asks to not stay connected to this network because it was found to not
705 * provide Internet access. Usually followed by call to {@code unwanted}. The transport is
706 * responsible for making sure the device does not automatically reconnect to the same network
707 * after the {@code unwanted} call.
708 */
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900709 public void onAutomaticReconnectDisabled() {
710 preventAutomaticReconnect();
711 }
712 /** @hide TODO delete once subclasses have moved to onAutomaticReconnectDisabled */
Paul Jensenf95d2202015-07-13 15:19:51 -0400713 protected void preventAutomaticReconnect() {
714 }
715
Lorenzo Colitti631f33a2020-01-15 00:13:37 +0900716 /** @hide */
Robert Greenwalt7b816022014-04-18 15:25:25 -0700717 protected void log(String s) {
718 Log.d(LOG_TAG, "NetworkAgent: " + s);
719 }
720}