Class ShadowWifiManager

    • Constructor Detail

      • ShadowWifiManager

        public ShadowWifiManager()
    • Method Detail

      • setWifiEnabled

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

        public void setWifiState​(int wifiState)
      • isWifiEnabled

        @Implementation
        protected boolean isWifiEnabled()
      • getWifiState

        @Implementation
        protected int getWifiState()
      • getConnectionInfo

        @Implementation
        protected 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​(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 List<ScanResult> getScanResults()
      • getPrivilegedConfiguredNetworks

        @Implementation(minSdk=21)
        protected List<WifiConfiguration> getPrivilegedConfiguredNetworks()
      • addNetwork

        @Implementation
        protected int addNetwork​(WifiConfiguration config)
      • removeNetwork

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

        @Implementation
        protected boolean saveConfiguration()
      • enableNetwork

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

        @Implementation
        protected boolean disableNetwork​(int netId)
      • 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 DhcpInfo getDhcpInfo()
      • isScanAlwaysAvailable

        @Implementation(minSdk=18)
        protected boolean isScanAlwaysAvailable()
      • 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​(List<ScanResult> scanResults)
      • setDhcpInfo

        public void setDhcpInfo​(DhcpInfo dhcpInfo)
      • 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 WifiConfiguration getWifiConfiguration​(int netId)
      • addOnWifiUsabilityStatsListener

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

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

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

        @Implementation
        protected boolean setWifiApConfiguration​(WifiConfiguration apConfig)
      • getWifiApConfiguration

        @Implementation
        protected WifiConfiguration getWifiApConfiguration()