Builder
class Builder
kotlin.Any | |
↳ | android.net.wifi.aware.PublishConfig.Builder |
Builder used to build PublishConfig
objects.
Summary
Public constructors | |
---|---|
Builder() |
Public methods | |
---|---|
PublishConfig! |
build() Build |
PublishConfig.Builder |
setDataPathSecurityConfig(securityConfig: WifiAwareDataPathSecurityConfig) Configure security config for the Wi-Fi Aware publish session. |
PublishConfig.Builder |
setInstantCommunicationModeEnabled(enabled: Boolean, band: Int) Configure whether to enable and use instant communication for this publish session. |
PublishConfig.Builder! |
setMatchFilter(matchFilter: MutableList<ByteArray!>?) The match filter for a publish session. |
PublishConfig.Builder |
setPairingConfig(config: AwarePairingConfig?) Set the |
PublishConfig.Builder! |
setPublishType(publishType: Int) 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(enable: Boolean) Configure whether the publish discovery session supports ranging and allows peers to measure distance to it. |
PublishConfig.Builder! |
setServiceName(serviceName: String) Specify the service name of the publish session. |
PublishConfig.Builder! |
setServiceSpecificInfo(serviceSpecificInfo: ByteArray?) Specify service specific information for the publish session. |
PublishConfig.Builder! |
setTerminateNotificationEnabled(enable: Boolean) Configure whether a publish terminate notification |
PublishConfig.Builder! |
Sets the time interval (in seconds) an unsolicited ( |
Public constructors
Public methods
build
fun build(): PublishConfig!
Build PublishConfig
given the current requests made on the builder.
setDataPathSecurityConfig
fun setDataPathSecurityConfig(securityConfig: WifiAwareDataPathSecurityConfig): PublishConfig.Builder
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 . |
Return | |
---|---|
PublishConfig.Builder |
the current Builder builder, enabling chaining of builder methods. This value cannot be null . |
setInstantCommunicationModeEnabled
fun setInstantCommunicationModeEnabled(
enabled: Boolean,
band: Int
): PublishConfig.Builder
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 android.net.wifi.ScanResult#WIFI_BAND_24_GHZ , or android.net.wifi.ScanResult#WIFI_BAND_5_GHZ |
Return | |
---|---|
PublishConfig.Builder |
the current Builder builder, enabling chaining of builder methods. This value cannot be null . |
setMatchFilter
fun setMatchFilter(matchFilter: MutableList<ByteArray!>?): PublishConfig.Builder!
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 |
MutableList<ByteArray!>?: A list of match filter entries (each of which is an arbitrary byte array). This value may be null . |
Return | |
---|---|
PublishConfig.Builder! |
The builder to facilitate chaining builder.setXXX(..).setXXX(..) . |
setPairingConfig
fun setPairingConfig(config: AwarePairingConfig?): PublishConfig.Builder
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 . |
Return | |
---|---|
PublishConfig.Builder |
the current Builder builder, enabling chaining of builder methods. This value cannot be null . |
setPublishType
fun setPublishType(publishType: Int): PublishConfig.Builder!
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 android.net.wifi.aware.PublishConfig#PUBLISH_TYPE_UNSOLICITED , or android.net.wifi.aware.PublishConfig#PUBLISH_TYPE_SOLICITED |
Return | |
---|---|
PublishConfig.Builder! |
The builder to facilitate chaining builder.setXXX(..).setXXX(..) . |
setRangingEnabled
fun setRangingEnabled(enable: Boolean): PublishConfig.Builder!
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. |
Return | |
---|---|
PublishConfig.Builder! |
The builder to facilitate chaining builder.setXXX(..).setXXX(..) . |
setServiceName
fun setServiceName(serviceName: String): PublishConfig.Builder!
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 . |
Return | |
---|---|
PublishConfig.Builder! |
The builder to facilitate chaining builder.setXXX(..).setXXX(..) . |
setServiceSpecificInfo
fun setServiceSpecificInfo(serviceSpecificInfo: ByteArray?): PublishConfig.Builder!
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 |
ByteArray?: A byte-array for the service-specific information field. This value may be null . |
Return | |
---|---|
PublishConfig.Builder! |
The builder to facilitate chaining builder.setXXX(..).setXXX(..) . |
setTerminateNotificationEnabled
fun setTerminateNotificationEnabled(enable: Boolean): PublishConfig.Builder!
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. |
Return | |
---|---|
PublishConfig.Builder! |
The builder to facilitate chaining builder.setXXX(..).setXXX(..) . |
setTtlSec
fun setTtlSec(ttlSec: Int): PublishConfig.Builder!
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. |
Return | |
---|---|
PublishConfig.Builder! |
The builder to facilitate chaining builder.setXXX(..).setXXX(..) . |