Merge "[NAN] Replace int peerId with more opaqure Object peerHandle per API review" am: 88da460cd8

am: bc74135d6a

Change-Id: I1368c0bfe18415126924e13eebe30f9061ac5b41
This commit is contained in:
Etan Cohen
2016-09-26 19:00:15 +00:00
committed by android-build-merger
5 changed files with 78 additions and 72 deletions

View File

@@ -50,8 +50,8 @@ interface IWifiNanManager
// session API // session API
void updatePublish(int clientId, int discoverySessionId, in PublishConfig publishConfig); void updatePublish(int clientId, int discoverySessionId, in PublishConfig publishConfig);
void updateSubscribe(int clientId, int discoverySessionId, in SubscribeConfig subscribeConfig); void updateSubscribe(int clientId, int discoverySessionId, in SubscribeConfig subscribeConfig);
void sendMessage(int clientId, int discoverySessionId, int peerId, in byte[] message, int messageId, void sendMessage(int clientId, int discoverySessionId, int peerId, in byte[] message,
int retryCount); int messageId, int retryCount);
void terminateSession(int clientId, int discoverySessionId); void terminateSession(int clientId, int discoverySessionId);
int startRanging(int clientId, int discoverySessionId, in RttManager.ParcelableRttParams parms); int startRanging(int clientId, int discoverySessionId, in RttManager.ParcelableRttParams parms);
} }

View File

