summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2017-05-18 07:03:11 -0700
committerEtan Cohen <etancohen@google.com>2017-05-18 09:25:51 -0700
commit0d8e6a7d72e6bd953939dc6976c00eafc08b8fce (patch)
tree4fcc4a732caf7a649f36a2d99b5736cef9807b41 /service
parentfd9a6d5607bd6c92045f80046ae344a1275a06d7 (diff)
[AWARE] Fix update publish/subscribe
When updating an existing publish/subscribe discovery session the native API must take the session ID of the existing session. The code provided 0 - which was an indication to create a new discovery session. Bug: 38397363 Test: unit tests and integration (sl4a) tests Change-Id: I8657493a39fe39d12a55af2bdee140b850351c1f
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java4
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java26
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareStateManager.java12
3 files changed, 22 insertions, 20 deletions
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java b/service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java
index d006aa801..b4ccf2e8f 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java
@@ -42,14 +42,14 @@ public class WifiAwareDiscoverySessionState {
private final WifiAwareNativeApi mWifiAwareNativeApi;
private int mSessionId;
- private int mPubSubId;
+ private byte mPubSubId;
private IWifiAwareDiscoverySessionCallback mCallback;
private boolean mIsPublishSession;
private final SparseArray<String> mMacByRequestorInstanceId = new SparseArray<>();
public WifiAwareDiscoverySessionState(WifiAwareNativeApi wifiAwareNativeApi, int sessionId,
- int pubSubId, IWifiAwareDiscoverySessionCallback callback, boolean isPublishSession) {
+ byte pubSubId, IWifiAwareDiscoverySessionCallback callback, boolean isPublishSession) {
mWifiAwareNativeApi = wifiAwareNativeApi;
mSessionId = sessionId;
mPubSubId = pubSubId;
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java b/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java
index fb7a144e8..69f70a39f 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java
@@ -365,9 +365,10 @@ public class WifiAwareNativeApi implements WifiAwareShellCommand.DelegatedShellC
* session.
* @param publishConfig Configuration of the discovery session.
*/
- public boolean publish(short transactionId, int publishId, PublishConfig publishConfig) {
+ public boolean publish(short transactionId, byte publishId, PublishConfig publishConfig) {
if (VDBG) {
- Log.d(TAG, "publish: transactionId=" + transactionId + ", config=" + publishConfig);
+ Log.d(TAG, "publish: transactionId=" + transactionId + ", publishId=" + publishId
+ + ", config=" + publishConfig);
}
IWifiNanIface iface = mHal.getWifiNanIface();
@@ -377,7 +378,7 @@ public class WifiAwareNativeApi implements WifiAwareShellCommand.DelegatedShellC
}
NanPublishRequest req = new NanPublishRequest();
- req.baseConfigs.sessionId = 0;
+ req.baseConfigs.sessionId = publishId;
req.baseConfigs.ttlSec = (short) publishConfig.mTtlSec;
req.baseConfigs.discoveryWindowPeriod = 1;
req.baseConfigs.discoveryCount = 0;
@@ -426,10 +427,11 @@ public class WifiAwareNativeApi implements WifiAwareShellCommand.DelegatedShellC
* subscribe session.
* @param subscribeConfig Configuration of the discovery session.
*/
- public boolean subscribe(short transactionId, int subscribeId,
+ public boolean subscribe(short transactionId, byte subscribeId,
SubscribeConfig subscribeConfig) {
if (VDBG) {
- Log.d(TAG, "subscribe: transactionId=" + transactionId + ", config=" + subscribeConfig);
+ Log.d(TAG, "subscribe: transactionId=" + transactionId + ", subscribeId=" + subscribeId
+ + ", config=" + subscribeConfig);
}
IWifiNanIface iface = mHal.getWifiNanIface();
@@ -439,7 +441,7 @@ public class WifiAwareNativeApi implements WifiAwareShellCommand.DelegatedShellC
}
NanSubscribeRequest req = new NanSubscribeRequest();
- req.baseConfigs.sessionId = 0;
+ req.baseConfigs.sessionId = subscribeId;
req.baseConfigs.ttlSec = (short) subscribeConfig.mTtlSec;
req.baseConfigs.discoveryWindowPeriod = 1;
req.baseConfigs.discoveryCount = 0;
@@ -491,7 +493,7 @@ public class WifiAwareNativeApi implements WifiAwareShellCommand.DelegatedShellC
* @param messageId Arbitary integer from host (not sent to HAL - useful for
* testing/debugging at this level)
*/
- public boolean sendMessage(short transactionId, int pubSubId, int requestorInstanceId,
+ public boolean sendMessage(short transactionId, byte pubSubId, int requestorInstanceId,
byte[] dest, byte[] message, int messageId) {
if (VDBG) {
Log.d(TAG,
@@ -508,7 +510,7 @@ public class WifiAwareNativeApi implements WifiAwareShellCommand.DelegatedShellC
}
NanTransmitFollowupRequest req = new NanTransmitFollowupRequest();
- req.discoverySessionId = (byte) pubSubId;
+ req.discoverySessionId = pubSubId;
req.peerId = requestorInstanceId;
copyArray(dest, req.addr);
req.isHighPriority = false;
@@ -538,7 +540,7 @@ public class WifiAwareNativeApi implements WifiAwareShellCommand.DelegatedShellC
* @param pubSubId ID of the publish/subscribe session - obtained when
* creating a session.
*/
- public boolean stopPublish(short transactionId, int pubSubId) {
+ public boolean stopPublish(short transactionId, byte pubSubId) {
if (VDBG) {
Log.d(TAG, "stopPublish: transactionId=" + transactionId + ", pubSubId=" + pubSubId);
}
@@ -550,7 +552,7 @@ public class WifiAwareNativeApi implements WifiAwareShellCommand.DelegatedShellC
}
try {
- WifiStatus status = iface.stopPublishRequest(transactionId, (byte) pubSubId);
+ WifiStatus status = iface.stopPublishRequest(transactionId, pubSubId);
if (status.code == WifiStatusCode.SUCCESS) {
return true;
} else {
@@ -571,7 +573,7 @@ public class WifiAwareNativeApi implements WifiAwareShellCommand.DelegatedShellC
* @param pubSubId ID of the publish/subscribe session - obtained when
* creating a session.
*/
- public boolean stopSubscribe(short transactionId, int pubSubId) {
+ public boolean stopSubscribe(short transactionId, byte pubSubId) {
if (VDBG) {
Log.d(TAG, "stopSubscribe: transactionId=" + transactionId + ", pubSubId=" + pubSubId);
}
@@ -583,7 +585,7 @@ public class WifiAwareNativeApi implements WifiAwareShellCommand.DelegatedShellC
}
try {
- WifiStatus status = iface.stopSubscribeRequest(transactionId, (byte) pubSubId);
+ WifiStatus status = iface.stopSubscribeRequest(transactionId, pubSubId);
if (status.code == WifiStatusCode.SUCCESS) {
return true;
} else {
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
index 9203b098b..1c4c07ffd 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
@@ -684,7 +684,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
* configuration (new or update) request succeeded.
*/
public void onSessionConfigSuccessResponse(short transactionId, boolean isPublish,
- int pubSubId) {
+ byte pubSubId) {
Message msg = mSm.obtainMessage(MESSAGE_TYPE_RESPONSE);
msg.arg1 = RESPONSE_TYPE_ON_SESSION_CONFIG_SUCCESS;
msg.arg2 = transactionId;
@@ -794,7 +794,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
/**
* Response from firmware to
- * {@link #respondToDataPathRequest(boolean, int, String, byte[], String)}.
+ * {@link #respondToDataPathRequest(boolean, int, String, byte[], String, boolean)}
*/
public void onRespondToDataPathSetupRequestResponse(short transactionId, boolean success,
int reasonOnFailure) {
@@ -1582,7 +1582,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
break;
}
case RESPONSE_TYPE_ON_SESSION_CONFIG_SUCCESS: {
- int pubSubId = (Integer) msg.obj;
+ byte pubSubId = (Byte) msg.obj;
boolean isPublish = msg.getData().getBoolean(MESSAGE_BUNDLE_KEY_SESSION_TYPE);
onSessionConfigSuccessLocal(mCurrentCommand, pubSubId, isPublish);
@@ -2055,7 +2055,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
return false;
}
- boolean success = mWifiAwareNativeApi.publish(transactionId, 0, publishConfig);
+ boolean success = mWifiAwareNativeApi.publish(transactionId, (byte) 0, publishConfig);
if (!success) {
try {
callback.onSessionConfigFail(NanStatusType.INTERNAL_FAILURE);
@@ -2103,7 +2103,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
return false;
}
- boolean success = mWifiAwareNativeApi.subscribe(transactionId, 0, subscribeConfig);
+ boolean success = mWifiAwareNativeApi.subscribe(transactionId, (byte) 0, subscribeConfig);
if (!success) {
try {
callback.onSessionConfigFail(NanStatusType.INTERNAL_FAILURE);
@@ -2392,7 +2392,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
}
}
- private void onSessionConfigSuccessLocal(Message completedCommand, int pubSubId,
+ private void onSessionConfigSuccessLocal(Message completedCommand, byte pubSubId,
boolean isPublish) {
if (VDBG) {
Log.v(TAG, "onSessionConfigSuccessLocal: completedCommand=" + completedCommand