summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristopher Wiley <wiley@google.com>2016-09-19 16:02:31 -0700
committerChristopher Wiley <wiley@google.com>2016-09-22 14:31:37 -0700
commit026cb51837e4cf3aea30b903320b992a3f5d0d7b (patch)
treec441f7e906cb12962f6f9252194d59391fc960fc /tests
parent22f57da33e6b132a0e7e4bd6d986f74b53d19527 (diff)
Remove implementation of user selected WiFi bands
This functionality artificially limits WiFi's ability to connect to WiFi networks and establish connectivity. We already prefer 5Ghz networks to 2.4Ghz networks, and offer knobs to scan on a particular band. The UI that exposed this feature has been removed since M. Bug: 31148223 Test: builds, unit tests pass Change-Id: I8ae1f9d2b7217d404557fb69eccb2dd42799d4df
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java13
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiQualifiedNetworkSelectorTest.java77
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java2
3 files changed, 3 insertions, 89 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
index 48dc074ab..84133acb7 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
@@ -22,8 +22,8 @@ import static com.android.server.wifi.WifiStateMachine.WIFI_WORK_SOURCE;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
-import android.app.test.TestAlarmManager;
import android.app.test.MockAnswerUtil.AnswerWithArguments;
+import android.app.test.TestAlarmManager;
import android.content.Context;
import android.content.res.Resources;
import android.net.wifi.ScanResult;
@@ -31,7 +31,6 @@ import android.net.wifi.ScanResult.InformationElement;
import android.net.wifi.SupplicantState;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
-import android.net.wifi.WifiManager;
import android.net.wifi.WifiScanner;
import android.net.wifi.WifiScanner.PnoScanListener;
import android.net.wifi.WifiScanner.PnoSettings;
@@ -53,7 +52,6 @@ import org.mockito.ArgumentCaptor;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.concurrent.atomic.AtomicInteger;
/**
* Unit tests for {@link com.android.server.wifi.WifiConnectivityManager}.
@@ -191,7 +189,6 @@ public class WifiConnectivityManagerTest {
WifiStateMachine mockWifiStateMachine() {
WifiStateMachine stateMachine = mock(WifiStateMachine.class);
- when(stateMachine.getFrequencyBand()).thenReturn(1);
when(stateMachine.isLinkDebouncing()).thenReturn(false);
when(stateMachine.isConnected()).thenReturn(false);
when(stateMachine.isDisconnected()).thenReturn(true);
@@ -796,15 +793,13 @@ public class WifiConnectivityManagerTest {
when(mWifiStateMachine.getCurrentWifiConfiguration())
.thenReturn(new WifiConfiguration());
- when(mWifiStateMachine.getFrequencyBand())
- .thenReturn(WifiManager.WIFI_FREQUENCY_BAND_5GHZ);
when(mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(anyInt(), anyInt()))
.thenReturn(channelList);
doAnswer(new AnswerWithArguments() {
public void answer(ScanSettings settings, ScanListener listener,
WorkSource workSource) throws Exception {
- assertEquals(settings.band, WifiScanner.WIFI_BAND_5_GHZ_WITH_DFS);
+ assertEquals(settings.band, WifiScanner.WIFI_BAND_BOTH_WITH_DFS);
assertNull(settings.channels);
}}).when(mWifiScanner).startScan(anyObject(), anyObject(), anyObject());
@@ -876,15 +871,13 @@ public class WifiConnectivityManagerTest {
when(mWifiStateMachine.getCurrentWifiConfiguration())
.thenReturn(new WifiConfiguration());
- when(mWifiStateMachine.getFrequencyBand())
- .thenReturn(WifiManager.WIFI_FREQUENCY_BAND_5GHZ);
when(mWifiConfigManager.fetchChannelSetForNetworkForPartialScan(anyInt(), anyInt()))
.thenReturn(channelList);
doAnswer(new AnswerWithArguments() {
public void answer(ScanSettings settings, ScanListener listener,
WorkSource workSource) throws Exception {
- assertEquals(settings.band, WifiScanner.WIFI_BAND_5_GHZ_WITH_DFS);
+ assertEquals(settings.band, WifiScanner.WIFI_BAND_BOTH_WITH_DFS);
assertNull(settings.channels);
}}).when(mWifiScanner).startScan(anyObject(), anyObject(), anyObject());
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiQualifiedNetworkSelectorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiQualifiedNetworkSelectorTest.java
index 4baf495b4..c83400b93 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiQualifiedNetworkSelectorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiQualifiedNetworkSelectorTest.java
@@ -33,7 +33,6 @@ import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiConfiguration.NetworkSelectionStatus;
import android.net.wifi.WifiEnterpriseConfig;
import android.net.wifi.WifiInfo;
-import android.net.wifi.WifiManager;
import android.net.wifi.WifiSsid;
import android.os.SystemClock;
import android.test.suitebuilder.annotation.SmallTest;
@@ -51,7 +50,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
/**
* Unit tests for {@link com.android.server.wifi.WifiQualifiedNetworkSelector}.
@@ -72,7 +70,6 @@ public class WifiQualifiedNetworkSelectorTest {
mWifiQualifiedNetworkSelector = new WifiQualifiedNetworkSelector(mWifiConfigManager,
mContext, mWifiInfo, mClock);
mWifiQualifiedNetworkSelector.enableVerboseLogging(1);
- mWifiQualifiedNetworkSelector.setUserPreferredBand(WifiManager.WIFI_FREQUENCY_BAND_AUTO);
mWifiQualifiedNetworkSelector.setWifiNetworkScoreCache(mScoreCache);
when(mClock.getElapsedSinceBootMillis()).thenReturn(SystemClock.elapsedRealtime());
}
@@ -562,7 +559,6 @@ public class WifiQualifiedNetworkSelectorTest {
scanResultLinkConfiguration(savedConfigs, scanDetails);
ScanResult chosenScanResult = scanDetails.get(0).getScanResult();
- mWifiQualifiedNetworkSelector.setUserPreferredBand(WifiManager.WIFI_FREQUENCY_BAND_AUTO);
WifiConfiguration candidate = mWifiQualifiedNetworkSelector.selectQualifiedNetwork(false,
false, false, false, true, false, scanDetails);
@@ -2232,78 +2228,6 @@ public class WifiQualifiedNetworkSelectorTest {
}
/**
- * Case #46 5GHz due to user band preference is set to 5GHz only
- *
- * In this test. we simulate following scenario
- * WifiStateMachine is under disconnected state
- * User band preference is set to 5GHz only
- * Two networks test1, test2 are secured network
- * Both network are enabled
- * test1 is @ 2GHz with RSSI -50
- * test2 is @ 5Ghz with RSSI -75
- *
- * Expected behavior: test2 is chosen due to user band preference
- */
- @Test
- public void chooseNetworkDisconnectUserPrefer5GTest() {
- String[] ssids = DEFAULT_SSIDS;
- String[] bssids = DEFAULT_BSSIDS;
- int[] frequencies = {2437, 5180};
- String[] caps = {"[WPA2-EAP-CCMP][ESS]", "[WPA2-EAP-CCMP][ESS]"};
- int[] levels = {-50, -75};
- int[] security = {SECURITY_PSK, SECURITY_PSK};
-
- List<ScanDetail> scanDetails = getScanDetails(ssids, bssids, frequencies, caps, levels);
- WifiConfiguration[] savedConfigs = generateWifiConfigurations(ssids, security);
- prepareConfigStore(savedConfigs);
-
- scanResultLinkConfiguration(savedConfigs, scanDetails);
- ScanResult chosenScanResult = scanDetails.get(1).getScanResult();
-
- mWifiQualifiedNetworkSelector.setUserPreferredBand(WifiManager.WIFI_FREQUENCY_BAND_5GHZ);
- WifiConfiguration candidate = mWifiQualifiedNetworkSelector.selectQualifiedNetwork(false,
- false, false, false, true, false, scanDetails);
-
- verifySelectedResult(chosenScanResult, candidate);
- }
-
- /**
- * Case #47 2GHz due to user band preference is set to 2GHz only
- *
- * In this test. we simulate following scenario
- * WifiStateMachine is under disconnected state
- * User band preference is set to 2.4GHz only
- * Two networks test1, test2 are secured network
- * Both network are enabled
- * test1 is @ 2GHz with RSSI -75
- * test2 is @ 5Ghz with RSSI -50
- *
- * Expected behavior: test1 is chosen due to user band preference
- */
- @Test
- public void chooseNetworkDisconnectUserPrefer2GTest() {
- String[] ssids = DEFAULT_SSIDS;
- String[] bssids = DEFAULT_BSSIDS;
- int[] frequencies = {2437, 5180};
- String[] caps = {"[WPA2-EAP-CCMP][ESS]", "[WPA2-EAP-CCMP][ESS]"};
- int[] levels = {-75, -50};
- int[] security = {SECURITY_PSK, SECURITY_PSK};
-
- List<ScanDetail> scanDetails = getScanDetails(ssids, bssids, frequencies, caps, levels);
- WifiConfiguration[] savedConfigs = generateWifiConfigurations(ssids, security);
- prepareConfigStore(savedConfigs);
-
- scanResultLinkConfiguration(savedConfigs, scanDetails);
- ScanResult chosenScanResult = scanDetails.get(0).getScanResult();
-
- mWifiQualifiedNetworkSelector.setUserPreferredBand(WifiManager.WIFI_FREQUENCY_BAND_2GHZ);
- WifiConfiguration candidate = mWifiQualifiedNetworkSelector.selectQualifiedNetwork(false,
- false, false, false, true, false, scanDetails);
-
- verifySelectedResult(chosenScanResult, candidate);
- }
-
- /**
* Case #48 5GHz due to user band preference is set to AUTO
*
* In this test. we simulate following scenario
@@ -2333,7 +2257,6 @@ public class WifiQualifiedNetworkSelectorTest {
scanResultLinkConfiguration(savedConfigs, scanDetails);
ScanResult chosenScanResult = scanDetails.get(1).getScanResult();
- mWifiQualifiedNetworkSelector.setUserPreferredBand(WifiManager.WIFI_FREQUENCY_BAND_AUTO);
WifiConfiguration candidate = mWifiQualifiedNetworkSelector.selectQualifiedNetwork(false,
false, false, false, true, false, scanDetails);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index cb65325f4..24f383a1d 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -436,7 +436,6 @@ public class WifiStateMachineTest {
assertEquals("SupplicantStartingState", getCurrentState().getName());
- when(mWifiNative.setBand(anyInt())).thenReturn(true);
when(mWifiNative.setDeviceName(anyString())).thenReturn(true);
when(mWifiNative.setManufacturer(anyString())).thenReturn(true);
when(mWifiNative.setModelName(anyString())).thenReturn(true);
@@ -549,7 +548,6 @@ public class WifiStateMachineTest {
mWsm.setSupplicantRunning(true);
mLooper.dispatchAll();
assertEquals("SupplicantStartingState", getCurrentState().getName());
- when(mWifiNative.setBand(anyInt())).thenReturn(true);
when(mWifiNative.setDeviceName(anyString())).thenReturn(true);
when(mWifiNative.setManufacturer(anyString())).thenReturn(true);
when(mWifiNative.setModelName(anyString())).thenReturn(true);