@@ -31,8 +31,8 @@ import java.lang.ref.WeakReference;
* {@link WifiNanPublishDiscoverySession} and {@link WifiNanSubscribeDiscoverySession}. This * {@link WifiNanPublishDiscoverySession} and {@link WifiNanSubscribeDiscoverySession}. This
* class provides 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, int, byte[])} or * <li>Sending messages: {@link #sendMessage(Object, int, byte[])} or
* {@link #sendMessage(int, int, byte[], int)} methods. * {@link #sendMessage(Object, int, byte[], int)} methods.
* <li>Creating a network-specifier when requesting a NAN connection: * <li>Creating a network-specifier when requesting a NAN connection:
* {@link #createNetworkSpecifier(int, int, byte[])}. * {@link #createNetworkSpecifier(int, int, byte[])}.
* </ul> * </ul>
@@ -61,7 +61,7 @@ public class WifiNanDiscoveryBaseSession {
/** /**
* Return the maximum permitted retry count when sending messages using * Return the maximum permitted retry count when sending messages using
* {@link #sendMessage(int, int, byte[], int)}. * {@link #sendMessage(Object, int, byte[], int)}.
* *
* @return Maximum retry count when sending messages. * @return Maximum retry count when sending messages.
*/ */
@@ -138,7 +138,7 @@ public class WifiNanDiscoveryBaseSession {
/** /**
* 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 WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} event. * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} event.
* <p> * <p>
* NAN messages are not guaranteed delivery. Callbacks on * NAN messages are not guaranteed delivery. Callbacks on
* {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully, * {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully,
@@ -147,12 +147,12 @@ public class WifiNanDiscoveryBaseSession {
* {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int)}. * {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(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 WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}. * {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])}.
* *
* @param peerId The peer's ID for the message. Must be a result of an * @param peerHandle The peer's handle for the message. Must be a result of an
* {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])}
* or * or
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} events. * {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])} events.
* @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
* failure. The {@code messageId} is not used internally by the NAN service - it * failure. The {@code messageId} is not used internally by the NAN service - it
@@ -163,7 +163,8 @@ public class WifiNanDiscoveryBaseSession {
* (note: no retransmissions are attempted in other failure cases). A value of 0 * (note: no retransmissions are attempted in other failure cases). A value of 0
* indicates no retries. Max permitted value is {@link #getMaxSendRetryCount()}. * indicates no retries. Max permitted value is {@link #getMaxSendRetryCount()}.
*/ */
public void sendMessage(int peerId, int messageId, @Nullable byte[] message, int retryCount) { public void sendMessage(Object peerHandle, int messageId, @Nullable byte[] message,
int retryCount) {
if (mTerminated) { if (mTerminated) {
Log.w(TAG, "sendMessage: called on terminated session"); Log.w(TAG, "sendMessage: called on terminated session");
return; return;
@@ -174,14 +175,14 @@ public class WifiNanDiscoveryBaseSession {
return; return;
} }
mgr.sendMessage(mClientId, mSessionId, peerId, message, messageId, retryCount); mgr.sendMessage(mClientId, mSessionId, peerHandle, message, messageId, retryCount);
} }
} }
/** /**
* 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 WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} event. * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} event.
* <p> * <p>
* NAN messages are not guaranteed delivery. Callbacks on * NAN messages are not guaranteed delivery. Callbacks on
* {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully, * {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully,
@@ -190,29 +191,29 @@ public class WifiNanDiscoveryBaseSession {
* {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int)}. * {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(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 WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}. * {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])}.
* Equivalent to {@link #sendMessage(int, int, byte[], int)} with a {@code retryCount} of * Equivalent to {@link #sendMessage(Object, int, byte[], int)} with a {@code retryCount} of
* 0. * 0.
* *
* @param peerId The peer's ID for the message. Must be a result of an * @param peerHandle The peer's handle for the message. Must be a result of an
* {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])}
* or * or
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} events. * {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])} events.
* @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
* failure. The {@code messageId} is not used internally by the NAN service - it * failure. The {@code messageId} is not used internally by the NAN service - it
* can be arbitrary and non-unique. * can be arbitrary and non-unique.
* @param message The message to be transmitted. * @param message The message to be transmitted.
*/ */
public void sendMessage(int peerId, int messageId, @Nullable byte[] message) { public void sendMessage(Object peerHandle, int messageId, @Nullable byte[] message) {
sendMessage(peerId, messageId, message, 0); sendMessage(peerHandle, messageId, message, 0);
} }
/** /**
* 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 WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} or * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} or
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} operation - can only * {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])} operation - can
* range devices which are part of an ongoing discovery session. * 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 * @param params RTT parameters - each corresponding to a specific peer ID (the array sizes
* must be identical). The * must be identical). The
@@ -252,12 +253,12 @@ public class WifiNanDiscoveryBaseSession {
* @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
* {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_RESPONDER} * {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_RESPONDER}
* @param peerId The peer ID obtained through * @param peerHandle The peer's handle obtained through
* {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} or * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} or
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}. On a RESPONDER this * {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])}. On a RESPONDER
* value is used to gate the acceptance of a connection request from only that * this value is used to gate the acceptance of a connection request from only
* peer. A RESPONDER may specified a 0 - indicating that it will accept * that peer. A RESPONDER may specified a null - indicating that it will accept
* connection requests from any device. * connection requests from any device.
* @param token An arbitrary token (message) to be used to match connection initiation request * @param token An arbitrary token (message) to be used to match connection initiation request
* to a responder setup. A RESPONDER is set up with a {@code token} which must * to a responder setup. A RESPONDER is set up with a {@code token} which must
* be matched by the token provided by the INITIATOR. A null token is permitted * be matched by the token provided by the INITIATOR. A null token is permitted
@@ -269,7 +270,7 @@ public class WifiNanDiscoveryBaseSession {
* {@link android.net.ConnectivityManager#requestNetwork(android.net.NetworkRequest,android.net.ConnectivityManager.NetworkCallback)} * {@link android.net.ConnectivityManager#requestNetwork(android.net.NetworkRequest,android.net.ConnectivityManager.NetworkCallback)}
* [or other varieties of that API]. * [or other varieties of that API].
*/ */
public String createNetworkSpecifier(@WifiNanManager.DataPathRole int role, int peerId, public String createNetworkSpecifier(@WifiNanManager.DataPathRole int role, Object peerHandle,
@Nullable byte[] token) { @Nullable byte[] token) {
if (mTerminated) { if (mTerminated) {
Log.w(TAG, "createNetworkSpecifier: called on terminated session"); Log.w(TAG, "createNetworkSpecifier: called on terminated session");
@@ -281,7 +282,7 @@ public class WifiNanDiscoveryBaseSession {
return null; return null;
} }
return mgr.createNetworkSpecifier(mClientId, role, mSessionId, peerId, token); return mgr.createNetworkSpecifier(mClientId, role, mSessionId, peerHandle, token);
} }
} }
} }

View File

@@ -125,19 +125,20 @@ public class WifiNanDiscoverySessionCallback {
* Called when a discovery (publish or subscribe) operation results in a * Called when a discovery (publish or subscribe) operation results in a
* service discovery. * service discovery.
* *
* @param peerId The ID of the peer matching our discovery operation. * @param peerHandle An opaque handle to the peer matching our discovery operation.
* @param serviceSpecificInfo The service specific information (arbitrary * @param serviceSpecificInfo The service specific information (arbitrary
* byte array) provided by the peer as part of its discovery * byte array) provided by the peer as part of its discovery
* configuration. * configuration.
* @param matchFilter The filter (Tx on advertiser and Rx on listener) which * @param matchFilter The filter (Tx on advertiser and Rx on listener) which
* resulted in this service discovery. * resulted in this service discovery.
*/ */
public void onServiceDiscovered(int peerId, byte[] serviceSpecificInfo, byte[] matchFilter) { public void onServiceDiscovered(Object peerHandle, byte[] serviceSpecificInfo,
byte[] matchFilter) {
/* empty */ /* empty */
} }
/** /**
* Called in response to {@link WifiNanDiscoveryBaseSession#sendMessage(int, int, byte[])} * Called in response to {@link WifiNanDiscoveryBaseSession#sendMessage(Object, int, byte[])}
* when a message is transmitted successfully - i.e. when it was received successfully by the * when a message is transmitted successfully - i.e. when it was received successfully by the
* peer (corresponds to an ACK being received). * peer (corresponds to an ACK being received).
* <p> * <p>
@@ -154,7 +155,7 @@ public class WifiNanDiscoverySessionCallback {
/** /**
* 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 WifiNanDiscoveryBaseSession#sendMessage(int, int, byte[], int)} method) - this * the {@link WifiNanDiscoveryBaseSession#sendMessage(Object, int, byte[], 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
@@ -169,13 +170,13 @@ public class WifiNanDiscoverySessionCallback {
/** /**
* 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 WifiNanDiscoveryBaseSession#sendMessage(int, int, byte[])} or * peer's {@link WifiNanDiscoveryBaseSession#sendMessage(Object, int, byte[])} or
* {@link WifiNanDiscoveryBaseSession#sendMessage(int, int, byte[], int)}. * {@link WifiNanDiscoveryBaseSession#sendMessage(Object, int, byte[], int)}.
* *
* @param peerId The ID of the peer sending the message. * @param peerHandle An opaque handle to the peer matching our discovery operation.
* @param message A byte array containing the message. * @param message A byte array containing the message.
*/ */
public void onMessageReceived(int peerId, byte[] message) { public void onMessageReceived(Object peerHandle, byte[] message) {
/* empty */ /* empty */
} }
} }

