DiscoverySessionCallback
open class DiscoverySessionCallback
kotlin.Any | |
↳ | android.net.wifi.aware.DiscoverySessionCallback |
Base class for Aware session events callbacks. Should be extended by applications wanting notifications. The callbacks are set when a publish or subscribe session is created using WifiAwareSession.publish(PublishConfig, DiscoverySessionCallback,
or WifiAwareSession.subscribe(SubscribeConfig, DiscoverySessionCallback,
.
A single callback is set at session creation - it cannot be replaced.
Summary
Public constructors | |
---|---|
Public methods | |
---|---|
open Unit |
onBootstrappingFailed(peerHandle: PeerHandle) Callback indicating that a Bootstrapping method negotiation failed. |
open Unit |
onBootstrappingSucceeded(peerHandle: PeerHandle, method: Int) Callback indicating that a Bootstrapping method negotiation succeeded. |
open Unit |
onMessageReceived(peerHandle: PeerHandle!, message: ByteArray!) Called when a message is received from a discovery session peer - in response to the peer's |
open Unit |
onMessageSendFailed(messageId: Int) Called when message transmission initiated with |
open Unit |
onMessageSendSucceeded(messageId: Int) Called in response to |
open Unit |
onPairingSetupFailed(peerHandle: PeerHandle) Callback indicating that a pairing setup process failed. |
open Unit |
onPairingSetupRequestReceived(peerHandle: PeerHandle, requestId: Int) Callback indicating that a pairing request is received from peer. |
open Unit |
onPairingSetupSucceeded(peerHandle: PeerHandle, alias: String) Callback indicating that a pairing setup process succeeded. |
open Unit |
onPairingVerificationFailed(peerHandle: PeerHandle) Callback indicating that a pairing verification process failed. |
open Unit |
onPairingVerificationSucceed(peerHandle: PeerHandle, alias: String) Callback indicating that a pairing verification process succeeded. |
open Unit |
onPublishStarted(session: PublishDiscoverySession) Called when a publish operation is started successfully in response to a |
open Unit |
onServiceDiscovered(peerHandle: PeerHandle!, serviceSpecificInfo: ByteArray!, matchFilter: MutableList<ByteArray!>!) Called when a subscribe operation results in a service discovery. |
open Unit |
Called when a subscribe operation results in a service discovery. |
open Unit |
onServiceDiscoveredWithinRange(peerHandle: PeerHandle!, serviceSpecificInfo: ByteArray!, matchFilter: MutableList<ByteArray!>!, distanceMm: Int) Called when a subscribe operation results in a service discovery. |
open Unit |
onServiceDiscoveredWithinRange(info: ServiceDiscoveryInfo, distanceMm: Int) Called when a subscribe operation results in a service discovery. |
open Unit |
onServiceLost(peerHandle: PeerHandle, reason: Int) Called when the discovered service is not available. |
open Unit |
Called when a publish or subscribe discovery session cannot be created: |
open Unit |
Called when a publish or subscribe discovery session configuration update request succeeds. |
open Unit |
Called when a discovery session (publish or subscribe) terminates. |
open Unit |
onSubscribeStarted(session: SubscribeDiscoverySession) Called when a subscribe operation is started successfully in response to a |
Public constructors
Public methods
onBootstrappingFailed
open fun onBootstrappingFailed(peerHandle: PeerHandle): Unit
Callback indicating that a Bootstrapping method negotiation failed.
Parameters | |
---|---|
peerHandle |
PeerHandle: The bootstrapping peer handle This value cannot be null . |
onBootstrappingSucceeded
open fun onBootstrappingSucceeded(
peerHandle: PeerHandle,
method: Int
): Unit
Callback indicating that a Bootstrapping method negotiation succeeded. The follow-up out-of-band bootstrapping can start
Parameters | |
---|---|
peerHandle |
PeerHandle: The bootstrapping peer handle This value cannot be null . |
method |
Int: The bootstrapping method accept by the peer Value is either 0 or a combination of android.net.wifi.aware.AwarePairingConfig#PAIRING_BOOTSTRAPPING_OPPORTUNISTIC , android.net.wifi.aware.AwarePairingConfig#PAIRING_BOOTSTRAPPING_PIN_CODE_DISPLAY , android.net.wifi.aware.AwarePairingConfig#PAIRING_BOOTSTRAPPING_PASSPHRASE_DISPLAY , android.net.wifi.aware.AwarePairingConfig#PAIRING_BOOTSTRAPPING_QR_DISPLAY , android.net.wifi.aware.AwarePairingConfig#PAIRING_BOOTSTRAPPING_NFC_TAG , android.net.wifi.aware.AwarePairingConfig#PAIRING_BOOTSTRAPPING_PIN_CODE_KEYPAD , android.net.wifi.aware.AwarePairingConfig#PAIRING_BOOTSTRAPPING_PASSPHRASE_KEYPAD , android.net.wifi.aware.AwarePairingConfig#PAIRING_BOOTSTRAPPING_QR_SCAN , and android.net.wifi.aware.AwarePairingConfig#PAIRING_BOOTSTRAPPING_NFC_READER |
onMessageReceived
open fun onMessageReceived(
peerHandle: PeerHandle!,
message: ByteArray!
): Unit
Called when a message is received from a discovery session peer - in response to the peer's DiscoverySession.sendMessage(PeerHandle, int, byte[])
.
Parameters | |
---|---|
peerHandle |
PeerHandle!: An opaque handle to the peer matching our discovery operation. |
message |
ByteArray!: A byte array containing the message. |
onMessageSendFailed
open fun onMessageSendFailed(messageId: Int): Unit
Called when message transmission initiated with DiscoverySession.sendMessage(PeerHandle, int, byte[])
fails. E.g. when no ACK is received from the peer.
Note that either this callback or DiscoverySessionCallback.onMessageSendSucceeded(int)
will be received - never both.
Parameters | |
---|---|
messageId |
Int: The arbitrary message ID specified when sending the message. |
onMessageSendSucceeded
open fun onMessageSendSucceeded(messageId: Int): Unit
Called in response to DiscoverySession.sendMessage(PeerHandle, int, byte[])
when a message is transmitted successfully - i.e. when it was received successfully by the peer (corresponds to an ACK being received).
Note that either this callback or DiscoverySessionCallback.onMessageSendFailed(int)
will be received - never both.
Parameters | |
---|---|
messageId |
Int: The arbitrary message ID specified when sending the message. |
onPairingSetupFailed
open fun onPairingSetupFailed(peerHandle: PeerHandle): Unit
Callback indicating that a pairing setup process failed.
Parameters | |
---|---|
peerHandle |
PeerHandle: The pairing peer handle. This value cannot be null . |
onPairingSetupRequestReceived
open fun onPairingSetupRequestReceived(
peerHandle: PeerHandle,
requestId: Int
): Unit
Callback indicating that a pairing request is received from peer.
Parameters | |
---|---|
peerHandle |
PeerHandle: The peer's handle where the request is from This value cannot be null . |
requestId |
Int: The ID of the Aware pairing session |
onPairingSetupSucceeded
open fun onPairingSetupSucceeded(
peerHandle: PeerHandle,
alias: String
): Unit
Callback indicating that a pairing setup process succeeded.
Parameters | |
---|---|
peerHandle |
PeerHandle: The pairing peer handle. This value cannot be null . |
alias |
String: This is the paired device alias set by the caller. DiscoverySession.initiatePairingRequest(PeerHandle, String, int, String) or DiscoverySession.acceptPairingRequest(int, PeerHandle, String, int, String) This value cannot be null . |
onPairingVerificationFailed
open fun onPairingVerificationFailed(peerHandle: PeerHandle): Unit
Callback indicating that a pairing verification process failed.
Parameters | |
---|---|
peerHandle |
PeerHandle: The pairing peer handle This value cannot be null . |
onPairingVerificationSucceed
open fun onPairingVerificationSucceed(
peerHandle: PeerHandle,
alias: String
): Unit
Callback indicating that a pairing verification process succeeded.
Parameters | |
---|---|
peerHandle |
PeerHandle: The pairing peer handle This value cannot be null . |
alias |
String: This is the paired device alias set by the caller. DiscoverySession.initiatePairingRequest(PeerHandle, String, int, String) or DiscoverySession.acceptPairingRequest(int, PeerHandle, String, int, String) This value cannot be null . |
onPublishStarted
open fun onPublishStarted(session: PublishDiscoverySession): Unit
Called when a publish operation is started successfully in response to a WifiAwareSession.publish(PublishConfig, DiscoverySessionCallback,
operation.
Parameters | |
---|---|
session |
PublishDiscoverySession: The PublishDiscoverySession used to control the discovery session. This value cannot be null . |
onServiceDiscovered
open fun onServiceDiscovered(
peerHandle: PeerHandle!,
serviceSpecificInfo: ByteArray!,
matchFilter: MutableList<ByteArray!>!
): Unit
Called when a subscribe operation results in a service discovery.
Note that this method and onServiceDiscoveredWithinRange(android.net.wifi.aware.PeerHandle,byte[],java.util.List,int)
may be called multiple times per service discovery.
Note: This method is superseded by onServiceDiscovered(android.net.wifi.aware.ServiceDiscoveryInfo)
which returns more information. Note that both legacy and new callback will be triggered on discovery.
Parameters | |
---|---|
peerHandle |
PeerHandle!: An opaque handle to the peer matching our discovery operation. |
serviceSpecificInfo |
ByteArray!: The service specific information (arbitrary byte array) provided by the peer as part of its discovery configuration. |
matchFilter |
MutableList<ByteArray!>!: The filter which resulted in this service discovery. For PublishConfig.PUBLISH_TYPE_UNSOLICITED , SubscribeConfig.SUBSCRIBE_TYPE_PASSIVE discovery sessions this is the publisher's match filter. For PublishConfig.PUBLISH_TYPE_SOLICITED , SubscribeConfig.SUBSCRIBE_TYPE_ACTIVE discovery sessions this is the subscriber's match filter. |
onServiceDiscovered
open fun onServiceDiscovered(info: ServiceDiscoveryInfo): Unit
Called when a subscribe operation results in a service discovery.
Note: This method supersedes onServiceDiscovered(android.net.wifi.aware.PeerHandle,byte[],java.util.List)
and provides additional information - including cipher suite type and security context of the peer. Both the legacy and the new callback will be triggered on discovery.
Parameters | |
---|---|
info |
ServiceDiscoveryInfo: A ServiceDiscoveryInfo structure containing information on the discovery session and the discovered peer. This value cannot be null . |
onServiceDiscoveredWithinRange
open fun onServiceDiscoveredWithinRange(
peerHandle: PeerHandle!,
serviceSpecificInfo: ByteArray!,
matchFilter: MutableList<ByteArray!>!,
distanceMm: Int
): Unit
Called when a subscribe operation results in a service discovery. Called when a Subscribe service was configured with a range requirement SubscribeConfig.Builder.setMinDistanceMm(int)
and/or SubscribeConfig.Builder.setMaxDistanceMm(int)
and the Publish service was configured with PublishConfig.Builder.setRangingEnabled(boolean)
.
If either Publisher or Subscriber does not enable Ranging, or if Ranging is temporarily disabled by the underlying device, service discovery proceeds without ranging and the onServiceDiscovered(android.net.wifi.aware.PeerHandle,byte[],java.util.List)
is called.
Note that this method and onServiceDiscovered(android.net.wifi.aware.PeerHandle,byte[],java.util.List)
may be called multiple times per service discovery.
Note: This method is superseded by onServiceDiscoveredWithinRange(android.net.wifi.aware.ServiceDiscoveryInfo,int)
which returns more information. Note that both legacy and new callback will be triggered on discovery.
Parameters | |
---|---|
peerHandle |
PeerHandle!: An opaque handle to the peer matching our discovery operation. |
serviceSpecificInfo |
ByteArray!: The service specific information (arbitrary byte array) provided by the peer as part of its discovery configuration. |
matchFilter |
MutableList<ByteArray!>!: The filter which resulted in this service discovery. For PublishConfig.PUBLISH_TYPE_UNSOLICITED , SubscribeConfig.SUBSCRIBE_TYPE_PASSIVE discovery sessions this is the publisher's match filter. For PublishConfig.PUBLISH_TYPE_SOLICITED , SubscribeConfig.SUBSCRIBE_TYPE_ACTIVE discovery sessions this is the subscriber's match filter. |
distanceMm |
Int: The measured distance to the Publisher in mm. Note: the measured distance may be negative for very close devices. |
onServiceDiscoveredWithinRange
open fun onServiceDiscoveredWithinRange(
info: ServiceDiscoveryInfo,
distanceMm: Int
): Unit
Called when a subscribe operation results in a service discovery. Called when a Subscribe service was configured with a range requirement SubscribeConfig.Builder.setMinDistanceMm(int)
and/or SubscribeConfig.Builder.setMaxDistanceMm(int)
and the Publish service was configured with PublishConfig.Builder.setRangingEnabled(boolean)
.
If either Publisher or Subscriber does not enable Ranging, or if Ranging is temporarily disabled by the underlying device, service discovery proceeds without ranging and the onServiceDiscovered(android.net.wifi.aware.PeerHandle,byte[],java.util.List)
is called.
Note: This method supersedes onServiceDiscoveredWithinRange(android.net.wifi.aware.PeerHandle,byte[],java.util.List,int)
and provides additional information - including cipher suite type and security context of the peer. Both the legacy and the new callback will be triggered on discovery.
Parameters | |
---|---|
info |
ServiceDiscoveryInfo: A ServiceDiscoveryInfo which indicate service config of the descovery sessions. This value cannot be null . |
distanceMm |
Int: The measured distance to the Publisher in mm. Note: the measured distance may be negative for very close devices. |
onServiceLost
open fun onServiceLost(
peerHandle: PeerHandle,
reason: Int
): Unit
Called when the discovered service is not available. All further operations on this discovery session will fail. If the service is available again, onServiceDiscovered(android.net.wifi.aware.PeerHandle,byte[],java.util.List)
or onServiceDiscoveredWithinRange(android.net.wifi.aware.PeerHandle,byte[],java.util.List,int)
will be called.
Parameters | |
---|---|
peerHandle |
PeerHandle: An opaque handle to the peer matching our discovery operation. This value cannot be null . |
reason |
Int: Discovered service lost reason code. One of WifiAwareManager.WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE , android.net.wifi.aware.WifiAwareManager#WIFI_AWARE_DISCOVERY_LOST_REASON_UNKNOWN } |
onSessionConfigFailed
open fun onSessionConfigFailed(): Unit
Called when a publish or subscribe discovery session cannot be created: WifiAwareSession.publish(PublishConfig, DiscoverySessionCallback,
or WifiAwareSession.subscribe(SubscribeConfig, DiscoverySessionCallback,
, or when a configuration update fails: PublishDiscoverySession.updatePublish(PublishConfig)
or SubscribeDiscoverySession.updateSubscribe(SubscribeConfig)
.
For discovery session updates failure leaves the session running with its previous configuration - the discovery session is not terminated.
onSessionConfigUpdated
open fun onSessionConfigUpdated(): Unit
Called when a publish or subscribe discovery session configuration update request succeeds. Called in response to PublishDiscoverySession.updatePublish(PublishConfig)
or SubscribeDiscoverySession.updateSubscribe(SubscribeConfig)
.
onSessionTerminated
open fun onSessionTerminated(): Unit
Called when a discovery session (publish or subscribe) terminates. Termination may be due to user-request (either directly through DiscoverySession.close()
or application-specified expiration, e.g. PublishConfig.Builder.setTtlSec(int)
or SubscribeConfig.Builder.setTtlSec(int)
).
onSubscribeStarted
open fun onSubscribeStarted(session: SubscribeDiscoverySession): Unit
Called when a subscribe operation is started successfully in response to a WifiAwareSession.subscribe(SubscribeConfig, DiscoverySessionCallback,
operation.
Parameters | |
---|---|
session |
SubscribeDiscoverySession: The SubscribeDiscoverySession used to control the discovery session. This value cannot be null . |