Merge "[NAN] Rename to make discovery explicit"

am: 5706a8f535

Change-Id: Ic71e0eced353dfdfb989876ddb4c11f4188625c5
This commit is contained in:
Etan Cohen
2016-09-20 16:50:01 +00:00
committed by android-build-merger
11 changed files with 185 additions and 172 deletions

View File

@@ -452,7 +452,7 @@ LOCAL_SRC_FILES += \
wifi/java/android/net/wifi/IWifiManager.aidl \ wifi/java/android/net/wifi/IWifiManager.aidl \
wifi/java/android/net/wifi/nan/IWifiNanEventCallback.aidl \ wifi/java/android/net/wifi/nan/IWifiNanEventCallback.aidl \
wifi/java/android/net/wifi/nan/IWifiNanManager.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/p2p/IWifiP2pManager.aidl \
wifi/java/android/net/wifi/IWifiScanner.aidl \ wifi/java/android/net/wifi/IWifiScanner.aidl \
wifi/java/android/net/wifi/IRttManager.aidl \ wifi/java/android/net/wifi/IRttManager.aidl \

View File

@@ -21,7 +21,7 @@ package android.net.wifi.nan;
* *
* {@hide} * {@hide}
*/ */
oneway interface IWifiNanSessionCallback oneway interface IWifiNanDiscoverySessionCallback
{ {
void onSessionStarted(int sessionId); void onSessionStarted(int sessionId);
void onSessionConfigSuccess(); void onSessionConfigSuccess();

View File

@@ -19,8 +19,8 @@ package android.net.wifi.nan;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.net.wifi.nan.ConfigRequest; import android.net.wifi.nan.ConfigRequest;
import android.net.wifi.nan.IWifiNanDiscoverySessionCallback;
import android.net.wifi.nan.IWifiNanEventCallback; import android.net.wifi.nan.IWifiNanEventCallback;
import android.net.wifi.nan.IWifiNanSessionCallback;
import android.net.wifi.nan.PublishConfig; import android.net.wifi.nan.PublishConfig;
import android.net.wifi.nan.SubscribeConfig; import android.net.wifi.nan.SubscribeConfig;
import android.net.wifi.RttManager; import android.net.wifi.RttManager;
@@ -42,9 +42,10 @@ interface IWifiNanManager
in ConfigRequest configRequest); in ConfigRequest configRequest);
void disconnect(int clientId, in IBinder binder); 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, void subscribe(int clientId, in SubscribeConfig subscribeConfig,
in IWifiNanSessionCallback callback); in IWifiNanDiscoverySessionCallback callback);
// session API // session API
void updatePublish(int clientId, int sessionId, in PublishConfig publishConfig); void updatePublish(int clientId, int sessionId, in PublishConfig publishConfig);

View File

