Added in API level 26

Builder


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

Builder used to build SubscribeConfig objects.

Summary

Public constructors

Public methods
SubscribeConfig!

Build SubscribeConfig given the current requests made on the builder.

SubscribeConfig.Builder

Configure whether to enable and use instant communication for this subscribe session.

SubscribeConfig.Builder!

The match filter for a subscribe session.

SubscribeConfig.Builder!
setMaxDistanceMm(maxDistanceMm: Int)

Configure the maximum distance to a discovered publisher at which to trigger a discovery notification.

SubscribeConfig.Builder!
setMinDistanceMm(minDistanceMm: Int)

Configure the minimum distance to a discovered publisher at which to trigger a discovery notification.

SubscribeConfig.Builder

Set the AwarePairingConfig for this subscribe session, the peer can use this info to determine the config of the following bootstrapping, pairing setup/verification request.

SubscribeConfig.Builder!
setServiceName(serviceName: String)

Specify the service name of the subscribe session.

SubscribeConfig.Builder!
setServiceSpecificInfo(serviceSpecificInfo: ByteArray?)

Specify service specific information for the subscribe session.

SubscribeConfig.Builder!
setSubscribeType(subscribeType: Int)

Sets the type of the subscribe session: active (subscribe packets are transmitted over-the-air), or passive (no subscribe packets are transmitted, a match is made against a solicited/active publish session whose packets are transmitted over-the-air).

SubscribeConfig.Builder!

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

SubscribeConfig.Builder!
setTtlSec(ttlSec: Int)

Sets the time interval (in seconds) an active ( SubscribeConfig.Builder#setSubscribeType(int)) subscribe session will be alive - i.

Public constructors

Builder

Added in API level 26
Builder()

Public methods

build

Added in API level 26
fun build(): SubscribeConfig!

Build SubscribeConfig given the current requests made on the builder.

setInstantCommunicationModeEnabled

Added in API level 33
fun setInstantCommunicationModeEnabled(
    enabled: Boolean,
    band: Int
): SubscribeConfig.Builder

Configure whether to enable and use instant communication for this subscribe 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
SubscribeConfig.Builder the current Builder builder, enabling chaining of builder methods. This value cannot be null.

setMatchFilter

Added in API level 26
fun setMatchFilter(matchFilter: MutableList<ByteArray!>?): SubscribeConfig.Builder!

The match filter for a subscribe 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
SubscribeConfig.Builder! The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setMaxDistanceMm

Added in API level 28
fun setMaxDistanceMm(maxDistanceMm: Int): SubscribeConfig.Builder!

Configure the maximum distance to a discovered publisher at which to trigger a discovery notification. I.e. discovery will be triggered if we've found a matching publisher (based on the other criteria in this configuration) and the distance to the publisher is smaller than the value specified in this API. Can be used in conjunction with setMinDistanceMm(int) to specify a geofence, i.e. discovery with min <= distance <= max.

For ranging to be used in discovery it must also be enabled on the publisher using PublishConfig.Builder#setRangingEnabled(boolean). However, ranging may not be available or enabled on the publisher or may be temporarily disabled on either subscriber or publisher - in such cases discovery will proceed without ranging.

When ranging is enabled and available on both publisher and subscriber and a service is discovered based on geofence constraints the DiscoverySessionCallback#onServiceDiscoveredWithinRange(PeerHandle, byte[], List, int) is called, otherwise the DiscoverySessionCallback#onServiceDiscovered(PeerHandle, byte[], List) is called.

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
maxDistanceMm Int: Maximum distance, in mm, to the publisher below which to trigger discovery.
Return
SubscribeConfig.Builder! The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setMinDistanceMm

Added in API level 28
fun setMinDistanceMm(minDistanceMm: Int): SubscribeConfig.Builder!

Configure the minimum distance to a discovered publisher at which to trigger a discovery notification. I.e. discovery will be triggered if we've found a matching publisher (based on the other criteria in this configuration) and the distance to the publisher is larger than the value specified in this API. Can be used in conjunction with setMaxDistanceMm(int) to specify a geofence, i.e. discovery with min <= distance <= max.

For ranging to be used in discovery it must also be enabled on the publisher using PublishConfig.Builder#setRangingEnabled(boolean). However, ranging may not be available or enabled on the publisher or may be temporarily disabled on either subscriber or publisher - in such cases discovery will proceed without ranging.

When ranging is enabled and available on both publisher and subscriber and a service is discovered based on geofence constraints the DiscoverySessionCallback#onServiceDiscoveredWithinRange(PeerHandle, byte[], List, int) is called, otherwise the DiscoverySessionCallback#onServiceDiscovered(PeerHandle, byte[], List) is called.

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
minDistanceMm Int: Minimum distance, in mm, to the publisher above which to trigger discovery.
Return
SubscribeConfig.Builder! The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setPairingConfig

Added in API level 34
fun setPairingConfig(config: AwarePairingConfig?): SubscribeConfig.Builder

Set the AwarePairingConfig for this subscribe 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
SubscribeConfig.Builder the current Builder builder, enabling chaining of builder methods. This value cannot be null.

setServiceName

Added in API level 26
fun setServiceName(serviceName: String): SubscribeConfig.Builder!

Specify the service name of the subscribe 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.

Must be called - an empty ServiceName is not valid.

Parameters
serviceName String: The service name for the subscribe session. This value cannot be null.
Return
SubscribeConfig.Builder! The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setServiceSpecificInfo

Added in API level 26
fun setServiceSpecificInfo(serviceSpecificInfo: ByteArray?): SubscribeConfig.Builder!

Specify service specific information for the subscribe session. This is a free-form byte array available to the application to send additional information as part of the discovery operation - i.e. 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
SubscribeConfig.Builder! The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setSubscribeType

Added in API level 26
fun setSubscribeType(subscribeType: Int): SubscribeConfig.Builder!

Sets the type of the subscribe session: active (subscribe packets are transmitted over-the-air), or passive (no subscribe packets are transmitted, a match is made against a solicited/active publish session whose packets are transmitted over-the-air).

Parameters
subscribeType Int: Subscribe session type: SubscribeConfig#SUBSCRIBE_TYPE_ACTIVE or SubscribeConfig#SUBSCRIBE_TYPE_PASSIVE. Value is android.net.wifi.aware.SubscribeConfig#SUBSCRIBE_TYPE_PASSIVE, or android.net.wifi.aware.SubscribeConfig#SUBSCRIBE_TYPE_ACTIVE
Return
SubscribeConfig.Builder! The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setTerminateNotificationEnabled

Added in API level 26
fun setTerminateNotificationEnabled(enable: Boolean): SubscribeConfig.Builder!

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

Parameters
enable Boolean: If true the terminate callback will be called when the subscribe is terminated. Otherwise it will not be called.
Return
SubscribeConfig.Builder! The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setTtlSec

Added in API level 26
fun setTtlSec(ttlSec: Int): SubscribeConfig.Builder!

Sets the time interval (in seconds) an active ( SubscribeConfig.Builder#setSubscribeType(int)) subscribe session will be alive - i.e. broadcasting a packet. When the TTL is reached an event will be generated for DiscoverySessionCallback#onSessionTerminated().

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 subscribe session in seconds.
Return
SubscribeConfig.Builder! The builder to facilitate chaining builder.setXXX(..).setXXX(..).