Added in API level 1

WifiInfo


open class WifiInfo : TransportInfo, Parcelable
kotlin.Any
   ↳ 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". getApMldMacAddress() will return null. 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

Builder for WifiInfo

Constants
static String

Frequency in MHz

static String

The unit in which links speeds are expressed.

static Int

Constant for unknown link speed.

static Int

Security type for Easy Connect (DPP) network

static Int

Security type for an EAP network.

static Int

Security type for a WPA3-Enterprise network.

static Int

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

static Int

Security type for an open network.

static Int

Security type for an OSEN network.

static Int

Security type for an OWE network.

static Int

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

static Int

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

static Int

Security type for a PSK network.

static Int

Security type for an SAE network.

static Int

Unknown security type.

static Int

Security type for a WAPI Certificate network.

static Int

Security type for a WAPI PSK network.

static Int

Security type for a WEP network.

Inherited constants
Public methods
open Int

Implement the Parcelable interface {@hide}

open Boolean
equals(other: Any?)

open MutableList<MloLink!>

Return the Multi-Link Operation (MLO) affiliated Links for Wi-Fi 7 access points.

open MacAddress?

Return the Multi-Link Device (MLD) MAC Address for the connected access point.

open Int

Return the access point Multi-Link Operation (MLO) link-id for Wi-Fi 7 access points.

open Long

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

open MutableList<MloLink!>

Return the associated Multi-Link Operation (MLO) Links for Wi-Fi 7 access points.

open String!

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

open Int

Returns the security type of the current 802.

open static NetworkInfo.DetailedState!

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

open Int

Returns the current frequency in FREQUENCY_UNITS.

open Boolean

open MutableList<ScanResult.InformationElement!>?

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

open Int

open Int

Returns the current link speed in LINK_SPEED_UNITS.

open String!

Returns the MAC address used for this connection.

open Int

Returns the maximum supported receive link speed in Mbps

open Int

Returns the maximum supported transmit link speed in Mbps

open Int

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

open String?

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

open String?

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

open String?

Get the Passpoint unique identifier for the current connection

open Int

Returns the received signal strength indicator of the current 802.

open Int

Returns the current receive link speed in Mbps.

open String!

Returns the service set identifier (SSID) of the current 802.

open Int

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

open SupplicantState!

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

open Int

Returns the current transmit link speed in Mbps.

open Int

Get connection Wi-Fi standard

open Int

open Boolean

Returns true if the current Wifi network is a restricted network, false otherwise.

open WifiInfo
makeCopy(redactions: Long)

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

open String

open Unit
writeToParcel(dest: Parcel, flags: Int)

Implement the Parcelable interface {@hide}

Constants

FREQUENCY_UNITS

Added in API level 21
static val FREQUENCY_UNITS: String

Frequency in MHz

Value: "MHz"
Added in API level 1
static val LINK_SPEED_UNITS: String

The unit in which links speeds are expressed.

Value: "Mbps"
Added in API level 29
static val LINK_SPEED_UNKNOWN: Int

Constant for unknown link speed.

Value: -1

SECURITY_TYPE_DPP

Added in API level 33
static val SECURITY_TYPE_DPP: Int

Security type for Easy Connect (DPP) network

Value: 13

SECURITY_TYPE_EAP

Added in API level 31
static val SECURITY_TYPE_EAP: Int

Security type for an EAP network.

Value: 3

SECURITY_TYPE_EAP_WPA3_ENTERPRISE

Added in API level 31
static val SECURITY_TYPE_EAP_WPA3_ENTERPRISE: Int

Security type for a WPA3-Enterprise network.

Value: 9

SECURITY_TYPE_EAP_WPA3_ENTERPRISE_192_BIT

Added in API level 31
static val SECURITY_TYPE_EAP_WPA3_ENTERPRISE_192_BIT: Int

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

Value: 5

SECURITY_TYPE_OPEN

Added in API level 31
static val SECURITY_TYPE_OPEN: Int

Security type for an open network.

Value: 0

SECURITY_TYPE_OSEN

Added in API level 31
static val SECURITY_TYPE_OSEN: Int

Security type for an OSEN network.

Value: 10

SECURITY_TYPE_OWE

Added in API level 31
static val SECURITY_TYPE_OWE: Int

Security type for an OWE network.

Value: 6

SECURITY_TYPE_PASSPOINT_R1_R2

Added in API level 31
static val SECURITY_TYPE_PASSPOINT_R1_R2: Int

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

Value: 11

SECURITY_TYPE_PASSPOINT_R3

Added in API level 31
static val SECURITY_TYPE_PASSPOINT_R3: Int

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

Value: 12

SECURITY_TYPE_PSK

Added in API level 31
static val SECURITY_TYPE_PSK: Int

Security type for a PSK network.

Value: 2

