Class ShadowWifiManager


  • @Implements(value=android.net.wifi.WifiManager.class,
                looseSignatures=true)
    public class ShadowWifiManager
    extends java.lang.Object
    Shadow for WifiManager.
    • Constructor Detail

      • ShadowWifiManager

        public ShadowWifiManager()
    • Method Detail

      • setWifiEnabled

        @Implementation
        protected boolean setWifiEnabled​(boolean wifiEnabled)
      • isWifiEnabled

        @Implementation
        protected boolean isWifiEnabled()
      • getWifiState

        @Implementation
        protected int getWifiState()
      • getConnectionInfo

        @Implementation
        protected android.net.wifi.WifiInfo getConnectionInfo()
      • is5GHzBandSupported

        @Implementation(minSdk=21)
        protected boolean is5GHzBandSupported()
      • setIs5GHzBandSupported

        public void setIs5GHzBandSupported​(boolean is5GHzBandSupported)
        Sets whether 5ghz band is supported.
      • setConnectionInfo

        public void setConnectionInfo​(android.net.wifi.WifiInfo wifiInfo)
        Sets the connection info as the provided WifiInfo.
      • setStartScanSucceeds

        public void setStartScanSucceeds​(boolean succeeds)
        Sets the return value of startScan().
      • getScanResults

        @Implementation
        protected java.util.List<android.net.wifi.ScanResult> getScanResults()
      • getConfiguredNetworks

        @Implementation
        protected java.util.List<android.net.wifi.WifiConfiguration> getConfiguredNetworks()
      • getPrivilegedConfiguredNetworks

        @Implementation(minSdk=21)
        protected java.util.List<android.net.wifi.WifiConfiguration> getPrivilegedConfiguredNetworks()
      • addNetwork

        @Implementation
        protected int addNetwork​(android.net.wifi.WifiConfiguration config)
      • removeNetwork

        @Implementation
        protected boolean removeNetwork​(int netId)
      • updateNetwork

        @Implementation
        protected int updateNetwork​(android.net.wifi.WifiConfiguration config)
        Adds or updates a network which can later be retrieved with 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.
      • saveConfiguration

        @Implementation
        protected boolean saveConfiguration()
      • enableNetwork

        @Implementation
        protected boolean enableNetwork​(int netId,
                                        boolean attemptConnect)
      • disableNetwork

        @Implementation
        protected boolean disableNetwork​(int netId)
      • createWifiLock

        @Implementation
        protected android.net.wifi.WifiManager.WifiLock createWifiLock​(int lockType,
                                                                       java.lang.String tag)
      • createWifiLock

        @Implementation
        protected android.net.wifi.WifiManager.WifiLock createWifiLock​(java.lang.String tag)
      • createMulticastLock

        @Implementation
        protected android.net.wifi.WifiManager.MulticastLock createMulticastLock​(java.lang.String tag)
      • calculateSignalLevel

        @Implementation
        protected static int calculateSignalLevel​(int rssi,
                                                  int numLevels)
      • startScan

        @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+.

        Returns:
        the value configured by setStartScanSucceeds(boolean), or true if that method was never called.
      • getDhcpInfo

        @Implementation
        protected android.net.DhcpInfo getDhcpInfo()
      • isScanAlwaysAvailable

        @Implementation(minSdk=18)
        protected boolean isScanAlwaysAvailable()
      • connect

        @HiddenApi
        @Implementation(minSdk=19)
        protected void connect​(android.net.wifi.WifiConfiguration wifiConfiguration,
                               android.net.wifi.WifiManager.ActionListener listener)
      • connect

        @HiddenApi
        @Implementation(minSdk=19)
        protected void connect​(int networkId,
                               android.net.wifi.WifiManager.ActionListener listener)
      • reconnect

        @Implementation
        protected boolean reconnect()
      • setSignalLevelInPercent

        public static void setSignalLevelInPercent​(float level)
      • setAccessWifiStatePermission

        public void setAccessWifiStatePermission​(boolean accessWifiStatePermission)
      • setUpdateNetworkPermission

        public void setUpdateNetworkPermission​(int networkId,
                                               boolean hasPermission)
        Prevents a networkId from being updated using the 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.
      • setScanResults

        public void setScanResults​(java.util.List<android.net.wifi.ScanResult> scanResults)
      • setDhcpInfo

        public void setDhcpInfo​(android.net.DhcpInfo dhcpInfo)
      • getLastEnabledNetwork

        public android.util.Pair<java.lang.Integer,​java.lang.Boolean> getLastEnabledNetwork()
      • isNetworkEnabled

        public boolean isNetworkEnabled​(int netId)
        Whether the network is enabled or not.
      • getActiveLockCount

        public int getActiveLockCount()
        Returns the number of WifiLocks and MulticastLocks that are currently acquired.
      • wasConfigurationSaved

        public boolean wasConfigurationSaved()
      • setIsScanAlwaysAvailable

        public void setIsScanAlwaysAvailable​(boolean isScanAlwaysAvailable)
      • getWifiConfiguration

        public android.net.wifi.WifiConfiguration getWifiConfiguration​(int netId)
      • addOnWifiUsabilityStatsListener

        @Implementation(minSdk=29)
        @HiddenApi
        protected void addOnWifiUsabilityStatsListener​(java.lang.Object executorObject,
                                                       java.lang.Object listenerObject)
      • removeOnWifiUsabilityStatsListener

        @Implementation(minSdk=29)
        @HiddenApi
        protected void removeOnWifiUsabilityStatsListener​(java.lang.Object listenerObject)
      • updateWifiUsabilityScore

        @Implementation(minSdk=29)
        @HiddenApi
        protected void updateWifiUsabilityScore​(int seqNum,
                                                int score,
                                                int predictionHorizonSec)
      • getUsabilityScores

        public java.util.List<ShadowWifiManager.WifiUsabilityScore> getUsabilityScores()
        Returns wifi usability scores previous passed to WifiManager.updateWifiUsabilityScore(int, int, int)
      • clearUsabilityScores

        public void clearUsabilityScores()
        Clears wifi usability scores previous passed to WifiManager.updateWifiUsabilityScore(int, int, int)
      • postUsabilityStats

        public 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)