WifiInfo
open class WifiInfo : Parcelable, TransportInfo
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 | |
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! |
getBSSID() 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! |
getDetailedStateOf(suppState: SupplicantState!) Map a supplicant state into a fine-grained network connectivity state. |
open Int |
Returns the current frequency in |
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 |
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 |
getRssi() Returns the received signal strength indicator of the current 802. |
open Int |
Returns the current receive link speed in Mbps. |
open String! |
getSSID() 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 |
open Int |
Returns the current transmit link speed in Mbps. |
open Int |
Get connection Wi-Fi standard |
open Int |
hashCode() |
open Boolean |
Returns true if the current Wifi network is a restricted network, false otherwise. |
open WifiInfo |
Create a copy of a |
open String |
toString() |
open Unit |
writeToParcel(dest: Parcel, flags: Int) Implement the Parcelable interface {@hide} |
Constants
FREQUENCY_UNITS
static val FREQUENCY_UNITS: String
Frequency in MHz
Value: "MHz"
LINK_SPEED_UNITS
static val LINK_SPEED_UNITS: String
The unit in which links speeds are expressed.
Value: "Mbps"
LINK_SPEED_UNKNOWN
static val LINK_SPEED_UNKNOWN: Int
Constant for unknown link speed.
Value: -1
SECURITY_TYPE_DPP
static val SECURITY_TYPE_DPP: Int
Security type for Easy Connect (DPP) network
Value: 13
SECURITY_TYPE_EAP
static val SECURITY_TYPE_EAP: Int
Security type for an EAP network.
Value: 3
SECURITY_TYPE_EAP_WPA3_ENTERPRISE
static val SECURITY_TYPE_EAP_WPA3_ENTERPRISE: Int
Security type for a WPA3-Enterprise network.
Value: 9
SECURITY_TYPE_EAP_WPA3_ENTERPRISE_192_BIT
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
static val SECURITY_TYPE_OPEN: Int
Security type for an open network.
Value: 0
SECURITY_TYPE_OSEN
static val SECURITY_TYPE_OSEN: Int
Security type for an OSEN network.
Value: 10
SECURITY_TYPE_OWE
static val SECURITY_TYPE_OWE: Int
Security type for an OWE network.
Value: 6
SECURITY_TYPE_PASSPOINT_R1_R2
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
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
static val SECURITY_TYPE_PSK: Int
Security type for a PSK network.
Value: 2
SECURITY_TYPE_SAE
static val SECURITY_TYPE_SAE: Int
Security type for an SAE network.
Value: 4
SECURITY_TYPE_UNKNOWN
static val SECURITY_TYPE_UNKNOWN: Int
Unknown security type.
Value: -1
SECURITY_TYPE_WAPI_CERT
static val SECURITY_TYPE_WAPI_CERT: Int
Security type for a WAPI Certificate network.
Value: 8
SECURITY_TYPE_WAPI_PSK
static val SECURITY_TYPE_WAPI_PSK: Int
Security type for a WAPI PSK network.
Value: 7
SECURITY_TYPE_WEP
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
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. |
getAffiliatedMloLinks
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
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
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
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. |
getAssociatedMloLinks
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
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 |
getCurrentSecurityType
open fun getCurrentSecurityType(): Int
Returns the security type of the current 802.11 network connection.
getDetailedStateOf
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
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
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
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
open fungetIpAddress(): Int
Deprecated: Use the methods on android.net.LinkProperties
which can be obtained either via NetworkCallback.onLinkPropertiesChanged(Network, LinkProperties)
or ConnectivityManager.getLinkProperties(Network)
.
getLinkSpeed
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. |
See Also
getMacAddress
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
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
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
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
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
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
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
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
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 |
See Also
getSSID
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
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
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
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 |
See Also
getWifiStandard
open fun getWifiStandard(): Int
Get connection Wi-Fi standard
hashCode
open fun hashCode(): Int
Return | |
---|---|
Int |
a hash code value for this object. |
isRestricted
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
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
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 |