diff options
author | Etan Cohen <etancohen@google.com> | 2017-09-11 21:02:32 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-09-11 21:02:32 +0000 |
commit | bad0137ff3af9bb082382e57f0e2a4b5fbda6dbd (patch) | |
tree | e782c053a166814aa868f291471e51ea1aa2dbfe /service | |
parent | f0653448fc27d0f73d58a3abf948ef38609331e4 (diff) | |
parent | a25953fc4fd640cebf57f1e33490a507af3c1db5 (diff) |
Merge "[AWARE] Support multiple NAN data interfaces (NDI)" into oc-mr1-dev
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)) { |