diff options
author | Randy Pan <zpan@google.com> | 2017-03-02 16:05:11 -0800 |
---|---|---|
committer | Randy Pan <zpan@google.com> | 2017-03-28 12:00:07 -0700 |
commit | c22ad7f19888f7967edcf30080543bb632ddd68d (patch) | |
tree | c801fd447a0ee57bb326c40a9c33814a43b572cf /tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java | |
parent | 17c2a7b30e5680b11fc0073ce322ee7bc14ef2c5 (diff) | |
download | android_frameworks_opt_net_wifi-c22ad7f19888f7967edcf30080543bb632ddd68d.tar.gz android_frameworks_opt_net_wifi-c22ad7f19888f7967edcf30080543bb632ddd68d.tar.bz2 android_frameworks_opt_net_wifi-c22ad7f19888f7967edcf30080543bb632ddd68d.zip |
Same BSSID award
When firmware roaming is supported, apply the same BSSID award to
all of the BSSIDs under the same network as the currently connected
BSSID. This is under the assumption that firmware will roam to that
better BSSID.
This might save a disconnection triggered by network switch when
the score of the currently connected BSSID is lower than a network
with a different SSID, but within the currently connected network
there is a BSSID better than the currently connected BSSID.
Bug: 35642269
Test: runtest.sh
Change-Id: Ie09170d0cb11565f72e3b45b702d39c88ababba9
Diffstat (limited to 'tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java index 865344506..1e255c86c 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java @@ -37,7 +37,9 @@ import android.text.TextUtils; import com.android.server.wifi.util.ScanResultUtil; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * Helper for WifiNetworkSelector unit tests. @@ -132,7 +134,7 @@ public class WifiNetworkSelectorTestUtil { /** * Generate an array of {@link android.net.wifi.WifiConfiguration} based on the caller - * supplied network SSID and sencurity information. + * supplied network SSID and security information. * * @param ssids an array of SSIDs * @param securities an array of the network's security setting @@ -145,10 +147,23 @@ public class WifiNetworkSelectorTestUtil { return null; } + Map<String, Integer> netIdMap = new HashMap<>(); + int netId = 0; + WifiConfiguration[] configs = new WifiConfiguration[ssids.length]; for (int index = 0; index < ssids.length; index++) { - configs[index] = generateWifiConfig(index, 0, ssids[index], false, true, null, null, - securities[index]); + String configKey = ssids[index] + Integer.toString(securities[index]); + Integer id; + + id = netIdMap.get(configKey); + if (id == null) { + id = new Integer(netId); + netIdMap.put(configKey, id); + netId++; + } + + configs[index] = generateWifiConfig(id.intValue(), 0, ssids[index], false, true, null, + null, securities[index]); } return configs; @@ -167,19 +182,20 @@ public class WifiNetworkSelectorTestUtil { when(wifiConfigManager.getConfiguredNetwork(anyInt())) .then(new AnswerWithArguments() { public WifiConfiguration answer(int netId) { - if (netId >= 0 && netId < configs.length) { - return new WifiConfiguration(configs[netId]); - } else { - return null; + for (WifiConfiguration config : configs) { + if (netId == config.networkId) { + return new WifiConfiguration(config); + } } + return null; } }); when(wifiConfigManager.getConfiguredNetwork(anyString())) .then(new AnswerWithArguments() { public WifiConfiguration answer(String configKey) { - for (int netId = 0; netId < configs.length; netId++) { - if (TextUtils.equals(configs[netId].configKey(), configKey)) { - return new WifiConfiguration(configs[netId]); + for (WifiConfiguration config : configs) { + if (TextUtils.equals(config.configKey(), configKey)) { + return new WifiConfiguration(config); } } return null; |