# Print output for @column tags ?> WifiInfo - Android SDK | Android Developers

Most visited

Recently visited

WifiInfo

public class WifiInfo
extends Object implements TransportInfo, Parcelable

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


Describes the state of any Wi-Fi connection that is active or is in the process of being set up. In the connected state, access to location sensitive fields requires the same permissions as WifiManager#getScanResults. If such access is not allowed, getSSID() will return WifiManager#UNKNOWN_SSID and getBSSID() will return "02:00:00:00:00:00". getNetworkId() will return -1. getPasspointFqdn() will return null. getPasspointProviderFriendlyName() will return null. getInformationElements() will return null. getMacAddress() will return "02:00:00:00:00:00".

Summary

Nested classes

class WifiInfo.Builder

Builder for WifiInfo 

Constants

String FREQUENCY_UNITS

Frequency in MHz

String LINK_SPEED_UNITS

The unit in which links speeds are expressed.

int LINK_SPEED_UNKNOWN

Constant for unknown link speed.

int SECURITY_TYPE_EAP

Security type for an EAP network.

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_OSEN

Security type for an OSEN network.

int SECURITY_TYPE_OWE

Security type for an OWE network.

int SECURITY_TYPE_PASSPOINT_R1_R2

Security type for a Passpoint R1/R2 network, where TKIP and WEP are not allowed.

int SECURITY_TYPE_PASSPOINT_R3

Security type for a Passpoint R3 network, where TKIP and WEP are not allowed, and PMF must be set to Required.

int SECURITY_TYPE_PSK

Security type for a PSK network.

int SECURITY_TYPE_SAE

Security type for an SAE network.

int SECURITY_TYPE_UNKNOWN

Unknown security type.

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

Public methods

boolean equals(Object that)

Indicates whether some other object is "equal to" this one.

long getApplicableRedactions()

Returns a bitmask of all the applicable redactions (based on the permissions held by the receiving app) to be performed on this TransportInfo.

String getBSSID()

Return the basic service set identifier (BSSID) of the current access point.

int getCurrentSecurityType()

Returns the security type of the current 802.11 network connection.

static NetworkInfo.DetailedState getDetailedStateOf(SupplicantState suppState)

Map a supplicant state into a fine-grained network connectivity state.

int getFrequency()

Returns the current frequency in FREQUENCY_UNITS.

boolean getHiddenSSID()
List<ScanResult.InformationElement> getInformationElements()

Get all information elements found in the beacon of the connected bssid.

int getIpAddress()

This method is deprecated. Use the methods on LinkProperties which can be obtained either via NetworkCallback#onLinkPropertiesChanged(Network, LinkProperties) or ConnectivityManager#getLinkProperties(Network).

int getLinkSpeed()

Returns the current link speed in LINK_SPEED_UNITS.

String getMacAddress()

Returns the MAC address used for this connection.

int getMaxSupportedRxLinkSpeedMbps()

Returns the maximum supported receive link speed in Mbps

int getMaxSupportedTxLinkSpeedMbps()

Returns the maximum supported transmit link speed in Mbps

int getNetworkId()

Each configured network has a unique small integer ID, used to identify the network.

String getPasspointFqdn()

Returns the Fully Qualified Domain Name of the network if it is a Passpoint network.

String getPasspointProviderFriendlyName()

Returns the Provider Friendly Name of the network if it is a Passpoint network.

int getRssi()

Returns the received signal strength indicator of the current 802.11 network, in dBm.

int getRxLinkSpeedMbps()

Returns the current receive link speed in Mbps.

String getSSID()

Returns the service set identifier (SSID) of the current 802.11 network.

int getSubscriptionId()

If this network is provisioned by a carrier, returns subscription Id corresponding to the associated SIM on the device.

SupplicantState getSupplicantState()

Return the detailed state of the supplicant's negotiation with an access point, in the form of a SupplicantState object.

int getTxLinkSpeedMbps()

Returns the current transmit link speed in Mbps.

int getWifiStandard()

Get connection Wi-Fi standard

int hashCode()

Returns a hash code value for the object.

WifiInfo makeCopy(long redactions)

Create a copy of a WifiInfo with some fields redacted based on the permissions held by the receiving app.

String toString()

Returns a string representation of the object.

Inherited methods

Constants

FREQUENCY_UNITS

public static final String FREQUENCY_UNITS

Frequency in MHz

Constant Value: "MHz"

public static final String LINK_SPEED_UNITS

The unit in which links speeds are expressed.

Constant Value: "Mbps"

public static final int LINK_SPEED_UNKNOWN

Constant for unknown link speed.

Constant Value: -1 (0xffffffff)

SECURITY_TYPE_EAP

public static final int SECURITY_TYPE_EAP

Security type for an EAP network.

Constant Value: 3 (0x00000003)

SECURITY_TYPE_EAP_WPA3_ENTERPRISE

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

