public abstract class NetworkAgent extends Handler
Handler.Callback
Modifier and Type | Field and Description |
---|---|
static int |
CMD_PREVENT_AUTOMATIC_RECONNECT
Sent by ConnectivityService to the NeworkAgent to inform the agent to avoid
automatically reconnecting to this network (e.g. via autojoin).
|
static int |
CMD_REPORT_NETWORK_STATUS
Sent by ConnectivityService 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.
|
static int |
CMD_REQUEST_BANDWIDTH_UPDATE
Sent by ConnectivityService to the NetworkAgent to inform the agent to pull
the underlying network connection for updated bandwidth information.
|
static int |
CMD_SAVE_ACCEPT_UNVALIDATED
Sent by ConnectivityService to the NetworkAgent to inform the agent of
whether the network should in the future be used even if not validated.
|
static int |
CMD_SET_SIGNAL_STRENGTH_THRESHOLDS
Sent by ConnectivityService to inform this network transport of signal strength thresholds
that when crossed should trigger a system wakeup and a NetworkCapabilities update.
|
static int |
CMD_START_PACKET_KEEPALIVE
Sent by ConnectivityService to the NetworkAgent to request that the specified packet be sent
periodically on the given interval.
|
static int |
CMD_STOP_PACKET_KEEPALIVE
Requests that the specified keepalive packet be stopped.
|
static int |
CMD_SUSPECT_BAD
Sent by ConnectivityService to the NetworkAgent to inform it of
suspected connectivity problems on its network.
|
static int |
EVENT_NETWORK_CAPABILITIES_CHANGED
Sent by the NetworkAgent to ConnectivityService to pass the current
NetworkCapabilties.
|
static int |
EVENT_NETWORK_INFO_CHANGED
Sent by the NetworkAgent (note the EVENT vs CMD prefix) to
ConnectivityService to pass the current NetworkInfo (connection state).
|
static int |
EVENT_NETWORK_PROPERTIES_CHANGED
Sent by the NetworkAgent to ConnectivityService to pass the current
NetworkProperties.
|
static int |
EVENT_NETWORK_SCORE_CHANGED
Sent by the NetworkAgent to ConnectivityService to pass the current
network score.
|
static int |
EVENT_PACKET_KEEPALIVE
Sent by the NetworkAgent to ConnectivityService to provide status on a packet keepalive
request.
|
static int |
EVENT_SET_EXPLICITLY_SELECTED
Sent by the NetworkAgent to ConnectivityService to indicate this network was
explicitly selected.
|
static int |
EVENT_UID_RANGES_ADDED
Sent by the NetworkAgent to ConnectivityService to add new UID ranges
to be forced into this Network.
|
static int |
EVENT_UID_RANGES_REMOVED
Sent by the NetworkAgent to ConnectivityService to remove UID ranges
from being forced into this Network.
|
static int |
INVALID_NETWORK |
int |
netId |
static String |
REDIRECT_URL_KEY |
static int |
VALID_NETWORK |
static int |
WIFI_BASE_SCORE |
Constructor and Description |
---|
NetworkAgent(Looper looper,
Context context,
String logTag,
NetworkInfo ni,
NetworkCapabilities nc,
LinkProperties lp,
int score) |
NetworkAgent(Looper looper,
Context context,
String logTag,
NetworkInfo ni,
NetworkCapabilities nc,
LinkProperties lp,
int score,
NetworkMisc misc) |
Modifier and Type | Method and Description |
---|---|
void |
addUidRanges(UidRange[] ranges)
Called by the VPN code when it wants to add ranges of UIDs to be routed
through the VPN network.
|
void |
explicitlySelected(boolean acceptUnvalidated)
Called by the bearer to indicate this network was manually selected by the user.
|
void |
handleMessage(Message msg)
Subclasses must implement this to receive messages.
|
protected void |
log(String s) |
protected void |
networkStatus(int status,
String redirectUrl)
Called when the system determines the usefulness of this network.
|
void |
onPacketKeepaliveEvent(int slot,
int reason)
Called by the network when a packet keepalive event occurs.
|
protected void |
pollLceData()
Called when ConnectivityService request a bandwidth update.
|
protected void |
preventAutomaticReconnect()
Called when the user asks to not stay connected to this network because it was found to not
provide Internet access.
|
void |
removeUidRanges(UidRange[] ranges)
Called by the VPN code when it wants to remove ranges of UIDs from being routed
through the VPN network.
|
protected void |
saveAcceptUnvalidated(boolean accept)
Called when the user asks to remember the choice to use this network even if unvalidated.
|
void |
sendLinkProperties(LinkProperties linkProperties)
Called by the bearer code when it has new LinkProperties data.
|
void |
sendNetworkCapabilities(NetworkCapabilities networkCapabilities)
Called by the bearer code when it has new NetworkCapabilities data.
|
void |
sendNetworkInfo(NetworkInfo networkInfo)
Called by the bearer code when it has new NetworkInfo data.
|
void |
sendNetworkScore(int score)
Called by the bearer code when it has a new score for this network.
|
protected void |
setSignalStrengthThresholds(int[] thresholds)
Called by ConnectivityService to inform this network transport of signal strength thresholds
that when crossed should trigger a system wakeup and a NetworkCapabilities update.
|
protected void |
startPacketKeepalive(Message msg)
Requests that the network hardware send the specified packet at the specified interval.
|
protected void |
stopPacketKeepalive(Message msg)
Requests that the network hardware send the specified packet at the specified interval.
|
protected abstract void |
unwanted()
Called when ConnectivityService has indicated they no longer want this network.
|
dispatchMessage, dump, getLooper, getMessageName, getTraceName, hasCallbacks, hasMessages, hasMessages, obtainMessage, obtainMessage, obtainMessage, obtainMessage, obtainMessage, post, postAtFrontOfQueue, postAtTime, postAtTime, postDelayed, removeCallbacks, removeCallbacks, removeCallbacksAndMessages, removeMessages, removeMessages, runWithScissors, sendEmptyMessage, sendEmptyMessageAtTime, sendEmptyMessageDelayed, sendMessage, sendMessageAtFrontOfQueue, sendMessageAtTime, sendMessageDelayed, toString
public final int netId
public static final int CMD_SUSPECT_BAD
public static final int EVENT_NETWORK_INFO_CHANGED
public static final int EVENT_NETWORK_CAPABILITIES_CHANGED
public static final int EVENT_NETWORK_PROPERTIES_CHANGED
public static final int WIFI_BASE_SCORE
public static final int EVENT_NETWORK_SCORE_CHANGED
public static final int EVENT_UID_RANGES_ADDED
public static final int EVENT_UID_RANGES_REMOVED
public static final int CMD_REPORT_NETWORK_STATUS
VALID_NETWORK
or INVALID_NETWORK
obj = Bundle containing map from REDIRECT_URL_KEY
to String
representing URL that Internet probe was redirect to, if it was redirected,
or mapping to null
otherwise.public static final int VALID_NETWORK
public static final int INVALID_NETWORK
public static String REDIRECT_URL_KEY
public static final int EVENT_SET_EXPLICITLY_SELECTED
public static final int CMD_SAVE_ACCEPT_UNVALIDATED
public static final int CMD_REQUEST_BANDWIDTH_UPDATE
public static final int CMD_START_PACKET_KEEPALIVE
public static final int CMD_STOP_PACKET_KEEPALIVE
public static final int EVENT_PACKET_KEEPALIVE
public static final int CMD_SET_SIGNAL_STRENGTH_THRESHOLDS
public static final int CMD_PREVENT_AUTOMATIC_RECONNECT
public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni, NetworkCapabilities nc, LinkProperties lp, int score)
public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni, NetworkCapabilities nc, LinkProperties lp, int score, NetworkMisc misc)
public void handleMessage(Message msg)
Handler
handleMessage
in class Handler
public void sendLinkProperties(LinkProperties linkProperties)
public void sendNetworkInfo(NetworkInfo networkInfo)
public void sendNetworkCapabilities(NetworkCapabilities networkCapabilities)
public void sendNetworkScore(int score)
public void addUidRanges(UidRange[] ranges)
public void removeUidRanges(UidRange[] ranges)
public void explicitlySelected(boolean acceptUnvalidated)
acceptUnvalidated
is
true
, then the system will switch to this network. If it is false
and the
network cannot be validated, the system will ask the user whether to switch to this network.
If the user confirms and selects "don't ask again", then the system will call
saveAcceptUnvalidated(boolean)
to persist the user's choice. Thus, if the transport ever
calls this method with acceptUnvalidated
set to false
, it must also implement
saveAcceptUnvalidated(boolean)
to respect the user's choice.protected abstract void unwanted()
protected void pollLceData()
protected void networkStatus(int status, String redirectUrl)
VALID_NETWORK
if the system is happy with the connection,
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.status
- one of VALID_NETWORK
or INVALID_NETWORK
.redirectUrl
- If the Internet probe was redirected, this is the destination it was
redirected to, otherwise null
.protected void saveAcceptUnvalidated(boolean accept)
acceptUnvalidated
set to true
.
This method will only be called if explicitlySelected(boolean)
was called with
acceptUnvalidated
set to false
.protected void startPacketKeepalive(Message msg)
protected void stopPacketKeepalive(Message msg)
public void onPacketKeepaliveEvent(int slot, int reason)
protected void setSignalStrengthThresholds(int[] thresholds)
protected void preventAutomaticReconnect()
unwanted
. The transport is
responsible for making sure the device does not automatically reconnect to the same network
after the unwanted
call.protected void log(String s)