summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSelector.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTest.java36
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)