diff options
author | Roshan Pius <rpius@google.com> | 2020-04-23 13:57:41 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2020-04-23 14:37:57 -0700 |
commit | d43b5f2f3e1bc80c86d32bf976ece572e81e2f95 (patch) | |
tree | 0bc97b79256859a470df3898e63660385c13ccb4 /tests | |
parent | e0e4592a0efe0170ad5a5e162253306f7d0f21fc (diff) |
WifiNetworkSelector: Fix isFromCarrierOrPrivilegedApp()
Bug: 154854542
Test: atest com.android.server.wifi
Change-Id: Ic04665101c939257c65e76cdec5dc57de3cd2575
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java | 36 |
1 files changed, 36 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 4f303d104..7c5ff1f3f 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java @@ -1438,6 +1438,42 @@ public class WifiNetworkSelectorTest extends WifiBaseTest { assertEquals(ssids[0], candidate.SSID); } + @Test + public void testIsFromCarrierOrPrivilegedApp() { + String[] ssids = {"\"test1\"", "\"test2\""}; + String[] bssids = {"6c:f3:7f:ae:8c:f3", "6c:f3:7f:ae:8c:f4"}; + int[] freqs = {2437, 5180}; + String[] caps = {"[WPA2-EAP-CCMP][ESS]", "[WPA2-EAP-CCMP][ESS]"}; + int[] levels = {mThresholdMinimumRssi2G + 1, mThresholdMinimumRssi5G + 1}; + int[] securities = {SECURITY_EAP, SECURITY_EAP}; + HashSet<String> blacklist = new HashSet<>(); + ScanDetailsAndWifiConfigs scanDetailsAndConfigs = + WifiNetworkSelectorTestUtil.setupScanDetailsAndConfigStore(ssids, bssids, + freqs, caps, levels, securities, mWifiConfigManager, mClock); + List<ScanDetail> scanDetails = scanDetailsAndConfigs.getScanDetails(); + WifiConfiguration[] configs = scanDetailsAndConfigs.getWifiConfigs(); + // Mark one of the networks as carrier privileged. + configs[0].fromWifiNetworkSuggestion = true; + configs[0].carrierId = 5; + mWifiNetworkSelector.registerNetworkNominator( + new AllNetworkNominator(scanDetailsAndConfigs)); + List<WifiCandidates.Candidate> candidates = mWifiNetworkSelector.getCandidatesFromScan( + scanDetails, blacklist, mWifiInfo, false, true, true); + // Expect one privileged and one regular candidate. + assertEquals(2, candidates.size()); + boolean foundCarrierOrPrivilegedAppCandidate = false; + boolean foundNotCarrierOrPrivilegedAppCandidate = false; + for (WifiCandidates.Candidate candidate : candidates) { + if (candidate.isCarrierOrPrivileged()) { + foundCarrierOrPrivilegedAppCandidate = true; + } else { + foundNotCarrierOrPrivilegedAppCandidate = true; + } + } + assertTrue(foundCarrierOrPrivilegedAppCandidate); + assertTrue(foundNotCarrierOrPrivilegedAppCandidate); + } + /** * Test that network which are not accepting new connections(MBO * association disallowed attribute in beacons/probe responses) |