@Implements(value=android.net.wifi.WifiManager.class) public class ShadowWifiManager extends Object
Shadow for WifiManager
.
Modifier and Type | Class and Description |
---|---|
static class |
ShadowWifiManager.ShadowMulticastLock |
static class |
ShadowWifiManager.ShadowWifiLock |
Constructor and Description |
---|
ShadowWifiManager() |
Modifier and Type | Method and Description |
---|---|
protected int |
addNetwork(WifiConfiguration config) |
protected static int |
calculateSignalLevel(int rssi,
int numLevels) |
protected void |
connect(int networkId,
WifiManager.ActionListener listener) |
protected void |
connect(WifiConfiguration wifiConfiguration,
WifiManager.ActionListener listener) |
protected WifiManager.MulticastLock |
createMulticastLock(String tag) |
protected WifiManager.WifiLock |
createWifiLock(int lockType,
String tag) |
protected WifiManager.WifiLock |
createWifiLock(String tag) |
protected boolean |
enableNetwork(int netId,
boolean disableOthers) |
int |
getActiveLockCount()
Returns the number of WifiLocks and MulticastLocks that are currently acquired.
|
protected List<WifiConfiguration> |
getConfiguredNetworks() |
protected WifiInfo |
getConnectionInfo() |
protected DhcpInfo |
getDhcpInfo() |
Pair<Integer,Boolean> |
getLastEnabledNetwork() |
protected List<WifiConfiguration> |
getPrivilegedConfiguredNetworks() |
protected List<ScanResult> |
getScanResults() |
WifiConfiguration |
getWifiConfiguration(int netId) |
protected int |
getWifiState() |
protected boolean |
is5GHzBandSupported() |
protected boolean |
isScanAlwaysAvailable() |
protected boolean |
isWifiEnabled() |
protected boolean |
reconnect() |
protected boolean |
removeNetwork(int netId) |
protected boolean |
saveConfiguration() |
void |
setAccessWifiStatePermission(boolean accessWifiStatePermission) |
void |
setConnectionInfo(WifiInfo wifiInfo)
Sets the connection info as the provided
WifiInfo . |
void |
setDhcpInfo(DhcpInfo dhcpInfo) |
void |
setIs5GHzBandSupported(boolean is5GHzBandSupported)
Sets whether 5ghz band is supported.
|
void |
setIsScanAlwaysAvailable(boolean isScanAlwaysAvailable) |
void |
setScanResults(List<ScanResult> scanResults) |
static void |
setSignalLevelInPercent(float level) |
void |
setStartScanSucceeds(boolean succeeds)
Sets the return value of
startScan() . |
void |
setUpdateNetworkPermission(int networkId,
boolean hasPermission)
Prevents a networkId from being updated using the
updateNetwork(WifiConfiguration) method. |
protected boolean |
setWifiEnabled(boolean wifiEnabled) |
protected boolean |
startScan()
Does nothing and returns the configured success status.
|
protected int |
updateNetwork(WifiConfiguration config)
Adds or updates a network which can later be retrieved with
getWifiConfiguration(int) method. |
boolean |
wasConfigurationSaved() |
@Implementation protected boolean setWifiEnabled(boolean wifiEnabled)
@Implementation protected boolean isWifiEnabled()
@Implementation protected int getWifiState()
@Implementation protected WifiInfo getConnectionInfo()
@Implementation(minSdk=21) protected boolean is5GHzBandSupported()
public void setIs5GHzBandSupported(boolean is5GHzBandSupported)
Sets whether 5ghz band is supported.
public void setConnectionInfo(WifiInfo wifiInfo)
Sets the connection info as the provided WifiInfo
.
public void setStartScanSucceeds(boolean succeeds)
Sets the return value of startScan()
.
@Implementation protected List<ScanResult> getScanResults()
@Implementation protected List<WifiConfiguration> getConfiguredNetworks()
@Implementation(minSdk=21) protected List<WifiConfiguration> getPrivilegedConfiguredNetworks()
@Implementation protected int addNetwork(WifiConfiguration config)
@Implementation protected boolean removeNetwork(int netId)
@Implementation protected int updateNetwork(WifiConfiguration config)
Adds or updates a network which can later be retrieved with getWifiConfiguration(int)
method. A null , or one with a networkId less than 0, or a networkId that had its updatePermission removed using the setUpdateNetworkPermission(int, boolean)
will return -1, which indicates a failure to update.
@Implementation protected boolean saveConfiguration()
@Implementation protected boolean enableNetwork(int netId, boolean disableOthers)
@Implementation protected WifiManager.WifiLock createWifiLock(int lockType, String tag)
@Implementation protected WifiManager.WifiLock createWifiLock(String tag)
@Implementation protected WifiManager.MulticastLock createMulticastLock(String tag)
@Implementation protected static int calculateSignalLevel(int rssi, int numLevels)
@Implementation protected boolean startScan()
Does nothing and returns the configured success status.
That is different from the Android implementation which always returns true
up to and including Android 8, and either true
or false
on Android 9+.
setStartScanSucceeds(boolean)
, or true
if that method was never called.@Implementation protected DhcpInfo getDhcpInfo()
@Implementation(minSdk=18) protected boolean isScanAlwaysAvailable()
@HiddenApi @Implementation(minSdk=19) protected void connect(WifiConfiguration wifiConfiguration, WifiManager.ActionListener listener)
@HiddenApi @Implementation(minSdk=19) protected void connect(int networkId, WifiManager.ActionListener listener)
@Implementation protected boolean reconnect()
public static void setSignalLevelInPercent(float level)
public void setAccessWifiStatePermission(boolean accessWifiStatePermission)
public void setUpdateNetworkPermission(int networkId, boolean hasPermission)
Prevents a networkId from being updated using the updateNetwork(WifiConfiguration)
method. This is to simulate the case where a separate application creates a network, and the Android security model prevents your application from updating it.
public void setScanResults(List<ScanResult> scanResults)
public void setDhcpInfo(DhcpInfo dhcpInfo)
public int getActiveLockCount()
Returns the number of WifiLocks and MulticastLocks that are currently acquired.
public boolean wasConfigurationSaved()
public void setIsScanAlwaysAvailable(boolean isScanAlwaysAvailable)
public WifiConfiguration getWifiConfiguration(int netId)