SECURITY_TYPE_SAE

Added in API level 31
static val SECURITY_TYPE_SAE: Int

Security type for an SAE network.

Value: 4

SECURITY_TYPE_UNKNOWN

Added in API level 31
static val SECURITY_TYPE_UNKNOWN: Int

Unknown security type.

Value: -1

SECURITY_TYPE_WAPI_CERT

Added in API level 31
static val SECURITY_TYPE_WAPI_CERT: Int

Security type for a WAPI Certificate network.

Value: 8

SECURITY_TYPE_WAPI_PSK

Added in API level 31
static val SECURITY_TYPE_WAPI_PSK: Int

Security type for a WAPI PSK network.

Value: 7

SECURITY_TYPE_WEP

Added in API level 31
static val SECURITY_TYPE_WEP: Int

Security type for a WEP network.

Value: 1

Public methods

describeContents

open fun describeContents(): Int

Implement the Parcelable interface {@hide}

Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 1
open fun equals(other: Any?): Boolean
Parameters
obj the reference object with which to compare.
Return
Boolean true if this object is the same as the obj argument; false otherwise.
Added in API level 33
open fun getAffiliatedMloLinks(): MutableList<MloLink!>

Return the Multi-Link Operation (MLO) affiliated Links for Wi-Fi 7 access points. i.e. when getWifiStandard() returns ScanResult#WIFI_STANDARD_11BE. Affiliated links are the links supported by the Access Point Multi Link Device (AP MLD). The Station Multi Link Device (STA MLD) gathers affiliated link information from scan results. Depending on Station's capability, it associates to all or a subset of affiliated links.

Note:getAssociatedMloLinks() returns associated links.

Return
MutableList<MloLink!> List of affiliated MLO links, or an empty list if access point is not Wi-Fi 7 This value cannot be null.

getApMldMacAddress

Added in API level 33
open fun getApMldMacAddress(): MacAddress?

Return the Multi-Link Device (MLD) MAC Address for the connected access point.

The returned MLD MAC Address will be null in the following cases: There is no network currently connected The connected access point is not an MLD access point, i.e. getWifiStandard() returns ScanResult#WIFI_STANDARD_11BE. The caller has insufficient permissions to access the access point MLD MAC Address.

Return
MacAddress? the MLD Mac address

getApMloLinkId

Added in API level 33
open fun getApMloLinkId(): Int

Return the access point Multi-Link Operation (MLO) link-id for Wi-Fi 7 access points. i.e. getWifiStandard() returns ScanResult#WIFI_STANDARD_11BE, otherwise return MloLink#INVALID_MLO_LINK_ID. Valid values are 0-15 as described in IEEE 802.11be Specification, section 9.4.2.295b.2.

Return
Int MloLink#INVALID_MLO_LINK_ID or a valid value (0-15). Value is between MloLink.INVALID_MLO_LINK_ID and MloLink.MAX_MLO_LINK_ID inclusive

getApplicableRedactions

Added in API level 31
open fun getApplicableRedactions(): Long

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

Return
Long bitmask of redactions applicable on this instance.
Added in API level 34
open fun getAssociatedMloLinks(): MutableList<MloLink!>

Return the associated Multi-Link Operation (MLO) Links for Wi-Fi 7 access points. i.e. when getWifiStandard() returns ScanResult#WIFI_STANDARD_11BE. Affiliated links are the links supported by the Access Point Multi Link Device (AP MLD). The Station Multi Link Device (STA MLD) gathers affiliated link information from scan results. Depending on Station's capability, it associates to all or a subset of affiliated links.

Note:getAffiliatedMloLinks() returns affiliated links.

Return
MutableList<MloLink!> List of associated MLO links, or an empty list if access point is not a multi-link device. This value cannot be null.

getBSSID

Added in API level 1
open fun getBSSID(): String!

Return the basic service set identifier (BSSID) of the current access point. In case of Multi Link Operation (MLO), the BSSID corresponds to the BSSID of the link used for association.

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.

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

getDetailedStateOf

Added in API level 1
open static fun getDetailedStateOf(suppState: SupplicantState!): NetworkInfo.DetailedState!

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

Parameters
suppState SupplicantState!: the supplicant state
Return
NetworkInfo.DetailedState! the corresponding DetailedState

getFrequency

Added in API level 21
open fun getFrequency(): Int

Returns the current frequency in FREQUENCY_UNITS. In case of Multi Link Operation (MLO), returned value is the frequency of the associated link with the highest RSSI.

Return
Int the frequency.

See Also

getHiddenSSID

Added in API level 1
open fun getHiddenSSID(): Boolean
Return
Boolean true if this network does not broadcast its SSID, so an SSID-specific probe request must be used for scans.

getInformationElements

Added in API level 31
open fun getInformationElements(): MutableList<ScanResult.InformationElement!>?

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.

