@Implements(value=android.net.ConnectivityManager.class) public class ShadowConnectivityManager extends java.lang.Object
Constructor and Description |
---|
ShadowConnectivityManager() |
Modifier and Type | Method and Description |
---|---|
protected void |
addDefaultNetworkActiveListener(android.net.ConnectivityManager.OnNetworkActiveListener l) |
void |
addNetwork(android.net.Network network,
android.net.NetworkInfo networkInfo)
Adds new
network to the list of all Network s. |
boolean |
bindProcessToNetwork(android.net.Network network) |
void |
clearAllNetworks()
Clears the list of all
Network s. |
android.net.Network |
getActiveNetwork() |
android.net.NetworkInfo |
getActiveNetworkInfo() |
android.net.NetworkInfo[] |
getAllNetworkInfo() |
android.net.Network[] |
getAllNetworks() |
boolean |
getBackgroundDataSetting() |
android.net.Network |
getBoundNetworkForProcess() |
java.util.Set<android.net.ConnectivityManager.NetworkCallback> |
getNetworkCallbacks() |
android.net.NetworkInfo |
getNetworkInfo(int networkType) |
android.net.NetworkInfo |
getNetworkInfo(android.net.Network network) |
int |
getNetworkPreference() |
boolean |
isActiveNetworkMetered()
Counts
ConnectivityManager.TYPE_MOBILE networks as metered. |
protected boolean |
isDefaultNetworkActive() |
void |
registerNetworkCallback(android.net.NetworkRequest request,
android.net.ConnectivityManager.NetworkCallback networkCallback) |
protected void |
removeDefaultNetworkActiveListener(android.net.ConnectivityManager.OnNetworkActiveListener l) |
void |
removeNetwork(android.net.Network network)
Removes the
network from the list of all Network s. |
void |
setActiveNetworkInfo(android.net.NetworkInfo info) |
void |
setBackgroundDataSetting(boolean b) |
void |
setDefaultNetworkActive(boolean isActive)
Sets the active state of the default network.
|
void |
setNetworkInfo(int networkType,
android.net.NetworkInfo networkInfo) |
void |
setNetworkPreference(int preference) |
void |
unregisterNetworkCallback(android.net.ConnectivityManager.NetworkCallback networkCallback) |
public java.util.Set<android.net.ConnectivityManager.NetworkCallback> getNetworkCallbacks()
@Implementation(minSdk=21) public void registerNetworkCallback(android.net.NetworkRequest request, android.net.ConnectivityManager.NetworkCallback networkCallback)
@Implementation(minSdk=21) public void unregisterNetworkCallback(android.net.ConnectivityManager.NetworkCallback networkCallback)
@Implementation public android.net.NetworkInfo getActiveNetworkInfo()
@Implementation(minSdk=23) public android.net.Network getActiveNetwork()
@Implementation public android.net.NetworkInfo[] getAllNetworkInfo()
@Implementation public android.net.NetworkInfo getNetworkInfo(int networkType)
@Implementation(minSdk=21) public android.net.NetworkInfo getNetworkInfo(android.net.Network network)
@Implementation(minSdk=21) public android.net.Network[] getAllNetworks()
@Implementation public boolean getBackgroundDataSetting()
@Implementation public void setNetworkPreference(int preference)
@Implementation public int getNetworkPreference()
@Implementation public boolean isActiveNetworkMetered()
Counts ConnectivityManager.TYPE_MOBILE
networks as metered. Other types will be considered unmetered.
true
if the active network is metered, otherwise false
.setActiveNetworkInfo(NetworkInfo)
,
setDefaultNetworkActive(boolean)
@Implementation(minSdk=23) public boolean bindProcessToNetwork(android.net.Network network)
@Implementation(minSdk=23) public android.net.Network getBoundNetworkForProcess()
public void setNetworkInfo(int networkType, android.net.NetworkInfo networkInfo)
@HiddenApi @Implementation public void setBackgroundDataSetting(boolean b)
public void setActiveNetworkInfo(android.net.NetworkInfo info)
public void addNetwork(android.net.Network network, android.net.NetworkInfo networkInfo)
Adds new network
to the list of all Network
s.
network
- The network.networkInfo
- The network info paired with the Network
.public void removeNetwork(android.net.Network network)
Removes the network
from the list of all Network
s.
network
- The network.public void clearAllNetworks()
Clears the list of all Network
s.
public void setDefaultNetworkActive(boolean isActive)
Sets the active state of the default network.
By default this is true and affects the result of ConnectivityManager.isActiveNetworkMetered()
, ConnectivityManager.isDefaultNetworkActive()
, ConnectivityManager.getActiveNetwork()
and ConnectivityManager.getAllNetworkInfo()
.
Calling this method with true
after any listeners have been registered with ConnectivityManager.addDefaultNetworkActiveListener(OnNetworkActiveListener)
will result in those listeners being fired.
isActive
- The active state of the default network.@Implementation(minSdk=21) protected boolean isDefaultNetworkActive()
true
by default, or the value specifed via setDefaultNetworkActive(boolean)
setDefaultNetworkActive(boolean)
@Implementation(minSdk=21) protected void addDefaultNetworkActiveListener(android.net.ConnectivityManager.OnNetworkActiveListener l)
@Implementation(minSdk=21) protected void removeDefaultNetworkActiveListener(android.net.ConnectivityManager.OnNetworkActiveListener l)