diff options
author | Peter Qiu <zqiu@google.com> | 2017-03-07 14:56:15 -0800 |
---|---|---|
committer | Peter Qiu <zqiu@google.com> | 2017-03-16 11:10:31 -0700 |
commit | b54f07e01c9daef8883c85e09f61436f2c06cc72 (patch) | |
tree | 4519f328bf81f54ebcd230392cda5a88a0d03db9 /service | |
parent | ec28f863c5e46c0a75e8bdb92283304b875ee0f2 (diff) |
hotspot2: update semantics for PasspointManager#matchProvider
Instead of returning a list of matched providers, it will now
return the best provider for the given AP (based on ScanResult).
It will return null if no match is found.
So PasspointManager is responsible for ranking providers for
a given AP (based on ScanResult), while PasspointNetworkEvalutor
is responsible for ranking Passpoint networks with matched provider.
Bug: 35888100
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Test: Manual test with Global Reach Passpoint AP
Change-Id: I9e2a76aaf319f6180d7767fe8f713547221feb6c
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/hotspot2/PasspointManager.java | 31 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java | 32 |
2 files changed, 20 insertions, 43 deletions
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java index f88c9d5bc..29656fd89 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java @@ -275,18 +275,22 @@ public class PasspointManager { } /** - * Find the providers that can provide service through the given AP, which means the - * providers contained credential to authenticate with the given AP. + * Find the best provider that can provide service through the given AP, which means the + * provider contained credential to authenticate with the given AP. * - * An empty list will returned in the case when no match is found. + * Here is the current precedence of the matching rule in descending order: + * 1. Home Provider + * 2. Roaming Provider + * + * A {code null} will be returned if no matching is found. * * @param scanResult The scan result associated with the AP - * @return List of {@link PasspointProvider} + * @return A pair of {@link PasspointProvider} and match status. */ - public List<Pair<PasspointProvider, PasspointMatch>> matchProvider(ScanResult scanResult) { + public Pair<PasspointProvider, PasspointMatch> matchProvider(ScanResult scanResult) { // Nothing to be done if no Passpoint provider is installed. if (mProviders.isEmpty()) { - return new ArrayList<Pair<PasspointProvider, PasspointMatch>>(); + return null; } // Retrieve the relevant information elements, mainly Roaming Consortium IE and Hotspot 2.0 @@ -306,19 +310,22 @@ public class PasspointManager { mAnqpRequestManager.requestANQPElements(bssid, anqpKey, roamingConsortium.anqpOICount > 0, vsa.hsRelease == NetworkDetail.HSRelease.R2); - return new ArrayList<Pair<PasspointProvider, PasspointMatch>>(); + return null; } - List<Pair<PasspointProvider, PasspointMatch>> results = new ArrayList<>(); + Pair<PasspointProvider, PasspointMatch> bestMatch = null; for (Map.Entry<String, PasspointProvider> entry : mProviders.entrySet()) { PasspointProvider provider = entry.getValue(); PasspointMatch matchStatus = provider.match(anqpEntry.getElements()); - if (matchStatus == PasspointMatch.HomeProvider - || matchStatus == PasspointMatch.RoamingProvider) { - results.add(new Pair<PasspointProvider, PasspointMatch>(provider, matchStatus)); + if (matchStatus == PasspointMatch.HomeProvider) { + bestMatch = Pair.create(provider, matchStatus); + break; + } + if (matchStatus == PasspointMatch.RoamingProvider && bestMatch == null) { + bestMatch = Pair.create(provider, matchStatus); } } - return results; + return bestMatch; } /** diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java index a1fbcffce..740a302cc 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java @@ -74,12 +74,9 @@ public class PasspointNetworkEvaluator implements WifiNetworkSelector.NetworkEva continue; } - List<Pair<PasspointProvider, PasspointMatch>> matchedProviders = - mPasspointManager.matchProvider(scanDetail.getScanResult()); - // Find the best provider for this ScanDetail. Pair<PasspointProvider, PasspointMatch> bestProvider = - findBestProvider(matchedProviders); + mPasspointManager.matchProvider(scanDetail.getScanResult()); if (bestProvider != null) { providerList.add(Pair.create(scanDetail, bestProvider)); } @@ -135,33 +132,6 @@ public class PasspointNetworkEvaluator implements WifiNetworkSelector.NetworkEva } /** - * Given a list of provider associated with a ScanDetail, determine and return the best - * provider from the list. - * - * Currently the only criteria is to prefer home provider over roaming provider. Additional - * criteria will be added when Hotspot 2.0 Release 2 support is added. - * - * A null will be returned if no match is found (providerList is empty). - * - * @param providerList The list of matched providers - * @return Pair of {@link PasspointProvider} with its matching status - */ - private Pair<PasspointProvider, PasspointMatch> findBestProvider( - List<Pair<PasspointProvider, PasspointMatch>> providerList) { - Pair<PasspointProvider, PasspointMatch> bestMatch = null; - for (Pair<PasspointProvider, PasspointMatch> providerMatch : providerList) { - if (providerMatch.second == PasspointMatch.HomeProvider) { - // Home provider found, done. - bestMatch = providerMatch; - break; - } else if (bestMatch == null) { - bestMatch = providerMatch; - } - } - return bestMatch; - } - - /** * Given a list of Passpoint networks (with both provider and scan info), find and return * the one with highest score. The score is calculated using * {@link PasspointNetworkScore#calculateScore}. |