PublishConfig.Builder
public
static
final
class
PublishConfig.Builder
extends Object
java.lang.Object | |
↳ | android.net.wifi.aware.PublishConfig.Builder |
Builder used to build PublishConfig
objects.
Summary
Public constructors | |
---|---|
Builder()
|
Public methods | |
---|---|
PublishConfig
|
build()
Build |
PublishConfig.Builder
|
setDataPathSecurityConfig(WifiAwareDataPathSecurityConfig securityConfig)
Configure security config for the Wi-Fi Aware publish session. |
PublishConfig.Builder
|
setInstantCommunicationModeEnabled(boolean enabled, int band)
Configure whether to enable and use instant communication for this publish session. |
PublishConfig.Builder
|
setMatchFilter(List<byte[]> matchFilter)
The match filter for a publish session. |
PublishConfig.Builder
|
setPairingConfig(AwarePairingConfig config)
Set the |
PublishConfig.Builder
|
setPublishType(int publishType)
Specify the type of the publish session: solicited (aka active - publish packets are transmitted over-the-air), or unsolicited (aka passive - no publish packets are transmitted, a match is made against an active subscribe session whose packets are transmitted over-the-air). |
PublishConfig.Builder
|
setRangingEnabled(boolean enable)
Configure whether the publish discovery session supports ranging and allows peers to measure distance to it. |
PublishConfig.Builder
|
setServiceName(String serviceName)
Specify the service name of the publish session. |
PublishConfig.Builder
|
setServiceSpecificInfo(byte[] serviceSpecificInfo)
Specify service specific information for the publish session. |
PublishConfig.Builder
|
setTerminateNotificationEnabled(boolean enable)
Configure whether a publish terminate notification
|
PublishConfig.Builder
|
setTtlSec(int ttlSec)
Sets the time interval (in seconds) an unsolicited (
|
Inherited methods | |
---|---|
Public constructors
Public methods
build
public PublishConfig build ()
Build PublishConfig
given the current requests made on the
builder.
Returns | |
---|---|
PublishConfig |
setDataPathSecurityConfig
public PublishConfig.Builder setDataPathSecurityConfig (WifiAwareDataPathSecurityConfig securityConfig)
Configure security config for the Wi-Fi Aware publish session. The security config set
here must be the same as the one used to request Wi-Fi Aware data-path connection using
WifiAwareNetworkSpecifier.Builder#setDataPathSecurityConfig(WifiAwareDataPathSecurityConfig)
.
This security config will create a security identifier (SCID) which contains a PMKID and
transmitted in the publish message. The device which subscribe this session can get this
info by ServiceDiscoveryInfo#getScid()
This method is optional - if not called, then no security context identifier will be
passed in the publish message, then no security context identifier will be provided in
the ServiceDiscoveryInfo
on the subscriber. Security can still be negotiated
using out-of-band (OOB) mechanisms.
Parameters | |
---|---|
securityConfig |
WifiAwareDataPathSecurityConfig : The (optional) security config to be used to create security
context Identifier
This value cannot be null . |
Returns | |
---|---|
PublishConfig.Builder |
the current Builder builder, enabling chaining of builder methods.
This value cannot be null . |
setInstantCommunicationModeEnabled
public PublishConfig.Builder setInstantCommunicationModeEnabled (boolean enabled, int band)
Configure whether to enable and use instant communication for this publish session.
Instant communication will speed up service discovery and any data-path set up as part of
this session. Use Characteristics#isInstantCommunicationModeSupported()
to check
if the device supports this feature.
Note: due to increased power requirements of this mode - it will only remain enabled for 30 seconds from the time the discovery session is started.
Parameters | |
---|---|
enabled |
boolean : true for enable instant communication mode, default is false. |
band |
int : When setting to ScanResult#WIFI_BAND_5_GHZ , device will try to enable
instant communication mode on 5Ghz, but may fall back to 2.4Ghz due to regulatory
requirements.
Value is ScanResult.WIFI_BAND_24_GHZ , or ScanResult.WIFI_BAND_5_GHZ |
Returns | |
---|---|
PublishConfig.Builder |
the current Builder builder, enabling chaining of builder methods.
This value cannot be null . |
setMatchFilter
public PublishConfig.Builder setMatchFilter (List<byte[]> matchFilter)
The match filter for a publish session. Used to determine whether a service discovery occurred - in addition to relying on the service name.
Optional. Empty by default.
Parameters | |
---|---|
matchFilter |
List : A list of match filter entries (each of which is an arbitrary byte
array).
This value may be null . |
Returns | |
---|---|
PublishConfig.Builder |
The builder to facilitate chaining
builder.setXXX(..).setXXX(..) . |
setPairingConfig
public PublishConfig.Builder setPairingConfig (AwarePairingConfig config)
Set the AwarePairingConfig
for this publish session, the peer can use this info
to determine the config of the following bootstrapping, pairing setup/verification
request.
Parameters | |
---|---|
config |
AwarePairingConfig : The pairing config set to the peer. Only valid when
Characteristics#isAwarePairingSupported() is true.
This value may be null . |
Returns | |
---|---|
PublishConfig.Builder |
the current Builder builder, enabling chaining of builder methods.
This value cannot be null . |
See also:
setPublishType
public PublishConfig.Builder setPublishType (int publishType)
Specify the type of the publish session: solicited (aka active - publish packets are transmitted over-the-air), or unsolicited (aka passive - no publish packets are transmitted, a match is made against an active subscribe session whose packets are transmitted over-the-air).
Parameters | |
---|---|
publishType |
int : Publish session type:
PublishConfig#PUBLISH_TYPE_SOLICITED or
PublishConfig#PUBLISH_TYPE_UNSOLICITED (the default).
Value is PublishConfig.PUBLISH_TYPE_UNSOLICITED , or PublishConfig.PUBLISH_TYPE_SOLICITED |
Returns | |
---|---|
PublishConfig.Builder |
The builder to facilitate chaining
builder.setXXX(..).setXXX(..) . |
setRangingEnabled
public PublishConfig.Builder setRangingEnabled (boolean enable)
Configure whether the publish discovery session supports ranging and allows peers to
measure distance to it. This API is used in conjunction with
SubscribeConfig.Builder#setMinDistanceMm(int)
and
SubscribeConfig.Builder#setMaxDistanceMm(int)
to specify a minimum and/or
maximum distance at which discovery will be triggered.
Optional. Disabled by default - i.e. any peer attempt to measure distance to this device will be refused and discovery will proceed without ranging constraints.
The device must support Wi-Fi RTT for this feature to be used. Feature support is checked
as described in android.net.wifi.rtt
.
Parameters | |
---|---|
enable |
boolean : If true, ranging is supported on request of the peer. |
Returns | |
---|---|
PublishConfig.Builder |
The builder to facilitate chaining
builder.setXXX(..).setXXX(..) . |
setServiceName
public PublishConfig.Builder setServiceName (String serviceName)
Specify the service name of the publish session. The actual on-air value is a 6 byte hashed representation of this string.
The Service Name is a UTF-8 encoded string from 1 to 255 bytes in length. The only acceptable single-byte UTF-8 symbols for a Service Name are alphanumeric values (A-Z, a-z, 0-9), the hyphen ('-'), the period ('.') and the underscore ('_'). All valid multi-byte UTF-8 characters are acceptable in a Service Name.
Note: for compatibility with devices running Android 11 or older, avoid using underscore ('_') symbol as a single-byte UTF-8 service name.
Must be called - an empty ServiceName is not valid.
Parameters | |
---|---|
serviceName |
String : The service name for the publish session.
This value cannot be null . |
Returns | |
---|---|
PublishConfig.Builder |
The builder to facilitate chaining
builder.setXXX(..).setXXX(..) . |
setServiceSpecificInfo
public PublishConfig.Builder setServiceSpecificInfo (byte[] serviceSpecificInfo)
Specify service specific information for the publish session. This is a free-form byte array available to the application to send additional information as part of the discovery operation - it will not be used to determine whether a publish/subscribe match occurs.
Optional. Empty by default.
Parameters | |
---|---|
serviceSpecificInfo |
byte : A byte-array for the service-specific
information field.
This value may be null . |
Returns | |
---|---|
PublishConfig.Builder |
The builder to facilitate chaining
builder.setXXX(..).setXXX(..) . |
setTerminateNotificationEnabled
public PublishConfig.Builder setTerminateNotificationEnabled (boolean enable)
Configure whether a publish terminate notification
DiscoverySessionCallback#onSessionTerminated()
is reported
back to the callback.
Parameters | |
---|---|
enable |
boolean : If true the terminate callback will be called when the
publish is terminated. Otherwise it will not be called. |
Returns | |
---|---|
PublishConfig.Builder |
The builder to facilitate chaining
builder.setXXX(..).setXXX(..) . |
setTtlSec
public PublishConfig.Builder setTtlSec (int ttlSec)
Sets the time interval (in seconds) an unsolicited (
PublishConfig.Builder#setPublishType(int)
) publish session
will be alive - broadcasting a packet. When the TTL is reached
an event will be generated for
DiscoverySessionCallback#onSessionTerminated()
[unless
setTerminateNotificationEnabled(boolean)
disables the callback].
Optional. 0 by default - indicating the session doesn't terminate on its own.
Session will be terminated when DiscoverySession#close()
is
called.
Parameters | |
---|---|
ttlSec |
int : Lifetime of a publish session in seconds. |
Returns | |
---|---|
PublishConfig.Builder |
The builder to facilitate chaining
builder.setXXX(..).setXXX(..) . |