WifiConfiguration


public class WifiConfiguration
extends Object implements Parcelable

java.lang.Object
   ↳ android.net.wifi.WifiConfiguration


This class was deprecated in API level 29.
Use WifiNetworkSpecifier.Builder to create NetworkSpecifier and WifiNetworkSuggestion.Builder to create WifiNetworkSuggestion. This class can still be used with privileged APIs such as WifiManager.addNetwork(WifiConfiguration).

A class representing a configured Wi-Fi network, including the security configuration.

Summary

Nested classes

class WifiConfiguration.AuthAlgorithm

Recognized IEEE 802.11 authentication algorithms. 

class WifiConfiguration.GroupCipher

Recognized group ciphers. 

class WifiConfiguration.GroupMgmtCipher

Recognized group management ciphers. 

class WifiConfiguration.KeyMgmt

Recognized key management schemes. 

class WifiConfiguration.PairwiseCipher

Recognized pairwise ciphers for WPA. 

class WifiConfiguration.Protocol

Recognized security protocols. 

class WifiConfiguration.Status

Possible status of a network configuration. 

Constants

int RANDOMIZATION_AUTO

Let the wifi framework automatically decide the MAC randomization strategy.

int RANDOMIZATION_NONE

Use factory MAC when connecting to this network

int RANDOMIZATION_NON_PERSISTENT

Use a randomly generated MAC address for connections to this network.

int RANDOMIZATION_PERSISTENT

Generate a randomized MAC once and reuse it for all connections to this network

int SECURITY_TYPE_DPP

Security type for Easy Connect (DPP) network

int SECURITY_TYPE_EAP

Security type for an EAP network.

int SECURITY_TYPE_EAP_SUITE_B

This constant was deprecated in API level 29. Use the SECURITY_TYPE_EAP_WPA3_ENTERPRISE_192_BIT constant (which is the same value).

int SECURITY_TYPE_EAP_WPA3_ENTERPRISE

Security type for a WPA3-Enterprise network.

int SECURITY_TYPE_EAP_WPA3_ENTERPRISE_192_BIT

Security type for a WPA3-Enterprise in 192-bit security network.

int SECURITY_TYPE_OPEN

Security type for an open network.

int SECURITY_TYPE_OWE

Security type for an OWE network.

int SECURITY_TYPE_PSK

Security type for a PSK network.

int SECURITY_TYPE_SAE

Security type for an SAE network.

int SECURITY_TYPE_WAPI_CERT

Security type for a WAPI Certificate network.

int SECURITY_TYPE_WAPI_PSK

Security type for a WAPI PSK network.

int SECURITY_TYPE_WEP

Security type for a WEP network.

Inherited constants

Fields

public String BSSID

When set, this network configuration entry should only be used when associating with the AP having the specified BSSID.

public String FQDN

Fully qualified domain name of a Passpoint configuration

public String SSID

The network's SSID.

public BitSet allowedAuthAlgorithms

The set of authentication protocols supported by this configuration.

public BitSet allowedGroupCiphers

The set of group ciphers supported by this configuration.

public BitSet allowedGroupManagementCiphers

The set of group management ciphers supported by this configuration.

public BitSet allowedKeyManagement

The set of key management protocols supported by this configuration.

public BitSet allowedPairwiseCiphers

The set of pairwise ciphers for WPA supported by this configuration.

public BitSet allowedProtocols

The set of security protocols supported by this configuration.

public BitSet allowedSuiteBCiphers

The set of SuiteB ciphers supported by this configuration.

public WifiEnterpriseConfig enterpriseConfig

The enterprise configuration details specifying the EAP method, certificates and other settings associated with the EAP.

public boolean hiddenSSID

This is a network that does not broadcast its SSID, so an SSID-specific probe request must be used for scans.

public boolean isHomeProviderNetwork

Flag indicating if this network is provided by a home Passpoint provider or a roaming Passpoint provider.

public int networkId

The ID number that the supplicant uses to identify this network configuration entry.

public String preSharedKey

Pre-shared key for use with WPA-PSK.

public int priority

This field was deprecated in API level 26. This field does not exist anymore.

public String providerFriendlyName

Name of Passpoint credential provider

public long[] roamingConsortiumIds

Roaming Consortium Id list for Passpoint credential; identifies a set of networks where Passpoint credential will be considered valid

public int status

The current status of this network configuration entry.

public String[] wepKeys

This field was deprecated in API level 28. Due to security and performance limitations, use of WEP networks is discouraged.

public int wepTxKeyIndex

This field was deprecated in API level 28. Due to security and performance limitations, use of WEP networks is discouraged.

Public constructors

WifiConfiguration()
WifiConfiguration(WifiConfiguration source)