View File

@@ -63,7 +63,7 @@ import java.util.Arrays;
* <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 WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, int, byte[])} and * {@link WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, Object, byte[])} and
* {@link WifiNanSession#createNetworkSpecifier(int, byte[], byte[])}. * {@link WifiNanSession#createNetworkSpecifier(int, byte[], byte[])}.
* </ul> * </ul>
* <p> * <p>
@@ -86,8 +86,8 @@ import java.util.Arrays;
* <p> * <p>
* Once a NAN attach is confirmed use the * Once a NAN attach is confirmed use the
* {@link WifiNanSession#publish(Handler, PublishConfig, WifiNanDiscoverySessionCallback)} or * {@link WifiNanSession#publish(Handler, PublishConfig, WifiNanDiscoverySessionCallback)} or
* {@link WifiNanSession#subscribe(Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)} to * {@link WifiNanSession#subscribe(Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)}
* create publish or subscribe NAN discovery sessions. Events are called on the provided * to create publish or subscribe NAN discovery sessions. Events are called on the provided
* callback object {@link WifiNanDiscoverySessionCallback}. Specifically, the * callback object {@link WifiNanDiscoverySessionCallback}. Specifically, the
* {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)} * {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}
* and * and
@@ -97,8 +97,8 @@ import java.util.Arrays;
* the session {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} and * the session {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} and
* {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. Sessions can also * {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. Sessions can also
* be used to send messages using the * be used to send messages using the
* {@link WifiNanDiscoveryBaseSession#sendMessage(int, int, byte[])} APIs. When an application * {@link WifiNanDiscoveryBaseSession#sendMessage(Object, int, byte[])} APIs. When an
* is finished with a discovery session it <b>must</b> terminate it using the * application is finished with a discovery session it <b>must</b> terminate it using the
* {@link WifiNanDiscoveryBaseSession#destroy()} API. * {@link WifiNanDiscoveryBaseSession#destroy()} API.
* <p> * <p>
* Creating connections between NAN devices is managed by the standard * Creating connections between NAN devices is managed by the standard
@@ -109,7 +109,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 WifiNanSession#createNetworkSpecifier(int, byte[], byte[])} or * {@link WifiNanSession#createNetworkSpecifier(int, byte[], byte[])} or
* {@link WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, int, byte[])}. * {@link WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, Object, byte[])}.
* </ul> * </ul>
* *
* @hide PROPOSED_NAN_API * @hide PROPOSED_NAN_API
@@ -217,7 +217,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 WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, int, byte[]) * @see WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, Object, byte[])
* @see WifiNanSession#createNetworkSpecifier(int, byte[], byte[]) * @see WifiNanSession#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;
@@ -226,7 +226,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 WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, int, byte[]) * @see WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, Object, byte[])
* @see WifiNanSession#createNetworkSpecifier(int, byte[], byte[]) * @see WifiNanSession#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;
@@ -457,16 +457,17 @@ public class WifiNanManager {
} }
/** @hide */ /** @hide */
public void sendMessage(int clientId, int sessionId, int peerId, byte[] message, int messageId, public void sendMessage(int clientId, int sessionId, Object peerHandle, byte[] message,
int retryCount) { int messageId, int retryCount) {
if (VDBG) { if (VDBG) {
Log.v(TAG, Log.v(TAG, "sendMessage(): clientId=" + clientId + ", sessionId=" + sessionId
"sendMessage(): clientId=" + clientId + ", sessionId=" + sessionId + ", peerId=" + ", peerHandle=" + peerHandle + ", messageId=" + messageId + ", retryCount="
+ peerId + ", messageId=" + messageId + ", retryCount=" + retryCount); + retryCount);
} }
try { try {
mService.sendMessage(clientId, sessionId, peerId, message, messageId, retryCount); mService.sendMessage(clientId, sessionId, (Integer) peerHandle, message, messageId,
retryCount);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -494,19 +495,19 @@ public class WifiNanManager {
} }
/** @hide */ /** @hide */
public String createNetworkSpecifier(int clientId, int role, int sessionId, int peerId, public String createNetworkSpecifier(int clientId, int role, int sessionId, Object peerHandle,
byte[] token) { byte[] token) {
if (VDBG) { if (VDBG) {
Log.v(TAG, "createNetworkSpecifier: role=" + role + ", sessionId=" + sessionId Log.v(TAG, "createNetworkSpecifier: role=" + role + ", sessionId=" + sessionId
+ ", peerId=" + peerId + ", token=" + token); + ", peerHandle=" + peerHandle + ", token=" + token);
} }
int type; int type;
if (token != null && peerId != 0) { if (token != null && peerHandle != null) {
type = NETWORK_SPECIFIER_TYPE_1A; type = NETWORK_SPECIFIER_TYPE_1A;
} else if (token == null && peerId != 0) { } else if (token == null && peerHandle != null) {
type = NETWORK_SPECIFIER_TYPE_1B; type = NETWORK_SPECIFIER_TYPE_1B;
} else if (token != null && peerId == 0) { } else if (token != null && peerHandle == null) {
type = NETWORK_SPECIFIER_TYPE_1C; type = NETWORK_SPECIFIER_TYPE_1C;
} else { } else {
type = NETWORK_SPECIFIER_TYPE_1D; type = NETWORK_SPECIFIER_TYPE_1D;
@@ -523,10 +524,10 @@ public class WifiNanManager {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"createNetworkSpecifier: Invalid null token - not permitted on INITIATOR"); "createNetworkSpecifier: Invalid null token - not permitted on INITIATOR");
} }
if (peerId == 0) { if (peerHandle == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"createNetworkSpecifier: Invalid peer ID (value of 0) - not permitted on " "createNetworkSpecifier: Invalid peer handle (value of null) - not "
+ "INITIATOR"); + "permitted on INITIATOR");
} }
} }
@@ -537,8 +538,8 @@ public class WifiNanManager {
json.put(NETWORK_SPECIFIER_KEY_ROLE, role); json.put(NETWORK_SPECIFIER_KEY_ROLE, role);
json.put(NETWORK_SPECIFIER_KEY_CLIENT_ID, clientId); json.put(NETWORK_SPECIFIER_KEY_CLIENT_ID, clientId);
json.put(NETWORK_SPECIFIER_KEY_SESSION_ID, sessionId); json.put(NETWORK_SPECIFIER_KEY_SESSION_ID, sessionId);
if (peerId != 0) { if (peerHandle != null) {
json.put(NETWORK_SPECIFIER_KEY_PEER_ID, peerId); json.put(NETWORK_SPECIFIER_KEY_PEER_ID, (Integer) peerHandle);
} }
if (token != null) { if (token != null) {
json.put(NETWORK_SPECIFIER_KEY_TOKEN, json.put(NETWORK_SPECIFIER_KEY_TOKEN,
@@ -552,8 +553,8 @@ public class WifiNanManager {
} }
/** @hide */ /** @hide */
public String createNetworkSpecifier(int clientId, @DataPathRole int role, @Nullable byte[] peer, public String createNetworkSpecifier(int clientId, @DataPathRole int role,
@Nullable byte[] token) { @Nullable byte[] peer, @Nullable byte[] token) {
if (VDBG) { if (VDBG) {
Log.v(TAG, "createNetworkSpecifier: role=" + role + ", token=" + token); Log.v(TAG, "createNetworkSpecifier: role=" + role + ", token=" + token);
} }
@@ -843,7 +844,7 @@ public class WifiNanManager {
break; break;
case CALLBACK_MATCH: case CALLBACK_MATCH:
mOriginalCallback.onServiceDiscovered( mOriginalCallback.onServiceDiscovered(
msg.arg1, Integer.valueOf(msg.arg1),
msg.getData().getByteArray(MESSAGE_BUNDLE_KEY_MESSAGE), msg.getData().getByteArray(MESSAGE_BUNDLE_KEY_MESSAGE),
msg.getData().getByteArray(MESSAGE_BUNDLE_KEY_MESSAGE2)); msg.getData().getByteArray(MESSAGE_BUNDLE_KEY_MESSAGE2));
break; break;
@@ -854,7 +855,8 @@ public class WifiNanManager {
mOriginalCallback.onMessageSendFailed(msg.arg1); mOriginalCallback.onMessageSendFailed(msg.arg1);
break; break;
case CALLBACK_MESSAGE_RECEIVED: case CALLBACK_MESSAGE_RECEIVED:
mOriginalCallback.onMessageReceived(msg.arg1, (byte[]) msg.obj); mOriginalCallback.onMessageReceived(Integer.valueOf(msg.arg1),
(byte[]) msg.obj);
break; break;
} }
} }

View File

@@ -98,7 +98,8 @@ public class WifiNanSession {
* 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 WifiNanDiscoverySessionCallback}: * are routed to the callbacks of {@link WifiNanDiscoverySessionCallback}:
* <ul> * <ul>
* <li>{@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)} * <li>
* {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}
* is called when the publish session is created and provides a handle to the session. * 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. * Further operations on the publish session can be executed on that object.
* <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed()} is called if the * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed()} is called if the
@@ -140,7 +141,8 @@ public class WifiNanSession {
* 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 WifiNanDiscoverySessionCallback}: * operation are routed to the callbacks of {@link WifiNanDiscoverySessionCallback}:
* <ul> * <ul>
* <li>{@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)} * <li>
* {@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)}
* is called when the subscribe session is created and provides a handle to the session. * 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. * Further operations on the subscribe session can be executed on that object.
* <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed()} is called if the * <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed()} is called if the
@@ -186,7 +188,7 @@ public class WifiNanSession {
* 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 WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, int, byte[])}. * {@link WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, Object, 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