public class PollerConnectivityManager
extends android.net.ConnectivityManager
NetworkInterface
which address is not 0.0.0.0
.Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
BASE_PROPERTY
Base property name.
|
protected static android.net.NetworkCapabilities |
INTERNET_CONNECTED
Capability with internet access.
|
protected static android.net.NetworkCapabilities |
INTERNET_UNCONNECTED
Capability with internet access.
|
Constructor and Description |
---|
PollerConnectivityManager()
Instantiates a
PollerConnectivityManager with default periods and delay and a new timer. |
PollerConnectivityManager(ej.bon.Timer timer)
Instantiates a
PollerConnectivityManager with default value. |
PollerConnectivityManager(ej.bon.Timer timer,
long delay,
long period)
Instantiates a
PollerConnectivityManager with the same period when up or not. |
PollerConnectivityManager(ej.bon.Timer timer,
long delay,
long periodWhenAvailable,
long periodWhenLost)
Instantiates a
PollerConnectivityManager with the different periods when available or not. |
PollerConnectivityManager(ej.bon.Timer timer,
long delay,
long periodWhenAvaialble,
long periodWhenLost,
long periodWhenInternet)
Instantiates a
PollerConnectivityManager with the same period when connected or not. |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the associated timer.
|
protected android.net.NetworkCapabilities |
getCapabilities(java.net.InetAddress connectedAddress)
Gets the capabilities of a network.
|
protected java.net.NetworkInterface |
getNetworkInterface(java.lang.String name)
Isolate for testing.
|
protected java.util.Enumeration<java.net.NetworkInterface> |
getNetworkInterfaces()
Isolate for testing.
|
protected void |
log(int msg)
Logs a message.
|
protected void |
log(int msg,
java.lang.Throwable t)
Logs a message and a throwable.
|
void |
startPolling(long delay)
Starts the polling function.
|
void |
stopPolling()
Stops the polling function.
|
doNotifyAvailabilityChange, doNotifyCapabilitiesChange, getActiveNetwork, getActiveNetworkInfo, getAllNetworks, getNetworkCapabilities, getNetworkInfo, notifyNetworkCallbacks, notifyNetworkCallbacks, notifyNetworkCallbacks, registerDefaultNetworkCallback, registerNetworkCallback, setActiveNetwork, setAvailable, unregisterNetworkCallback
protected static final android.net.NetworkCapabilities INTERNET_CONNECTED
protected static final android.net.NetworkCapabilities INTERNET_UNCONNECTED
protected static final java.lang.String BASE_PROPERTY
public PollerConnectivityManager()
PollerConnectivityManager
with default periods and delay and a new timer.public PollerConnectivityManager(ej.bon.Timer timer)
PollerConnectivityManager
with default value.timer
- the timer to use, cannot be null
.public PollerConnectivityManager(ej.bon.Timer timer, long delay, long period)
PollerConnectivityManager
with the same period when up or not.timer
- the timer to use, cannot be null
.delay
- the delay before the start.period
- the period for the polling.public PollerConnectivityManager(ej.bon.Timer timer, long delay, long periodWhenAvailable, long periodWhenLost)
PollerConnectivityManager
with the different periods when available or not. The same
period is used wth or without internet access when availble.timer
- the timer to use, cannot be null
.delay
- the delay before the start.periodWhenAvailable
- the period for the polling when at least one interface is available.periodWhenLost
- the period for the polling when all the interface are down.public PollerConnectivityManager(ej.bon.Timer timer, long delay, long periodWhenAvaialble, long periodWhenLost, long periodWhenInternet)
PollerConnectivityManager
with the same period when connected or not.timer
- the timer to use, cannot be null
.delay
- the delay before the start.periodWhenAvaialble
- the period for the polling when at least one interface is available.periodWhenLost
- the period for the polling when all the interface are down.periodWhenInternet
- the period for the polling when there is internet access.public void startPolling(long delay)
delay
- the delay before starting.public void stopPolling()
public void cancel()
protected void log(int msg)
msg
- the message to log.protected void log(int msg, java.lang.Throwable t)
msg
- the message to log.t
- a throwable to print, cannot be null
.protected android.net.NetworkCapabilities getCapabilities(java.net.InetAddress connectedAddress)
connectedAddress
- the address to get the capabilities from, cannot be null
.@Nullable protected java.util.Enumeration<java.net.NetworkInterface> getNetworkInterfaces() throws java.net.SocketException
java.net.SocketException
- if an I/O exception occurs.@Nullable protected java.net.NetworkInterface getNetworkInterface(java.lang.String name) throws java.net.SocketException
name
- the name of the interface, cannot be null
.java.net.SocketException
- if an I/O exception occurs.