Copy constructor

Public methods

ProxyInfo getHttpProxy()

Returns the HTTP proxy used by this object.

String getKey()

Return a String that can be used to uniquely identify this WifiConfiguration.

int getMacRandomizationSetting()

Get the MAC randomization setting for this network.

MacAddress getRandomizedMacAddress()

Returns MAC address set to be the local randomized MAC address.

boolean isDppConfigurator()

To check if this WifiConfiguration supports configuring a peer Enrollee device with SECURITY_TYPE_DPP

boolean isPasspoint()

Identify if this configuration represents a Passpoint network

void setHttpProxy(ProxyInfo httpProxy)

Set the ProxyInfo for this WifiConfiguration.

void setIpConfiguration(IpConfiguration ipConfiguration)

Set the IpConfiguration for this network.

void setMacRandomizationSetting(int macRandomizationSetting)

Set the MAC randomization setting for this network.

void setSecurityParams(int securityType)

Set the various security params to correspond to the provided security type.

String toString()

Returns a string representation of the object.

Inherited methods

Constants

RANDOMIZATION_AUTO

Added in API level 33
Deprecated in API level 29
public static final int RANDOMIZATION_AUTO

Let the wifi framework automatically decide the MAC randomization strategy.

Constant Value: 3 (0x00000003)

RANDOMIZATION_NONE

Added in API level 33
Deprecated in API level 29
public static final int RANDOMIZATION_NONE

Use factory MAC when connecting to this network

Constant Value: 0 (0x00000000)

RANDOMIZATION_NON_PERSISTENT

Added in API level 33
Deprecated in API level 29
public static final int RANDOMIZATION_NON_PERSISTENT

Use a randomly generated MAC address for connections to this network. This option does not persist the randomized MAC address.

Constant Value: 2 (0x00000002)

RANDOMIZATION_PERSISTENT

Added in API level 33
Deprecated in API level 29
public static final int RANDOMIZATION_PERSISTENT

Generate a randomized MAC once and reuse it for all connections to this network

Constant Value: 1 (0x00000001)

SECURITY_TYPE_DPP

Added in API level 33
Deprecated in API level 29
public static final int SECURITY_TYPE_DPP

Security type for Easy Connect (DPP) network

Constant Value: 13 (0x0000000d)

SECURITY_TYPE_EAP

Added in API level 30
Deprecated in API level 29
public static final int SECURITY_TYPE_EAP

Security type for an EAP network.

Constant Value: 3 (0x00000003)

SECURITY_TYPE_EAP_SUITE_B

Added in API level 30
Deprecated in API level 29
public static final int SECURITY_TYPE_EAP_SUITE_B

This constant was deprecated in API level 29.
Use the SECURITY_TYPE_EAP_WPA3_ENTERPRISE_192_BIT constant (which is the same value).

Security type for a WPA3-Enterprise in 192-bit security network.

Constant Value: 5 (0x00000005)

SECURITY_TYPE_EAP_WPA3_ENTERPRISE

Added in API level 31
Deprecated in API level 29
public static final int SECURITY_TYPE_EAP_WPA3_ENTERPRISE

Security type for a WPA3-Enterprise network.

Constant Value: 9 (0x00000009)

SECURITY_TYPE_EAP_WPA3_ENTERPRISE_192_BIT

Added in API level 31
Deprecated in API level 29
public static final int SECURITY_TYPE_EAP_WPA3_ENTERPRISE_192_BIT

Security type for a WPA3-Enterprise in 192-bit security network. This is the same as SECURITY_TYPE_EAP_SUITE_B and uses the same value.

Constant Value: 5 (0x00000005)

SECURITY_TYPE_OPEN

Added in API level 30
Deprecated in API level 29
public static final int SECURITY_TYPE_OPEN

Security type for an open network.

Constant Value: 0 (0x00000000)

SECURITY_TYPE_OWE

Added in API level 30
Deprecated in API level 29
public static final int SECURITY_TYPE_OWE

Security type for an OWE network.

Constant Value: 6 (0x00000006)

SECURITY_TYPE_PSK

Added in API level 30
Deprecated in API level 29
public static final int SECURITY_TYPE_PSK

Security type for a PSK network.

Constant Value: 2 (0x00000002)

SECURITY_TYPE_SAE

Added in API level 30
Deprecated in API level 29
public static final int SECURITY_TYPE_SAE

Security type for an SAE network.

Constant Value: 4 (0x00000004)

SECURITY_TYPE_WAPI_CERT

Added in API level 30
Deprecated in API level 29
public static final int SECURITY_TYPE_WAPI_CERT

Security type for a WAPI Certificate network.

Constant Value: 8 (0x00000008)

SECURITY_TYPE_WAPI_PSK

