summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorPeter Qiu <zqiu@google.com>2017-03-31 23:18:03 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-03-31 23:18:03 +0000
commitb687f772eacbc984f5ac4a46e19cacaebde84f4e (patch)
treeae189647bcb13a2cc6e2e7c742d1e9fd874e8d50 /service
parentf916f03c6c0864a3578dacbcad1930afcdc9f0b9 (diff)
parent63a874bf77ec9b59ae6113e17fd90221c64125fb (diff)
Merge "hotspot2: set WifiConfiguration#isHomeProviderNetwork for Passpoint networks" into oc-dev
am: 63a874bf77 Change-Id: Ic5b02133c47b2abacfef45f1307356219bf08980
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointManager.java3
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java84
2 files changed, 51 insertions, 36 deletions
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
index f472d86db..6103b494e 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
@@ -450,6 +450,9 @@ public class PasspointManager {
}
WifiConfiguration config = matchedProvider.first.getWifiConfig();
config.SSID = ScanResultUtil.createQuotedSSID(scanResult.SSID);
+ if (matchedProvider.second == PasspointMatch.HomeProvider) {
+ config.isHomeProviderNetwork = true;
+ }
return config;
}
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java
index 1bade6c52..132a2f22c 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java
@@ -42,6 +42,21 @@ public class PasspointNetworkEvaluator implements WifiNetworkSelector.NetworkEva
private final WifiConfigManager mWifiConfigManager;
private final LocalLog mLocalLog;
+ /**
+ * Contained information for a Passpoint network candidate.
+ */
+ private class PasspointNetworkCandidate {
+ PasspointNetworkCandidate(PasspointProvider provider, PasspointMatch matchStatus,
+ ScanDetail scanDetail) {
+ mProvider = provider;
+ mMatchStatus = matchStatus;
+ mScanDetail = scanDetail;
+ }
+ PasspointProvider mProvider;
+ PasspointMatch mMatchStatus;
+ ScanDetail mScanDetail;
+ }
+
public PasspointNetworkEvaluator(PasspointManager passpointManager,
WifiConfigManager wifiConfigManager, LocalLog localLog) {
mPasspointManager = passpointManager;
@@ -66,8 +81,7 @@ public class PasspointNetworkEvaluator implements WifiNetworkSelector.NetworkEva
mPasspointManager.sweepCache();
// Go through each ScanDetail and find the best provider for each ScanDetail.
- List<Pair<ScanDetail, Pair<PasspointProvider, PasspointMatch>>> providerList =
- new ArrayList<>();
+ List<PasspointNetworkCandidate> candidateList = new ArrayList<>();
for (ScanDetail scanDetail : scanDetails) {
// Skip non-Passpoint APs.
if (!scanDetail.getNetworkDetail().isInterworking()) {
@@ -78,31 +92,31 @@ public class PasspointNetworkEvaluator implements WifiNetworkSelector.NetworkEva
Pair<PasspointProvider, PasspointMatch> bestProvider =
mPasspointManager.matchProvider(scanDetail.getScanResult());
if (bestProvider != null) {
- providerList.add(Pair.create(scanDetail, bestProvider));
+ candidateList.add(new PasspointNetworkCandidate(
+ bestProvider.first, bestProvider.second, scanDetail));
}
}
- // Done if no matching provider is found.
- if (providerList.isEmpty()) {
+ // Done if no candidate is found.
+ if (candidateList.isEmpty()) {
localLog("No suitable Passpoint network found");
return null;
}
- // Find the best Passpoint network among all matches.
- Pair<PasspointProvider, ScanDetail> bestNetwork = findBestNetwork(providerList,
- currentNetwork == null ? null : currentNetwork.SSID);
+ // Find the best Passpoint network among all candidates.
+ PasspointNetworkCandidate bestNetwork =
+ findBestNetwork(candidateList, currentNetwork == null ? null : currentNetwork.SSID);
// Return the configuration for the current connected network if it is the best network.
if (currentNetwork != null && TextUtils.equals(currentNetwork.SSID,
- ScanResultUtil.createQuotedSSID(bestNetwork.second.getSSID()))) {
+ ScanResultUtil.createQuotedSSID(bestNetwork.mScanDetail.getSSID()))) {
localLog("Staying with current Passpoint network " + currentNetwork.SSID);
- connectableNetworks.add(Pair.create(bestNetwork.second, currentNetwork));
+ connectableNetworks.add(Pair.create(bestNetwork.mScanDetail, currentNetwork));
return currentNetwork;
}
- WifiConfiguration config =
- createWifiConfigForProvider(bestNetwork.first, bestNetwork.second);
- connectableNetworks.add(Pair.create(bestNetwork.second, config));
+ WifiConfiguration config = createWifiConfigForProvider(bestNetwork);
+ connectableNetworks.add(Pair.create(bestNetwork.mScanDetail, config));
localLog("Passpoint network to connect to: " + config.SSID);
return config;
}
@@ -111,14 +125,15 @@ public class PasspointNetworkEvaluator implements WifiNetworkSelector.NetworkEva
* Create and return a WifiConfiguration for the given ScanDetail and PasspointProvider.
* The newly created WifiConfiguration will also be added to WifiConfigManager.
*
- * @param provider The provider to create WifiConfiguration from
- * @param scanDetail The ScanDetail to create WifiConfiguration from
+ * @param networkInfo Contained information for the Passpoint network to connect to
* @return {@link WifiConfiguration}
*/
- private WifiConfiguration createWifiConfigForProvider(PasspointProvider provider,
- ScanDetail scanDetail) {
- WifiConfiguration config = provider.getWifiConfig();
- config.SSID = ScanResultUtil.createQuotedSSID(scanDetail.getSSID());
+ private WifiConfiguration createWifiConfigForProvider(PasspointNetworkCandidate networkInfo) {
+ WifiConfiguration config = networkInfo.mProvider.getWifiConfig();
+ config.SSID = ScanResultUtil.createQuotedSSID(networkInfo.mScanDetail.getSSID());
+ if (networkInfo.mMatchStatus == PasspointMatch.HomeProvider) {
+ config.isHomeProviderNetwork = true;
+ }
// Add the newly created WifiConfiguration to WifiConfigManager.
NetworkUpdateResult result =
@@ -129,8 +144,9 @@ public class PasspointNetworkEvaluator implements WifiNetworkSelector.NetworkEva
}
mWifiConfigManager.enableNetwork(result.getNetworkId(), false, Process.WIFI_UID);
mWifiConfigManager.setNetworkCandidateScanResult(result.getNetworkId(),
- scanDetail.getScanResult(), 0);
- mWifiConfigManager.updateScanDetailForNetwork(result.getNetworkId(), scanDetail);
+ networkInfo.mScanDetail.getScanResult(), 0);
+ mWifiConfigManager.updateScanDetailForNetwork(
+ result.getNetworkId(), networkInfo.mScanDetail);
return mWifiConfigManager.getConfiguredNetwork(result.getNetworkId());
}
@@ -141,18 +157,15 @@ public class PasspointNetworkEvaluator implements WifiNetworkSelector.NetworkEva
*
* @param networkList List of Passpoint networks
* @param currentNetworkSsid The SSID of the currently connected network, null if not connected
- * @return {@link PasspointProvider} and {@link ScanDetail} associated with the network
+ * @return {@link PasspointNetworkCandidate}
*/
- private Pair<PasspointProvider, ScanDetail> findBestNetwork(
- List<Pair<ScanDetail, Pair<PasspointProvider, PasspointMatch>>> networkList,
- String currentNetworkSsid) {
- ScanDetail bestScanDetail = null;
- PasspointProvider bestProvider = null;
+ private PasspointNetworkCandidate findBestNetwork(
+ List<PasspointNetworkCandidate> networkList, String currentNetworkSsid) {
+ PasspointNetworkCandidate bestCandidate = null;
int bestScore = Integer.MIN_VALUE;
- for (Pair<ScanDetail, Pair<PasspointProvider, PasspointMatch>> candidate : networkList) {
- ScanDetail scanDetail = candidate.first;
- PasspointProvider provider = candidate.second.first;
- PasspointMatch match = candidate.second.second;
+ for (PasspointNetworkCandidate candidate : networkList) {
+ ScanDetail scanDetail = candidate.mScanDetail;
+ PasspointMatch match = candidate.mMatchStatus;
boolean isActiveNetwork = TextUtils.equals(currentNetworkSsid,
ScanResultUtil.createQuotedSSID(scanDetail.getSSID()));
@@ -161,14 +174,13 @@ public class PasspointNetworkEvaluator implements WifiNetworkSelector.NetworkEva
isActiveNetwork);
if (score > bestScore) {
- bestScanDetail = scanDetail;
- bestProvider = provider;
+ bestCandidate = candidate;
bestScore = score;
}
}
- localLog("Best Passpoint network " + bestScanDetail.getSSID() + " provided by "
- + bestProvider.getConfig().getHomeSp().getFqdn());
- return Pair.create(bestProvider, bestScanDetail);
+ localLog("Best Passpoint network " + bestCandidate.mScanDetail.getSSID() + " provided by "
+ + bestCandidate.mProvider.getConfig().getHomeSp().getFqdn());
+ return bestCandidate;
}
private void localLog(String log) {