diff options
author | Roshan Pius <rpius@google.com> | 2020-04-22 16:52:46 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2020-04-23 14:36:38 -0700 |
commit | e0e4592a0efe0170ad5a5e162253306f7d0f21fc (patch) | |
tree | 97798c26eacc73f13059eb30cdbee775916d25bc /service | |
parent | 19df2d0dfa75acecef66737dee97e605bd2b00a3 (diff) |
WifiNetworkFactory: Don't use WifiConfig from UI for matching
The WifiConfiguration passed in from the UI in the
NetworkRequestUserSelectionCallback.select() only has the SSID field
set (in hindsight the select() API should just have accepted a string
param instead of WifiConfiguration). The rest of params including
security params are constructed from the original app's request. Ensure
that we use the merged WifiConfiguration to find matching scan results
to set bssid for connection.
Also, fixed the unit tests to reflect the correct behavior from UI (only
set the SSID field in WifiConfiguration). The unit tests were
incorrectly setting the securiy params and masking the problem.
Bug: 154764757
Test: act.py -c wifi_manager_cross.config -tb dut-name -tc WifiNetworkRequestTest
Test: atest com.android.server.wifi
Change-Id: I611e05f15a0e1fff3cdbc1f6d0e2347653446678
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiNetworkFactory.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/WifiNetworkFactory.java b/service/java/com/android/server/wifi/WifiNetworkFactory.java index 26e602354..52fc0e5a7 100644 --- a/service/java/com/android/server/wifi/WifiNetworkFactory.java +++ b/service/java/com/android/server/wifi/WifiNetworkFactory.java @@ -790,7 +790,9 @@ public class WifiNetworkFactory extends NetworkFactory { new WifiConfiguration(mActiveSpecificNetworkRequestSpecifier.wifiConfiguration); networkToConnect.SSID = network.SSID; // Set the WifiConfiguration.BSSID field to prevent roaming. - networkToConnect.BSSID = findBestBssidFromActiveMatchedScanResultsForNetwork(network); + networkToConnect.BSSID = + findBestBssidFromActiveMatchedScanResultsForNetwork( + ScanResultMatchInfo.fromWifiConfiguration(networkToConnect)); networkToConnect.ephemeral = true; // Mark it user private to avoid conflicting with any saved networks the user might have. // TODO (b/142035508): Use a more generic mechanism to fix this. @@ -1246,14 +1248,14 @@ public class WifiNetworkFactory extends NetworkFactory { // i) The latest scan results were empty. // ii) The latest scan result did not contain any BSSID for the SSID user chose. private @Nullable String findBestBssidFromActiveMatchedScanResultsForNetwork( - @NonNull WifiConfiguration network) { + @NonNull ScanResultMatchInfo scanResultMatchInfo) { if (mActiveSpecificNetworkRequestSpecifier == null || mActiveMatchedScanResults == null) return null; ScanResult selectedScanResult = mActiveMatchedScanResults .stream() .filter(scanResult -> Objects.equals( ScanResultMatchInfo.fromScanResult(scanResult), - ScanResultMatchInfo.fromWifiConfiguration(network))) + scanResultMatchInfo)) .max(Comparator.comparing(scanResult -> scanResult.level)) .orElse(null); if (selectedScanResult == null) { // Should never happen. |