diff --git a/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl b/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl index 006097df08bed..56baba9141aa6 100644 --- a/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl +++ b/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl @@ -50,8 +50,8 @@ interface IWifiNanManager // session API void updatePublish(int clientId, int discoverySessionId, in PublishConfig publishConfig); void updateSubscribe(int clientId, int discoverySessionId, in SubscribeConfig subscribeConfig); - void sendMessage(int clientId, int discoverySessionId, int peerId, in byte[] message, int messageId, - int retryCount); + void sendMessage(int clientId, int discoverySessionId, int peerId, in byte[] message, + int messageId, int retryCount); void terminateSession(int clientId, int discoverySessionId); int startRanging(int clientId, int discoverySessionId, in RttManager.ParcelableRttParams parms); } diff --git a/wifi/java/android/net/wifi/nan/WifiNanDiscoveryBaseSession.java b/wifi/java/android/net/wifi/nan/WifiNanDiscoveryBaseSession.java index fa2b54735cc11..b3722468afee8 100644 --- a/wifi/java/android/net/wifi/nan/WifiNanDiscoveryBaseSession.java +++ b/wifi/java/android/net/wifi/nan/WifiNanDiscoveryBaseSession.java @@ -31,8 +31,8 @@ import java.lang.ref.WeakReference; * {@link WifiNanPublishDiscoverySession} and {@link WifiNanSubscribeDiscoverySession}. This * class provides functionality common to both publish and subscribe discovery sessions: *
* NAN messages are not guaranteed delivery. Callbacks on * {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully, @@ -147,12 +147,12 @@ public class WifiNanDiscoveryBaseSession { * {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int)}. *
* 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 - * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} - * or - * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} events. + * @param peerHandle The peer's handle for the message. Must be a result of an + * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} + * or + * {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])} events. * @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 * 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 * 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) { Log.w(TAG, "sendMessage: called on terminated session"); return; @@ -174,14 +175,14 @@ public class WifiNanDiscoveryBaseSession { 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 * of a discovery session - executed subsequent to a publish/subscribe - * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} event. + * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} event. *
* NAN messages are not guaranteed delivery. Callbacks on * {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully, @@ -190,29 +191,29 @@ public class WifiNanDiscoveryBaseSession { * {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int)}. *
* The peer will get a callback indicating a message was received using - * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}. - * Equivalent to {@link #sendMessage(int, int, byte[], int)} with a {@code retryCount} of + * {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])}. + * Equivalent to {@link #sendMessage(Object, int, byte[], int)} with a {@code retryCount} of * 0. * - * @param peerId The peer's ID for the message. Must be a result of an - * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} - * or - * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} events. + * @param peerHandle The peer's handle for the message. Must be a result of an + * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} + * or + * {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])} events. * @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 * failure. The {@code messageId} is not used internally by the NAN service - it * can be arbitrary and non-unique. * @param message The message to be transmitted. */ - public void sendMessage(int peerId, int messageId, @Nullable byte[] message) { - sendMessage(peerId, messageId, message, 0); + public void sendMessage(Object peerHandle, int messageId, @Nullable byte[] message) { + sendMessage(peerHandle, messageId, message, 0); } /** * Start a ranging operation with the specified peers. The peer IDs are obtained from an - * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} or - * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])} operation - can only - * range devices which are part of an ongoing discovery session. + * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} or + * {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, 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 * must be identical). The @@ -252,12 +253,12 @@ public class WifiNanDiscoveryBaseSession { * @param role The role of this device: * {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_INITIATOR} or * {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_RESPONDER} - * @param peerId The peer ID obtained through - * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(int, byte[], byte[])} or - * {@link WifiNanDiscoverySessionCallback#onMessageReceived(int, byte[])}. On a RESPONDER this - * value is used to gate the acceptance of a connection request from only that - * peer. A RESPONDER may specified a 0 - indicating that it will accept - * connection requests from any device. + * @param peerHandle The peer's handle obtained through + * {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} or + * {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, 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 null - indicating that it will accept + * connection requests from any device. * @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 * 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)} * [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) { if (mTerminated) { Log.w(TAG, "createNetworkSpecifier: called on terminated session"); @@ -281,7 +282,7 @@ public class WifiNanDiscoveryBaseSession { return null; } - return mgr.createNetworkSpecifier(mClientId, role, mSessionId, peerId, token); + return mgr.createNetworkSpecifier(mClientId, role, mSessionId, peerHandle, token); } } } diff --git a/wifi/java/android/net/wifi/nan/WifiNanDiscoverySessionCallback.java b/wifi/java/android/net/wifi/nan/WifiNanDiscoverySessionCallback.java index 058845fb1573e..271f420272e57 100644 --- a/wifi/java/android/net/wifi/nan/WifiNanDiscoverySessionCallback.java +++ b/wifi/java/android/net/wifi/nan/WifiNanDiscoverySessionCallback.java @@ -125,19 +125,20 @@ public class WifiNanDiscoverySessionCallback { * Called when a discovery (publish or subscribe) operation results in a * 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 * byte array) provided by the peer as part of its discovery * configuration. * @param matchFilter The filter (Tx on advertiser and Rx on listener) which * resulted in this service discovery. */ - public void onServiceDiscovered(int peerId, byte[] serviceSpecificInfo, byte[] matchFilter) { + public void onServiceDiscovered(Object peerHandle, byte[] serviceSpecificInfo, + byte[] matchFilter) { /* 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 * peer (corresponds to an ACK being received). *
@@ -154,7 +155,7 @@ public class WifiNanDiscoverySessionCallback { /** * 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 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. *
* 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 - * peer's {@link WifiNanDiscoveryBaseSession#sendMessage(int, int, byte[])} or - * {@link WifiNanDiscoveryBaseSession#sendMessage(int, int, byte[], int)}. + * peer's {@link WifiNanDiscoveryBaseSession#sendMessage(Object, int, byte[])} or + * {@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. */ - public void onMessageReceived(int peerId, byte[] message) { + public void onMessageReceived(Object peerHandle, byte[] message) { /* empty */ } } diff --git a/wifi/java/android/net/wifi/nan/WifiNanManager.java b/wifi/java/android/net/wifi/nan/WifiNanManager.java index 380924f27a13d..0d6ee94a1156a 100644 --- a/wifi/java/android/net/wifi/nan/WifiNanManager.java +++ b/wifi/java/android/net/wifi/nan/WifiNanManager.java @@ -63,7 +63,7 @@ import java.util.Arrays; *
@@ -86,8 +86,8 @@ import java.util.Arrays; *
* Once a NAN attach is confirmed use the * {@link WifiNanSession#publish(Handler, PublishConfig, WifiNanDiscoverySessionCallback)} or - * {@link WifiNanSession#subscribe(Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)} to - * create publish or subscribe NAN discovery sessions. Events are called on the provided + * {@link WifiNanSession#subscribe(Handler, 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 @@ -97,8 +97,8 @@ import java.util.Arrays; * 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, int, byte[])} APIs. When an application - * is finished with a discovery session it must terminate it using the + * {@link WifiNanDiscoveryBaseSession#sendMessage(Object, int, byte[])} APIs. When an + * application is finished with a discovery session it must terminate it using the * {@link WifiNanDiscoveryBaseSession#destroy()} API. *
* 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}. *