Added in API level 30
Deprecated in API level 29
public static final int SECURITY_TYPE_WAPI_PSK

Security type for a WAPI PSK network.

Constant Value: 7 (0x00000007)

SECURITY_TYPE_WEP

Added in API level 30
Deprecated in API level 29
public static final int SECURITY_TYPE_WEP

Security type for a WEP network.

Constant Value: 1 (0x00000001)

Fields

BSSID

Added in API level 1
public String BSSID

When set, this network configuration entry should only be used when associating with the AP having the specified BSSID. The value is a string in the format of an Ethernet MAC address, e.g., XX:XX:XX:XX:XX:XX where each X is a hex digit.

FQDN

Added in API level 21
Deprecated in API level 29
public String FQDN

Fully qualified domain name of a Passpoint configuration

SSID

Added in API level 1
public String SSID

The network's SSID. Can either be a UTF-8 string, which must be enclosed in double quotation marks (e.g., "MyNetwork"), or a string of hex digits, which are not enclosed in quotes (e.g., 01a243f405).

allowedAuthAlgorithms

Added in API level 1
public BitSet allowedAuthAlgorithms

The set of authentication protocols supported by this configuration. See AuthAlgorithm for descriptions of the values. Defaults to automatic selection.

allowedGroupCiphers

Added in API level 1
public BitSet allowedGroupCiphers

The set of group ciphers supported by this configuration. See GroupCipher for descriptions of the values. Defaults to CCMP TKIP WEP104 WEP40.

allowedGroupManagementCiphers

Added in API level 29
Deprecated in API level 29
public BitSet allowedGroupManagementCiphers

The set of group management ciphers supported by this configuration. See GroupMgmtCipher for descriptions of the values.

allowedKeyManagement

Added in API level 1
public BitSet allowedKeyManagement

The set of key management protocols supported by this configuration. See KeyMgmt for descriptions of the values. Defaults to WPA-PSK WPA-EAP.

allowedPairwiseCiphers

Added in API level 1
public BitSet allowedPairwiseCiphers

The set of pairwise ciphers for WPA supported by this configuration. See PairwiseCipher for descriptions of the values. Defaults to CCMP TKIP.

allowedProtocols

Added in API level 1
public BitSet allowedProtocols

The set of security protocols supported by this configuration. See Protocol for descriptions of the values. Defaults to WPA RSN.

allowedSuiteBCiphers

Added in API level 29
Deprecated in API level 29
public BitSet allowedSuiteBCiphers

The set of SuiteB ciphers supported by this configuration. To be used for WPA3-Enterprise mode. Set automatically by the framework based on the certificate type that is used in this configuration.

enterpriseConfig

Added in API level 18
Deprecated in API level 29
public WifiEnterpriseConfig enterpriseConfig

The enterprise configuration details specifying the EAP method, certificates and other settings associated with the EAP.

hiddenSSID

Added in API level 1
public boolean hiddenSSID

This is a network that does not broadcast its SSID, so an SSID-specific probe request must be used for scans.

isHomeProviderNetwork

Added in API level 26
Deprecated in API level 29
public boolean isHomeProviderNetwork

Flag indicating if this network is provided by a home Passpoint provider or a roaming Passpoint provider. This flag will be true if this network is provided by a home Passpoint provider and false if is provided by a roaming Passpoint provider or is a non-Passpoint network.

networkId

Added in API level 1
public int networkId

The ID number that the supplicant uses to identify this network configuration entry. This must be passed as an argument to most calls into the supplicant.

preSharedKey

Added in API level 1
public String preSharedKey

