Merge "WifiConfigManager: do not use ScanDetailCache to set SSID for... passpoint networks"
diff --git a/service/java/com/android/server/wifi/ScanDetailCache.java b/service/java/com/android/server/wifi/ScanDetailCache.java
index e3f3192..cb44e2a 100644
--- a/service/java/com/android/server/wifi/ScanDetailCache.java
+++ b/service/java/com/android/server/wifi/ScanDetailCache.java
@@ -85,11 +85,6 @@
return size() == 0;
}
- ScanDetail getFirst() {
- Iterator<ScanDetail> it = mMap.values().iterator();
- return it.hasNext() ? it.next() : null;
- }
-
Collection<String> keySet() {
return mMap.keySet();
}
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 6a066c7..e747c3c 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -674,19 +674,20 @@
NetworkDetail selectedPasspointNetwork = null;
if (config.isPasspoint()) {
- /* need to slap on the SSID of selected bssid to work */
- if (getScanDetailCache(config).size() != 0) {
- ScanDetail result = getScanDetailCache(config).getFirst();
- if (result == null) {
- loge("Could not find scan result for " + config.BSSID);
- } else {
- logd("Setting SSID for " + config.networkId + " to" + result.getSSID());
+ // Set the SSID for the underlying WPA supplicant network entry corresponding to this
+ // Passpoint profile to the SSID of the BSS selected by QNS. |config.SSID| is set by
+ // selectQualifiedNetwork.selectQualifiedNetwork(), when the qualified network selected
+ // is a Passpoint network.
+ logd("Setting SSID for WPA supplicant network " + config.networkId + " to "
+ + config.SSID);
+ setSSIDNative(config, config.SSID);
+ String selectedPasspointNetworkBssid = mWifiSupplicantControl.getNetworkBSSID(config);
+ if (selectedPasspointNetworkBssid != null) {
+ ScanDetail result =
+ getScanDetailCache(config).getScanDetail(selectedPasspointNetworkBssid);
+ if (result != null) {
selectedPasspointNetwork = result.getNetworkDetail();
- setSSIDNative(config, result.getSSID());
}
-
- } else {
- loge("Could not find bssid for " + config);
}
}
mSelectedPasspointNetwork = selectedPasspointNetwork;
diff --git a/service/java/com/android/server/wifi/WifiSupplicantControl.java b/service/java/com/android/server/wifi/WifiSupplicantControl.java
index eb668c0..d05f3ef 100644
--- a/service/java/com/android/server/wifi/WifiSupplicantControl.java
+++ b/service/java/com/android/server/wifi/WifiSupplicantControl.java
@@ -736,6 +736,25 @@
}
/**
+ * Get BSSID for a network in wpa_supplicant.
+ *
+ * @param config Config corresponding to the network.
+ * @return BSSID for the network, if it exists, null otherwise.
+ */
+ public String getNetworkBSSID(WifiConfiguration config) {
+ // Sanity check the config is valid
+ if (config == null
+ || (config.networkId == WifiConfiguration.INVALID_NETWORK_ID
+ && config.SSID == null)) {
+ return null;
+ }
+ if (mVerboseLoggingEnabled) localLog("getNetworkBSSID: " + config.networkId);
+ String bssid =
+ mWifiNative.getNetworkVariable(config.networkId, WifiConfiguration.bssidVarName);
+ return (TextUtils.isEmpty(bssid) ? null : bssid);
+ }
+
+ /**
* Enable/Disable HS20 parameter in wpa_supplicant.
*
* @param enable Enable/Disable the parameter.