Builder

class Builder
kotlin.Any
   ↳ android.net.wifi.aware.PublishConfig.Builder

Builder used to build PublishConfig objects.
Requires API level 26 (Android 8.0, Oreo)

Summary

Public constructors

Public methods
PublishConfig.Builder!
setTtlSec(ttlSec: Int)

Sets the time interval (in seconds) an unsolicited ( PublishConfig.Builder#setPublishType(int)) publish session will be alive - broadcasting a packet.

PublishConfig.Builder!

Configure whether a publish terminate notification DiscoverySessionCallback#onSessionTerminated() is reported back to the callback.

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!

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!

The match filter for a publish session.

PublishConfig!

Build PublishConfig given the current requests made on the builder.

Public constructors

<init>

Builder()

Public methods

setTtlSec

added in API level 26
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.
Requires API level 26 (Android 8.0, Oreo)

Parameters
ttlSec Int: Lifetime of a publish session in seconds.
Return
PublishConfig.Builder!: The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setTerminateNotificationEnabled

added in API level 26
fun setTerminateNotificationEnabled(enable: Boolean): PublishConfig.Builder!

Configure whether a publish terminate notification DiscoverySessionCallback#onSessionTerminated() is reported back to the callback.
Requires API level 26 (Android 8.0, Oreo)

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(..).

setPublishType

added in API level 26
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).
Requires API level 26 (Android 8.0, Oreo)

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

added in API level 28
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.
Requires API level 28 (Android 8.+, P)

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

added in API level 26
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 ('-'), and the period ('.'). All valid multi-byte UTF-8 characters are acceptable in a Service Name.

Must be called - an empty ServiceName is not valid.
Requires API level 26 (Android 8.0, Oreo)

Parameters
serviceName String: The service name for the publish session. This value must never be null.
Return
PublishConfig.Builder!: The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setServiceSpecificInfo

added in API level 26
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.
Requires API level 26 (Android 8.0, Oreo)

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(..).

setMatchFilter

added in API level 26
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.
Requires API level 26 (Android 8.0, Oreo)

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(..).

build

added in API level 26
fun build(): PublishConfig!

Build PublishConfig given the current requests made on the builder.
Requires API level 26 (Android 8.0, Oreo)