summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRandy Pan <zpan@google.com>2016-10-05 11:40:51 -0700
committerRandy Pan <zpan@google.com>2016-10-10 12:00:53 -0700
commit0b9b32c53a83dea56417bda7bc9ddc1dc1e4222e (patch)
tree42f368adfe7afc5037052bb59dfddb9db72a75fc /tests
parent67344e5255ad4c00ef7e036986e54cfe1e04998e (diff)
ExternalScoreEvaluator: factor in active network
When obtaining the score for an externally scored network, indicate whether the network is the currently connected one, which is favored by the external scorer. This helps avoid unnecessary roaming caused by RSSI fluctuation. Bug: 31928897 Test: Wifi framework unit tests Change-Id: I4a0657de58f4dab3fc5e004082dcf5d7c4a02e31
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ExternalScoreEvaluatorTest.java71
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java19
2 files changed, 84 insertions, 6 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ExternalScoreEvaluatorTest.java b/tests/wifitests/src/com/android/server/wifi/ExternalScoreEvaluatorTest.java
index 16bd4f8d8..ada21461f 100644
--- a/tests/wifitests/src/com/android/server/wifi/ExternalScoreEvaluatorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ExternalScoreEvaluatorTest.java
@@ -416,4 +416,75 @@ public class ExternalScoreEvaluatorTest {
assertEquals("Expect null configuration", null, candidate);
}
+
+ /**
+ * Between two ephemeral networks with the same RSSI, choose
+ * the currently connected one.
+ */
+ @Test
+ public void chooseActiveEphemeralNetwork() {
+ String[] ssids = {"\"test1\"", "\"test2\""};
+ String[] bssids = {"6c:f3:7f:ae:8c:f3", "6c:f3:7f:ae:8c:f4"};
+ int[] freqs = {2470, 2437};
+ String[] caps = {"[ESS]", "[ESS]"};
+ int[] levels = {mThresholdQualifiedRssi2G + 28, mThresholdQualifiedRssi2G + 28};
+ boolean[] meteredHints = {true, true};
+ ScanResult[] scanResults = new ScanResult[2];
+ WifiConfiguration[] ephemeralNetworkConfigs = new WifiConfiguration[2];
+
+ List<ScanDetail> scanDetails = WifiNetworkSelectorTestUtil.buildScanDetails(
+ ssids, bssids, freqs, caps, levels, mClock);
+ WifiNetworkSelectorTestUtil.configureScoreCache(mScoreCache,
+ scanDetails, null, meteredHints);
+
+ // No saved networks.
+ when(mWifiConfigManager.getSavedNetworkForScanDetailAndCache(any(ScanDetail.class)))
+ .thenReturn(null);
+
+ for (int i = 0; i < 2; i++) {
+ scanResults[i] = scanDetails.get(i).getScanResult();
+ ephemeralNetworkConfigs[i] = WifiNetworkSelectorTestUtil
+ .setupEphemeralNetwork(mWifiConfigManager, i, scanResults[i], meteredHints[i]);
+ }
+
+ WifiConfiguration candidate = mExternalScoreEvaluator.evaluateNetworks(scanDetails,
+ null, bssids[1], true, true, null);
+
+ WifiConfigurationTestUtil.assertConfigurationEqual(ephemeralNetworkConfigs[1], candidate);
+ WifiNetworkSelectorTestUtil.verifySelectedScanResult(mWifiConfigManager,
+ scanResults[1], candidate);
+ assertEquals(meteredHints[1], candidate.meteredHint);
+ }
+
+ /**
+ * Between two externally scored saved networks with the same RSSI, choose
+ * the currently connected one.
+ */
+ @Test
+ public void chooseActiveSavedNetwork() {
+ String[] ssids = {"\"test1\"", "\"test2\""};
+ String[] bssids = {"6c:f3:7f:ae:8c:f3", "6c:f3:7f:ae:8c:f4"};
+ int[] freqs = {2470, 2437};
+ String[] caps = {"[WPA2-EAP-CCMP][ESS]", "[WPA2-EAP-CCMP][ESS]"};
+ int[] securities = {SECURITY_PSK, SECURITY_PSK};
+ int[] levels = {mThresholdQualifiedRssi2G + 28, mThresholdQualifiedRssi2G + 28};
+ boolean[] meteredHints = {false, false};
+
+ ScanDetailsAndWifiConfigs scanDetailsAndConfigs =
+ WifiNetworkSelectorTestUtil.setupScanDetailsAndConfigStore(ssids, bssids,
+ freqs, caps, levels, securities, mWifiConfigManager, mClock);
+ List<ScanDetail> scanDetails = scanDetailsAndConfigs.getScanDetails();
+ WifiConfiguration[] savedConfigs = scanDetailsAndConfigs.getWifiConfigs();
+ savedConfigs[0].useExternalScores = savedConfigs[1].useExternalScores = true;
+
+ WifiNetworkSelectorTestUtil.configureScoreCache(mScoreCache,
+ scanDetails, null, meteredHints);
+
+ WifiConfiguration candidate = mExternalScoreEvaluator.evaluateNetworks(scanDetails,
+ savedConfigs[1], bssids[1], true, true, null);
+
+ WifiConfigurationTestUtil.assertConfigurationEqual(savedConfigs[1], candidate);
+ WifiNetworkSelectorTestUtil.verifySelectedScanResult(mWifiConfigManager,
+ scanDetails.get(1).getScanResult(), candidate);
+ }
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java
index db3aff14c..e01af28b1 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSelectorTestUtil.java
@@ -309,17 +309,24 @@ public class WifiNetworkSelectorTestUtil {
for (int i = 0; i < scanDetails.size(); i++) {
ScanDetail scanDetail = scanDetails.get(i);
- byte rssiScore;
- Integer score = scores[i];
ScanResult scanResult = scanDetail.getScanResult();
WifiKey wifiKey = new WifiKey("\"" + scanResult.SSID + "\"", scanResult.BSSID);
NetworkKey ntwkKey = new NetworkKey(wifiKey);
- if (scores[i] == null) {
- rssiScore = WifiNetworkScoreCache.INVALID_NETWORK_SCORE;
+ RssiCurve rssiCurve;
+
+ if (scores != null) { // fixed score
+ byte rssiScore;
+ Integer score = scores[i];
+
+ if (scores[i] == null) {
+ rssiScore = WifiNetworkScoreCache.INVALID_NETWORK_SCORE;
+ } else {
+ rssiScore = scores[i].byteValue();
+ }
+ rssiCurve = new RssiCurve(-100, 100, new byte[] {rssiScore});
} else {
- rssiScore = scores[i].byteValue();
+ rssiCurve = new RssiCurve(-80, 20, new byte[] {-10, 0, 10, 20, 30, 40});
}
- RssiCurve rssiCurve = new RssiCurve(-100, 100, new byte[] {rssiScore});
ScoredNetwork scoredNetwork = new ScoredNetwork(ntwkKey, rssiCurve, meteredHints[i]);
networks.add(scoredNetwork);