Loading core/java/android/net/NetworkAgent.java +38 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,18 @@ public abstract class NetworkAgent extends Handler { */ public static final int EVENT_UNBLOCK_ADDRESS_FAMILY = BASE + 8; /** * Sent by ConnectivitySerice to the NetworkAgent to inform the agent of the * networks status - whether we could use the network or could not, due to * either a bad network configuration (no internet link) or captive portal. * * arg1 = either {@code VALID_NETWORK} or {@code INVALID_NETWORK} */ public static final int CMD_REPORT_NETWORK_STATUS = BASE + 9; public static final int VALID_NETWORK = 1; public static final int INVALID_NETWORK = 2; public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni, NetworkCapabilities nc, LinkProperties lp, int score) { this(looper, context, logTag, ni, nc, lp, score, null); Loading Loading @@ -181,6 +193,14 @@ public abstract class NetworkAgent extends Handler { log("Unhandled Message " + msg); break; } case CMD_REPORT_NETWORK_STATUS: { if (VDBG) { log("CMD_REPORT_NETWORK_STATUS(" + (msg.arg1 == VALID_NETWORK ? "VALID)" : "INVALID)")); } networkStatus(msg.arg1); break; } } } Loading Loading @@ -268,6 +288,24 @@ public abstract class NetworkAgent extends Handler { */ abstract protected void unwanted(); /** * Called when the system determines the usefulness of this network. * * Networks claiming internet connectivity will have their internet * connectivity verified. * * Currently there are two possible values: * {@code VALID_NETWORK} if the system is happy with the connection, * {@code INVALID_NETWORK} if the system is not happy. * TODO - add indications of captive portal-ness and related success/failure, * ie, CAPTIVE_SUCCESS_NETWORK, CAPTIVE_NETWORK for successful login and detection * * This may be called multiple times as the network status changes and may * generate false negatives if we lose ip connectivity before the link is torn down. */ protected void networkStatus(int status) { } protected void log(String s) { Log.d(LOG_TAG, "NetworkAgent: " + s); } Loading services/core/java/com/android/server/ConnectivityService.java +6 −0 Original line number Diff line number Diff line Loading @@ -1935,6 +1935,11 @@ public class ConnectivityService extends IConnectivityManager.Stub { rematchNetworkAndRequests(nai); } updateInetCondition(nai, valid); // Let the NetworkAgent know the state of its network nai.asyncChannel.sendMessage( android.net.NetworkAgent.CMD_REPORT_NETWORK_STATUS, (valid ? NetworkAgent.VALID_NETWORK : NetworkAgent.INVALID_NETWORK), 0, null); } break; } Loading Loading @@ -2517,6 +2522,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { nai = mNetworkForNetId.get(network.netId); } if (nai == null) return; if (DBG) log("reportBadNetwork(" + nai.name() + ") by " + uid); synchronized (nai) { if (isNetworkBlocked(nai, uid)) return; Loading services/core/java/com/android/server/connectivity/NetworkMonitor.java +1 −1 Original line number Diff line number Diff line Loading @@ -260,7 +260,7 @@ public class NetworkMonitor extends StateMachine { addState(mUserPromptedState, mDefaultState); addState(mCaptivePortalState, mDefaultState); addState(mLingeringState, mDefaultState); setInitialState(mOfflineState); setInitialState(mDefaultState); mServer = Settings.Global.getString(mContext.getContentResolver(), Settings.Global.CAPTIVE_PORTAL_SERVER); Loading Loading
core/java/android/net/NetworkAgent.java +38 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,18 @@ public abstract class NetworkAgent extends Handler { */ public static final int EVENT_UNBLOCK_ADDRESS_FAMILY = BASE + 8; /** * Sent by ConnectivitySerice to the NetworkAgent to inform the agent of the * networks status - whether we could use the network or could not, due to * either a bad network configuration (no internet link) or captive portal. * * arg1 = either {@code VALID_NETWORK} or {@code INVALID_NETWORK} */ public static final int CMD_REPORT_NETWORK_STATUS = BASE + 9; public static final int VALID_NETWORK = 1; public static final int INVALID_NETWORK = 2; public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni, NetworkCapabilities nc, LinkProperties lp, int score) { this(looper, context, logTag, ni, nc, lp, score, null); Loading Loading @@ -181,6 +193,14 @@ public abstract class NetworkAgent extends Handler { log("Unhandled Message " + msg); break; } case CMD_REPORT_NETWORK_STATUS: { if (VDBG) { log("CMD_REPORT_NETWORK_STATUS(" + (msg.arg1 == VALID_NETWORK ? "VALID)" : "INVALID)")); } networkStatus(msg.arg1); break; } } } Loading Loading @@ -268,6 +288,24 @@ public abstract class NetworkAgent extends Handler { */ abstract protected void unwanted(); /** * Called when the system determines the usefulness of this network. * * Networks claiming internet connectivity will have their internet * connectivity verified. * * Currently there are two possible values: * {@code VALID_NETWORK} if the system is happy with the connection, * {@code INVALID_NETWORK} if the system is not happy. * TODO - add indications of captive portal-ness and related success/failure, * ie, CAPTIVE_SUCCESS_NETWORK, CAPTIVE_NETWORK for successful login and detection * * This may be called multiple times as the network status changes and may * generate false negatives if we lose ip connectivity before the link is torn down. */ protected void networkStatus(int status) { } protected void log(String s) { Log.d(LOG_TAG, "NetworkAgent: " + s); } Loading
services/core/java/com/android/server/ConnectivityService.java +6 −0 Original line number Diff line number Diff line Loading @@ -1935,6 +1935,11 @@ public class ConnectivityService extends IConnectivityManager.Stub { rematchNetworkAndRequests(nai); } updateInetCondition(nai, valid); // Let the NetworkAgent know the state of its network nai.asyncChannel.sendMessage( android.net.NetworkAgent.CMD_REPORT_NETWORK_STATUS, (valid ? NetworkAgent.VALID_NETWORK : NetworkAgent.INVALID_NETWORK), 0, null); } break; } Loading Loading @@ -2517,6 +2522,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { nai = mNetworkForNetId.get(network.netId); } if (nai == null) return; if (DBG) log("reportBadNetwork(" + nai.name() + ") by " + uid); synchronized (nai) { if (isNetworkBlocked(nai, uid)) return; Loading
services/core/java/com/android/server/connectivity/NetworkMonitor.java +1 −1 Original line number Diff line number Diff line Loading @@ -260,7 +260,7 @@ public class NetworkMonitor extends StateMachine { addState(mUserPromptedState, mDefaultState); addState(mCaptivePortalState, mDefaultState); addState(mLingeringState, mDefaultState); setInitialState(mOfflineState); setInitialState(mDefaultState); mServer = Settings.Global.getString(mContext.getContentResolver(), Settings.Global.CAPTIVE_PORTAL_SERVER); Loading