/**
* Defines a request object to configure a Wi-Fi NAN network. Built using
* {@link ConfigRequest.Builder}. Configuration is requested using
- * {@link WifiNanManager#connect(android.os.Handler, ConfigRequest, WifiNanEventCallback)}.
+ * {@link WifiNanManager#attach(android.os.Handler, WifiNanEventCallback)}.
* Note that the actual achieved configuration may be different from the
* requested configuration - since different applications may request different
* configurations.
/**
* Defines the configuration of a NAN publish session. Built using
* {@link PublishConfig.Builder}. A publish session is created using
- * {@link WifiNanManager#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or updated using
+ * {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or updated using
* {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)}.
*
* @hide PROPOSED_NAN_API
* {@link #setEnableTerminateNotification(boolean)} disables the callback].
* <p>
* Optional. 0 by default - indicating the session doesn't terminate on its own.
- * Session will be terminated when {@link WifiNanDiscoveryBaseSession#terminate()} is
+ * Session will be terminated when {@link WifiNanDiscoveryBaseSession#destroy()} is
* called.
*
* @param publishCount Number of publish packets to broadcast.
* {@link #setEnableTerminateNotification(boolean)} disables the callback].
* <p>
* Optional. 0 by default - indicating the session doesn't terminate on its own.
- * Session will be terminated when {@link WifiNanDiscoveryBaseSession#terminate()} is
+ * Session will be terminated when {@link WifiNanDiscoveryBaseSession#destroy()} is
* called.
*
* @param ttlSec Lifetime of a publish session in seconds.
/**
* Defines the configuration of a NAN subscribe session. Built using
* {@link SubscribeConfig.Builder}. Subscribe is done using
- * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} or
+ * {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} or
* {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
*
* @hide PROPOSED_NAN_API
* with {@link WifiNanDiscoverySessionCallback#TERMINATE_REASON_DONE}.
* <p>
* Optional. 0 by default - indicating the session doesn't terminate on its own.
- * Session will be terminated when {@link WifiNanDiscoveryBaseSession#terminate()} is
+ * Session will be terminated when {@link WifiNanDiscoveryBaseSession#destroy()} is
* called.
*
* @param subscribeCount Number of subscribe packets to broadcast.
* {@link WifiNanDiscoverySessionCallback#TERMINATE_REASON_DONE}.
* <p>
* Optional. 0 by default - indicating the session doesn't terminate on its own.
- * Session will be terminated when {@link WifiNanDiscoveryBaseSession#terminate()} is
+ * Session will be terminated when {@link WifiNanDiscoveryBaseSession#destroy()} is
* called.
*
* @param ttlSec Lifetime of a subscribe session in seconds.
* Sets the match style of the subscription - how are matches from a
* single match session (corresponding to the same publish action on the
* peer) reported to the host (using the
- * {@link WifiNanDiscoverySessionCallback#onMatch(int, byte[], byte[])}
+ * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])}
* ). The options are: only report the first match and ignore the rest
* {@link SubscribeConfig#MATCH_STYLE_FIRST_ONLY} or report every single
* match {@link SubscribeConfig#MATCH_STYLE_ALL} (the default).
package android.net.wifi.nan;
import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.net.wifi.RttManager;
import android.util.Log;
* <li>Creating a network-specifier when requesting a NAN connection:
* {@link #createNetworkSpecifier(int, int, byte[])}.
* </ul>
- * The {@link #terminate()} method must be called to terminate discovery sessions once they are
+ * The {@link #destroy()} method must be called to destroy discovery sessions once they are
* no longer needed.
*
* @hide PROPOSED_NAN_API
mClientId = clientId;
mSessionId = sessionId;
- mCloseGuard.open("terminate");
+ mCloseGuard.open("destroy");
}
/**
- * Terminate the publish or subscribe session - free any resources, and stop
+ * Destroy the publish or subscribe session - free any resources, and stop
* transmitting packets on-air (for an active session) or listening for
* matches (for a passive session). The session may not be used for any
- * additional operations after termination.
+ * additional operations after its destruction.
* <p>
* This operation must be done on a session which is no longer needed. Otherwise system
- * resources will continue to be utilized until the application terminates. The only
+ * resources will continue to be utilized until the application exits. The only
* exception is a session for which we received a termination callback,
* {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)}.
*/
- public void terminate() {
+ public void destroy() {
WifiNanManager mgr = mMgr.get();
if (mgr == null) {
- Log.w(TAG, "terminate: called post GC on WifiNanManager");
+ Log.w(TAG, "destroy: called post GC on WifiNanManager");
return;
}
mgr.terminateSession(mClientId, mSessionId);
try {
if (!mTerminated) {
mCloseGuard.warnIfOpen();
- terminate();
+ destroy();
}
} finally {
super.finalize();
/**
* Sends a message to the specified destination. NAN messages are transmitted in the context
* of a discovery session - executed subsequent to a publish/subscribe
- * {@link WifiNanDiscoverySessionCallback#onMatch(int, byte[], byte[])} event.
+ * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} event.
* <p>
* NAN messages are not guaranteed delivery. Callbacks on
* {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully,
- * {@link WifiNanDiscoverySessionCallback#onMessageSendSuccess(int)}, or transmission failed
+ * {@link WifiNanDiscoverySessionCallback#onMessageSent(int)}, or transmission failed
* (possibly after several retries) -
- * {@link WifiNanDiscoverySessionCallback#onMessageSendFail(int, int)}.
+ * {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int, int)}.
* <p>
* The peer will get a callback indicating a message was received using
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}.
*
* @param peerId The peer's ID for the message. Must be a result of an
- * {@link WifiNanDiscoverySessionCallback#onMatch(int, byte[], byte[])} or
- * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} events.
+ * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])}
+ * or
+ * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} events.
* @param message The message to be transmitted.
* @param messageId An arbitrary integer used by the caller to identify the message. The same
* integer ID will be returned in the callbacks indicating message send success or
/**
* Sends a message to the specified destination. NAN messages are transmitted in the context
* of a discovery session - executed subsequent to a publish/subscribe
- * {@link WifiNanDiscoverySessionCallback#onMatch(int, byte[], byte[])} event.
+ * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} event.
* <p>
* NAN messages are not guaranteed delivery. Callbacks on
* {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully,
- * {@link WifiNanDiscoverySessionCallback#onMessageSendSuccess(int)}, or transmission failed
+ * {@link WifiNanDiscoverySessionCallback#onMessageSent(int)}, or transmission failed
* (possibly after several retries) -
- * {@link WifiNanDiscoverySessionCallback#onMessageSendFail(int, int)}.
+ * {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int, int)}.
* <p>
* The peer will get a callback indicating a message was received using
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}.
* 0.
*
* @param peerId The peer's ID for the message. Must be a result of an
- * {@link WifiNanDiscoverySessionCallback#onMatch(int, byte[], byte[])} or
- * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} events.
+ * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])}
+ * or
+ * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} events.
* @param message The message to be transmitted.
* @param messageId An arbitrary integer used by the caller to identify the message. The same
* integer ID will be returned in the callbacks indicating message send success or
/**
* Start a ranging operation with the specified peers. The peer IDs are obtained from an
- * {@link WifiNanDiscoverySessionCallback#onMatch(int, byte[], byte[])} or
+ * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} or
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} operation - can only
* range devices which are part of an ongoing discovery session.
*
* {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_INITIATOR} or
* {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_RESPONDER}
* @param peerId The peer ID obtained through
- * {@link WifiNanDiscoverySessionCallback#onMatch(int, byte[], byte[])} or
+ * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} or
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}. On a RESPONDER this
* value is used to gate the acceptance of a connection request from only that
* peer. A RESPONDER may specified a 0 - indicating that it will accept
* Base class for NAN session events callbacks. Should be extended by
* applications wanting notifications. The callbacks are set when a
* publish or subscribe session is created using
- * {@link WifiNanManager#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or
- * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} .
+ * {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or
+ * {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} .
* <p>
* A single callback is set at session creation - it cannot be replaced.
*
* Indicates transmission failure: this may be due to local transmission
* failure or to no ACK received - remote device didn't receive the
* sent message. Failure reason flag for
- * {@link WifiNanDiscoverySessionCallback#onMessageSendFail(int, int)} callback.
+ * {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int, int)} callback.
*/
public static final int REASON_TX_FAIL = 3;
/**
* Called when a publish operation is started successfully in response to a
- * {@link WifiNanManager#publish(PublishConfig, WifiNanDiscoverySessionCallback)} operation.
+ * {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} operation.
*
* @param session The {@link WifiNanPublishDiscoverySession} used to control the
* discovery session.
/**
* Called when a subscribe operation is started successfully in response to a
- * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} operation.
+ * {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} operation.
*
* @param session The {@link WifiNanSubscribeDiscoverySession} used to control the
* discovery session.
}
/**
- * Called when a publish or subscribe discovery session configuration is update request
+ * Called when a publish or subscribe discovery session configuration update request
* succeeds. Called in response to
* {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} or
* {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
*/
- public void onSessionConfigSuccess() {
+ public void onSessionConfigUpdated() {
/* empty */
}
/**
* Called when a publish or subscribe discovery session cannot be created:
- * {@link WifiNanManager#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or
- * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)},
+ * {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or
+ * {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)},
* or when a configuration update fails:
* {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} or
* {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
* @param reason The failure reason using
* {@code WifiNanDiscoverySessionCallback.REASON_*} codes.
*/
- public void onSessionConfigFail(@SessionReasonCodes int reason) {
+ public void onSessionConfigFailed(@SessionReasonCodes int reason) {
/* empty */
}
/**
* Called when a discovery session (publish or subscribe) terminates. Termination may be due
- * to user-request (either directly through {@link WifiNanDiscoveryBaseSession#terminate()} or
+ * to user-request (either directly through {@link WifiNanDiscoveryBaseSession#destroy()} or
* application-specified expiration, e.g. {@link PublishConfig.Builder#setPublishCount(int)}
* or {@link SubscribeConfig.Builder#setTtlSec(int)}) or due to a failure.
*
/**
* Called when a discovery (publish or subscribe) operation results in a
- * match - when a peer is discovered.
+ * service discovery.
*
* @param peerId The ID of the peer matching our discovery operation.
* @param serviceSpecificInfo The service specific information (arbitrary
* byte array) provided by the peer as part of its discovery
* configuration.
* @param matchFilter The filter (Tx on advertiser and Rx on listener) which
- * resulted in this match.
+ * resulted in this service discovery.
*/
- public void onMatch(int peerId, byte[] serviceSpecificInfo, byte[] matchFilter) {
+ public void onServiceDiscovered(int peerId, byte[] serviceSpecificInfo, byte[] matchFilter) {
/* empty */
}
/**
* Called in response to {@link WifiNanDiscoveryBaseSession#sendMessage(int, byte[], int)}
- * when a message is transmitted successfully - when it was received successfully by the peer
- * (corresponds to an ACK being received).
+ * when a message is transmitted successfully - i.e. when it was received successfully by the
+ * peer (corresponds to an ACK being received).
* <p>
* Note that either this callback or
- * {@link WifiNanDiscoverySessionCallback#onMessageSendFail(int, int)} will be
+ * {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int, int)} will be
* received - never both.
*
* @param messageId The arbitrary message ID specified when sending the message.
*/
- public void onMessageSendSuccess(@SuppressWarnings("unused") int messageId) {
+ public void onMessageSent(@SuppressWarnings("unused") int messageId) {
/* empty */
}
* event is received after all retries are exhausted.
* <p>
* Note that either this callback or
- * {@link WifiNanDiscoverySessionCallback#onMessageSendSuccess(int)} will be received
+ * {@link WifiNanDiscoverySessionCallback#onMessageSent(int)} will be received
* - never both.
*
* @param messageId The arbitrary message ID specified when sending the message.
* @param reason The failure reason using
* {@code WifiNanDiscoverySessionCallback.REASON_*} codes.
*/
- public void onMessageSendFail(@SuppressWarnings("unused") int messageId,
+ public void onMessageSendFailed(@SuppressWarnings("unused") int messageId,
@SessionReasonCodes int reason) {
/* empty */
}
/**
* Base class for NAN events callbacks. Should be extended by applications and set when calling
- * {@link WifiNanManager#connect(android.os.Handler, WifiNanEventCallback)}. These are callbacks
+ * {@link WifiNanManager#attach(android.os.Handler, WifiNanEventCallback)}. These are callbacks
* applying to the NAN connection as a whole - not to specific publish or subscribe sessions -
* for that see {@link WifiNanDiscoverySessionCallback}.
*
/**
* Indicates invalid argument in the requested operation. Failure reason flag for
- * {@link WifiNanEventCallback#onConnectFail(int)}.
+ * {@link WifiNanEventCallback#onAttachFailed(int)}.
*/
public static final int REASON_INVALID_ARGS = 1000;
/**
* Indicates that a {@link ConfigRequest} passed in
- * {@link WifiNanManager#connect(android.os.Handler, ConfigRequest, WifiNanEventCallback)}
+ * {@link WifiNanManager#attach(android.os.Handler, ConfigRequest, WifiNanEventCallback)}
* couldn't be applied since other connections already exist with an incompatible
- * configurations. Failure reason flag for {@link WifiNanEventCallback#onConnectFail(int)}.
+ * configurations. Failure reason flag for {@link WifiNanEventCallback#onAttachFailed(int)}.
*/
public static final int REASON_ALREADY_CONNECTED_INCOMPAT_CONFIG = 1001;
/**
* Indicates an unspecified error occurred during the operation. Failure reason flag for
- * {@link WifiNanEventCallback#onConnectFail(int)}.
+ * {@link WifiNanEventCallback#onAttachFailed(int)}.
*/
public static final int REASON_OTHER = 1002;
/**
- * Called when NAN connect operation
- * {@link WifiNanManager#connect(android.os.Handler, WifiNanEventCallback)}
+ * Called when NAN attach operation
+ * {@link WifiNanManager#attach(android.os.Handler, WifiNanEventCallback)}
* is completed and that we can now start discovery sessions or connections.
*
- * @param session The NAN connection on which we can execute further NAN operations - e.g.
+ * @param session The NAN object on which we can execute further NAN operations - e.g.
* discovery, connections.
*/
- public void onConnectSuccess(WifiNanSession session) {
+ public void onAttached(WifiNanSession session) {
/* empty */
}
/**
- * Called when NAN connect operation
- * {@link WifiNanManager#connect(android.os.Handler, WifiNanEventCallback)} failed.
+ * Called when NAN attach operation
+ * {@link WifiNanManager#attach(android.os.Handler, WifiNanEventCallback)} failed.
*
* @param reason Failure reason code, see
* {@code WifiNanEventCallback.REASON_*}.
*/
- public void onConnectFail(@EventReasonCodes int reason) {
+ public void onAttachFailed(@EventReasonCodes int reason) {
/* empty */
}
* of the interface may also be useful if the application uses alternative (non-NAN)
* discovery but needs to set up a NAN connection. The provided NAN discovery interface MAC
* address can then be used in
- * {@link WifiNanManager#createNetworkSpecifier(int, byte[], byte[])}.
+ * {@link WifiNanSession#createNetworkSpecifier(int, byte[], byte[])}.
* <p>
* This callback is only called if the NAN connection enables it using
* {@link ConfigRequest.Builder#setEnableIdentityChangeCallback(boolean)} in
- * {@link WifiNanManager#connect(android.os.Handler, ConfigRequest, WifiNanEventCallback)}
+ * {@link WifiNanManager#attach(android.os.Handler, ConfigRequest, WifiNanEventCallback)}
* . It is disabled by default since it may result in additional wake-ups of the host -
* increasing power.
*
* The class provides access to:
* <ul>
* <li>Initialize a NAN cluster (peer-to-peer synchronization). Refer to
- * {@link #connect(Handler, WifiNanEventCallback)}. <li>Create discovery sessions (publish or
+ * {@link #attach(Handler, WifiNanEventCallback)}. <li>Create discovery sessions (publish or
* subscribe sessions). Refer to
* {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} and
* {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)}. <li>Create
* </ul>
* <p>
* NAN may not be usable when Wi-Fi is disabled (and other conditions). To validate that
- * the functionality is available use the {@link #isUsageEnabled()} function. To track
+ * the functionality is available use the {@link #isAvailable()} function. To track
* changes in NAN usability register for the {@link #ACTION_WIFI_NAN_STATE_CHANGED} broadcast.
* Note that this broadcast is not sticky - you should register for it and then check the
* above API to avoid a race condition.
* <p>
- * An application must use {@link #connect(Handler, WifiNanEventCallback)} to initialize a NAN
+ * An application must use {@link #attach(Handler, WifiNanEventCallback)} to initialize a NAN
* cluster - before making any other NAN operation. NAN cluster membership is a device-wide
* operation - the API guarantees that the device is in a cluster or joins a NAN cluster (or
- * starts one if none can be found). Information about connection success (or failure) are
+ * starts one if none can be found). Information about attach success (or failure) are
* returned in callbacks of {@link WifiNanEventCallback}. Proceed with NAN discovery or
- * connection setup only after receiving confirmation that NAN connection succeeded -
- * {@link WifiNanEventCallback#onConnectSuccess(WifiNanSession)}. When an application is
- * finished using NAN it <b>must</b> use the {@link WifiNanSession#disconnect()} API
- * to indicate to the NAN service that the device may disconnect from the NAN cluster. The
- * device will actually disconnect from the NAN cluster once the last application disconnects.
+ * connection setup only after receiving confirmation that NAN attach succeeded -
+ * {@link WifiNanEventCallback#onAttached(WifiNanSession)}. When an application is
+ * finished using NAN it <b>must</b> use the {@link WifiNanSession#destroy()} API
+ * to indicate to the NAN service that the device may detach from the NAN cluster. The
+ * device will actually disable NAN once the last application detaches.
* <p>
- * Once a NAN connection is confirmed use the
+ * Once a NAN attach is confirmed use the
* {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or
* {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} to
* create publish or subscribe NAN discovery sessions. Events are called on the provided
* be used to send messages using the
* {@link WifiNanDiscoveryBaseSession#sendMessage(int, byte[], int)} APIs. When an application
* is finished with a discovery session it <b>must</b> terminate it using the
- * {@link WifiNanDiscoveryBaseSession#terminate()} API.
+ * {@link WifiNanDiscoveryBaseSession#destroy()} API.
* <p>
* Creating connections between NAN devices is managed by the standard
* {@link ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)}.
* disabled. An extra {@link #EXTRA_WIFI_STATE} provides the state
* information as int using {@link #WIFI_NAN_STATE_DISABLED} and
* {@link #WIFI_NAN_STATE_ENABLED} constants. This broadcast is <b>not</b> sticky,
- * use the {@link #isUsageEnabled()} API after registering the broadcast to check the current
+ * use the {@link #isAvailable()} API after registering the broadcast to check the current
* state of Wi-Fi NAN.
*
* @see #EXTRA_WIFI_STATE
}
/**
- * Enable the usage of the NAN API. Doesn't actually turn on NAN cluster formation - that only
- * happens when a connection is made. {@link #ACTION_WIFI_NAN_STATE_CHANGED} broadcast will be
- * triggered.
+ * Enable the usage of the NAN API. Doesn't actually turn on NAN cluster formation - that
+ * only happens when an attach is attempted. {@link #ACTION_WIFI_NAN_STATE_CHANGED} broadcast
+ * will be triggered.
*
* @hide
*/
}
/**
- * Disable the usage of the NAN API. All attempts to connect() will be rejected. All open
+ * Disable the usage of the NAN API. All attempts to attach() will be rejected. All open
* connections and sessions will be terminated. {@link #ACTION_WIFI_NAN_STATE_CHANGED} broadcast
* will be triggered.
*
}
/**
- * Returns the current status of NAN API: whether or not usage is enabled. To track changes
+ * Returns the current status of NAN API: whether or not NAN is available. To track changes
* in the state of NAN API register for the {@link #ACTION_WIFI_NAN_STATE_CHANGED} broadcast.
*
- * @return A boolean indicating whether the app can use the NAN API (true)
- * or not (false).
+ * @return A boolean indicating whether the app can use the NAN API at this time (true) or
+ * not (false).
*/
- public boolean isUsageEnabled() {
+ public boolean isAvailable() {
try {
return mService.isUsageEnabled();
} catch (RemoteException e) {
}
/**
- * Connect to the Wi-Fi NAN service - enabling the application to create discovery session or
- * create connection to peers. The device will connect to an existing cluster if it can find
+ * Attach to the Wi-Fi NAN service - enabling the application to create discovery session or
+ * create connection to peers. The device will attach to an existing cluster if it can find
* one or create a new cluster (if it is the first to enable NAN in its vicinity). Results
- * (e.g. successful connection to a cluster) are provided to the {@code callback} object.
- * An application <b>must</b> call {@link WifiNanSession#disconnect()} when done with the
- * Wi-Fi NAN connection.
+ * (e.g. successful attach to a cluster) are provided to the {@code callback} object.
+ * An application <b>must</b> call {@link WifiNanSession#destroy()} when done with the
+ * Wi-Fi NAN object.
* <p>
- * Note: a NAN cluster is a shared resource - if the device is already connected to a cluster
+ * Note: a NAN cluster is a shared resource - if the device is already attached to a cluster
* than this function will simply indicate success immediately.
*
* @param handler The Handler on whose thread to execute all callbacks related to the
- * connection - including all sessions opened as part of this
- * connection. If a null is provided then the application's main thread will be used.
+ * attach request - including all sessions opened as part of this
+ * attach. If a null is provided then the application's main thread will be used.
* @param callback A callback extended from {@link WifiNanEventCallback}.
*/
- public void connect(@Nullable Handler handler, @NonNull WifiNanEventCallback callback) {
- connect(handler, null, callback);
+ public void attach(@Nullable Handler handler, @NonNull WifiNanEventCallback callback) {
+ attach(handler, null, callback);
}
/**
- * Connect to the Wi-Fi NAN service - enabling the application to create discovery session or
- * create connection to peers. The device will connect to an existing cluster if it can find
+ * Attach to the Wi-Fi NAN service - enabling the application to create discovery session or
+ * create connection to peers. The device will attach to an existing cluster if it can find
* one or create a new cluster (if it is the first to enable NAN in its vicinity). Results
- * (e.g. successful connection to a cluster) are provided to the {@code callback} object.
- * An application <b>must</b> call {@link WifiNanSession#disconnect()} when done with the
- * Wi-Fi NAN connection. Allows requesting a specific configuration using
+ * (e.g. successful attach to a cluster) are provided to the {@code callback} object.
+ * An application <b>must</b> call {@link WifiNanSession#destroy()} when done with the
+ * Wi-Fi NAN object. Allows requesting a specific configuration using
* {@link ConfigRequest}. If not necessary (default configuration should usually work) use
- * the {@link #connect(Handler, WifiNanEventCallback)} method instead.
+ * the {@link #attach(Handler, WifiNanEventCallback)} method instead.
* <p>
- * Note: a NAN cluster is a shared resource - if the device is already connected to a cluster
+ * Note: a NAN cluster is a shared resource - if the device is already attached to a cluster
* than this function will simply indicate success immediately.
*
* @param handler The Handler on whose thread to execute all callbacks related to the
- * connection - including all sessions opened as part of this
- * connection. If a null is provided then the application's main thread will be used.
+ * attach request - including all sessions opened as part of this
+ * attach. If a null is provided then the application's main thread will be used.
* @param configRequest The requested NAN configuration.
* @param callback A callback extended from {@link WifiNanEventCallback}.
*/
- public void connect(@Nullable Handler handler, @Nullable ConfigRequest configRequest,
+ public void attach(@Nullable Handler handler, @Nullable ConfigRequest configRequest,
@NonNull WifiNanEventCallback callback) {
if (VDBG) {
Log.v(TAG,
- "connect(): handler=" + handler + ", callback=" + callback + ", configRequest="
+ "attach(): handler=" + handler + ", callback=" + callback + ", configRequest="
+ configRequest);
}
switch (msg.what) {
case CALLBACK_CONNECT_SUCCESS:
- originalCallback.onConnectSuccess(
+ originalCallback.onAttached(
new WifiNanSession(mgr, mBinder, mLooper, msg.arg1));
break;
case CALLBACK_CONNECT_FAIL:
mNanManager.clear();
- originalCallback.onConnectFail(msg.arg1);
+ originalCallback.onAttachFailed(msg.arg1);
break;
case CALLBACK_IDENTITY_CHANGED:
originalCallback.onIdentityChanged((byte[]) msg.obj);
onProxySessionStarted(msg.arg1);
break;
case CALLBACK_SESSION_CONFIG_SUCCESS:
- mOriginalCallback.onSessionConfigSuccess();
+ mOriginalCallback.onSessionConfigUpdated();
break;
case CALLBACK_SESSION_CONFIG_FAIL:
- mOriginalCallback.onSessionConfigFail(msg.arg1);
+ mOriginalCallback.onSessionConfigFailed(msg.arg1);
if (mSession == null) {
/*
* creation failed (as opposed to update
onProxySessionTerminated(msg.arg1);
break;
case CALLBACK_MATCH:
- mOriginalCallback.onMatch(
+ mOriginalCallback.onServiceDiscovered(
msg.arg1,
msg.getData().getByteArray(MESSAGE_BUNDLE_KEY_MESSAGE),
msg.getData().getByteArray(MESSAGE_BUNDLE_KEY_MESSAGE2));
break;
case CALLBACK_MESSAGE_SEND_SUCCESS:
- mOriginalCallback.onMessageSendSuccess(msg.arg1);
+ mOriginalCallback.onMessageSent(msg.arg1);
break;
case CALLBACK_MESSAGE_SEND_FAIL:
- mOriginalCallback.onMessageSendFail(msg.arg1, msg.arg2);
+ mOriginalCallback.onMessageSendFailed(msg.arg1, msg.arg2);
break;
case CALLBACK_MESSAGE_RECEIVED:
mOriginalCallback.onMessageReceived(msg.arg1, (byte[]) msg.obj);
/**
* A class representing a NAN publish session. Created when
- * {@link WifiNanManager#publish(PublishConfig, WifiNanDiscoverySessionCallback)} is called and a
+ * {@link WifiNanSession#publish(PublishConfig, WifiNanDiscoverySessionCallback)} is called and a
* discovery session is created and returned in
* {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}. See
* baseline functionality of all discovery sessions in {@link WifiNanDiscoveryBaseSession}. This
* at creation is still used. The results of the configuration are returned using
* {@link WifiNanDiscoverySessionCallback}:
* <ul>
- * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigSuccess()}: configuration
+ * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigUpdated()}: configuration
* update succeeded.
- * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFail(int)}: configuration
+ * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed(int)}: configuration
* update failed. The publish discovery session is still running using its previous
* configuration (i.e. update failure does not terminate the session).
* </ul>
mClientId = clientId;
mTerminated = false;
- mCloseGuard.open("disconnect");
+ mCloseGuard.open("destroy");
}
/**
- * Disconnect from the Wi-Fi NAN service and, if no other applications are connected to NAN,
- * also disconnect from the NAN cluster. This method destroys all outstanding operations -
- * i.e. all publish and subscribes are terminated, and any outstanding data-links are
- * shut-down. However, it is good practice to terminate these discovery sessions and
- * connections explicitly before a disconnect.
+ * Destroy the Wi-Fi NAN service session and, if no other applications are attached to NAN,
+ * also disable NAN. This method destroys all outstanding operations - i.e. all publish and
+ * subscribes are terminated, and any outstanding data-links are shut-down. However, it is
+ * good practice to destroy these discovery sessions and connections explicitly before a
+ * session-wide destroy.
* <p>
- * An application may re-connect after a disconnect using
- * {@link WifiNanManager#connect(Handler, WifiNanEventCallback)} .
+ * An application may re-attach after a destroy using
+ * {@link WifiNanManager#attach(Handler, WifiNanEventCallback)} .
*/
- public void disconnect() {
+ public void destroy() {
WifiNanManager mgr = mMgr.get();
if (mgr == null) {
- Log.w(TAG, "disconnect: called post GC on WifiNanManager");
+ Log.w(TAG, "destroy: called post GC on WifiNanManager");
return;
}
mgr.disconnect(mClientId, mBinder);
try {
if (!mTerminated) {
mCloseGuard.warnIfOpen();
- disconnect();
+ destroy();
}
} finally {
super.finalize();
* <li>{@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}
* is called when the publish session is created and provides a handle to the session.
* Further operations on the publish session can be executed on that object.
- * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFail(int)} is called if the
+ * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed(int)} is called if the
* publish operation failed.
* </ul>
* <p>
* on the {@code callback} object. The resulting publish session can be modified using
* {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)}.
* <p>
- * An application must use the {@link WifiNanDiscoveryBaseSession#terminate()} to
+ * An application must use the {@link WifiNanDiscoveryBaseSession#destroy()} to
* terminate the publish discovery session once it isn't needed. This will free
* resources as well terminate any on-air transmissions.
*
* <li>{@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)}
* is called when the subscribe session is created and provides a handle to the session.
* Further operations on the subscribe session can be executed on that object.
- * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFail(int)} is called if the
+ * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed(int)} is called if the
* subscribe operation failed.
* </ul>
* <p>
* on the {@code callback} object. The resulting subscribe session can be modified using
* {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
* <p>
- * An application must use the {@link WifiNanDiscoveryBaseSession#terminate()} to
+ * An application must use the {@link WifiNanDiscoveryBaseSession#destroy()} to
* terminate the subscribe discovery session once it isn't needed. This will free
* resources as well terminate any on-air transmissions.
*
/**
* A class representing a NAN subscribe session. Created when
- * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} is called
+ * {@link WifiNanSession#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} is called
* and a discovery session is created and returned in
* {@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)}.
* See baseline functionality of all discovery sessions in {@link WifiNanDiscoveryBaseSession}.
* at creation is still used. The results of the configuration are returned using
* {@link WifiNanDiscoverySessionCallback}:
* <ul>
- * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigSuccess()}: configuration
+ * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigUpdated()}: configuration
* update succeeded.
- * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFail(int)}: configuration
+ * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed(int)}: configuration
* update failed. The subscribe discovery session is still running using its previous
* configuration (i.e. update failure does not terminate the session).
* </ul>