summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointManager.java31
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java32
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}.