@Implements(value=android.net.wifi.WifiManager.class, looseSignatures=true) public class ShadowWifiManager extends Object
WifiManager
.Modifier and Type | Class | Description |
---|---|---|
static class |
ShadowWifiManager.ShadowMulticastLock |
|
static class |
ShadowWifiManager.ShadowWifiLock |
|
static class |
ShadowWifiManager.WifiUsabilityScore |
Class to record scores passed to WifiManager#updateWifiUsabilityScore
|
Constructor | Description |
---|---|
ShadowWifiManager() |
Modifier and Type | Method | Description |
---|---|---|
protected int |
addNetwork(WifiConfiguration config) |
|
protected void |
addOnWifiUsabilityStatsListener(Object executorObject,
Object listenerObject) |
|
protected static int |
calculateSignalLevel(int rssi,
int numLevels) |
|
void |
clearUsabilityScores() |
Clears wifi usability scores previous passed to
WifiManager.updateWifiUsabilityScore(int, int, int) |
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 |
disableNetwork(int netId) |
|
protected boolean |
enableNetwork(int netId,
boolean attemptConnect) |
|
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() |
|
List<ShadowWifiManager.WifiUsabilityScore> |
getUsabilityScores() |
Returns wifi usability scores previous passed to
WifiManager.updateWifiUsabilityScore(int, int, int) |
WifiConfiguration |
getWifiConfiguration(int netId) |
|
protected int |
getWifiState() |
|
protected boolean |
is5GHzBandSupported() |
|
boolean |
isNetworkEnabled(int netId) |
Whether the network is enabled or not.
|
protected boolean |
isScanAlwaysAvailable() |
|
protected boolean |
isWifiEnabled() |
|
void |
postUsabilityStats(int seqNum,
boolean isSameBssidAndFreq,
WifiUsabilityStatsEntryBuilder statsBuilder) |
Post Wifi stats to any listeners registered with
WifiManager.addOnWifiUsabilityStatsListener(java.util.concurrent.Executor, android.net.wifi.WifiManager.OnWifiUsabilityStatsListener) |
protected boolean |
reconnect() |
|
protected boolean |
removeNetwork(int netId) |
|
protected void |
removeOnWifiUsabilityStatsListener(Object listenerObject) |
|
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(android.net.wifi.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. |
protected void |
updateWifiUsabilityScore(int seqNum,
int score,
int predictionHorizonSec) |
|
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)
public void setConnectionInfo(WifiInfo wifiInfo)
WifiInfo
.public void setStartScanSucceeds(boolean succeeds)
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)
getWifiConfiguration(int)
method. A null {@param config}, 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 attemptConnect)
@Implementation protected boolean disableNetwork(int netId)
@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()
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)
updateNetwork(android.net.wifi.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 boolean isNetworkEnabled(int netId)
public int getActiveLockCount()
public boolean wasConfigurationSaved()
public void setIsScanAlwaysAvailable(boolean isScanAlwaysAvailable)
public WifiConfiguration getWifiConfiguration(int netId)
@Implementation(minSdk=29) @HiddenApi protected void addOnWifiUsabilityStatsListener(Object executorObject, Object listenerObject)
@Implementation(minSdk=29) @HiddenApi protected void removeOnWifiUsabilityStatsListener(Object listenerObject)
@Implementation(minSdk=29) @HiddenApi protected void updateWifiUsabilityScore(int seqNum, int score, int predictionHorizonSec)
public List<ShadowWifiManager.WifiUsabilityScore> getUsabilityScores()
WifiManager.updateWifiUsabilityScore(int, int, int)
public void clearUsabilityScores()
WifiManager.updateWifiUsabilityScore(int, int, int)
public void postUsabilityStats(int seqNum, boolean isSameBssidAndFreq, WifiUsabilityStatsEntryBuilder statsBuilder)
WifiManager.addOnWifiUsabilityStatsListener(java.util.concurrent.Executor, android.net.wifi.WifiManager.OnWifiUsabilityStatsListener)