summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2016-11-16 07:09:28 -0800
committerEtan Cohen <etancohen@google.com>2016-11-30 07:11:53 -0800
commitc2d0f22f7b29507d29e517c329d82a0d30342f44 (patch)
treeb97a9727718c067ba5956aa3a729c6af230f9323 /service
parent04e60c403cfdb750fdaf8b418d63b4386d971fe6 (diff)
[AWARE] Data-path creation roles hard-coded for discovery sessions
Data-path roles (initiator & responder) are hard-coded for discovery session participants by the spec: subscriber <-> initiator and publisher <-> responder. Added checks for role to session type mismatch. Added unit-tests to validate negative condition: i.e. no data-path setup on such mismatched requests. (cherry-pick of commit 80a2a2558b3b64918a20434422a5307b03b68799) Bug: 32883026 Test: unit-tests and integration (sl4a) tests passing. Change-Id: Iad0727e5ad522e67222a6053918ce99fda1260b4
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java53
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java4
2 files changed, 38 insertions, 19 deletions
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
index 3f77a62e7..f7364f08d 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
@@ -867,36 +867,51 @@ public class WifiAwareDataPathStateManager {
}
uid = client.getUid();
+ // validate the role (if session ID provided: i.e. session 1xx)
if (type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1A
- || type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1B) {
+ || type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1B
+ || type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1C
+ || type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1D) {
WifiAwareDiscoverySessionState session = client.getSession(sessionId);
if (session == null) {
Log.e(TAG,
"parseNetworkSpecifier: networkSpecifier=" + networkSpecifier
- + " -- not session with this id -- sessionId=" + sessionId);
+ + " -- no session with this id -- sessionId=" + sessionId);
return null;
}
- pubSubId = session.getPubSubId();
- String peerMacStr = session.getMac(peerId, null);
- if (peerMacStr == null) {
- Log.e(TAG,
- "parseNetworkSpecifier: networkSpecifier=" + networkSpecifier
- + " -- no MAC address associated with this peer id -- peerId="
- + peerId);
+
+ if ((session.isPublishSession()
+ && role != WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER) || (
+ !session.isPublishSession()
+ && role != WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR)) {
+ Log.e(TAG, "parseNetworkSpecifier: networkSpecifier=" + networkSpecifier
+ + " -- invalid role for session type");
return null;
}
- try {
- peerMac = HexEncoding.decode(peerMacStr.toCharArray(), false);
- if (peerMac == null || peerMac.length != 6) {
- Log.e(TAG, "parseNetworkSpecifier: networkSpecifier="
- + networkSpecifier + " -- invalid peer MAC address");
+
+ if (type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1A
+ || type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1B) {
+ pubSubId = session.getPubSubId();
+ String peerMacStr = session.getMac(peerId, null);
+ if (peerMacStr == null) {
+ Log.e(TAG, "parseNetworkSpecifier: networkSpecifier=" + networkSpecifier
+ + " -- no MAC address associated with this peer id -- peerId="
+ + peerId);
+ return null;
+ }
+ try {
+ peerMac = HexEncoding.decode(peerMacStr.toCharArray(), false);
+ if (peerMac == null || peerMac.length != 6) {
+ Log.e(TAG, "parseNetworkSpecifier: networkSpecifier="
+ + networkSpecifier + " -- invalid peer MAC address");
+ return null;
+ }
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG,
+ "parseNetworkSpecifier: networkSpecifier=" + networkSpecifier
+ + " -- invalid peer MAC address -- e=" + e);
return null;
}
- } catch (IllegalArgumentException e) {
- Log.e(TAG,
- "parseNetworkSpecifier: networkSpecifier=" + networkSpecifier
- + " -- invalid peer MAC address -- e=" + e);
- return null;
}
}
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java b/service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java
index c5598d763..124e67065 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java
@@ -62,6 +62,10 @@ public class WifiAwareDiscoverySessionState {
return mPubSubId;
}
+ public boolean isPublishSession() {
+ return mIsPublishSession;
+ }
+
public IWifiAwareDiscoverySessionCallback getCallback() {
return mCallback;
}