NAN: update test harness to include message ID information
Message ID is a caller-side arbitrary integer identifying a message.
Same message ID is provided back to caller on any callback relating
to message - e.g. message send success or fail.
Bug: 26769293
Change-Id: Ia6d67e1bd60294893e1f0959ccd25bcc3fffbbab
diff --git a/sl4a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiNanManagerFacade.java b/sl4a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiNanManagerFacade.java
index 01a53a7..2108d1b 100644
--- a/sl4a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiNanManagerFacade.java
+++ b/sl4a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiNanManagerFacade.java
@@ -273,11 +273,16 @@
| WifiNanSessionListener.LISTEN_MESSAGE_RECEIVED);
}
- @Rpc(description = "Send message.")
- public void wifiNanSendMessage(@RpcParameter(name = "peerId") Integer peerId,
- @RpcParameter(name = "message") String message) throws RemoteException {
-
- mSession.sendMessage(peerId, message.getBytes(), message.length());
+ @Rpc(description = "Send peer-to-peer NAN message")
+ public void wifiNanSendMessage(
+ @RpcParameter(name = "peerId", description = "The ID of the peer being communicated "
+ + "with. Obtained from a previous message or match session.") Integer peerId,
+ @RpcParameter(name = "message") String message,
+ @RpcParameter(name = "messageId", description = "Arbitrary handle used for "
+ + "identification of the message in the message status callbacks")
+ Integer messageId)
+ throws RemoteException {
+ mSession.sendMessage(peerId, message.getBytes(), message.length(), messageId);
}
private class NanEventListenerPostsEvents extends WifiNanEventListener {
@@ -367,16 +372,18 @@
}
@Override
- public void onMessageSendSuccess() {
+ public void onMessageSendSuccess(int messageId) {
Bundle mResults = new Bundle();
mResults.putInt("listenerId", mListenerId);
+ mResults.putInt("messageId", messageId);
mEventFacade.postEvent("WifiNanSessionOnMessageSendSuccess", mResults);
}
@Override
- public void onMessageSendFail(int reason) {
+ public void onMessageSendFail(int messageId, int reason) {
Bundle mResults = new Bundle();
mResults.putInt("listenerId", mListenerId);
+ mResults.putInt("messageId", messageId);
mResults.putInt("reason", reason);
mEventFacade.postEvent("WifiNanSessionOnMessageSendFail", mResults);
}