Return
MutableList<ScanResult.InformationElement!>? List of information elements ScanResult.InformationElement or null.

getIpAddress

Added in API level 1
Deprecated in API level 31
open fun getIpAddress(): Int

Deprecated: Use the methods on android.net.LinkProperties which can be obtained either via NetworkCallback#onLinkPropertiesChanged(Network, LinkProperties) or ConnectivityManager#getLinkProperties(Network).

getLinkSpeed

Added in API level 1
open fun getLinkSpeed(): Int

Returns the current link speed in LINK_SPEED_UNITS. In case of Multi Link Operation (MLO), returned value is the current link speed of the associated link with the highest RSSI.

Return
Int the link speed or LINK_SPEED_UNKNOWN if link speed is unknown.

getMacAddress

Added in API level 1
open fun getMacAddress(): String!

Returns the MAC address used for this connection. In case of Multi Link Operation (MLO), returned value is the Station MLD MAC address.

Return
String! MAC address of the connection or "02:00:00:00:00:00" if the caller has insufficient permission. Requires android.Manifest.permission#LOCAL_MAC_ADDRESS and android.Manifest.permission#ACCESS_FINE_LOCATION.

getMaxSupportedRxLinkSpeedMbps

Added in API level 30
open fun getMaxSupportedRxLinkSpeedMbps(): Int

Returns the maximum supported receive link speed in Mbps

Return
Int the max supported Rx link speed or LINK_SPEED_UNKNOWN if link speed is unknown. @see #LINK_SPEED_UNKNOWN

getMaxSupportedTxLinkSpeedMbps

Added in API level 30
open fun getMaxSupportedTxLinkSpeedMbps(): Int

Returns the maximum supported transmit link speed in Mbps

Return
Int the max supported tx link speed or LINK_SPEED_UNKNOWN if link speed is unknown. @see #LINK_SPEED_UNKNOWN

getNetworkId

Added in API level 1
open fun getNetworkId(): Int

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.

Return
Int the network ID.

getPasspointFqdn

Added in API level 29
open fun getPasspointFqdn(): String?

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.

getPasspointProviderFriendlyName

Added in API level 29
open fun getPasspointProviderFriendlyName(): String?

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.

getPasspointUniqueId

Added in API level 35
open fun getPasspointUniqueId(): String?

Get the Passpoint unique identifier for the current connection

Return
String? Passpoint unique identifier, or null if this connection is not Passpoint.

getRssi

Added in API level 1
open fun getRssi(): Int

Returns the received signal strength indicator of the current 802.11 network, in dBm. In case of Multi Link Operation (MLO), returned RSSI is the highest of all associated links.

Use android.net.wifi.WifiManager#calculateSignalLevel to convert this number into an absolute signal level which can be displayed to a user.

Return
Int the RSSI.

getRxLinkSpeedMbps

Added in API level 29
open fun getRxLinkSpeedMbps(): Int

Returns the current receive link speed in Mbps. In case of Multi Link Operation (MLO), returned value is the receive link speed of the associated link with the highest RSSI.

Return
Int the Rx link speed or LINK_SPEED_UNKNOWN if link speed is unknown. Value is -1 or greater

getSSID

Added in API level 1
open fun getSSID(): String!

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 android.os.Build.VERSION_CODES#JELLY_BEAN_MR1, this method always returned the SSID with no quotes around it.

Return
String! the SSID.

getSubscriptionId

Added in API level 31
open fun getSubscriptionId(): Int

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 android.telephony.SubscriptionManager#INVALID_SUBSCRIPTION_ID

getSupplicantState

Added in API level 1
open fun getSupplicantState(): SupplicantState!

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

Return
SupplicantState! the current SupplicantState

getTxLinkSpeedMbps

Added in API level 29
open fun getTxLinkSpeedMbps(): Int

Returns the current transmit link speed in Mbps. In case of Multi Link Operation (MLO), returned value is the current transmit link speed of the associated link with the highest RSSI.

Return
Int the Tx link speed or LINK_SPEED_UNKNOWN if link speed is unknown. Value is -1 or greater

hashCode

Added in API level 1
open fun hashCode(): Int
Return
Int a hash code value for this object.

isRestricted

Added in API level 33
open fun isRestricted(): Boolean

Returns true if the current Wifi network is a restricted network, false otherwise. A restricted network has its NetworkCapabilities#NET_CAPABILITY_NOT_RESTRICTED capability removed.

makeCopy

Added in API level 31
open fun makeCopy(redactions: Long): WifiInfo

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.
Return
WifiInfo Copy of this instance with the necessary redactions. This value cannot be null.

toString

Added in API level 1
open fun toString(): String
Return
String a string representation of the object.

writeToParcel

open fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit

Implement the Parcelable interface {@hide}

Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES