WifiP2pConfig
public class WifiP2pConfig
extends Object
implements Parcelable
java.lang.Object | |
↳ | android.net.wifi.p2p.WifiP2pConfig |
A class representing a Wi-Fi P2p configuration for setting up a connection
See also:
Summary
Nested classes | |
---|---|
class | WifiP2pConfig.Builder Builder used to build |
Constants | |
---|---|
int | GROUP_CLIENT_IP_PROVISIONING_MODE_IPV4_DHCP IP provisioning via IPv4 DHCP, when joining a group as a group client. |
int | GROUP_CLIENT_IP_PROVISIONING_MODE_IPV6_LINK_LOCAL IP provisioning via IPv6 link-local, when joining a group as a group client. |
int | GROUP_OWNER_BAND_2GHZ Allow the system to pick the operating frequency from the 2.4 GHz band. |
int | GROUP_OWNER_BAND_5GHZ Allow the system to pick the operating frequency from the 5 GHz band. |
int | GROUP_OWNER_BAND_6GHZ Allow the system to pick the operating frequency from the 6 GHz band. |
int | GROUP_OWNER_BAND_AUTO Allow the system to pick the operating frequency from all supported bands. |
int | GROUP_OWNER_INTENT_AUTO The system can choose an appropriate owner intent value, to be filled in the field |
int | GROUP_OWNER_INTENT_MAX The most inclination to be a group owner, to be filled in the field |
int | GROUP_OWNER_INTENT_MIN The least inclination to be a group owner, to be filled in the field |
int | P2P_VERSION_1 P2P Protocol version 1 |
int | P2P_VERSION_2 P2P Protocol version 2 |
int | PCC_MODE_CONNECTION_TYPE_LEGACY_ONLY Legacy connection type. |
int | PCC_MODE_CONNECTION_TYPE_LEGACY_OR_R2 Wi-Fi Direct R1/R2 compatible mode connection type. |
int | PCC_MODE_CONNECTION_TYPE_R2_ONLY This configuration allows only Wi-Fi Direct R2 supported devices to establish connection. |
Inherited constants |
---|
Fields | |
---|---|
public static final Creator<WifiP2pConfig> | CREATOR Implement the Parcelable interface |
public String | deviceAddress The device MAC address uniquely identifies a Wi-Fi p2p device |
public int | groupOwnerIntent This is an integer value between |
public WpsInfo | wps Wi-Fi Protected Setup information |
Public constructors | |
---|---|
WifiP2pConfig() | |
WifiP2pConfig(WifiP2pConfig source) copy constructor |
Public methods | |
---|---|
int | describeContents() Implement the Parcelable interface |
int | getGroupClientIpProvisioningMode() Get the IP provisioning mode when joining a group as a group client. |
int | getGroupOwnerBand() Get the required band for the group owner. |
int | getGroupOwnerVersion() Get the P2P Group Owner version. |
int | getNetworkId() Get the network ID of this P2P configuration. |
String | getNetworkName() Get the network name of this P2P configuration, or null if unset. |
WifiP2pPairingBootstrappingConfig | getPairingBootstrappingConfig() Get the pairing bootstrapping configuration , or null if unset. |
String | getPassphrase() Get the passphrase of this P2P configuration, or null if unset. |
int | getPccModeConnectionType() Get the PCC Mode connection type. |
boolean | isAuthorizeConnectionFromPeerEnabled() Query to check if the configuration is for authorizing a connection request from the peer device. |
void | setGroupOwnerVersion(int version) Set the P2P Group Owner version. |
String | toString() Returns a string representation of the object. |
void | writeToParcel(Parcel dest, int flags) Implement the Parcelable interface |
Inherited methods | |
---|---|
Constants
GROUP_CLIENT_IP_PROVISIONING_MODE_IPV4_DHCP
public static final int GROUP_CLIENT_IP_PROVISIONING_MODE_IPV4_DHCP
IP provisioning via IPv4 DHCP, when joining a group as a group client.
Constant Value: 0 (0x00000000)
GROUP_CLIENT_IP_PROVISIONING_MODE_IPV6_LINK_LOCAL
public static final int GROUP_CLIENT_IP_PROVISIONING_MODE_IPV6_LINK_LOCAL
IP provisioning via IPv6 link-local, when joining a group as a group client.
Constant Value: 1 (0x00000001)
GROUP_OWNER_BAND_2GHZ
public static final int GROUP_OWNER_BAND_2GHZ
Allow the system to pick the operating frequency from the 2.4 GHz band.
Constant Value: 1 (0x00000001)
GROUP_OWNER_BAND_5GHZ
public static final int GROUP_OWNER_BAND_5GHZ
Allow the system to pick the operating frequency from the 5 GHz band.
Constant Value: 2 (0x00000002)
GROUP_OWNER_BAND_6GHZ
public static final int GROUP_OWNER_BAND_6GHZ
Allow the system to pick the operating frequency from the 6 GHz band.
Constant Value: 3 (0x00000003)
GROUP_OWNER_BAND_AUTO
public static final int GROUP_OWNER_BAND_AUTO
Allow the system to pick the operating frequency from all supported bands.
Constant Value: 0 (0x00000000)
GROUP_OWNER_INTENT_AUTO
public static final int GROUP_OWNER_INTENT_AUTO
The system can choose an appropriate owner intent value, to be filled in the field groupOwnerIntent
.
Constant Value: -1 (0xffffffff)
GROUP_OWNER_INTENT_MAX
public static final int GROUP_OWNER_INTENT_MAX
The most inclination to be a group owner, to be filled in the field groupOwnerIntent
.
Constant Value: 15 (0x0000000f)
GROUP_OWNER_INTENT_MIN
public static final int GROUP_OWNER_INTENT_MIN
The least inclination to be a group owner, to be filled in the field groupOwnerIntent
.
Constant Value: 0 (0x00000000)
P2P_VERSION_1
public static final int P2P_VERSION_1
P2P Protocol version 1
Constant Value: 0 (0x00000000)
P2P_VERSION_2
public static final int P2P_VERSION_2
P2P Protocol version 2
Constant Value: 1 (0x00000001)
PCC_MODE_CONNECTION_TYPE_LEGACY_ONLY
public static final int PCC_MODE_CONNECTION_TYPE_LEGACY_ONLY
Legacy connection type.
Group Owner: Configured to support WPA2-Personal connections.
Group Client: Configured to connect to Group Owner using WPA2-Personal.
Constant Value: 0 (0x00000000)
PCC_MODE_CONNECTION_TYPE_LEGACY_OR_R2
public static final int PCC_MODE_CONNECTION_TYPE_LEGACY_OR_R2
Wi-Fi Direct R1/R2 compatible mode connection type.
Group Owner: Configured in WPA3-Personal Compatibility Mode to support WPA3-Personal and WPA2-Personal connections simultaneously.
Group Client: Configured to connect to Group Owner using WPA3-Personal or WPA2-Personal. The system will choose WPA3-Personal if Group Owner support WPA3-Personal.
Constant Value: 1 (0x00000001)
PCC_MODE_CONNECTION_TYPE_R2_ONLY
public static final int PCC_MODE_CONNECTION_TYPE_R2_ONLY
This configuration allows only Wi-Fi Direct R2 supported devices to establish connection.
Group Owner: Configured to support WPA3-Personal connections.
Group Client: Configured to connect to Group Owner using WPA3-Personal.
Constant Value: 2 (0x00000002)
Fields
CREATOR
public static final Creator<WifiP2pConfig> CREATOR
Implement the Parcelable interface
deviceAddress
public String deviceAddress
The device MAC address uniquely identifies a Wi-Fi p2p device
groupOwnerIntent
public int groupOwnerIntent
This is an integer value between GROUP_OWNER_INTENT_MIN
and GROUP_OWNER_INTENT_MAX
where GROUP_OWNER_INTENT_MIN
indicates the least inclination to be a group owner and GROUP_OWNER_INTENT_MAX
indicates the highest inclination to be a group owner. A value of GROUP_OWNER_INTENT_AUTO
indicates the system can choose an appropriate value. By default this field is set to GROUP_OWNER_INTENT_AUTO
.
Value is between 0 and 15 inclusive
Public constructors
WifiP2pConfig
public WifiP2pConfig (WifiP2pConfig source)
copy constructor
Parameters | |
---|---|
source | WifiP2pConfig |
Public methods
describeContents
public int describeContents ()
Implement the Parcelable interface
Returns | |
---|---|
int | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or CONTENTS_FILE_DESCRIPTOR |
getGroupClientIpProvisioningMode
public int getGroupClientIpProvisioningMode ()
Get the IP provisioning mode when joining a group as a group client. The result will be one of the following: GROUP_CLIENT_IP_PROVISIONING_MODE_IPV4_DHCP
, GROUP_CLIENT_IP_PROVISIONING_MODE_IPV6_LINK_LOCAL
Returns | |
---|---|
int | Value is GROUP_CLIENT_IP_PROVISIONING_MODE_IPV4_DHCP , or GROUP_CLIENT_IP_PROVISIONING_MODE_IPV6_LINK_LOCAL |
getGroupOwnerBand
public int getGroupOwnerBand ()
Get the required band for the group owner. The result will be one of the following: GROUP_OWNER_BAND_AUTO
, GROUP_OWNER_BAND_2GHZ
, GROUP_OWNER_BAND_5GHZ
, GROUP_OWNER_BAND_6GHZ
Returns | |
---|---|
int | Value is GROUP_OWNER_BAND_AUTO , GROUP_OWNER_BAND_2GHZ , GROUP_OWNER_BAND_5GHZ , or GROUP_OWNER_BAND_6GHZ |
getGroupOwnerVersion
public int getGroupOwnerVersion ()
Get the P2P Group Owner version. See also setGroupOwnerVersion(int)
.
Returns | |
---|---|
int | The P2P Group Owner protocol version. Value is android.net.wifi.p2p.WifiP2pConfig.P2P_DEFAULT_VERSION_1, P2P_VERSION_1 , or P2P_VERSION_2 |
getNetworkId
public int getNetworkId ()
Get the network ID of this P2P configuration.
Returns | |
---|---|
int | either a non-negative network ID, or one of WifiP2pGroup.NETWORK_ID_PERSISTENT or WifiP2pGroup.NETWORK_ID_TEMPORARY . |
getNetworkName
public String getNetworkName ()
Get the network name of this P2P configuration, or null if unset.
Returns | |
---|---|
String |
getPairingBootstrappingConfig
public WifiP2pPairingBootstrappingConfig getPairingBootstrappingConfig ()
Get the pairing bootstrapping configuration , or null if unset.
Returns | |
---|---|
WifiP2pPairingBootstrappingConfig |
getPassphrase
public String getPassphrase ()
Get the passphrase of this P2P configuration, or null if unset.
Returns | |
---|---|
String |
getPccModeConnectionType
public int getPccModeConnectionType ()
Get the PCC Mode connection type.
Returns | |
---|---|
int | One of the PCC_MODE_CONNECTION_TYPE_* . Value is android.net.wifi.p2p.WifiP2pConfig.PCC_MODE_DEFAULT_CONNECTION_TYPE_LEGACY_ONLY, PCC_MODE_CONNECTION_TYPE_LEGACY_ONLY , PCC_MODE_CONNECTION_TYPE_LEGACY_OR_R2 , or PCC_MODE_CONNECTION_TYPE_R2_ONLY |
isAuthorizeConnectionFromPeerEnabled
public boolean isAuthorizeConnectionFromPeerEnabled ()
Query to check if the configuration is for authorizing a connection request from the peer device. @see Builder.setAuthorizeConnectionFromPeerEnabled(boolean)
Returns | |
---|---|
boolean | true if configured to authorize a connection request from the Peer device, False otherwise. |
setGroupOwnerVersion
public void setGroupOwnerVersion (int version)
Set the P2P Group Owner version.
Parameters | |
---|---|
version | int : The P2P Group Owner protocol version. Value is android.net.wifi.p2p.WifiP2pConfig.P2P_DEFAULT_VERSION_1, P2P_VERSION_1 , or P2P_VERSION_2 |
toString
public String toString ()
Returns a string representation of the object.
Returns | |
---|---|
String | a string representation of the object. |
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Implement the Parcelable interface
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.PARCELABLE_WRITE_RETURN_VALUE . Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-03-13 UTC.