diff options
author | Etan Cohen <etancohen@google.com> | 2017-08-14 17:42:37 -0700 |
---|---|---|
committer | Etan Cohen <etancohen@google.com> | 2017-09-05 12:04:08 -0700 |
commit | a25953fc4fd640cebf57f1e33490a507af3c1db5 (patch) | |
tree | 65c5317b0c961f7c85eef089c1576eb081f4555f /service | |
parent | 083b290298faaed46e3a175eb3f707a9c453d7f6 (diff) |
[AWARE] Support multiple NAN data interfaces (NDI)
Support all the NAN data-interfaces which the firmware supports -
based on the returned capability.
- Create the data-interfaces
- Assign data-paths to data-interfaces based on constraints of
unique [(src mac, dst mac), security config] tuples. I.e. a
single data-interface can only have a single security configuration
to a specific destination interface.
Bug: 63635857
Test: unit tests + integrated test suite
Change-Id: I4a21f3b025e8164673366e22da062d536d588148
Diffstat (limited to 'service')
3 files changed, 41 insertions, 11 deletions
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java index 16888c81e..efeca655b 100644 --- a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java @@ -60,10 +60,11 @@ import java.net.SocketException; import java.util.Arrays; import java.util.Enumeration; import java.util.HashSet; -import java.util.Iterator; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; /** * Manages Aware data-path lifetime: interface creation/deletion, data-path setup and tear-down. @@ -323,6 +324,8 @@ public class WifiAwareDataPathStateManager { * - The discovery session (pub/sub ID) must match. * - The peer MAC address (if specified - i.e. non-null) must match. A null peer MAC == * accept (otherwise matching) requests from any peer MAC. + * - The request must be pending (i.e. we could have completed requests for the same + * parameters) */ if (entry.getValue().pubSubId != 0 && entry.getValue().pubSubId != pubSubId) { continue; @@ -333,6 +336,11 @@ public class WifiAwareDataPathStateManager { continue; } + if (entry.getValue().state + != AwareNetworkRequestInformation.STATE_RESPONDER_WAIT_FOR_REQUEST) { + continue; + } + networkSpecifier = entry.getKey(); nnri = entry.getValue(); break; @@ -884,18 +892,43 @@ public class WifiAwareDataPathStateManager { } /** - * Select one of the existing interfaces for the new network request. + * Select one of the existing interfaces for the new network request. A request is canonical + * (otherwise it wouldn't be executed). * - * TODO: for now there is only a single interface - simply pick it. + * Construct a list of all interfaces currently used to communicate to the peer. The remaining + * interfaces are available for use for this request - if none are left then the request should + * fail (signaled to the caller by returning a null). */ private String selectInterfaceForRequest(AwareNetworkRequestInformation req) { - Iterator<String> it = mInterfaces.iterator(); - if (it.hasNext()) { - return it.next(); + SortedSet<String> potential = new TreeSet<>(mInterfaces); + Set<String> used = new HashSet<>(); + + if (VDBG) { + Log.v(TAG, "selectInterfaceForRequest: req=" + req + ", mNetworkRequestsCache=" + + mNetworkRequestsCache); } - Log.e(TAG, "selectInterfaceForRequest: req=" + req + " - but no interfaces available!"); + for (AwareNetworkRequestInformation nnri : mNetworkRequestsCache.values()) { + if (nnri == req) { + continue; + } + + if (Arrays.equals(req.peerDiscoveryMac, nnri.peerDiscoveryMac)) { + used.add(nnri.interfaceName); + } + } + + if (VDBG) { + Log.v(TAG, "selectInterfaceForRequest: potential=" + potential + ", used=" + used); + } + + for (String ifName: potential) { + if (!used.contains(ifName)) { + return ifName; + } + } + Log.e(TAG, "selectInterfaceForRequest: req=" + req + " - no interfaces available!"); return null; } diff --git a/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java b/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java index 2f424db4c..2121160bb 100644 --- a/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java @@ -167,10 +167,6 @@ public class WifiAwareNativeCallback extends IWifiNanIfaceEventCallback.Stub imp capabilities.maxSubscribeInterfaceAddresses; frameworkCapabilities.supportedCipherSuites = capabilities.supportedCipherSuites; - // TODO (b/63635857): enable framework support of >1 NDI - // Until then: force corresponding capability to 1. - frameworkCapabilities.maxNdiInterfaces = 1; - mWifiAwareStateManager.onCapabilitiesUpdateResponse(id, frameworkCapabilities); } else { Log.e(TAG, "notifyCapabilitiesResponse: error code=" + status.status + " (" diff --git a/service/java/com/android/server/wifi/aware/WifiAwareShellCommand.java b/service/java/com/android/server/wifi/aware/WifiAwareShellCommand.java index 41eef6960..a2f604686 100644 --- a/service/java/com/android/server/wifi/aware/WifiAwareShellCommand.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareShellCommand.java @@ -55,6 +55,7 @@ public class WifiAwareShellCommand extends ShellCommand { for (DelegatedShellCommand dsc: mDelegatedCommands.values()) { dsc.onReset(); } + return 0; } else { DelegatedShellCommand delegatedCmd = null; if (!TextUtils.isEmpty(cmd)) { |