Pre-shared key for use with WPA-PSK. Either an ASCII string enclosed in double quotation marks (e.g., "abcdefghij" for PSK passphrase or a string of 64 hex digits for raw PSK.

When the value of this key is read, the actual key is not returned, just a "*" if the key has a value, or the null string otherwise.

priority

Added in API level 1
Deprecated in API level 26
public int priority

This field was deprecated in API level 26.
This field does not exist anymore.

Priority determines the preference given to a network by wpa_supplicant when choosing an access point with which to associate.

providerFriendlyName

Added in API level 23
Deprecated in API level 29
public String providerFriendlyName

Name of Passpoint credential provider

roamingConsortiumIds

Added in API level 23
Deprecated in API level 29
public long[] roamingConsortiumIds

Roaming Consortium Id list for Passpoint credential; identifies a set of networks where Passpoint credential will be considered valid

status

Added in API level 1
public int status

The current status of this network configuration entry.

wepKeys

Added in API level 1
Deprecated in API level 28
public String[] wepKeys

This field was deprecated in API level 28.
Due to security and performance limitations, use of WEP networks is discouraged.

Four WEP keys. For each of the four values, provide either an ASCII string enclosed in double quotation marks (e.g., "abcdef") or a string of hex digits (e.g., 0102030405).

When the value of one of these keys is read, the actual key is not returned, just a "*" if the key has a value, or the null string otherwise.

wepTxKeyIndex

Added in API level 1
Deprecated in API level 28
public int wepTxKeyIndex

This field was deprecated in API level 28.
Due to security and performance limitations, use of WEP networks is discouraged.

Default WEP key index, ranging from 0 to 3.

Public constructors

WifiConfiguration

Added in API level 1
public WifiConfiguration ()

WifiConfiguration

Added in API level 30
public WifiConfiguration (WifiConfiguration source)

Copy constructor

Parameters
source WifiConfiguration: This value cannot be null.

Public methods

getHttpProxy

Added in API level 26
Deprecated in API level 29
public ProxyInfo getHttpProxy ()

Returns the HTTP proxy used by this object.

Returns
ProxyInfo a httpProxy representing the proxy specified by this WifiConfiguration, or null if no proxy is specified.

getKey

Added in API level 30
Deprecated in API level 29
public String getKey ()

Return a String that can be used to uniquely identify this WifiConfiguration.
Note: Do not persist this value! This value is not guaranteed to remain backwards compatible.

Returns
String This value cannot be null.

getMacRandomizationSetting

Added in API level 33
Deprecated in API level 29
public int getMacRandomizationSetting ()

Get the MAC randomization setting for this network.

Returns
int Value is RANDOMIZATION_NONE, RANDOMIZATION_PERSISTENT, RANDOMIZATION_NON_PERSISTENT, or RANDOMIZATION_AUTO

getRandomizedMacAddress

Added in API level 29
Deprecated in API level 29
public MacAddress getRandomizedMacAddress ()

Returns MAC address set to be the local randomized MAC address. Depending on user preference, the device may or may not use the returned MAC address for connections to this network.

Information is restricted to Device Owner, Profile Owner, and Carrier apps (which will only obtain addresses for configurations which they create). Other callers will receive a default "02:00:00:00:00:00" MAC address.

Returns
MacAddress This value cannot be null.

isDppConfigurator

Added in API level 33
Deprecated in API level 29
public boolean isDppConfigurator ()

To check if this WifiConfiguration supports configuring a peer Enrollee device with SECURITY_TYPE_DPP

Returns
boolean

isPasspoint

Added in API level 23
Deprecated in API level 29
public boolean isPasspoint ()

Identify if this configuration represents a Passpoint network

Returns
boolean

setHttpProxy

Added in API level 26
Deprecated in API level 29
public void setHttpProxy (ProxyInfo httpProxy)

Set the ProxyInfo for this WifiConfiguration. This method should only be used by a device owner or profile owner. When other apps attempt to save a WifiConfiguration with modified proxy settings, the methods WifiManager.addNetwork and WifiManager.updateNetwork fail and return -1.

Parameters
httpProxy ProxyInfo: ProxyInfo representing the httpProxy to be used by this WifiConfiguration. Setting this to null will explicitly set no proxy, removing any proxy that was previously set.

setIpConfiguration

Added in API level 33
Deprecated in API level 29
public void setIpConfiguration (IpConfiguration ipConfiguration)

Set the IpConfiguration for this network.

Parameters
ipConfiguration IpConfiguration: a IpConfiguration to use for this Wi-Fi configuration, or null to use the default configuration.

setMacRandomizationSetting

Added in API level 33
Deprecated in API level 29
public void setMacRandomizationSetting (int macRandomizationSetting)

Set the MAC randomization setting for this network.

Caller must satify one of the following conditions:

  • Have android.Manifest.permission#NETWORK_SETTINGS permission.
  • Have android.Manifest.permission#NETWORK_SETUP_WIZARD permission.
  • Be in Demo Mode.
  • Be the creator adding or updating a passpoint network.
  • Be an admin updating their own network.

Parameters
macRandomizationSetting int: Value is RANDOMIZATION_NONE, RANDOMIZATION_PERSISTENT, RANDOMIZATION_NON_PERSISTENT, or RANDOMIZATION_AUTO

setSecurityParams

Added in API level 30
Deprecated in API level 29
public void setSecurityParams (int securityType)

Set the various security params to correspond to the provided security type. This is accomplished by setting the various BitSets exposed in WifiConfiguration.
This API would clear existing security types and add a default one. Before calling this API with SECURITY_TYPE_DPP as securityType, call WifiManager.isEasyConnectDppAkmSupported()}

Parameters
securityType int

toString

Added in API level 1
public String toString ()

Returns a string representation of the object.

Returns
String a string representation of the object.