From 93d3c79b54cbc913ff013102a408c6d330d6e73a Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Tue, 10 May 2016 11:56:06 -0700 Subject: [PATCH] [NAN] Add retry count for transmitting L2 NAN messages Bug: 28690414 Change-Id: I0a253f6d7e0d15f4bb50cae685c5e2496682cd67 --- .../android/net/wifi/nan/IWifiNanManager.aidl | 2 +- .../android/net/wifi/nan/WifiNanManager.java | 8 +-- .../android/net/wifi/nan/WifiNanSession.java | 50 +++++++++++++------ 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl b/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl index aaf43e53914d2..efa6211a8063a 100644 --- a/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl +++ b/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl @@ -50,7 +50,7 @@ interface IWifiNanManager void updatePublish(int clientId, int sessionId, in PublishConfig publishConfig); void updateSubscribe(int clientId, int sessionId, in SubscribeConfig subscribeConfig); void sendMessage(int clientId, int sessionId, int peerId, in byte[] message, int messageLength, - int messageId); + int messageId, int retryCount); void terminateSession(int clientId, int sessionId); int startRanging(int clientId, int sessionId, in RttManager.ParcelableRttParams parms); } diff --git a/wifi/java/android/net/wifi/nan/WifiNanManager.java b/wifi/java/android/net/wifi/nan/WifiNanManager.java index 4f7545d2d3de4..b08932b2a98d3 100644 --- a/wifi/java/android/net/wifi/nan/WifiNanManager.java +++ b/wifi/java/android/net/wifi/nan/WifiNanManager.java @@ -399,10 +399,11 @@ public class WifiNanManager { * {@hide} */ public void sendMessage(int sessionId, int peerId, byte[] message, int messageLength, - int messageId) { + int messageId, int retryCount) { if (VDBG) { Log.v(TAG, "sendMessage(): sessionId=" + sessionId + ", peerId=" + peerId - + ", messageLength=" + messageLength + ", messageId=" + messageId); + + ", messageLength=" + messageLength + ", messageId=" + messageId + + ", retryCount=" + retryCount); } int clientId; @@ -416,7 +417,8 @@ public class WifiNanManager { } try { - mService.sendMessage(clientId, sessionId, peerId, message, messageLength, messageId); + mService.sendMessage(clientId, sessionId, peerId, message, messageLength, messageId, + retryCount); } catch (RemoteException e) { e.rethrowAsRuntimeException(); } diff --git a/wifi/java/android/net/wifi/nan/WifiNanSession.java b/wifi/java/android/net/wifi/nan/WifiNanSession.java index 32872ba8dc6a8..3533c02184b3d 100644 --- a/wifi/java/android/net/wifi/nan/WifiNanSession.java +++ b/wifi/java/android/net/wifi/nan/WifiNanSession.java @@ -33,6 +33,8 @@ public class WifiNanSession { private static final boolean DBG = false; private static final boolean VDBG = false; // STOPSHIP if true + public static final int MAX_SEND_RETRY_COUNT = 5; + /** * @hide */ @@ -102,23 +104,24 @@ public class WifiNanSession { } /** - * Sends a message to the specified destination. Message transmission is - * part of the current discovery session - i.e. executed subsequent to a - * publish/subscribe - * {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)} - * event. + * Sends a message to the specified destination. Message transmission is part of the current + * discovery session - i.e. executed subsequent to a publish/subscribe + * {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)} event. * * @param peerId The peer's ID for the message. Must be a result of an - * {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)} - * event. + * {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)} event. * @param message The message to be transmitted. - * @param messageLength The number of bytes from the {@code message} to be - * transmitted. - * @param messageId An arbitrary integer used by the caller to identify the - * message. The same integer ID will be returned in the callbacks - * indicated message send success or failure. + * @param messageLength The number of bytes from the {@code message} to be transmitted. + * @param messageId An arbitrary integer used by the caller to identify the message. The same + * integer ID will be returned in the callbacks indicated message send success or + * failure. + * @param retryCount An integer specifying how many additional service-level (as opposed to PHY + * or MAC level) retries should be attempted if there is no ACK from the receiver + * (note: no retransmissions are attempted in other failure cases). A value of 0 + * indicates no retries. Max possible value is {@link #MAX_SEND_RETRY_COUNT}. */ - public void sendMessage(int peerId, byte[] message, int messageLength, int messageId) { + public void sendMessage(int peerId, byte[] message, int messageLength, int messageId, + int retryCount) { if (mTerminated) { Log.w(TAG, "sendMessage: called on terminated session"); return; @@ -129,10 +132,29 @@ public class WifiNanSession { return; } - mgr.sendMessage(mSessionId, peerId, message, messageLength, messageId); + mgr.sendMessage(mSessionId, peerId, message, messageLength, messageId, retryCount); } } + /** + * Sends a message to the specified destination. Message transmission is part of the current + * discovery session - i.e. executed subsequent to a publish/subscribe + * {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)} event. This is + * equivalent to {@link #sendMessage(int, byte[], int, int, int)} with a {@code retryCount} of + * 0. + * + * @param peerId The peer's ID for the message. Must be a result of an + * {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)} event. + * @param message The message to be transmitted. + * @param messageLength The number of bytes from the {@code message} to be transmitted. + * @param messageId An arbitrary integer used by the caller to identify the message. The same + * integer ID will be returned in the callbacks indicated message send success or + * failure. + */ + public void sendMessage(int peerId, byte[] message, int messageLength, int messageId) { + sendMessage(peerId, message, messageLength, messageId, 0); + } + /** * Start a ranging operation with the specified peers. The peer IDs are obtained from an * {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)} or