diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-04-24 02:25:36 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-04-24 02:25:36 +0000 |
commit | fbfbe4b17e862e01caa20db25d52cdd0d83835d3 (patch) | |
tree | 04763cdf1531740650f1f110949fa447db7a9967 | |
parent | bf5903c9c270c329aa2eaffcf777ce72752d7021 (diff) | |
parent | d43b5f2f3e1bc80c86d32bf976ece572e81e2f95 (diff) |
Merge "WifiNetworkSelector: Fix isFromCarrierOrPrivilegedApp()" into rvc-dev
-rw-r--r-- | service/java/com/android/server/wifi/WifiNetworkSelector.java | 2 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java | 36 |
2 files changed, 37 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java index 20544282f..da583df65 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSelector.java +++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java @@ -1047,7 +1047,7 @@ public class WifiNetworkSelector { private static boolean isFromCarrierOrPrivilegedApp(WifiConfiguration config) { if (config.fromWifiNetworkSuggestion - && config.carrierId == TelephonyManager.UNKNOWN_CARRIER_ID) { + && config.carrierId != TelephonyManager.UNKNOWN_CARRIER_ID) { // Privileged carrier suggestion return true; } 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) |