@@ -32,8 +32,8 @@ import java.util.Arrays;
/** /**
* Defines the configuration of a NAN publish session. Built using * Defines the configuration of a NAN publish session. Built using
* {@link PublishConfig.Builder}. A publish session is created using * {@link PublishConfig.Builder}. A publish session is created using
* {@link WifiNanManager#publish(PublishConfig, WifiNanSessionCallback)} or updated using * {@link WifiNanManager#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or updated using
* {@link WifiNanPublishSession#updatePublish(PublishConfig)}. * {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)}.
* *
* @hide PROPOSED_NAN_API * @hide PROPOSED_NAN_API
*/ */
@@ -318,12 +318,13 @@ public final class PublishConfig implements Parcelable {
* Sets the number of times an unsolicited (configured using * Sets the number of times an unsolicited (configured using
* {@link PublishConfig.Builder#setPublishType(int)}) publish session * {@link PublishConfig.Builder#setPublishType(int)}) publish session
* will be broadcast. When the count is reached an event will be * will be broadcast. When the count is reached an event will be
* generated for {@link WifiNanSessionCallback#onSessionTerminated(int)} * generated for {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)}
* with {@link WifiNanSessionCallback#TERMINATE_REASON_DONE} [unless * with {@link WifiNanDiscoverySessionCallback#TERMINATE_REASON_DONE} [unless
* {@link #setEnableTerminateNotification(boolean)} disables the callback]. * {@link #setEnableTerminateNotification(boolean)} disables the callback].
* <p> * <p>
* Optional. 0 by default - indicating the session doesn't terminate on its own. * 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. * @param publishCount Number of publish packets to broadcast.
* *
@@ -343,12 +344,13 @@ public final class PublishConfig implements Parcelable {
* {@link PublishConfig.Builder#setPublishType(int)}) publish session * {@link PublishConfig.Builder#setPublishType(int)}) publish session
* will be alive - broadcasting a packet. When the TTL is reached * will be alive - broadcasting a packet. When the TTL is reached
* an event will be generated for * an event will be generated for
* {@link WifiNanSessionCallback#onSessionTerminated(int)} with * {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} with
* {@link WifiNanSessionCallback#TERMINATE_REASON_DONE} [unless * {@link WifiNanDiscoverySessionCallback#TERMINATE_REASON_DONE} [unless
* {@link #setEnableTerminateNotification(boolean)} disables the callback]. * {@link #setEnableTerminateNotification(boolean)} disables the callback].
* <p> * <p>
* Optional. 0 by default - indicating the session doesn't terminate on its own. * 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. * @param ttlSec Lifetime of a publish session in seconds.
* *
@@ -365,7 +367,7 @@ public final class PublishConfig implements Parcelable {
/** /**
* Configure whether a publish terminate notification * Configure whether a publish terminate notification
* {@link WifiNanSessionCallback#onSessionTerminated(int)} is reported * {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} is reported
* back to the callback. * back to the callback.
* *
* @param enable If true the terminate callback will be called when the * @param enable If true the terminate callback will be called when the

View File

@@ -32,8 +32,8 @@ import java.util.Arrays;
/** /**
* Defines the configuration of a NAN subscribe session. Built using * Defines the configuration of a NAN subscribe session. Built using
* {@link SubscribeConfig.Builder}. Subscribe is done using * {@link SubscribeConfig.Builder}. Subscribe is done using
* {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionCallback)} or * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} or
* {@link WifiNanSubscribeSession#updateSubscribe(SubscribeConfig)}. * {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
* *
* @hide PROPOSED_NAN_API * @hide PROPOSED_NAN_API
*/ */
@@ -350,11 +350,12 @@ public final class SubscribeConfig implements Parcelable {
* Sets the number of times an active ( * Sets the number of times an active (
* {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe session * {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe session
* will broadcast. When the count is reached an event will be * will broadcast. When the count is reached an event will be
* generated for {@link WifiNanSessionCallback#onSessionTerminated(int)} * generated for {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)}
* with {@link WifiNanSessionCallback#TERMINATE_REASON_DONE}. * with {@link WifiNanDiscoverySessionCallback#TERMINATE_REASON_DONE}.
* <p> * <p>
* Optional. 0 by default - indicating the session doesn't terminate on its own. * 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. * @param subscribeCount Number of subscribe packets to broadcast.
* *
@@ -374,11 +375,12 @@ public final class SubscribeConfig implements Parcelable {
* {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe session * {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe session
* will be alive - i.e. broadcasting a packet. When the TTL is reached * will be alive - i.e. broadcasting a packet. When the TTL is reached
* an event will be generated for * an event will be generated for
* {@link WifiNanSessionCallback#onSessionTerminated(int)} with * {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} with
* {@link WifiNanSessionCallback#TERMINATE_REASON_DONE}. * {@link WifiNanDiscoverySessionCallback#TERMINATE_REASON_DONE}.
* <p> * <p>
* Optional. 0 by default - indicating the session doesn't terminate on its own. * 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. * @param ttlSec Lifetime of a subscribe session in seconds.
* *
@@ -397,7 +399,7 @@ public final class SubscribeConfig implements Parcelable {
* Sets the match style of the subscription - how are matches from a * Sets the match style of the subscription - how are matches from a
* single match session (corresponding to the same publish action on the * single match session (corresponding to the same publish action on the
* peer) reported to the host (using 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 * ). The options are: only report the first match and ignore the rest
* {@link SubscribeConfig#MATCH_STYLE_FIRST_ONLY} or report every single * {@link SubscribeConfig#MATCH_STYLE_FIRST_ONLY} or report every single
* match {@link SubscribeConfig#MATCH_STYLE_ALL} (the default). * match {@link SubscribeConfig#MATCH_STYLE_ALL} (the default).
@@ -417,7 +419,7 @@ public final class SubscribeConfig implements Parcelable {
/** /**
* Configure whether a subscribe terminate notification * Configure whether a subscribe terminate notification
* {@link WifiNanSessionCallback#onSessionTerminated(int)} is reported * {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} is reported
* back to the callback. * back to the callback.
* *
* @param enable If true the terminate callback will be called when the * @param enable If true the terminate callback will be called when the

View File

@@ -17,7 +17,6 @@
package android.net.wifi.nan; package android.net.wifi.nan;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.net.wifi.RttManager; import android.net.wifi.RttManager;
import android.util.Log; import android.util.Log;
@@ -28,8 +27,8 @@ import java.lang.ref.WeakReference;
/** /**
* A class representing a single publish or subscribe NAN session. This object * A class representing a single publish or subscribe NAN session. This object
* will not be created directly - only its child classes are available: * will not be created directly - only its child classes are available:
* {@link WifiNanPublishSession} and {@link WifiNanSubscribeSession}. This class provides * {@link WifiNanPublishDiscoverySession} and {@link WifiNanSubscribeDiscoverySession}. This
* functionality common to both publish and subscribe discovery sessions: * class provides functionality common to both publish and subscribe discovery sessions:
* <ul> * <ul>
* <li>Sending messages: {@link #sendMessage(int, byte[], int)} or * <li>Sending messages: {@link #sendMessage(int, byte[], int)} or
* {@link #sendMessage(int, byte[], int, int)} methods. * {@link #sendMessage(int, byte[], int, int)} methods.
@@ -41,8 +40,8 @@ import java.lang.ref.WeakReference;
* *
* @hide PROPOSED_NAN_API * @hide PROPOSED_NAN_API
*/ */
public class WifiNanSession { public class WifiNanDiscoveryBaseSession {
private static final String TAG = "WifiNanSession"; private static final String TAG = "WifiNanDiscoveryBaseSsn";
private static final boolean DBG = false; private static final boolean DBG = false;
private static final boolean VDBG = false; // STOPSHIP if true private static final boolean VDBG = false; // STOPSHIP if true
@@ -68,7 +67,7 @@ public class WifiNanSession {
} }
/** @hide */ /** @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); if (VDBG) Log.v(TAG, "New client created: manager=" + manager + ", sessionId=" + sessionId);
mMgr = new WeakReference<>(manager); mMgr = new WeakReference<>(manager);
@@ -86,7 +85,7 @@ public class WifiNanSession {
* This operation must be done on a session which is no longer needed. Otherwise system * 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 terminates. The only
* exception is a session for which we received a termination callback, * exception is a session for which we received a termination callback,
* {@link WifiNanSessionCallback#onSessionTerminated(int)}. * {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)}.
*/ */
public void terminate() { public void terminate() {
WifiNanManager mgr = mMgr.get(); WifiNanManager mgr = mMgr.get();
@@ -132,20 +131,20 @@ public class WifiNanSession {
/** /**
* Sends a message to the specified destination. NAN messages are transmitted in the context * Sends a message to the specified destination. NAN messages are transmitted in the context
* of a discovery session - executed subsequent to a publish/subscribe * 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> * <p>
* NAN messages are not guaranteed delivery. Callbacks on {@link WifiNanSessionCallback} * NAN messages are not guaranteed delivery. Callbacks on
* indicate message was transmitted successfully, * {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully,
* {@link WifiNanSessionCallback#onMessageSendSuccess(int)}, or transmission failed * {@link WifiNanDiscoverySessionCallback#onMessageSendSuccess(int)}, or transmission failed
* (possibly after several retries) - * (possibly after several retries) -
* {@link WifiNanSessionCallback#onMessageSendFail(int, int)}. * {@link WifiNanDiscoverySessionCallback#onMessageSendFail(int, int)}.
* <p> * <p>
* The peer will get a callback indicating a message was received using * 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 * @param peerId The peer's ID for the message. Must be a result of an
* {@link WifiNanSessionCallback#onMatch(int, byte[], byte[])} or * {@link WifiNanDiscoverySessionCallback#onMatch(int, byte[], byte[])} or
* {@link WifiNanSessionCallback#onMessageReceived(int, byte[])} events. * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} events.
* @param message The message to be transmitted. * @param message The message to be transmitted.
* @param messageId An arbitrary integer used by the caller to identify the message. The same * @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 * integer ID will be returned in the callbacks indicating message send success or
@@ -174,22 +173,22 @@ public class WifiNanSession {
/** /**
* Sends a message to the specified destination. NAN messages are transmitted in the context * Sends a message to the specified destination. NAN messages are transmitted in the context
* of a discovery session - executed subsequent to a publish/subscribe * 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> * <p>
* NAN messages are not guaranteed delivery. Callbacks on {@link WifiNanSessionCallback} * NAN messages are not guaranteed delivery. Callbacks on
* indicate message was transmitted successfully, * {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully,
* {@link WifiNanSessionCallback#onMessageSendSuccess(int)}, or transmission failed * {@link WifiNanDiscoverySessionCallback#onMessageSendSuccess(int)}, or transmission failed
* (possibly after several retries) - * (possibly after several retries) -
* {@link WifiNanSessionCallback#onMessageSendFail(int, int)}. * {@link WifiNanDiscoverySessionCallback#onMessageSendFail(int, int)}.
* <p> * <p>
* The peer will get a callback indicating a message was received using * 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 * Equivalent to {@link #sendMessage(int, byte[], int, int)} with a {@code retryCount} of
* 0. * 0.
* *
* @param peerId The peer's ID for the message. Must be a result of an * @param peerId The peer's ID for the message. Must be a result of an
* {@link WifiNanSessionCallback#onMatch(int, byte[], byte[])} or * {@link WifiNanDiscoverySessionCallback#onMatch(int, byte[], byte[])} or
* {@link WifiNanSessionCallback#onMessageReceived(int, byte[])} events. * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} events.
* @param message The message to be transmitted. * @param message The message to be transmitted.
* @param messageId An arbitrary integer used by the caller to identify the message. The same * @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 * integer ID will be returned in the callbacks indicating message send success or
@@ -202,8 +201,8 @@ public class WifiNanSession {
/** /**
* Start a ranging operation with the specified peers. The peer IDs are obtained from an * Start a ranging operation with the specified peers. The peer IDs are obtained from an
* {@link WifiNanSessionCallback#onMatch(int, byte[], byte[])} or * {@link WifiNanDiscoverySessionCallback#onMatch(int, byte[], byte[])} or
* {@link WifiNanSessionCallback#onMessageReceived(int, byte[])} operation - can only * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} operation - can only
* range devices which are part of an ongoing discovery session. * range devices which are part of an ongoing discovery session.
* *
* @param params RTT parameters - each corresponding to a specific peer ID (the array sizes * @param params RTT parameters - each corresponding to a specific peer ID (the array sizes
@@ -245,8 +244,8 @@ public class WifiNanSession {
* {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_INITIATOR} or * {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_INITIATOR} or
* {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_RESPONDER} * {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_RESPONDER}
* @param peerId The peer ID obtained through * @param peerId The peer ID obtained through
* {@link WifiNanSessionCallback#onMatch(int, byte[], byte[])} or * {@link WifiNanDiscoverySessionCallback#onMatch(int, byte[], byte[])} or
* {@link WifiNanSessionCallback#onMessageReceived(int, byte[])}. On a RESPONDER this * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}. On a RESPONDER this
* value is used to gate the acceptance of a connection request from only that * 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 * peer. A RESPONDER may specified a 0 - indicating that it will accept
* connection requests from any device. * connection requests from any device.

View File

@@ -26,14 +26,14 @@ import java.lang.annotation.RetentionPolicy;
* Base class for NAN session events callbacks. Should be extended by * Base class for NAN session events callbacks. Should be extended by
* applications wanting notifications. The callbacks are set when a * applications wanting notifications. The callbacks are set when a
* publish or subscribe session is created using * publish or subscribe session is created using
* {@link WifiNanManager#publish(PublishConfig, WifiNanSessionCallback)} or * {@link WifiNanManager#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or
* {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionCallback)} . * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} .
* <p> * <p>
* A single callback is set at session creation - it cannot be replaced. * A single callback is set at session creation - it cannot be replaced.
* *
* @hide PROPOSED_NAN_API * @hide PROPOSED_NAN_API
*/ */
public class WifiNanSessionCallback { public class WifiNanDiscoverySessionCallback {
/** @hide */ /** @hide */
@IntDef({ @IntDef({
REASON_NO_RESOURCES, REASON_INVALID_ARGS, REASON_NO_MATCH_SESSION, REASON_NO_RESOURCES, REASON_INVALID_ARGS, REASON_NO_MATCH_SESSION,
@@ -51,20 +51,20 @@ public class WifiNanSessionCallback {
/** /**
* Indicates no resources to execute the requested operation. * 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; public static final int REASON_NO_RESOURCES = 0;
/** /**
* Indicates invalid argument in the requested operation. * 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; public static final int REASON_INVALID_ARGS = 1;
/** /**
* Indicates a message is transmitted without a match (a discovery) or received message * Indicates a message is transmitted without a match (a discovery) or received message
* from peer occurring first. * 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; public static final int REASON_NO_MATCH_SESSION = 2;
@@ -72,13 +72,13 @@ public class WifiNanSessionCallback {
* Indicates transmission failure: this may be due to local transmission * Indicates transmission failure: this may be due to local transmission
* failure or to no ACK received - remote device didn't receive the * failure or to no ACK received - remote device didn't receive the
* sent message. Failure reason flag for * 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; public static final int REASON_TX_FAIL = 3;
/** /**
* Indicates an unspecified error occurred during the operation. * 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; public static final int REASON_OTHER = 4;
@@ -86,7 +86,7 @@ public class WifiNanSessionCallback {
* Indicates that publish or subscribe session is done - all the * Indicates that publish or subscribe session is done - all the
* requested operations (per {@link PublishConfig} or * requested operations (per {@link PublishConfig} or
* {@link SubscribeConfig}) have been executed. Failure reason flag for * {@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; public static final int TERMINATE_REASON_DONE = 100;
@@ -94,36 +94,37 @@ public class WifiNanSessionCallback {
* Indicates that publish or subscribe session is terminated due to a * Indicates that publish or subscribe session is terminated due to a
* failure. * failure.
* Failure reason flag for * Failure reason flag for
* {@link WifiNanSessionCallback#onSessionTerminated(int)} callback. * {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} callback.
*/ */
public static final int TERMINATE_REASON_FAIL = 101; public static final int TERMINATE_REASON_FAIL = 101;
/** /**
* Called when a publish operation is started successfully in response to a * 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. * discovery session.
*/ */
public void onPublishStarted(@NonNull WifiNanPublishSession session) { public void onPublishStarted(@NonNull WifiNanPublishDiscoverySession session) {
/* empty */ /* empty */
} }
/** /**
* Called when a subscribe operation is started successfully in response to a * 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. * discovery session.
*/ */
public void onSubscribeStarted(@NonNull WifiNanSubscribeSession session) { public void onSubscribeStarted(@NonNull WifiNanSubscribeDiscoverySession session) {
/* empty */ /* empty */
} }
/** /**
* Called when a publish or subscribe discovery session configuration is update request * Called when a publish or subscribe discovery session configuration is update request
* succeeds. Called in response to {@link WifiNanPublishSession#updatePublish(PublishConfig)} * succeeds. Called in response to
* or {@link WifiNanSubscribeSession#updateSubscribe(SubscribeConfig)}. * {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} or
* {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
*/ */
public void onSessionConfigSuccess() { public void onSessionConfigSuccess() {
/* empty */ /* empty */
@@ -131,17 +132,17 @@ public class WifiNanSessionCallback {
/** /**
* Called when a publish or subscribe discovery session cannot be created: * Called when a publish or subscribe discovery session cannot be created:
* {@link WifiNanManager#publish(PublishConfig, WifiNanSessionCallback)} or * {@link WifiNanManager#publish(PublishConfig, WifiNanDiscoverySessionCallback)} or
* {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionCallback)}, * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)},
* or when a configuration update fails: * or when a configuration update fails:
* {@link WifiNanPublishSession#updatePublish(PublishConfig)} or * {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} or
* {@link WifiNanSubscribeSession#updateSubscribe(SubscribeConfig)}. * {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
* <p> * <p>
* For discovery session updates failure leaves the session running with its previous * For discovery session updates failure leaves the session running with its previous
* configuration - the discovery session is not terminated. * configuration - the discovery session is not terminated.
* *
* @param reason The failure reason using * @param reason The failure reason using
* {@code WifiNanSessionCallback.REASON_*} codes. * {@code WifiNanDiscoverySessionCallback.REASON_*} codes.
*/ */
public void onSessionConfigFail(@SessionReasonCodes int reason) { public void onSessionConfigFail(@SessionReasonCodes int reason) {
/* empty */ /* empty */
@@ -149,12 +150,12 @@ public class WifiNanSessionCallback {
/** /**
* Called when a discovery session (publish or subscribe) terminates. Termination may be due * 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)} * application-specified expiration, e.g. {@link PublishConfig.Builder#setPublishCount(int)}
* or {@link SubscribeConfig.Builder#setTtlSec(int)}) or due to a failure. * or {@link SubscribeConfig.Builder#setTtlSec(int)}) or due to a failure.
* *
* @param reason The termination reason using * @param reason The termination reason using
* {@code WifiNanSessionCallback.TERMINATE_*} codes. * {@code WifiNanDiscoverySessionCallback.TERMINATE_*} codes.
*/ */
public void onSessionTerminated(@SessionTerminateCodes int reason) { public void onSessionTerminated(@SessionTerminateCodes int reason) {
/* empty */ /* empty */
@@ -176,12 +177,12 @@ public class WifiNanSessionCallback {
} }
/** /**
* Called in response to {@link WifiNanSession#sendMessage(int, byte[], int)} when a message * Called in response to {@link WifiNanDiscoveryBaseSession#sendMessage(int, byte[], int)}
* is transmitted successfully - when it was received successfully by the peer * when a message is transmitted successfully - when it was received successfully by the peer
* (corresponds to an ACK being received). * (corresponds to an ACK being received).
* <p> * <p>
* Note that either this callback or * Note that either this callback or
* {@link WifiNanSessionCallback#onMessageSendFail(int, int)} will be * {@link WifiNanDiscoverySessionCallback#onMessageSendFail(int, int)} will be
* received - never both. * received - never both.
* *
* @param messageId The arbitrary message ID specified when sending the message. * @param messageId The arbitrary message ID specified when sending the message.
@@ -193,16 +194,16 @@ public class WifiNanSessionCallback {
/** /**
* Called when message transmission fails - when no ACK is received from the peer. * 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 * 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. * event is received after all retries are exhausted.
* <p> * <p>
* Note that either this callback or * Note that either this callback or
* {@link WifiNanSessionCallback#onMessageSendSuccess(int)} will be received * {@link WifiNanDiscoverySessionCallback#onMessageSendSuccess(int)} will be received
* - never both. * - never both.
* *
* @param messageId The arbitrary message ID specified when sending the message. * @param messageId The arbitrary message ID specified when sending the message.
* @param reason The failure reason using * @param reason The failure reason using
* {@code WifiNanSessionCallback.REASON_*} codes. * {@code WifiNanDiscoverySessionCallback.REASON_*} codes.
*/ */
public void onMessageSendFail(@SuppressWarnings("unused") int messageId, public void onMessageSendFail(@SuppressWarnings("unused") int messageId,
@SessionReasonCodes int reason) { @SessionReasonCodes int reason) {
@@ -211,8 +212,8 @@ public class WifiNanSessionCallback {
/** /**
* Called when a message is received from a discovery session peer - in response to the * Called when a message is received from a discovery session peer - in response to the
* peer's {@link WifiNanSession#sendMessage(int, byte[], int)} or * peer's {@link WifiNanDiscoveryBaseSession#sendMessage(int, byte[], int)} or
* {@link WifiNanSession#sendMessage(int, byte[], int, int)}. * {@link WifiNanDiscoveryBaseSession#sendMessage(int, byte[], int, int)}.
* *
* @param peerId The ID of the peer sending the message. * @param peerId The ID of the peer sending the message.
* @param message A byte array containing the message. * @param message A byte array containing the message.

View File

@@ -25,7 +25,7 @@ import java.lang.annotation.RetentionPolicy;
* Base class for NAN events callbacks. Should be extended by applications and set when calling * 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#connect(android.os.Handler, WifiNanEventCallback)}. These are callbacks
* applying to the NAN connection as a whole - not to specific publish or subscribe sessions - * 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 * @hide PROPOSED_NAN_API
*/ */

View File

@@ -21,7 +21,6 @@ import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.SdkConstant; import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
import android.content.Context; import android.content.Context;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkRequest; import android.net.NetworkRequest;
@@ -62,12 +61,12 @@ import java.util.Arrays;
* <li>Initialize a NAN cluster (peer-to-peer synchronization). Refer to * <li>Initialize a NAN cluster (peer-to-peer synchronization). Refer to
* {@link #connect(Handler, WifiNanEventCallback)}. * {@link #connect(Handler, WifiNanEventCallback)}.
* <li>Create discovery sessions (publish or subscribe sessions). * <li>Create discovery sessions (publish or subscribe sessions).
* Refer to {@link #publish(PublishConfig, WifiNanSessionCallback)} and * Refer to {@link #publish(PublishConfig, WifiNanDiscoverySessionCallback)} and
* {@link #subscribe(SubscribeConfig, WifiNanSessionCallback)}. * {@link #subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)}.
* <li>Create a NAN network specifier to be used with * <li>Create a NAN network specifier to be used with
* {@link ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)} * {@link ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)}
* to set-up a NAN connection with a peer. Refer to * 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[])}. * {@link #createNetworkSpecifier(int, byte[], byte[])}.
* </ul> * </ul>
* <p> * <p>
@@ -89,19 +88,21 @@ import java.util.Arrays;
* device will actually disconnect from the NAN cluster once the last application disconnects. * device will actually disconnect from the NAN cluster once the last application disconnects.
* <p> * <p>
* Once a NAN connection is confirmed use the * Once a NAN connection is confirmed use the
* {@link #publish(PublishConfig, WifiNanSessionCallback)} or * {@link #publish(PublishConfig, WifiNanDiscoverySessionCallback)} or
* {@link #subscribe(SubscribeConfig, WifiNanSessionCallback)} to create publish or subscribe * {@link #subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} to create publish or
* NAN discovery sessions. Events are called on the provided callback object * subscribe NAN discovery sessions. Events are called on the provided callback object
* {@link WifiNanSessionCallback}. Specifically, the * {@link WifiNanDiscoverySessionCallback}. Specifically, the
* {@link WifiNanSessionCallback#onPublishStarted(WifiNanPublishSession)} and * {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}
* {@link WifiNanSessionCallback#onSubscribeStarted(WifiNanSubscribeSession)} return * and
* {@link WifiNanPublishSession} and {@link WifiNanSubscribeSession} objects respectively on * {@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)}
* which additional session operations can be performed, e.g. updating the session * return {@link WifiNanPublishDiscoverySession} and {@link WifiNanSubscribeDiscoverySession}
* {@link WifiNanPublishSession#updatePublish(PublishConfig)} and * objects respectively on which additional session operations can be performed, e.g. updating
* {@link WifiNanSubscribeSession#updateSubscribe(SubscribeConfig)}. Sessions can also be * the session {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} and
* used to send messages using the {@link WifiNanSession#sendMessage(int, byte[], int)} APIs. * {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. Sessions can also
* When an application is finished with a discovery session it <b>must</b> terminate it using * be used to send messages using the
* the {@link WifiNanSession#terminate()} API. * {@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> * <p>
* Creating connections between NAN devices is managed by the standard * Creating connections between NAN devices is managed by the standard
* {@link ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)}. * {@link ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)}.
@@ -111,7 +112,7 @@ import java.util.Arrays;
* {@link android.net.NetworkCapabilities#TRANSPORT_WIFI_NAN}. * {@link android.net.NetworkCapabilities#TRANSPORT_WIFI_NAN}.
* <li>{@link NetworkRequest.Builder#setNetworkSpecifier(String)} using * <li>{@link NetworkRequest.Builder#setNetworkSpecifier(String)} using
* {@link #createNetworkSpecifier(int, byte[], byte[])} or * {@link #createNetworkSpecifier(int, byte[], byte[])} or
* {@link WifiNanSession#createNetworkSpecifier(int, int, byte[])}. * {@link WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, int, byte[])}.
* </ul> * </ul>
* *
* @hide PROPOSED_NAN_API * @hide PROPOSED_NAN_API
@@ -249,7 +250,7 @@ public class WifiNanManager {
* Connection creation role is that of INITIATOR. Used to create a network specifier string * Connection creation role is that of INITIATOR. Used to create a network specifier string
* when requesting a NAN network. * when requesting a NAN network.
* *
* @see WifiNanSession#createNetworkSpecifier(int, int, byte[]) * @see WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, int, byte[])
* @see #createNetworkSpecifier(int, byte[], byte[]) * @see #createNetworkSpecifier(int, byte[], byte[])
*/ */
public static final int WIFI_NAN_DATA_PATH_ROLE_INITIATOR = 0; public static final int WIFI_NAN_DATA_PATH_ROLE_INITIATOR = 0;
@@ -258,7 +259,7 @@ public class WifiNanManager {
* Connection creation role is that of RESPONDER. Used to create a network specifier string * Connection creation role is that of RESPONDER. Used to create a network specifier string
* when requesting a NAN network. * when requesting a NAN network.
* *
* @see WifiNanSession#createNetworkSpecifier(int, int, byte[]) * @see WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, int, byte[])
* @see #createNetworkSpecifier(int, byte[], byte[]) * @see #createNetworkSpecifier(int, byte[], byte[])
*/ */
public static final int WIFI_NAN_DATA_PATH_ROLE_RESPONDER = 1; public static final int WIFI_NAN_DATA_PATH_ROLE_RESPONDER = 1;
@@ -445,30 +446,30 @@ public class WifiNanManager {
/** /**
* Issue a request to the NAN service to create a new NAN publish discovery session, using * 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 * 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> * <ul>
* <li>{@link WifiNanSessionCallback#onPublishStarted(WifiNanPublishSession)} is called * <li>{@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}
* when the publish session is created and provides a handle to the session. Further * is called when the publish session is created and provides a handle to the session.
* operations on the publish session can be executed on that object. * Further operations on the publish session can be executed on that object.
* <li>{@link WifiNanSessionCallback#onSessionConfigFail(int)} is called if the publish * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFail(int)} is called if the
* operation failed. * publish operation failed.
* </ul> * </ul>
* <p> * <p>
* Other results of the publish session operations will also be routed to callbacks * 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 * on the {@code callback} object. The resulting publish session can be modified using
* {@link WifiNanPublishSession#updatePublish(PublishConfig)}. * {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)}.
* <p> * <p>
* An application must use the {@link WifiNanSession#terminate()} to terminate the publish * An application must use the {@link WifiNanDiscoveryBaseSession#terminate()} to
* discovery session once it isn't needed. This will free resources as well terminate * terminate the publish discovery session once it isn't needed. This will free
* any on-air transmissions. * resources as well terminate any on-air transmissions.
* *
* @param publishConfig The {@link PublishConfig} specifying the * @param publishConfig The {@link PublishConfig} specifying the
* configuration of the requested publish session. * configuration of the requested publish session.
* @param callback A {@link WifiNanSessionCallback} derived object to be used for session * @param callback A {@link WifiNanDiscoverySessionCallback} derived object to be used for
* event callbacks. * session event callbacks.
*/ */
public void publish(@NonNull PublishConfig publishConfig, public void publish(@NonNull PublishConfig publishConfig,
@NonNull WifiNanSessionCallback callback) { @NonNull WifiNanDiscoverySessionCallback callback) {
if (VDBG) Log.v(TAG, "publish(): config=" + publishConfig); if (VDBG) Log.v(TAG, "publish(): config=" + publishConfig);
int clientId; int clientId;
@@ -485,7 +486,7 @@ public class WifiNanManager {
} }
try { try {
mService.publish(clientId, publishConfig, mService.publish(clientId, publishConfig,
new WifiNanSessionCallbackProxy(this, looper, true, callback)); new WifiNanDiscoverySessionCallbackProxy(this, looper, true, callback));
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -514,30 +515,30 @@ public class WifiNanManager {
/** /**
* Issue a request to the NAN service to create a new NAN subscribe discovery session, using * 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 * 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> * <ul>
* <li>{@link WifiNanSessionCallback#onSubscribeStarted(WifiNanSubscribeSession)} is called * <li>{@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)}
* when the subscribe session is created and provides a handle to the session. Further * is called when the subscribe session is created and provides a handle to the session.
* operations on the subscribe session can be executed on that object. * Further operations on the subscribe session can be executed on that object.
* <li>{@link WifiNanSessionCallback#onSessionConfigFail(int)} is called if the subscribe * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFail(int)} is called if the
* operation failed. * subscribe operation failed.
* </ul> * </ul>
* <p> * <p>
* Other results of the subscribe session operations will also be routed to callbacks * 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 * on the {@code callback} object. The resulting subscribe session can be modified using
* {@link WifiNanSubscribeSession#updateSubscribe(SubscribeConfig)}. * {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
* <p> * <p>
* An application must use the {@link WifiNanSession#terminate()} to terminate the * An application must use the {@link WifiNanDiscoveryBaseSession#terminate()} to
* subscribe discovery session once it isn't needed. This will free resources as well * terminate the subscribe discovery session once it isn't needed. This will free
* terminate any on-air transmissions. * resources as well terminate any on-air transmissions.
* *
* @param subscribeConfig The {@link SubscribeConfig} specifying the * @param subscribeConfig The {@link SubscribeConfig} specifying the
* configuration of the requested subscribe session. * configuration of the requested subscribe session.
* @param callback A {@link WifiNanSessionCallback} derived object to be used for session * @param callback A {@link WifiNanDiscoverySessionCallback} derived object to be used for
* event callbacks. * session event callbacks.
*/ */
public void subscribe(@NonNull SubscribeConfig subscribeConfig, public void subscribe(@NonNull SubscribeConfig subscribeConfig,
@NonNull WifiNanSessionCallback callback) { @NonNull WifiNanDiscoverySessionCallback callback) {
if (VDBG) { if (VDBG) {
Log.v(TAG, "subscribe(): config=" + subscribeConfig); Log.v(TAG, "subscribe(): config=" + subscribeConfig);
} }
@@ -557,7 +558,7 @@ public class WifiNanManager {
try { try {
mService.subscribe(clientId, subscribeConfig, mService.subscribe(clientId, subscribeConfig,
new WifiNanSessionCallbackProxy(this, looper, false, callback)); new WifiNanDiscoverySessionCallbackProxy(this, looper, false, callback));
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -744,7 +745,7 @@ public class WifiNanManager {
* This API is targeted for applications which can obtain the peer MAC address using OOB * 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 - * (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 - * 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: * @param role The role of this device:
* {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_INITIATOR} or * {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_INITIATOR} or
@@ -760,8 +761,8 @@ public class WifiNanManager {
* not the same as a null token and requires the peer token to be empty as well. * 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 * @return A string to be used to construct
* {@link android.net.NetworkRequest.Builder#setNetworkSpecifier(String)} to pass to {@link * {@link android.net.NetworkRequest.Builder#setNetworkSpecifier(String)} to pass to
* android.net.ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)} * {@link android.net.ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)}
* [or other varieties of that API]. * [or other varieties of that API].
*/ */
public String createNetworkSpecifier(@DataPathRole int role, @Nullable byte[] peer, public String createNetworkSpecifier(@DataPathRole int role, @Nullable byte[] peer,
@@ -999,7 +1000,8 @@ public class WifiNanManager {
} }
} }
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_STARTED = 0;
private static final int CALLBACK_SESSION_CONFIG_SUCCESS = 1; private static final int CALLBACK_SESSION_CONFIG_SUCCESS = 1;
private static final int CALLBACK_SESSION_CONFIG_FAIL = 2; private static final int CALLBACK_SESSION_CONFIG_FAIL = 2;
@@ -1014,18 +1016,20 @@ public class WifiNanManager {
private final WeakReference<WifiNanManager> mNanManager; private final WeakReference<WifiNanManager> mNanManager;
private final boolean mIsPublish; private final boolean mIsPublish;
private final WifiNanSessionCallback mOriginalCallback; private final WifiNanDiscoverySessionCallback mOriginalCallback;
private final Handler mHandler; private final Handler mHandler;
private WifiNanSession mSession; private WifiNanDiscoveryBaseSession mSession;
WifiNanSessionCallbackProxy(WifiNanManager mgr, Looper looper, boolean isPublish, WifiNanDiscoverySessionCallbackProxy(WifiNanManager mgr, Looper looper, boolean isPublish,
WifiNanSessionCallback originalCallback) { WifiNanDiscoverySessionCallback originalCallback) {
mNanManager = new WeakReference<>(mgr); mNanManager = new WeakReference<>(mgr);
mIsPublish = isPublish; mIsPublish = isPublish;
mOriginalCallback = originalCallback; mOriginalCallback = originalCallback;
if (VDBG) Log.v(TAG, "WifiNanSessionCallbackProxy ctor: isPublish=" + isPublish); if (VDBG) {
Log.v(TAG, "WifiNanDiscoverySessionCallbackProxy ctor: isPublish=" + isPublish);
}
mHandler = new Handler(looper) { mHandler = new Handler(looper) {
@Override @Override
@@ -1033,7 +1037,7 @@ public class WifiNanManager {
if (DBG) Log.d(TAG, "What=" + msg.what + ", msg=" + msg); if (DBG) Log.d(TAG, "What=" + msg.what + ", msg=" + msg);
if (mNanManager.get() == null) { if (mNanManager.get() == null) {
Log.w(TAG, "WifiNanSessionCallbackProxy: handleMessage post GC"); Log.w(TAG, "WifiNanDiscoverySessionCallbackProxy: handleMessage post GC");
return; return;
} }
@@ -1176,11 +1180,13 @@ public class WifiNanManager {
} }
if (mIsPublish) { if (mIsPublish) {
WifiNanPublishSession session = new WifiNanPublishSession(mgr, sessionId); WifiNanPublishDiscoverySession session = new WifiNanPublishDiscoverySession(mgr,
sessionId);
mSession = session; mSession = session;
mOriginalCallback.onPublishStarted(session); mOriginalCallback.onPublishStarted(session);
} else { } else {
WifiNanSubscribeSession session = new WifiNanSubscribeSession(mgr, sessionId); WifiNanSubscribeDiscoverySession
session = new WifiNanSubscribeDiscoverySession(mgr, sessionId);
mSession = session; mSession = session;
mOriginalCallback.onSubscribeStarted(session); mOriginalCallback.onSubscribeStarted(session);
} }

View File

@@ -21,32 +21,33 @@ import android.util.Log;
/** /**
* A class representing a NAN publish session. Created when * 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 * discovery session is created and returned in
* {@link WifiNanSessionCallback#onPublishStarted(WifiNanPublishSession)}. See baseline * {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}. See
* functionality of all discovery sessions in {@link WifiNanSession}. This object allows updating * baseline functionality of all discovery sessions in {@link WifiNanDiscoveryBaseSession}. This
* an existing/running publish discovery session using {@link #updatePublish(PublishConfig)}. * object allows updating an existing/running publish discovery session using
* {@link #updatePublish(PublishConfig)}.
* *
* @hide PROPOSED_NAN_API * @hide PROPOSED_NAN_API
*/ */
public class WifiNanPublishSession extends WifiNanSession { public class WifiNanPublishDiscoverySession extends WifiNanDiscoveryBaseSession {
private static final String TAG = "WifiNanPublishSession"; private static final String TAG = "WifiNanPublishDiscSsn";
/** @hide */ /** @hide */
public WifiNanPublishSession(WifiNanManager manager, int sessionId) { public WifiNanPublishDiscoverySession(WifiNanManager manager, int sessionId) {
super(manager, sessionId); super(manager, sessionId);
} }
/** /**
* Re-configure the currently active publish session. The * 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 * at creation is still used. The results of the configuration are returned using
* {@link WifiNanSessionCallback}: * {@link WifiNanDiscoverySessionCallback}:
* <ul> * <ul>
* <li>{@link WifiNanSessionCallback#onSessionConfigSuccess()}: configuration update * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigSuccess()}: configuration
* succeeded. * update succeeded.
* <li>{@link WifiNanSessionCallback#onSessionConfigFail(int)}: configuration update * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFail(int)}: configuration
* failed. The publish discovery session is still running using its previous * update failed. The publish discovery session is still running using its previous
* configuration (i.e. update failure does not terminate the session). * configuration (i.e. update failure does not terminate the session).
* </ul> * </ul>
* *

View File

@@ -21,34 +21,35 @@ import android.util.Log;
/** /**
* A class representing a NAN subscribe session. Created when * A class representing a NAN subscribe session. Created when
* {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionCallback)} is called and a * {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanDiscoverySessionCallback)} is called
* discovery session is created and returned in * and a discovery session is created and returned in
* {@link WifiNanSessionCallback#onSubscribeStarted(WifiNanSubscribeSession)}. See baseline * {@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)}.
* functionality of all discovery sessions in {@link WifiNanSession}. This object allows updating * See baseline functionality of all discovery sessions in {@link WifiNanDiscoveryBaseSession}.
* an existing/running subscribe discovery session using {@link #updateSubscribe(SubscribeConfig)}. * This object allows updating an existing/running subscribe discovery session using
* {@link #updateSubscribe(SubscribeConfig)}.
* *
* @hide PROPOSED_NAN_API * @hide PROPOSED_NAN_API
*/ */
public class WifiNanSubscribeSession extends WifiNanSession { public class WifiNanSubscribeDiscoverySession extends WifiNanDiscoveryBaseSession {
private static final String TAG = "WifiNanSubscribeSession"; private static final String TAG = "WifiNanSubscribeDiscSsn";
/** /**
* {@hide} * {@hide}
*/ */
public WifiNanSubscribeSession(WifiNanManager manager, int sessionId) { public WifiNanSubscribeDiscoverySession(WifiNanManager manager, int sessionId) {
super(manager, sessionId); super(manager, sessionId);
} }
/** /**
* Re-configure the currently active subscribe session. The * 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 * at creation is still used. The results of the configuration are returned using
* {@link WifiNanSessionCallback}: * {@link WifiNanDiscoverySessionCallback}:
* <ul> * <ul>
* <li>{@link WifiNanSessionCallback#onSessionConfigSuccess()}: configuration update * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigSuccess()}: configuration
* succeeded. * update succeeded.
* <li>{@link WifiNanSessionCallback#onSessionConfigFail(int)}: configuration update * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFail(int)}: configuration
* failed. The subscribe discovery session is still running using its previous * update failed. The subscribe discovery session is still running using its previous
* configuration (i.e. update failure does not terminate the session). * configuration (i.e. update failure does not terminate the session).
* </ul> * </ul>
* *