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,android.os.Handler) or WifiAwareSession.subscribe(SubscribeConfig,DiscoverySessionCallback,android.os.Handler).
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 |
onBootstrappingSucceeded(peerHandle: PeerHandle, method: Int, message: ByteArray?)Callback indicating that a Bootstrapping method negotiation succeeded. |
| open Unit |
onDataPathConnected(peerHandle: PeerHandle, info: WifiAwareNetworkInfo)Callback indicating that a data path has been connected. |
| open Unit |
onDataPathDisconnected(peerHandle: PeerHandle)Callback indicating that a data path has been disconnected. |
| open Unit |
onDataPathRequestFailed(peerHandle: PeerHandle, reason: Int)Callback indicating that a data path request has failed. |
| open Unit |
onDataPathRequestReceived(peerHandle: PeerHandle)Callback indicating that a data path request has been received. |
| 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
onBootstrappingSucceeded
open fun onBootstrappingSucceeded(
peerHandle: PeerHandle,
method: Int,
message: ByteArray?
): Unit
Callback indicating that a Bootstrapping method negotiation succeeded. The follow-up out-of-band bootstrapping can start.
This variant is similar to onBootstrappingSucceeded(PeerHandle,int), but includes optional service specific information provided by the peer during the request.
onDataPathConnected
open fun onDataPathConnected(
peerHandle: PeerHandle,
info: WifiAwareNetworkInfo
): Unit
Callback indicating that a data path has been connected.
| Parameters | |
|---|---|
peerHandle |
PeerHandle: The peer's handle for the data path request. This value cannot be null. |
info |
WifiAwareNetworkInfo: The network information of the connected data path. This value cannot be null. |
onDataPathDisconnected
open fun onDataPathDisconnected(peerHandle: PeerHandle): Unit
Callback indicating that a data path has been disconnected. Could be triggered by either side calling DiscoverySession.releaseDataPath(PeerHandle).
| Parameters | |
|---|---|
peerHandle |
PeerHandle: The peer's handle for the data path request. This value cannot be null. |
onDataPathRequestFailed
open fun onDataPathRequestFailed(
peerHandle: PeerHandle,
reason: Int
): Unit
Callback indicating that a data path request has failed.
| Parameters | |
|---|---|
peerHandle |
PeerHandle: The peer's handle for the data path request. This value cannot be null. |
reason |
Int: The reason for the data path connection failure. Value is one of the following:
|
onDataPathRequestReceived
open fun onDataPathRequestReceived(peerHandle: PeerHandle): Unit
Callback indicating that a data path request has been received. Caller should call PublishDiscoverySession.acceptDataPathRequest(PeerHandle,AwareDataPathRequest) to set up the data path. Or call PublishDiscoverySession.rejectDataPathRequest(PeerHandle) to reject the request.
| Parameters | |
|---|---|
peerHandle |
PeerHandle: The peer's handle for the data path request. This value cannot be null. |
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,android.os.Handler) 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(PeerHandle,byte[],List,int) may be called multiple times per service discovery.
Note: This method is superseded by onServiceDiscovered(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(PeerHandle,byte[],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.setEgressDistanceMm(int) and/or SubscribeConfig.Builder.setIngressDistanceMm(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(PeerHandle,byte[],List) is called.
Note that this method and onServiceDiscovered(PeerHandle,byte[],List) may be called multiple times per service discovery.
Note: This method is superseded by onServiceDiscoveredWithinRange(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.setEgressDistanceMm(int) and/or SubscribeConfig.Builder.setIngressDistanceMm(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(PeerHandle,byte[],List) is called.
Note: This method supersedes onServiceDiscoveredWithinRange(PeerHandle,byte[],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(PeerHandle,byte[],List) or onServiceDiscoveredWithinRange(PeerHandle,byte[],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, WifiAwareManager.WIFI_AWARE_DISCOVERY_LOST_REASON_UNKNOWN Value is one of the following: |
onSessionConfigFailed
open fun onSessionConfigFailed(): Unit
Called when a publish or subscribe discovery session cannot be created: WifiAwareSession.publish(PublishConfig,DiscoverySessionCallback,android.os.Handler) or WifiAwareSession.subscribe(SubscribeConfig,DiscoverySessionCallback,android.os.Handler), 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,android.os.Handler) operation.
| Parameters | |
|---|---|
session |
SubscribeDiscoverySession: The SubscribeDiscoverySession used to control the discovery session. This value cannot be null. |