WifiP2pConfig.Builder
public
static
final
class
WifiP2pConfig.Builder
extends Object
java.lang.Object | |
↳ | android.net.wifi.p2p.WifiP2pConfig.Builder |
Builder used to build WifiP2pConfig
objects for
creating or joining a group.
The WifiP2pConfig can be constructed for two use-cases:
- SSID + Passphrase are known: use
setNetworkName(java.lang.String)
andsetPassphrase(java.lang.String)
. - SSID or Passphrase is unknown, in such a case the MAC address must be known and
specified using
setDeviceAddress(android.net.MacAddress)
.
Summary
Public constructors | |
---|---|
Builder()
|
Public methods | |
---|---|
WifiP2pConfig
|
build()
Build |
WifiP2pConfig.Builder
|
enablePersistentMode(boolean persistent)
Specify that the group configuration be persisted (i.e. |
WifiP2pConfig.Builder
|
setDeviceAddress(MacAddress deviceAddress)
Specify the peer's MAC address. |
WifiP2pConfig.Builder
|
setGroupClientIpProvisioningMode(int groupClientIpProvisioningMode)
Specify the IP provisioning mode when joining a group as a group client. |
WifiP2pConfig.Builder
|
setGroupOperatingBand(int band)
Specify the band to use for creating the group or joining the group. |
WifiP2pConfig.Builder
|
setGroupOperatingFrequency(int frequency)
Specify the frequency, in MHz, to use for creating the group or joining the group. |
WifiP2pConfig.Builder
|
setNetworkName(String networkName)
Specify the network name, a.k.a. |
WifiP2pConfig.Builder
|
setPairingBootstrappingConfig(WifiP2pPairingBootstrappingConfig config)
Set the pairing bootstrapping configuration for connecting using P2P pairing Protocol. |
WifiP2pConfig.Builder
|
setPassphrase(String passphrase)
Specify the passphrase for creating or joining a group. |
WifiP2pConfig.Builder
|
setPccModeConnectionType(int connectionType)
Specifies the PCC Mode connection type. |
Inherited methods | |
---|---|
Public constructors
Public methods
build
public WifiP2pConfig build ()
Build WifiP2pConfig
given the current requests made on the builder.
Returns | |
---|---|
WifiP2pConfig |
WifiP2pConfig constructed based on builder method calls.
This value cannot be null . |
enablePersistentMode
public WifiP2pConfig.Builder enablePersistentMode (boolean persistent)
Specify that the group configuration be persisted (i.e. saved). By default the group configuration will not be saved.
Optional. false by default.
Parameters | |
---|---|
persistent |
boolean : is this group persistent group. |
Returns | |
---|---|
WifiP2pConfig.Builder |
The builder to facilitate chaining
builder.setXXX(..).setXXX(..) .
This value cannot be null . |
setDeviceAddress
public WifiP2pConfig.Builder setDeviceAddress (MacAddress deviceAddress)
Specify the peer's MAC address. If not set, the device will
try to find a peer whose SSID matches the network name as
specified by setNetworkName(java.lang.String)
. Specifying null will
reset the peer's MAC address to "02:00:00:00:00:00".
Optional. "02:00:00:00:00:00" by default.
If the network name is not set, the peer's MAC address is mandatory.
Parameters | |
---|---|
deviceAddress |
MacAddress : the peer's MAC address.
This value may be null . |
Returns | |
---|---|
WifiP2pConfig.Builder |
The builder to facilitate chaining
builder.setXXX(..).setXXX(..) . |
setGroupClientIpProvisioningMode
public WifiP2pConfig.Builder setGroupClientIpProvisioningMode (int groupClientIpProvisioningMode)
Specify the IP provisioning mode when joining a group as a group client. The IP
provisioning mode should be WifiP2pConfig.GROUP_CLIENT_IP_PROVISIONING_MODE_IPV4_DHCP
or
WifiP2pConfig.GROUP_CLIENT_IP_PROVISIONING_MODE_IPV6_LINK_LOCAL
.
When joining a group as group client using WifiP2pManager.connect(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pConfig, android.net.wifi.p2p.WifiP2pManager.ActionListener)
,
specifying WifiP2pConfig.GROUP_CLIENT_IP_PROVISIONING_MODE_IPV4_DHCP
directs the system to
assign a IPv4 to the group client using DHCP. Specifying
WifiP2pConfig.GROUP_CLIENT_IP_PROVISIONING_MODE_IPV6_LINK_LOCAL
directs the system to assign
a link-local IPv6 to the group client.
Optional. WifiP2pConfig.GROUP_CLIENT_IP_PROVISIONING_MODE_IPV4_DHCP
by default.
If WifiP2pManager.isGroupOwnerIPv6LinkLocalAddressProvided()
is true
and
WifiP2pConfig.GROUP_CLIENT_IP_PROVISIONING_MODE_IPV6_LINK_LOCAL
is used then the system will
discover the group owner's IPv6 link-local address and broadcast it using the
WifiP2pManager.EXTRA_WIFI_P2P_INFO
extra of the
WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION
broadcast. Otherwise, if
WifiP2pManager.isGroupOwnerIPv6LinkLocalAddressProvided()
is
false
then the group owner's IPv6 link-local address is not discovered and it is
the responsibility of the caller to obtain it in some other way, e.g. via out-of-band
communication.
Parameters | |
---|---|
groupClientIpProvisioningMode |
int : the IP provisioning mode of the group client.
This should be one of WifiP2pConfig.GROUP_CLIENT_IP_PROVISIONING_MODE_IPV4_DHCP ,
WifiP2pConfig.GROUP_CLIENT_IP_PROVISIONING_MODE_IPV6_LINK_LOCAL .
Value is WifiP2pConfig.GROUP_CLIENT_IP_PROVISIONING_MODE_IPV4_DHCP , or WifiP2pConfig.GROUP_CLIENT_IP_PROVISIONING_MODE_IPV6_LINK_LOCAL |
Returns | |
---|---|
WifiP2pConfig.Builder |
The builder to facilitate chaining
builder.setXXX(..).setXXX(..) .
This value cannot be null . |
setGroupOperatingBand
public WifiP2pConfig.Builder setGroupOperatingBand (int band)
Specify the band to use for creating the group or joining the group. The band should
be WifiP2pConfig.GROUP_OWNER_BAND_2GHZ
, WifiP2pConfig.GROUP_OWNER_BAND_5GHZ
or
WifiP2pConfig.GROUP_OWNER_BAND_6GHZ
or WifiP2pConfig.GROUP_OWNER_BAND_AUTO
.
When creating a group as Group Owner using WifiP2pManager.createGroup(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pConfig, android.net.wifi.p2p.WifiP2pManager.ActionListener)
,
specifying WifiP2pConfig.GROUP_OWNER_BAND_AUTO
allows the system to pick the operating
frequency from all supported bands.
Specifying WifiP2pConfig.GROUP_OWNER_BAND_2GHZ
or WifiP2pConfig.GROUP_OWNER_BAND_5GHZ
or
WifiP2pConfig.GROUP_OWNER_BAND_6GHZ
only allows the system to pick the operating frequency in the specified band.
If the Group Owner cannot create a group in the specified band, the operation will fail.
When joining a group as Group Client using WifiP2pManager.connect(android.net.wifi.p2p.WifiP2pManager.Channel, android.net.wifi.p2p.WifiP2pConfig, android.net.wifi.p2p.WifiP2pManager.ActionListener)
,
specifying WifiP2pConfig.GROUP_OWNER_BAND_AUTO
allows the system to scan all supported
frequencies to find the desired group. Specifying WifiP2pConfig.GROUP_OWNER_BAND_2GHZ
or
WifiP2pConfig.GROUP_OWNER_BAND_5GHZ
or WifiP2pConfig.GROUP_OWNER_BAND_6GHZ
only allows the
system to scan the specified band.
setGroupOperatingBand(int)
and setGroupOperatingFrequency(int)
are
mutually exclusive. Setting operating band and frequency both is invalid.
Optional. WifiP2pConfig.GROUP_OWNER_BAND_AUTO
by default.
Parameters | |
---|---|
band |
int : the operating band of the group.
This should be one of WifiP2pConfig.GROUP_OWNER_BAND_AUTO ,
WifiP2pConfig.GROUP_OWNER_BAND_2GHZ , WifiP2pConfig.GROUP_OWNER_BAND_5GHZ ,
WifiP2pConfig.GROUP_OWNER_BAND_6GHZ .
Value is WifiP2pConfig.GROUP_OWNER_BAND_AUTO , WifiP2pConfig.GROUP_OWNER_BAND_2GHZ , WifiP2pConfig.GROUP_OWNER_BAND_5GHZ , or WifiP2pConfig.GROUP_OWNER_BAND_6GHZ |
Returns | |
---|---|
WifiP2pConfig.Builder |
The builder to facilitate chaining
builder.setXXX(..).setXXX(..) .
This value cannot be null . |
setGroupOperatingFrequency
public WifiP2pConfig.Builder setGroupOperatingFrequency (int frequency)
Specify the frequency, in MHz, to use for creating the group or joining the group.
When creating a group as Group Owner using WifiP2pManager.createGroup(
WifiP2pManager.Channel, WifiP2pConfig, WifiP2pManager.ActionListener)
,
specifying a frequency only allows the system to pick the specified frequency.
If the Group Owner cannot create a group at the specified frequency,
the operation will fail.
When not specifying a frequency, it allows the system to pick operating frequency
from all supported bands.
When joining a group as Group Client using WifiP2pManager.connect(
WifiP2pManager.Channel, WifiP2pConfig, WifiP2pManager.ActionListener)
,
specifying a frequency only allows the system to scan the specified frequency.
If the frequency is not supported or invalid, the operation will fail.
When not specifying a frequency, it allows the system to scan all supported
frequencies to find the desired group.
setGroupOperatingBand(int)
and setGroupOperatingFrequency(int)
are
mutually exclusive. Setting operating band and frequency both is invalid.
Optional. 0 by default.
Parameters | |
---|---|
frequency |
int : the operating frequency of the group. |
Returns | |
---|---|
WifiP2pConfig.Builder |
The builder to facilitate chaining
builder.setXXX(..).setXXX(..) .
This value cannot be null . |
setNetworkName
public WifiP2pConfig.Builder setNetworkName (String networkName)
Specify the network name, a.k.a. group name, for creating or joining a group.
A network name shall begin with "DIRECT-xy". x and y are selected from the following character set: upper case letters, lower case letters and numbers. Any byte values allowed for an SSID according to IEEE802.11-2012 [1] may be included after the string "DIRECT-xy" (including none).
Must be called - an empty network name or an network name not conforming to the P2P Group ID naming rule is not valid.
Parameters | |
---|---|
networkName |
String : network name of a group.
This value cannot be null . |
Returns | |
---|---|
WifiP2pConfig.Builder |
The builder to facilitate chaining
builder.setXXX(..).setXXX(..) .
This value cannot be null . |
setPairingBootstrappingConfig
public WifiP2pConfig.Builder setPairingBootstrappingConfig (WifiP2pPairingBootstrappingConfig config)
Set the pairing bootstrapping configuration for connecting using P2P pairing Protocol.
Parameters | |
---|---|
config |
WifiP2pPairingBootstrappingConfig : See WifiP2pPairingBootstrappingConfig
This value cannot be null . |
Returns | |
---|---|
WifiP2pConfig.Builder |
The builder to facilitate chaining builder.setXXX(..).setXXX(..) .
This value cannot be null . |
setPassphrase
public WifiP2pConfig.Builder setPassphrase (String passphrase)
Specify the passphrase for creating or joining a group.
The passphrase must be an ASCII string whose length is,
1. Between 8 and 63 for WifiP2pConfig.PCC_MODE_CONNECTION_TYPE_LEGACY_ONLY
and
WifiP2pConfig.PCC_MODE_CONNECTION_TYPE_LEGACY_OR_R2
.
2. Less than 128 for WifiP2pConfig.PCC_MODE_CONNECTION_TYPE_R2_ONLY
.
Must be called - an empty passphrase is not valid.
Parameters | |
---|---|
passphrase |
String : the passphrase of a group.
This value cannot be null . |
Returns | |
---|---|
WifiP2pConfig.Builder |
The builder to facilitate chaining
builder.setXXX(..).setXXX(..) .
This value cannot be null . |
setPccModeConnectionType
public WifiP2pConfig.Builder setPccModeConnectionType (int connectionType)
Specifies the PCC Mode connection type.
Parameters | |
---|---|
connectionType |
int : One of the PCC_MODE_CONNECTION_TYPE_* .
Value is android.net.wifi.p2p.WifiP2pConfig.PCC_MODE_DEFAULT_CONNECTION_TYPE_LEGACY_ONLY, WifiP2pConfig.PCC_MODE_CONNECTION_TYPE_LEGACY_ONLY , WifiP2pConfig.PCC_MODE_CONNECTION_TYPE_LEGACY_OR_R2 , or WifiP2pConfig.PCC_MODE_CONNECTION_TYPE_R2_ONLY |
Returns | |
---|---|
WifiP2pConfig.Builder |
Builder for chaining.
This value cannot be null . |
Throws | |
---|---|
IllegalArgumentException |
when the connectionType is invalid. |