public static final int SECURITY_TYPE_EAP_WPA3_ENTERPRISE_192_BIT

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

Constant Value: 5 (0x00000005)

SECURITY_TYPE_OPEN

public static final int SECURITY_TYPE_OPEN

Security type for an open network.

Constant Value: 0 (0x00000000)

SECURITY_TYPE_OSEN

public static final int SECURITY_TYPE_OSEN

Security type for an OSEN network.

Constant Value: 10 (0x0000000a)

SECURITY_TYPE_OWE

public static final int SECURITY_TYPE_OWE

Security type for an OWE network.

Constant Value: 6 (0x00000006)

SECURITY_TYPE_PASSPOINT_R1_R2

public static final int SECURITY_TYPE_PASSPOINT_R1_R2

Security type for a Passpoint R1/R2 network, where TKIP and WEP are not allowed.

Constant Value: 11 (0x0000000b)

SECURITY_TYPE_PASSPOINT_R3

public static final int SECURITY_TYPE_PASSPOINT_R3

Security type for a Passpoint R3 network, where TKIP and WEP are not allowed, and PMF must be set to Required.

Constant Value: 12 (0x0000000c)

SECURITY_TYPE_PSK

public static final int SECURITY_TYPE_PSK

Security type for a PSK network.

Constant Value: 2 (0x00000002)

SECURITY_TYPE_SAE

public static final int SECURITY_TYPE_SAE

Security type for an SAE network.

Constant Value: 4 (0x00000004)

SECURITY_TYPE_UNKNOWN

public static final int SECURITY_TYPE_UNKNOWN

Unknown security type.

Constant Value: -1 (0xffffffff)

SECURITY_TYPE_WAPI_CERT

public static final int SECURITY_TYPE_WAPI_CERT

Security type for a WAPI Certificate network.

Constant Value: 8 (0x00000008)

SECURITY_TYPE_WAPI_PSK

public static final int SECURITY_TYPE_WAPI_PSK

Security type for a WAPI PSK network.

Constant Value: 7 (0x00000007)

SECURITY_TYPE_WEP

public static final int SECURITY_TYPE_WEP

Security type for a WEP network.

Constant Value: 1 (0x00000001)

Public methods

equals

public boolean equals (Object that)

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
that Object: the reference object with which to compare.

Returns
boolean true if this object is the same as the obj argument; false otherwise.

getApplicableRedactions

public long getApplicableRedactions ()

Returns a bitmask of all the applicable redactions (based on the permissions held by the receiving app) to be performed on this TransportInfo.

Returns
long bitmask of redactions applicable on this instance.

getBSSID

public String getBSSID ()

Return the basic service set identifier (BSSID) of the current access point.

The BSSID may be null, if there is no network currently connected. "02:00:00:00:00:00", if the caller has insufficient permissions to access the BSSID.

Returns
String the BSSID, in the form of a six-byte MAC address: XX:XX:XX:XX:XX:XX

getCurrentSecurityType

public int getCurrentSecurityType ()

Returns the security type of the current 802.11 network connection.

Returns
int the security type, or SECURITY_TYPE_UNKNOWN if not currently connected. Value is SECURITY_TYPE_UNKNOWN, SECURITY_TYPE_OPEN, SECURITY_TYPE_WEP, SECURITY_TYPE_PSK, SECURITY_TYPE_EAP, SECURITY_TYPE_SAE, SECURITY_TYPE_OWE, SECURITY_TYPE_WAPI_PSK, SECURITY_TYPE_WAPI_CERT, SECURITY_TYPE_EAP_WPA3_ENTERPRISE, SECURITY_TYPE_EAP_WPA3_ENTERPRISE_192_BIT, SECURITY_TYPE_PASSPOINT_R1_R2, or SECURITY_TYPE_PASSPOINT_R3

getDetailedStateOf

public static NetworkInfo.DetailedState getDetailedStateOf (SupplicantState suppState)

Map a supplicant state into a fine-grained network connectivity state.

Parameters
suppState SupplicantState: the supplicant state

Returns
NetworkInfo.DetailedState the corresponding DetailedState

getFrequency

public int getFrequency ()

Returns the current frequency in FREQUENCY_UNITS.

Returns
int the frequency.

See also:

getHiddenSSID

public boolean getHiddenSSID ()

Returns
boolean true if this network does not broadcast its SSID, so an SSID-specific probe request must be used for scans.

getInformationElements

public List<ScanResult.InformationElement> getInformationElements ()

Get all information elements found in the beacon of the connected bssid.

The information elements will be null if there is no network currently connected or if the caller has insufficient permissions to access the info elements.

Returns
List<ScanResult.InformationElement> List of information elements ScanResult.InformationElement or null.

getIpAddress

public int getIpAddress ()

