summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKai Shi <kaishi@google.com>2020-09-09 23:27:11 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-09-09 23:27:11 +0000
commit2a2fc39e77bf780fbb2e98255738c818c5927392 (patch)
tree21a2b4979a2acb45769fb02b7e228c7ac4ca3944 /tests
parent22f265e77b3c293c1a9ef2c15aae06e6b8a9e27d (diff)
parente9cfb8f54b276b3b5afc72a9fb239aab48f4d86f (diff)
Merge "wifi: bug fix of network selection when autoConnect == false" into rvc-qpr-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
index 0bd14a470..1507e9c55 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java
@@ -741,6 +741,56 @@ public class WifiNetworkSelectorTest extends WifiBaseTest {
}
/**
+ * Wifi network selector stays with current network if current network is not nominated
+ * but has the higher score
+ */
+ @Test
+ public void includeCurrentNetworkWhenCurrentNetworkNotNominated() {
+ String[] ssids = {"\"test1\"", "\"test2\""};
+ String[] bssids = {"6c:f3:7f:ae:8c:f3", "6c:f3:7f:ae:8c:f4"};
+ int[] freqs = {2437, 5120};
+ String[] caps = {"[WPA2-EAP-CCMP][ESS]", "[WPA2-PSK][ESS]"};
+ int[] levels = {mThresholdMinimumRssi2G + 10, mThresholdMinimumRssi2G + 20};
+ int[] securities = {SECURITY_EAP, SECURITY_PSK};
+ // VHT cap IE
+ byte[] iesBytes = {(byte) 0x92, (byte) 0x01, (byte) 0x80, (byte) 0x33, (byte) 0xaa,
+ (byte) 0xff, (byte) 0x00, (byte) 0x00, (byte) 0xaa, (byte) 0xff, (byte) 0x00,
+ (byte) 0x00};
+ byte[][] iesByteStream = {iesBytes, iesBytes};
+ // Make a network selection to connect to test1.
+ ScanDetailsAndWifiConfigs scanDetailsAndConfigs =
+ WifiNetworkSelectorTestUtil.setupScanDetailsAndConfigStore(ssids, bssids,
+ freqs, caps, levels, securities, mWifiConfigManager, mClock, iesByteStream);
+ List<ScanDetail> scanDetails = scanDetailsAndConfigs.getScanDetails();
+ assertEquals(2, scanDetails.size());
+ HashSet<String> blocklist = new HashSet<String>();
+ List<WifiCandidates.Candidate> candidates = mWifiNetworkSelector.getCandidatesFromScan(
+ scanDetails, blocklist, mWifiInfo, false, true, false);
+ WifiConfiguration candidate = mWifiNetworkSelector.selectNetwork(candidates);
+
+ when(mWifiInfo.getSupplicantState()).thenReturn(SupplicantState.COMPLETED);
+ when(mWifiInfo.getNetworkId()).thenReturn(0); // 0 is current network
+ when(mWifiInfo.getBSSID()).thenReturn(bssids[0]);
+ when(mWifiInfo.is24GHz()).thenReturn(true);
+ when(mWifiInfo.getScore()).thenReturn(ConnectedScore.WIFI_TRANSITION_SCORE);
+ when(mWifiInfo.is5GHz()).thenReturn(false);
+ when(mWifiInfo.getFrequency()).thenReturn(2400);
+ when(mWifiInfo.getRssi()).thenReturn(levels[0]);
+ when(mClock.getElapsedSinceBootMillis()).thenReturn(SystemClock.elapsedRealtime()
+ + WifiNetworkSelector.MINIMUM_NETWORK_SELECTION_INTERVAL_MS + 2000);
+
+ when(mThroughputPredictor.predictThroughput(any(), anyInt(), anyInt(), anyInt(),
+ anyInt(), anyInt(), anyInt(), anyInt(), anyBoolean())).thenReturn(100);
+ // Force to return 2nd network in the network nominator
+ mDummyNominator.setNetworkIndexToReturn(1);
+
+ candidates = mWifiNetworkSelector.getCandidatesFromScan(
+ scanDetails, blocklist, mWifiInfo, true, false, false);
+ assertEquals(2, candidates.size());
+ assertEquals(100, candidates.get(0).getPredictedThroughputMbps());
+ }
+
+ /**
* If two qualified networks, test1 and test2, are in range when the user selects test2 over
* test1, WifiNetworkSelector will override the NetworkSelector's choice to connect to test1
* with test2.