From b54f07e01c9daef8883c85e09f61436f2c06cc72 Mon Sep 17 00:00:00 2001 From: Peter Qiu Date: Tue, 7 Mar 2017 14:56:15 -0800 Subject: 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 --- .../server/wifi/hotspot2/PasspointManager.java | 31 +++++++++++++-------- .../wifi/hotspot2/PasspointNetworkEvaluator.java | 32 +--------------------- 2 files changed, 20 insertions(+), 43 deletions(-) (limited to 'service') 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> matchProvider(ScanResult scanResult) { + public Pair matchProvider(ScanResult scanResult) { // Nothing to be done if no Passpoint provider is installed. if (mProviders.isEmpty()) { - return new ArrayList>(); + 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>(); + return null; } - List> results = new ArrayList<>(); + Pair bestMatch = null; for (Map.Entry entry : mProviders.entrySet()) { PasspointProvider provider = entry.getValue(); PasspointMatch matchStatus = provider.match(anqpEntry.getElements()); - if (matchStatus == PasspointMatch.HomeProvider - || matchStatus == PasspointMatch.RoamingProvider) { - results.add(new Pair(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> matchedProviders = - mPasspointManager.matchProvider(scanDetail.getScanResult()); - // Find the best provider for this ScanDetail. Pair bestProvider = - findBestProvider(matchedProviders); + mPasspointManager.matchProvider(scanDetail.getScanResult()); if (bestProvider != null) { providerList.add(Pair.create(scanDetail, bestProvider)); } @@ -134,33 +131,6 @@ public class PasspointNetworkEvaluator implements WifiNetworkSelector.NetworkEva return mWifiConfigManager.getConfiguredNetwork(result.getNetworkId()); } - /** - * 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 findBestProvider( - List> providerList) { - Pair bestMatch = null; - for (Pair 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 -- cgit v1.2.3