This method is deprecated.
Use the methods on LinkProperties which can be obtained either via NetworkCallback#onLinkPropertiesChanged(Network, LinkProperties) or ConnectivityManager#getLinkProperties(Network).

Returns
int

getLinkSpeed

public int getLinkSpeed ()

Returns the current link speed in LINK_SPEED_UNITS.

Returns
int the link speed or LINK_SPEED_UNKNOWN if link speed is unknown.

See also:

getMacAddress

public String getMacAddress ()

Returns the MAC address used for this connection.
Requires android.Manifest.permission.LOCAL_MAC_ADDRESS and Manifest.permission.ACCESS_FINE_LOCATION

Returns
String MAC address of the connection or "02:00:00:00:00:00" if the caller has insufficient permission.

getMaxSupportedRxLinkSpeedMbps

public int getMaxSupportedRxLinkSpeedMbps ()

Returns the maximum supported receive link speed in Mbps

Returns
int the max supported Rx link speed or LINK_SPEED_UNKNOWN if link speed is unknown. @see #LINK_SPEED_UNKNOWN

getMaxSupportedTxLinkSpeedMbps

public int getMaxSupportedTxLinkSpeedMbps ()

Returns the maximum supported transmit link speed in Mbps

Returns
int the max supported tx link speed or LINK_SPEED_UNKNOWN if link speed is unknown. @see #LINK_SPEED_UNKNOWN

getNetworkId

public int getNetworkId ()

Each configured network has a unique small integer ID, used to identify the network. This method returns the ID for the currently connected network.

The networkId may be -1 if there is no currently connected network or if the caller has insufficient permissions to access the network ID.

Returns
int the network ID.

getPasspointFqdn

public String getPasspointFqdn ()

Returns the Fully Qualified Domain Name of the network if it is a Passpoint network.

The FQDN may be null if no network currently connected, currently connected network is not passpoint network or the caller has insufficient permissions to access the FQDN.

Returns
String

getPasspointProviderFriendlyName

public String getPasspointProviderFriendlyName ()

Returns the Provider Friendly Name of the network if it is a Passpoint network.

The Provider Friendly Name may be null if no network currently connected, currently connected network is not passpoint network or the caller has insufficient permissions to access the Provider Friendly Name.

Returns
String

getRssi

public int getRssi ()

Returns the received signal strength indicator of the current 802.11 network, in dBm.

Use WifiManager.calculateSignalLevel(int) to convert this number into an absolute signal level which can be displayed to a user.

Returns
int the RSSI.

getRxLinkSpeedMbps

public int getRxLinkSpeedMbps ()

Returns the current receive link speed in Mbps.

Returns
int the Rx link speed or LINK_SPEED_UNKNOWN if link speed is unknown. Value is -1 or greater

See also:

getSSID

public String getSSID ()

Returns the service set identifier (SSID) of the current 802.11 network.

If the SSID can be decoded as UTF-8, it will be returned surrounded by double quotation marks. Otherwise, it is returned as a string of hex digits. The SSID may be WifiManager#UNKNOWN_SSID, if there is no network currently connected or if the caller has insufficient permissions to access the SSID.

Prior to Build.VERSION_CODES.JELLY_BEAN_MR1, this method always returned the SSID with no quotes around it.

Returns
String the SSID.

getSubscriptionId

public int getSubscriptionId ()

If this network is provisioned by a carrier, returns subscription Id corresponding to the associated SIM on the device. If this network is not provisioned by a carrier, returns SubscriptionManager.INVALID_SUBSCRIPTION_ID

Returns
int

See also:

getSupplicantState

public SupplicantState getSupplicantState ()

Return the detailed state of the supplicant's negotiation with an access point, in the form of a SupplicantState object.

Returns
SupplicantState the current SupplicantState

getTxLinkSpeedMbps

public int getTxLinkSpeedMbps ()

Returns the current transmit link speed in Mbps.

Returns
int the Tx link speed or LINK_SPEED_UNKNOWN if link speed is unknown. Value is -1 or greater

See also:

getWifiStandard

public int getWifiStandard ()

Get connection Wi-Fi standard

Returns
int the connection Wi-Fi standard Value is ScanResult.WIFI_STANDARD_UNKNOWN, ScanResult.WIFI_STANDARD_LEGACY, ScanResult.WIFI_STANDARD_11N, ScanResult.WIFI_STANDARD_11AC, ScanResult.WIFI_STANDARD_11AX, or ScanResult.WIFI_STANDARD_11AD

hashCode

public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java™ programming language.)

Returns
int a hash code value for this object.

makeCopy

public WifiInfo makeCopy (long redactions)

Create a copy of a WifiInfo with some fields redacted based on the permissions held by the receiving app.

Parameters
redactions long: bitmask of redactions that needs to be performed on this instance.

Returns
WifiInfo Copy of this instance with the necessary redactions. This value cannot be null.

toString

public String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.