wifi/java/android/net/wifi/IWifiManager.aidl \
wifi/java/android/net/wifi/nan/IWifiNanEventCallback.aidl \
wifi/java/android/net/wifi/nan/IWifiNanManager.aidl \
- wifi/java/android/net/wifi/nan/IWifiNanSessionCallback.aidl \
+ wifi/java/android/net/wifi/nan/IWifiNanDiscoverySessionCallback.aidl \
wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl \
wifi/java/android/net/wifi/IWifiScanner.aidl \
wifi/java/android/net/wifi/IRttManager.aidl \
*
* {@hide}
*/
-oneway interface IWifiNanSessionCallback
+oneway interface IWifiNanDiscoverySessionCallback
{
void onSessionStarted(int sessionId);
void onSessionConfigSuccess();
import android.app.PendingIntent;
import android.net.wifi.nan.ConfigRequest;
+import android.net.wifi.nan.IWifiNanDiscoverySessionCallback;
import android.net.wifi.nan.IWifiNanEventCallback;
-import android.net.wifi.nan.IWifiNanSessionCallback;
import android.net.wifi.nan.PublishConfig;
import android.net.wifi.nan.SubscribeConfig;
import android.net.wifi.RttManager;
in ConfigRequest configRequest);
void disconnect(int clientId, in IBinder binder);
- void publish(int clientId, in PublishConfig publishConfig, in IWifiNanSessionCallback callback);
+ void publish(int clientId, in PublishConfig publishConfig,
+ in IWifiNanDiscoverySessionCallback callback);
void subscribe(int clientId, in SubscribeConfig subscribeConfig,
- in IWifiNanSessionCallback callback);
+ in IWifiNanDiscoverySessionCallback callback);
// session API
void updatePublish(int clientId, int sessionId, in PublishConfig publishConfig);
/**
* Defines the configuration of a NAN publish session. Built using
* {@link PublishConfig.Builder}. A publish session is created using
- * {@link WifiNanManager#publish(PublishConfig, WifiNanSessionCallback)} or updated using
- * {@link WifiNanPublishSession#updatePublish(PublishConfig)}.
+ * {@link WifiNanManager#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or updated using
+ * {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)}.
*
* @hide PROPOSED_NAN_API
*/
* Sets the number of times an unsolicited (configured using
* {@link PublishConfig.Builder#setPublishType(int)}) publish session
* will be broadcast. When the count is reached an event will be
- * generated for {@link WifiNanSessionCallback#onSessionTerminated(int)}
- * with {@link WifiNanSessionCallback#TERMINATE_REASON_DONE} [unless
+ * generated for {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)}
+ * with {@link WifiNanDiscoverySessionCallback#TERMINATE_REASON_DONE} [unless
* {@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 WifiNanSession#terminate()} is called.
+ * Session will be terminated when {@link WifiNanDiscoveryBaseSession#terminate()} is
+ * called.
*
* @param publishCount Number of publish packets to broadcast.
*
* {@link PublishConfig.Builder#setPublishType(int)}) publish session
* will be alive - broadcasting a packet. When the TTL is reached
* an event will be generated for
- * {@link WifiNanSessionCallback#onSessionTerminated(int)} with
- * {@link WifiNanSessionCallback#TERMINATE_REASON_DONE} [unless
+ * {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} with
+ * {@link WifiNanDiscoverySessionCallback#TERMINATE_REASON_DONE} [unless
* {@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 WifiNanSession#terminate()} is called.
+ * Session will be terminated when {@link WifiNanDiscoveryBaseSession#terminate()} is
+ * called.
*
* @param ttlSec Lifetime of a publish session in seconds.
*
/**
* Configure whether a publish terminate notification
- * {@link WifiNanSessionCallback#onSessionTerminated(int)} is reported
+ * {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} is reported
* back to the callback.
*
* @param enable If true the terminate callback will be called when the
/**
* Defines the configuration of a NAN subscribe session. Built using
* {@link SubscribeConfig.Builder}. Subscribe is done using
- * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionCallback)} or
- * {@link WifiNanSubscribeSession#updateSubscribe(SubscribeConfig)}.
+ * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} or
+ * {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
*
* @hide PROPOSED_NAN_API
*/
* Sets the number of times an active (
* {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe session
* will broadcast. When the count is reached an event will be
- * generated for {@link WifiNanSessionCallback#onSessionTerminated(int)}
- * with {@link WifiNanSessionCallback#TERMINATE_REASON_DONE}.
+ * generated for {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)}
+ * 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 WifiNanSession#terminate()} is called.
+ * Session will be terminated when {@link WifiNanDiscoveryBaseSession#terminate()} is
+ * called.
*
* @param subscribeCount Number of subscribe packets to broadcast.
*
* {@link 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
- * {@link WifiNanSessionCallback#onSessionTerminated(int)} with
- * {@link WifiNanSessionCallback#TERMINATE_REASON_DONE}.
+ * {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} 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 WifiNanSession#terminate()} is called.
+ * Session will be terminated when {@link WifiNanDiscoveryBaseSession#terminate()} 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 WifiNanSessionCallback#onMatch(int, byte[], byte[])}
+ * {@link WifiNanDiscoverySessionCallback#onMatch(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).
/**
* Configure whether a subscribe terminate notification
- * {@link WifiNanSessionCallback#onSessionTerminated(int)} is reported
+ * {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} is reported
* back to the callback.
*
* @param enable If true the terminate callback will be called when the
package android.net.wifi.nan;
import android.annotation.Nullable;
-import android.annotation.SystemApi;
import android.net.wifi.RttManager;
import android.util.Log;
/**
* A class representing a single publish or subscribe NAN session. This object
* will not be created directly - only its child classes are available:
- * {@link WifiNanPublishSession} and {@link WifiNanSubscribeSession}. This class provides
- * functionality common to both publish and subscribe discovery sessions:
+ * {@link WifiNanPublishDiscoverySession} and {@link WifiNanSubscribeDiscoverySession}. This
+ * class provides functionality common to both publish and subscribe discovery sessions:
* <ul>
* <li>Sending messages: {@link #sendMessage(int, byte[], int)} or
* {@link #sendMessage(int, byte[], int, int)} methods.
*
* @hide PROPOSED_NAN_API
*/
-public class WifiNanSession {
- private static final String TAG = "WifiNanSession";
+public class WifiNanDiscoveryBaseSession {
+ private static final String TAG = "WifiNanDiscoveryBaseSsn";
private static final boolean DBG = false;
private static final boolean VDBG = false; // STOPSHIP if true
}
/** @hide */
- public WifiNanSession(WifiNanManager manager, int sessionId) {
+ public WifiNanDiscoveryBaseSession(WifiNanManager manager, int sessionId) {
if (VDBG) Log.v(TAG, "New client created: manager=" + manager + ", sessionId=" + sessionId);
mMgr = new WeakReference<>(manager);
* 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
* exception is a session for which we received a termination callback,
- * {@link WifiNanSessionCallback#onSessionTerminated(int)}.
+ * {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)}.
*/
public void terminate() {
WifiNanManager mgr = mMgr.get();
/**
* 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 WifiNanSessionCallback#onMatch(int, byte[], byte[])} event.
+ * {@link WifiNanDiscoverySessionCallback#onMatch(int, byte[], byte[])} event.
* <p>
- * NAN messages are not guaranteed delivery. Callbacks on {@link WifiNanSessionCallback}
- * indicate message was transmitted successfully,
- * {@link WifiNanSessionCallback#onMessageSendSuccess(int)}, or transmission failed
+ * NAN messages are not guaranteed delivery. Callbacks on
+ * {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully,
+ * {@link WifiNanDiscoverySessionCallback#onMessageSendSuccess(int)}, or transmission failed
* (possibly after several retries) -
- * {@link WifiNanSessionCallback#onMessageSendFail(int, int)}.
+ * {@link WifiNanDiscoverySessionCallback#onMessageSendFail(int, int)}.
* <p>
* The peer will get a callback indicating a message was received using
- * {@link WifiNanSessionCallback#onMessageReceived(int, byte[])}.
+ * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}.
*
* @param peerId The peer's ID for the message. Must be a result of an
- * {@link WifiNanSessionCallback#onMatch(int, byte[], byte[])} or
- * {@link WifiNanSessionCallback#onMessageReceived(int, byte[])} events.
+ * {@link WifiNanDiscoverySessionCallback#onMatch(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 WifiNanSessionCallback#onMatch(int, byte[], byte[])} event.
+ * {@link WifiNanDiscoverySessionCallback#onMatch(int, byte[], byte[])} event.
* <p>
- * NAN messages are not guaranteed delivery. Callbacks on {@link WifiNanSessionCallback}
- * indicate message was transmitted successfully,
- * {@link WifiNanSessionCallback#onMessageSendSuccess(int)}, or transmission failed
+ * NAN messages are not guaranteed delivery. Callbacks on
+ * {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully,
+ * {@link WifiNanDiscoverySessionCallback#onMessageSendSuccess(int)}, or transmission failed
* (possibly after several retries) -
- * {@link WifiNanSessionCallback#onMessageSendFail(int, int)}.
+ * {@link WifiNanDiscoverySessionCallback#onMessageSendFail(int, int)}.
* <p>
* The peer will get a callback indicating a message was received using
- * {@link WifiNanSessionCallback#onMessageReceived(int, byte[])}.
+ * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}.
* Equivalent to {@link #sendMessage(int, byte[], int, int)} with a {@code retryCount} of
* 0.
*
* @param peerId The peer's ID for the message. Must be a result of an
- * {@link WifiNanSessionCallback#onMatch(int, byte[], byte[])} or
- * {@link WifiNanSessionCallback#onMessageReceived(int, byte[])} events.
+ * {@link WifiNanDiscoverySessionCallback#onMatch(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 WifiNanSessionCallback#onMatch(int, byte[], byte[])} or
- * {@link WifiNanSessionCallback#onMessageReceived(int, byte[])} operation - can only
+ * {@link WifiNanDiscoverySessionCallback#onMatch(int, byte[], byte[])} or
+ * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} operation - can only
* range devices which are part of an ongoing discovery session.
*
* @param params RTT parameters - each corresponding to a specific peer ID (the array sizes
* {@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 WifiNanSessionCallback#onMatch(int, byte[], byte[])} or
- * {@link WifiNanSessionCallback#onMessageReceived(int, byte[])}. On a RESPONDER this
+ * {@link WifiNanDiscoverySessionCallback#onMatch(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
* connection requests from any device.
* 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, WifiNanSessionCallback)} or
- * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionCallback)} .
+ * {@link WifiNanManager#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or
+ * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} .
* <p>
* A single callback is set at session creation - it cannot be replaced.
*
* @hide PROPOSED_NAN_API
*/
-public class WifiNanSessionCallback {
+public class WifiNanDiscoverySessionCallback {
/** @hide */
@IntDef({
REASON_NO_RESOURCES, REASON_INVALID_ARGS, REASON_NO_MATCH_SESSION,
/**
* Indicates no resources to execute the requested operation.
- * Failure reason flag for {@link WifiNanSessionCallback} callbacks.
+ * Failure reason flag for {@link WifiNanDiscoverySessionCallback} callbacks.
*/
public static final int REASON_NO_RESOURCES = 0;
/**
* Indicates invalid argument in the requested operation.
- * Failure reason flag for {@link WifiNanSessionCallback} callbacks.
+ * Failure reason flag for {@link WifiNanDiscoverySessionCallback} callbacks.
*/
public static final int REASON_INVALID_ARGS = 1;
/**
* Indicates a message is transmitted without a match (a discovery) or received message
* from peer occurring first.
- * Failure reason flag for {@link WifiNanSessionCallback} callbacks.
+ * Failure reason flag for {@link WifiNanDiscoverySessionCallback} callbacks.
*/
public static final int REASON_NO_MATCH_SESSION = 2;
* 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 WifiNanSessionCallback#onMessageSendFail(int, int)} callback.
+ * {@link WifiNanDiscoverySessionCallback#onMessageSendFail(int, int)} callback.
*/
public static final int REASON_TX_FAIL = 3;
/**
* Indicates an unspecified error occurred during the operation.
- * Failure reason flag for {@link WifiNanSessionCallback} callbacks.
+ * Failure reason flag for {@link WifiNanDiscoverySessionCallback} callbacks.
*/
public static final int REASON_OTHER = 4;
* Indicates that publish or subscribe session is done - all the
* requested operations (per {@link PublishConfig} or
* {@link SubscribeConfig}) have been executed. Failure reason flag for
- * {@link WifiNanSessionCallback#onSessionTerminated(int)} callback.
+ * {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} callback.
*/
public static final int TERMINATE_REASON_DONE = 100;
* Indicates that publish or subscribe session is terminated due to a
* failure.
* Failure reason flag for
- * {@link WifiNanSessionCallback#onSessionTerminated(int)} callback.
+ * {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} callback.
*/
public static final int TERMINATE_REASON_FAIL = 101;
/**
* Called when a publish operation is started successfully in response to a
- * {@link WifiNanManager#publish(PublishConfig, WifiNanSessionCallback)} operation.
+ * {@link WifiNanManager#publish(PublishConfig, WifiNanDiscoverySessionCallback)} operation.
*
- * @param session The {@link WifiNanPublishSession} used to control the
+ * @param session The {@link WifiNanPublishDiscoverySession} used to control the
* discovery session.
*/
- public void onPublishStarted(@NonNull WifiNanPublishSession session) {
+ public void onPublishStarted(@NonNull WifiNanPublishDiscoverySession session) {
/* empty */
}
/**
* Called when a subscribe operation is started successfully in response to a
- * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionCallback)} operation.
+ * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} operation.
*
- * @param session The {@link WifiNanSubscribeSession} used to control the
+ * @param session The {@link WifiNanSubscribeDiscoverySession} used to control the
* discovery session.
*/
- public void onSubscribeStarted(@NonNull WifiNanSubscribeSession session) {
+ public void onSubscribeStarted(@NonNull WifiNanSubscribeDiscoverySession session) {
/* empty */
}
/**
* Called when a publish or subscribe discovery session configuration is update request
- * succeeds. Called in response to {@link WifiNanPublishSession#updatePublish(PublishConfig)}
- * or {@link WifiNanSubscribeSession#updateSubscribe(SubscribeConfig)}.
+ * succeeds. Called in response to
+ * {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} or
+ * {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
*/
public void onSessionConfigSuccess() {
/* empty */
/**
* Called when a publish or subscribe discovery session cannot be created:
- * {@link WifiNanManager#publish(PublishConfig, WifiNanSessionCallback)} or
- * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionCallback)},
+ * {@link WifiNanManager#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or
+ * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)},
* or when a configuration update fails:
- * {@link WifiNanPublishSession#updatePublish(PublishConfig)} or
- * {@link WifiNanSubscribeSession#updateSubscribe(SubscribeConfig)}.
+ * {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} or
+ * {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
* <p>
* For discovery session updates failure leaves the session running with its previous
* configuration - the discovery session is not terminated.
*
* @param reason The failure reason using
- * {@code WifiNanSessionCallback.REASON_*} codes.
+ * {@code WifiNanDiscoverySessionCallback.REASON_*} codes.
*/
public void onSessionConfigFail(@SessionReasonCodes int reason) {
/* empty */
/**
* Called when a discovery session (publish or subscribe) terminates. Termination may be due
- * to user-request (either directly through {@link WifiNanSession#terminate()} or
+ * to user-request (either directly through {@link WifiNanDiscoveryBaseSession#terminate()} or
* application-specified expiration, e.g. {@link PublishConfig.Builder#setPublishCount(int)}
* or {@link SubscribeConfig.Builder#setTtlSec(int)}) or due to a failure.
*
* @param reason The termination reason using
- * {@code WifiNanSessionCallback.TERMINATE_*} codes.
+ * {@code WifiNanDiscoverySessionCallback.TERMINATE_*} codes.
*/
public void onSessionTerminated(@SessionTerminateCodes int reason) {
/* empty */
}
/**
- * Called in response to {@link WifiNanSession#sendMessage(int, byte[], int)} when a message
- * is transmitted successfully - when it was received successfully by the peer
+ * 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).
* <p>
* Note that either this callback or
- * {@link WifiNanSessionCallback#onMessageSendFail(int, int)} will be
+ * {@link WifiNanDiscoverySessionCallback#onMessageSendFail(int, int)} will be
* received - never both.
*
* @param messageId The arbitrary message ID specified when sending the message.
/**
* Called when message transmission fails - when no ACK is received from the peer.
* Retries when ACKs are not received are done by hardware, MAC, and in the NAN stack (using
- * the {@link WifiNanSession#sendMessage(int, byte[], int, int)} method) - this
+ * the {@link WifiNanDiscoveryBaseSession#sendMessage(int, byte[], int, int)} method) - this
* event is received after all retries are exhausted.
* <p>
* Note that either this callback or
- * {@link WifiNanSessionCallback#onMessageSendSuccess(int)} will be received
+ * {@link WifiNanDiscoverySessionCallback#onMessageSendSuccess(int)} will be received
* - never both.
*
* @param messageId The arbitrary message ID specified when sending the message.
* @param reason The failure reason using
- * {@code WifiNanSessionCallback.REASON_*} codes.
+ * {@code WifiNanDiscoverySessionCallback.REASON_*} codes.
*/
public void onMessageSendFail(@SuppressWarnings("unused") int messageId,
@SessionReasonCodes int reason) {
/**
* Called when a message is received from a discovery session peer - in response to the
- * peer's {@link WifiNanSession#sendMessage(int, byte[], int)} or
- * {@link WifiNanSession#sendMessage(int, byte[], int, int)}.
+ * peer's {@link WifiNanDiscoveryBaseSession#sendMessage(int, byte[], int)} or
+ * {@link WifiNanDiscoveryBaseSession#sendMessage(int, byte[], int, int)}.
*
* @param peerId The ID of the peer sending the message.
* @param message A byte array containing the message.
* 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
* applying to the NAN connection as a whole - not to specific publish or subscribe sessions -
- * for that see {@link WifiNanSessionCallback}.
+ * for that see {@link WifiNanDiscoverySessionCallback}.
*
* @hide PROPOSED_NAN_API
*/
import android.annotation.Nullable;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
-import android.annotation.SystemApi;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkRequest;
* <li>Initialize a NAN cluster (peer-to-peer synchronization). Refer to
* {@link #connect(Handler, WifiNanEventCallback)}.
* <li>Create discovery sessions (publish or subscribe sessions).
- * Refer to {@link #publish(PublishConfig, WifiNanSessionCallback)} and
- * {@link #subscribe(SubscribeConfig, WifiNanSessionCallback)}.
+ * Refer to {@link #publish(PublishConfig, WifiNanDiscoverySessionCallback)} and
+ * {@link #subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)}.
* <li>Create a NAN network specifier to be used with
* {@link ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)}
* to set-up a NAN connection with a peer. Refer to
- * {@link WifiNanSession#createNetworkSpecifier(int, int, byte[])} and
+ * {@link WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, int, byte[])} and
* {@link #createNetworkSpecifier(int, byte[], byte[])}.
* </ul>
* <p>
* device will actually disconnect from the NAN cluster once the last application disconnects.
* <p>
* Once a NAN connection is confirmed use the
- * {@link #publish(PublishConfig, WifiNanSessionCallback)} or
- * {@link #subscribe(SubscribeConfig, WifiNanSessionCallback)} to create publish or subscribe
- * NAN discovery sessions. Events are called on the provided callback object
- * {@link WifiNanSessionCallback}. Specifically, the
- * {@link WifiNanSessionCallback#onPublishStarted(WifiNanPublishSession)} and
- * {@link WifiNanSessionCallback#onSubscribeStarted(WifiNanSubscribeSession)} return
- * {@link WifiNanPublishSession} and {@link WifiNanSubscribeSession} objects respectively on
- * which additional session operations can be performed, e.g. updating the session
- * {@link WifiNanPublishSession#updatePublish(PublishConfig)} and
- * {@link WifiNanSubscribeSession#updateSubscribe(SubscribeConfig)}. Sessions can also be
- * used to send messages using the {@link WifiNanSession#sendMessage(int, byte[], int)} APIs.
- * When an application is finished with a discovery session it <b>must</b> terminate it using
- * the {@link WifiNanSession#terminate()} API.
+ * {@link #publish(PublishConfig, WifiNanDiscoverySessionCallback)} or
+ * {@link #subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} to create publish or
+ * subscribe NAN discovery sessions. Events are called on the provided callback object
+ * {@link WifiNanDiscoverySessionCallback}. Specifically, the
+ * {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}
+ * and
+ * {@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)}
+ * return {@link WifiNanPublishDiscoverySession} and {@link WifiNanSubscribeDiscoverySession}
+ * objects respectively on which additional session operations can be performed, e.g. updating
+ * the session {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} and
+ * {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. Sessions can also
+ * 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.
* <p>
* Creating connections between NAN devices is managed by the standard
* {@link ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)}.
* {@link android.net.NetworkCapabilities#TRANSPORT_WIFI_NAN}.
* <li>{@link NetworkRequest.Builder#setNetworkSpecifier(String)} using
* {@link #createNetworkSpecifier(int, byte[], byte[])} or
- * {@link WifiNanSession#createNetworkSpecifier(int, int, byte[])}.
+ * {@link WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, int, byte[])}.
* </ul>
*
* @hide PROPOSED_NAN_API
* Connection creation role is that of INITIATOR. Used to create a network specifier string
* when requesting a NAN network.
*
- * @see WifiNanSession#createNetworkSpecifier(int, int, byte[])
+ * @see WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, int, byte[])
* @see #createNetworkSpecifier(int, byte[], byte[])
*/
public static final int WIFI_NAN_DATA_PATH_ROLE_INITIATOR = 0;
* Connection creation role is that of RESPONDER. Used to create a network specifier string
* when requesting a NAN network.
*
- * @see WifiNanSession#createNetworkSpecifier(int, int, byte[])
+ * @see WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, int, byte[])
* @see #createNetworkSpecifier(int, byte[], byte[])
*/
public static final int WIFI_NAN_DATA_PATH_ROLE_RESPONDER = 1;
/**
* Issue a request to the NAN service to create a new NAN publish discovery session, using
* the specified {@code publishConfig} configuration. The results of the publish operation
- * are routed to the callbacks of {@link WifiNanSessionCallback}:
+ * are routed to the callbacks of {@link WifiNanDiscoverySessionCallback}:
* <ul>
- * <li>{@link WifiNanSessionCallback#onPublishStarted(WifiNanPublishSession)} 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 WifiNanSessionCallback#onSessionConfigFail(int)} is called if the publish
- * operation failed.
+ * <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
+ * publish operation failed.
* </ul>
* <p>
* Other results of the publish session operations will also be routed to callbacks
* on the {@code callback} object. The resulting publish session can be modified using
- * {@link WifiNanPublishSession#updatePublish(PublishConfig)}.
+ * {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)}.
* <p>
- * An application must use the {@link WifiNanSession#terminate()} to terminate the publish
- * discovery session once it isn't needed. This will free resources as well terminate
- * any on-air transmissions.
+ * An application must use the {@link WifiNanDiscoveryBaseSession#terminate()} to
+ * terminate the publish discovery session once it isn't needed. This will free
+ * resources as well terminate any on-air transmissions.
*
* @param publishConfig The {@link PublishConfig} specifying the
* configuration of the requested publish session.
- * @param callback A {@link WifiNanSessionCallback} derived object to be used for session
- * event callbacks.
+ * @param callback A {@link WifiNanDiscoverySessionCallback} derived object to be used for
+ * session event callbacks.
*/
public void publish(@NonNull PublishConfig publishConfig,
- @NonNull WifiNanSessionCallback callback) {
+ @NonNull WifiNanDiscoverySessionCallback callback) {
if (VDBG) Log.v(TAG, "publish(): config=" + publishConfig);
int clientId;
}
try {
mService.publish(clientId, publishConfig,
- new WifiNanSessionCallbackProxy(this, looper, true, callback));
+ new WifiNanDiscoverySessionCallbackProxy(this, looper, true, callback));
} catch (RemoteException e) {
e.rethrowAsRuntimeException();
}
/**
* Issue a request to the NAN service to create a new NAN subscribe discovery session, using
* the specified {@code subscribeConfig} configuration. The results of the subscribe
- * operation are routed to the callbacks of {@link WifiNanSessionCallback}:
+ * operation are routed to the callbacks of {@link WifiNanDiscoverySessionCallback}:
* <ul>
- * <li>{@link WifiNanSessionCallback#onSubscribeStarted(WifiNanSubscribeSession)} 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 WifiNanSessionCallback#onSessionConfigFail(int)} is called if the subscribe
- * operation failed.
+ * <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
+ * subscribe operation failed.
* </ul>
* <p>
* Other results of the subscribe session operations will also be routed to callbacks
* on the {@code callback} object. The resulting subscribe session can be modified using
- * {@link WifiNanSubscribeSession#updateSubscribe(SubscribeConfig)}.
+ * {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
* <p>
- * An application must use the {@link WifiNanSession#terminate()} to terminate the
- * subscribe discovery session once it isn't needed. This will free resources as well
- * terminate any on-air transmissions.
+ * An application must use the {@link WifiNanDiscoveryBaseSession#terminate()} to
+ * terminate the subscribe discovery session once it isn't needed. This will free
+ * resources as well terminate any on-air transmissions.
*
* @param subscribeConfig The {@link SubscribeConfig} specifying the
* configuration of the requested subscribe session.
- * @param callback A {@link WifiNanSessionCallback} derived object to be used for session
- * event callbacks.
+ * @param callback A {@link WifiNanDiscoverySessionCallback} derived object to be used for
+ * session event callbacks.
*/
public void subscribe(@NonNull SubscribeConfig subscribeConfig,
- @NonNull WifiNanSessionCallback callback) {
+ @NonNull WifiNanDiscoverySessionCallback callback) {
if (VDBG) {
Log.v(TAG, "subscribe(): config=" + subscribeConfig);
}
try {
mService.subscribe(clientId, subscribeConfig,
- new WifiNanSessionCallbackProxy(this, looper, false, callback));
+ new WifiNanDiscoverySessionCallbackProxy(this, looper, false, callback));
} catch (RemoteException e) {
e.rethrowAsRuntimeException();
}
* This API is targeted for applications which can obtain the peer MAC address using OOB
* (out-of-band) discovery. NAN discovery does not provide the MAC address of the peer -
* when using NAN discovery use the alternative network specifier method -
- * {@link WifiNanSession#createNetworkSpecifier(int, int, byte[])}.
+ * {@link WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, int, byte[])}.
*
* @param role The role of this device:
* {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_INITIATOR} or
* not the same as a null token and requires the peer token to be empty as well.
*
* @return A string to be used to construct
- * {@link android.net.NetworkRequest.Builder#setNetworkSpecifier(String)} to pass to {@link
- * android.net.ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)}
+ * {@link android.net.NetworkRequest.Builder#setNetworkSpecifier(String)} to pass to
+ * {@link android.net.ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)}
* [or other varieties of that API].
*/
public String createNetworkSpecifier(@DataPathRole int role, @Nullable byte[] peer,
}
}
- private static class WifiNanSessionCallbackProxy extends IWifiNanSessionCallback.Stub {
+ private static class WifiNanDiscoverySessionCallbackProxy extends
+ IWifiNanDiscoverySessionCallback.Stub {
private static final int CALLBACK_SESSION_STARTED = 0;
private static final int CALLBACK_SESSION_CONFIG_SUCCESS = 1;
private static final int CALLBACK_SESSION_CONFIG_FAIL = 2;
private final WeakReference<WifiNanManager> mNanManager;
private final boolean mIsPublish;
- private final WifiNanSessionCallback mOriginalCallback;
+ private final WifiNanDiscoverySessionCallback mOriginalCallback;
private final Handler mHandler;
- private WifiNanSession mSession;
+ private WifiNanDiscoveryBaseSession mSession;
- WifiNanSessionCallbackProxy(WifiNanManager mgr, Looper looper, boolean isPublish,
- WifiNanSessionCallback originalCallback) {
+ WifiNanDiscoverySessionCallbackProxy(WifiNanManager mgr, Looper looper, boolean isPublish,
+ WifiNanDiscoverySessionCallback originalCallback) {
mNanManager = new WeakReference<>(mgr);
mIsPublish = isPublish;
mOriginalCallback = originalCallback;
- if (VDBG) Log.v(TAG, "WifiNanSessionCallbackProxy ctor: isPublish=" + isPublish);
+ if (VDBG) {
+ Log.v(TAG, "WifiNanDiscoverySessionCallbackProxy ctor: isPublish=" + isPublish);
+ }
mHandler = new Handler(looper) {
@Override
if (DBG) Log.d(TAG, "What=" + msg.what + ", msg=" + msg);
if (mNanManager.get() == null) {
- Log.w(TAG, "WifiNanSessionCallbackProxy: handleMessage post GC");
+ Log.w(TAG, "WifiNanDiscoverySessionCallbackProxy: handleMessage post GC");
return;
}
}
if (mIsPublish) {
- WifiNanPublishSession session = new WifiNanPublishSession(mgr, sessionId);
+ WifiNanPublishDiscoverySession session = new WifiNanPublishDiscoverySession(mgr,
+ sessionId);
mSession = session;
mOriginalCallback.onPublishStarted(session);
} else {
- WifiNanSubscribeSession session = new WifiNanSubscribeSession(mgr, sessionId);
+ WifiNanSubscribeDiscoverySession
+ session = new WifiNanSubscribeDiscoverySession(mgr, sessionId);
mSession = session;
mOriginalCallback.onSubscribeStarted(session);
}
/**
* A class representing a NAN publish session. Created when
- * {@link WifiNanManager#publish(PublishConfig, WifiNanSessionCallback)} is called and a
+ * {@link WifiNanManager#publish(PublishConfig, WifiNanDiscoverySessionCallback)} is called and a
* discovery session is created and returned in
- * {@link WifiNanSessionCallback#onPublishStarted(WifiNanPublishSession)}. See baseline
- * functionality of all discovery sessions in {@link WifiNanSession}. This object allows updating
- * an existing/running publish discovery session using {@link #updatePublish(PublishConfig)}.
+ * {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}. See
+ * baseline functionality of all discovery sessions in {@link WifiNanDiscoveryBaseSession}. This
+ * object allows updating an existing/running publish discovery session using
+ * {@link #updatePublish(PublishConfig)}.
*
* @hide PROPOSED_NAN_API
*/
-public class WifiNanPublishSession extends WifiNanSession {
- private static final String TAG = "WifiNanPublishSession";
+public class WifiNanPublishDiscoverySession extends WifiNanDiscoveryBaseSession {
+ private static final String TAG = "WifiNanPublishDiscSsn";
/** @hide */
- public WifiNanPublishSession(WifiNanManager manager, int sessionId) {
+ public WifiNanPublishDiscoverySession(WifiNanManager manager, int sessionId) {
super(manager, sessionId);
}
/**
* Re-configure the currently active publish session. The
- * {@link WifiNanSessionCallback} is not replaced - the same listener used
+ * {@link WifiNanDiscoverySessionCallback} is not replaced - the same listener used
* at creation is still used. The results of the configuration are returned using
- * {@link WifiNanSessionCallback}:
+ * {@link WifiNanDiscoverySessionCallback}:
* <ul>
- * <li>{@link WifiNanSessionCallback#onSessionConfigSuccess()}: configuration update
- * succeeded.
- * <li>{@link WifiNanSessionCallback#onSessionConfigFail(int)}: configuration update
- * failed. The publish discovery session is still running using its previous
+ * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigSuccess()}: configuration
+ * update succeeded.
+ * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFail(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>
*
/**
* A class representing a NAN subscribe session. Created when
- * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionCallback)} is called and a
- * discovery session is created and returned in
- * {@link WifiNanSessionCallback#onSubscribeStarted(WifiNanSubscribeSession)}. See baseline
- * functionality of all discovery sessions in {@link WifiNanSession}. This object allows updating
- * an existing/running subscribe discovery session using {@link #updateSubscribe(SubscribeConfig)}.
+ * {@link WifiNanManager#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}.
+ * This object allows updating an existing/running subscribe discovery session using
+ * {@link #updateSubscribe(SubscribeConfig)}.
*
* @hide PROPOSED_NAN_API
*/
-public class WifiNanSubscribeSession extends WifiNanSession {
- private static final String TAG = "WifiNanSubscribeSession";
+public class WifiNanSubscribeDiscoverySession extends WifiNanDiscoveryBaseSession {
+ private static final String TAG = "WifiNanSubscribeDiscSsn";
/**
* {@hide}
*/
- public WifiNanSubscribeSession(WifiNanManager manager, int sessionId) {
+ public WifiNanSubscribeDiscoverySession(WifiNanManager manager, int sessionId) {
super(manager, sessionId);
}
/**
* Re-configure the currently active subscribe session. The
- * {@link WifiNanSessionCallback} is not replaced - the same listener used
+ * {@link WifiNanDiscoverySessionCallback} is not replaced - the same listener used
* at creation is still used. The results of the configuration are returned using
- * {@link WifiNanSessionCallback}:
+ * {@link WifiNanDiscoverySessionCallback}:
* <ul>
- * <li>{@link WifiNanSessionCallback#onSessionConfigSuccess()}: configuration update
- * succeeded.
- * <li>{@link WifiNanSessionCallback#onSessionConfigFail(int)}: configuration update
- * failed. The subscribe discovery session is still running using its previous
+ * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigSuccess()}: configuration
+ * update succeeded.
+ * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFail(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>
*