diff options
author | Etan Cohen <etancohen@google.com> | 2017-07-20 07:06:31 -0700 |
---|---|---|
committer | Etan Cohen <etancohen@google.com> | 2017-07-25 16:20:32 -0700 |
commit | 86ce666f62db6b464536d68944780b46996af04b (patch) | |
tree | 41dd0c87f8dd5aae9f03f79a6c4e65228a180e0f /service | |
parent | d2b34d876c5b21790a4b98a94ae69cc95d2f5521 (diff) |
[AWARE] Support multiple NDPs on an NDI
Support multiple NAN data-paths (NDPs) on a single NAN data-interface
(NDI). Interface bring-up and bring-down should be tied to first NDP
and last NDP.
Bug: 63635780
Test: unit tests and integrated (sl4a) tests pass (or bugs filed)
Change-Id: I05ac824e551d33897eba7b7e0d5ab45b56492558
Diffstat (limited to 'service')
3 files changed, 55 insertions, 31 deletions
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java index f3ffb08fe..ead0c5f5e 100644 --- a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java @@ -85,7 +85,7 @@ public class WifiAwareDataPathStateManager { private static final int NETWORK_FACTORY_SIGNAL_STRENGTH_AVAIL = 1; private final WifiAwareStateManager mMgr; - private final NetworkInterfaceWrapper mNiWrapper = new NetworkInterfaceWrapper(); + public NetworkInterfaceWrapper mNiWrapper = new NetworkInterfaceWrapper(); private final NetworkCapabilities mNetworkCapabilitiesFilter = new NetworkCapabilities(); private final Set<String> mInterfaces = new HashSet<>(); private final Map<WifiAwareNetworkSpecifier, AwareNetworkRequestInformation> @@ -95,7 +95,7 @@ public class WifiAwareDataPathStateManager { private WifiPermissionsWrapper mPermissionsWrapper; private Looper mLooper; private WifiAwareNetworkFactory mNetworkFactory; - private INetworkManagementService mNwService; + public INetworkManagementService mNwService; public WifiAwareDataPathStateManager(WifiAwareStateManager mgr) { mMgr = mgr; @@ -471,14 +471,23 @@ public class WifiAwareDataPathStateManager { mNetworkCapabilitiesFilter); LinkProperties linkProperties = new LinkProperties(); - try { - mNwService.setInterfaceUp(nnri.interfaceName); - mNwService.enableIpv6(nnri.interfaceName); - } catch (Exception e) { // NwService throws runtime exceptions for errors - Log.e(TAG, "onDataPathConfirm: ACCEPT nnri=" + nnri + ": can't configure network - " - + e); - mMgr.endDataPath(ndpId); - return networkSpecifier; + boolean interfaceUsedByAnotherNdp = isInterfaceUpAndUsedByAnotherNdp(nnri); + if (!interfaceUsedByAnotherNdp) { + try { + mNwService.setInterfaceUp(nnri.interfaceName); + mNwService.enableIpv6(nnri.interfaceName); + } catch (Exception e) { // NwService throws runtime exceptions for errors + Log.e(TAG, "onDataPathConfirm: ACCEPT nnri=" + nnri + + ": can't configure network - " + + e); + mMgr.endDataPath(ndpId); + return networkSpecifier; + } + } else { + if (VDBG) { + Log.v(TAG, "onDataPathConfirm: interface already configured: " + + nnri.interfaceName); + } } if (!mNiWrapper.configureAgentProperties(nnri, networkSpecifier, ndpId, networkInfo, @@ -528,7 +537,7 @@ public class WifiAwareDataPathStateManager { return; } - tearDownInterface(nnriE.getValue()); + tearDownInterfaceIfPossible(nnriE.getValue()); if (nnriE.getValue().state == AwareNetworkRequestInformation.STATE_CONFIRMED) { mAwareMetrics.recordNdpSessionDuration(nnriE.getValue().startTimestamp); } @@ -542,7 +551,7 @@ public class WifiAwareDataPathStateManager { if (VDBG) Log.v(TAG, "onAwareDownCleanupDataPaths"); for (AwareNetworkRequestInformation nnri : mNetworkRequestsCache.values()) { - tearDownInterface(nnri); + tearDownInterfaceIfPossible(nnri); } mNetworkRequestsCache.clear(); } @@ -629,13 +638,6 @@ public class WifiAwareDataPathStateManager { return false; } - // TODO (b/63635780) support more then a single concurrent NDP - if (mNetworkRequestsCache.size() > 0) { - Log.e(TAG, "WifiAwareNetworkFactory.acceptRequest: request=" + request - + " - >1 concurrent NDPs aren't supported (yet)."); - return false; - } - mNetworkRequestsCache.put(networkSpecifier, nnri); return true; @@ -778,15 +780,23 @@ public class WifiAwareDataPathStateManager { } } - private void tearDownInterface(AwareNetworkRequestInformation nnri) { - if (VDBG) Log.v(TAG, "tearDownInterface: nnri=" + nnri); + private void tearDownInterfaceIfPossible(AwareNetworkRequestInformation nnri) { + if (VDBG) Log.v(TAG, "tearDownInterfaceIfPossible: nnri=" + nnri); - if (nnri.interfaceName != null && !nnri.interfaceName.isEmpty()) { - try { - mNwService.setInterfaceDown(nnri.interfaceName); - } catch (Exception e) { // NwService throws runtime exceptions for errors - Log.e(TAG, - "tearDownInterface: nnri=" + nnri + ": can't bring interface down - " + e); + if (!TextUtils.isEmpty(nnri.interfaceName)) { + boolean interfaceUsedByAnotherNdp = isInterfaceUpAndUsedByAnotherNdp(nnri); + if (interfaceUsedByAnotherNdp) { + if (VDBG) { + Log.v(TAG, "tearDownInterfaceIfPossible: interfaceName=" + nnri.interfaceName + + ", still in use - not turning down"); + } + } else { + try { + mNwService.setInterfaceDown(nnri.interfaceName); + } catch (Exception e) { // NwService throws runtime exceptions for errors + Log.e(TAG, "tearDownInterfaceIfPossible: nnri=" + nnri + + ": can't bring interface down - " + e); + } } } @@ -795,6 +805,21 @@ public class WifiAwareDataPathStateManager { } } + private boolean isInterfaceUpAndUsedByAnotherNdp(AwareNetworkRequestInformation nri) { + for (AwareNetworkRequestInformation lnri : mNetworkRequestsCache.values()) { + if (lnri == nri) { + continue; + } + + if (nri.interfaceName.equals(lnri.interfaceName) + && lnri.state == AwareNetworkRequestInformation.STATE_CONFIRMED) { + return true; + } + } + + return false; + } + /** * Select one of the existing interfaces for the new network request. * diff --git a/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java b/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java index 05721afee..2f424db4c 100644 --- a/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java @@ -167,10 +167,9 @@ public class WifiAwareNativeCallback extends IWifiNanIfaceEventCallback.Stub imp capabilities.maxSubscribeInterfaceAddresses; frameworkCapabilities.supportedCipherSuites = capabilities.supportedCipherSuites; - // TODO (b/63635780, b/63635857): enable framework support of >1 NDI and >1 NDP per NDI - // Until then: force corresponding capabilities to 1. + // TODO (b/63635857): enable framework support of >1 NDI + // Until then: force corresponding capability to 1. frameworkCapabilities.maxNdiInterfaces = 1; - frameworkCapabilities.maxNdpSessions = 1; mWifiAwareStateManager.onCapabilitiesUpdateResponse(id, frameworkCapabilities); } else { diff --git a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java index 30aa42a26..6ced9486c 100644 --- a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java @@ -204,7 +204,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe private volatile Characteristics mCharacteristics = null; private WifiAwareStateMachine mSm; private WifiAwareRttStateManager mRtt; - private WifiAwareDataPathStateManager mDataPathMgr; + public WifiAwareDataPathStateManager mDataPathMgr; private PowerManager mPowerManager; private final SparseArray<WifiAwareClientState> mClients = new SparseArray<>(); |