Builder
class Builder
kotlin.Any | |
↳ | android.net.wifi.SoftApConfiguration.Builder |
Builds a SoftApConfiguration
, which allows an app to configure various aspects of a Soft AP. All fields are optional. By default, SSID and BSSID are automatically chosen by the framework, and an open network is created.
Summary
Public constructors | |
---|---|
Builder() Constructs a Builder with default values (see |
Public methods | |
---|---|
SoftApConfiguration |
build() Builds the |
SoftApConfiguration.Builder |
setBssid(bssid: MacAddress?) Specifies a BSSID for the AP. |
SoftApConfiguration.Builder |
setChannels(channels: SparseIntArray) Specifies the channels and associated bands for the APs. |
SoftApConfiguration.Builder |
setPassphrase(passphrase: String?, securityType: Int) Specifies that this AP should use specific security type with the given ASCII passphrase. |
SoftApConfiguration.Builder |
setWifiSsid(wifiSsid: WifiSsid?) Specifies an SSID for the AP in the form of WifiSsid. |
Public constructors
Public methods
build
fun build(): SoftApConfiguration
Builds the SoftApConfiguration
.
Return | |
---|---|
SoftApConfiguration |
A new SoftApConfiguration , as configured by previous method calls. This value cannot be null . |
setBssid
fun setBssid(bssid: MacAddress?): SoftApConfiguration.Builder
Specifies a BSSID for the AP.
setChannels(android.util.SparseIntArray)
, HAL will derive 2 MAC addresses since framework only sends down 1 MAC address. An example (but different implementation may perform a different mapping):
Use android.net.wifi.WifiManager.SoftApCallback#onCapabilityChanged(android.net.wifi.SoftApCapability) and SoftApCapability.areFeaturesSupported(long)
with SoftApCapability.SOFTAP_FEATURE_MAC_ADDRESS_CUSTOMIZATION to determine whether or not this feature is supported.
Callers without the listed permissions will not be able to start SoftAP with a non-null BSSID. DO and Carrier apps starting SoftAp with TetheringManager.startTethering
are exempted from this permission restriction.
Parameters | |
---|---|
bssid |
MacAddress?: BSSID, or null to have the BSSID chosen by the framework. The caller is responsible for avoiding collisions. |
Return | |
---|---|
SoftApConfiguration.Builder |
Builder for chaining. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
when the given BSSID is the all-zero, multicast or broadcast MAC address. |
setChannels
fun setChannels(channels: SparseIntArray): SoftApConfiguration.Builder
Specifies the channels and associated bands for the APs.
The API contains (band, channel) input since the 6GHz band uses the same channel numbering scheme as is used in the 2.4GHz and 5GHz band. Therefore, both are needed to uniquely identify individual channels.
Reference the Wi-Fi channel numbering and the channelization in IEEE 802.11-2016 specifications, section 17.3.8.4.2, 17.3.8.4.3 and Table 15-6.
Using the special value 0 which has the framework auto-select a valid channel from the band configured. When more than 1 channel/band is set, this will bring up concurrent APs on the requested channels and bands (if possible). Use WifiManager.isBridgedApConcurrencySupported()
to determine whether concurrent APs are supported. If not set, the default value is BAND_2GHZ
with the special channel value 0 which has the framework auto-select from BAND_2GHZ
.
Parameters | |
---|---|
channels |
SparseIntArray: SparseIntArray (key: BandType , value: channel) consists of BAND_ and corresponding channel. This value cannot be null . |
Return | |
---|---|
SoftApConfiguration.Builder |
Builder for chaining. This value cannot be null . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
when more than 2 channels are set or the invalid channel or band type is configured. |
setPassphrase
fun setPassphrase(
passphrase: String?,
securityType: Int
): SoftApConfiguration.Builder
Specifies that this AP should use specific security type with the given ASCII passphrase.
Parameters | |
---|---|
securityType |
Int: One of the following security types: SECURITY_TYPE_OPEN , SECURITY_TYPE_WPA2_PSK , SECURITY_TYPE_WPA3_SAE_TRANSITION , SECURITY_TYPE_WPA3_SAE , SECURITY_TYPE_WPA3_OWE_TRANSITION , SECURITY_TYPE_WPA3_OWE . Value is android.net.wifi.SoftApConfiguration#SECURITY_TYPE_OPEN , android.net.wifi.SoftApConfiguration#SECURITY_TYPE_WPA2_PSK , android.net.wifi.SoftApConfiguration#SECURITY_TYPE_WPA3_SAE_TRANSITION , android.net.wifi.SoftApConfiguration#SECURITY_TYPE_WPA3_SAE , android.net.wifi.SoftApConfiguration#SECURITY_TYPE_WPA3_OWE_TRANSITION , or android.net.wifi.SoftApConfiguration#SECURITY_TYPE_WPA3_OWE |
passphrase |
String?: The passphrase to use for sepcific securityType configuration or null with SECURITY_TYPE_OPEN , SECURITY_TYPE_WPA3_OWE_TRANSITION , and SECURITY_TYPE_WPA3_OWE . |
Return | |
---|---|
SoftApConfiguration.Builder |
Builder for chaining. This value cannot be null . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
before android.os.Build.VERSION_CODES#TIRAMISU ) when the passphrase is not between 8 and 63 bytes (inclusive) for - SECURITY_TYPE_WPA2_PSK - SECURITY_TYPE_WPA3_SAE_TRANSITION |
setWifiSsid
fun setWifiSsid(wifiSsid: WifiSsid?): SoftApConfiguration.Builder
Specifies an SSID for the AP in the form of WifiSsid.
Null SSID only support when configure a local-only hotspot.
Parameters | |
---|---|
wifiSsid |
WifiSsid?: SSID, or null ot have the SSID automatically chosen by the framework. |
Return | |
---|---|
SoftApConfiguration.Builder |
Builder for chaining. |