From 358daf5df00f5563253ba3465fbc7029f7ac1056 Mon Sep 17 00:00:00 2001 From: Michael Plass Date: Wed, 28 Mar 2018 14:36:07 -0700 Subject: [WifiScoreReport] Stay on working wifi If packets are actually moving in both directions at a sufficiently high rate, stay on wifi. Bug: 74613347 Test: Unit tests Change-Id: I49862984c9c3f67d64669102bb929a07110797ba --- .../android/server/wifi/WifiScoreReportTest.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java index d60264c61..bf662f01a 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java @@ -259,6 +259,35 @@ public class WifiScoreReportTest { assertTrue(oops, minScore > ConnectedScore.WIFI_TRANSITION_SCORE); } + /** + * Don't breach if the success rates are great + * + * Ramp the RSSI down, but maintain a high packet throughput + * + * Expect score to stay above above threshold. + */ + @Test + public void allowTerribleRssiIfDataIsMovingWell() throws Exception { + mWifiInfo.txSuccessRate = mScoringParams.getYippeeSkippyPacketsPerSecond() + 0.1; + mWifiInfo.rxSuccessRate = mScoringParams.getYippeeSkippyPacketsPerSecond() + 0.1; + assertTrue(mWifiInfo.txSuccessRate > 10); + mWifiInfo.setFrequency(5220); + for (int r = -30; r >= -200; r -= 2) { + mWifiInfo.setRssi(r); + mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); + assertTrue(mWifiInfo.score > ConnectedScore.WIFI_TRANSITION_SCORE); + } + // If the throughput dips, we should let go + mWifiInfo.rxSuccessRate = mScoringParams.getYippeeSkippyPacketsPerSecond() - 0.1; + mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); + assertTrue(mWifiInfo.score < ConnectedScore.WIFI_TRANSITION_SCORE); + // And even if throughput improves again, once we have decided to let go, disregard + // the good rates. + mWifiInfo.rxSuccessRate = mScoringParams.getYippeeSkippyPacketsPerSecond() + 0.1; + mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); + assertTrue(mWifiInfo.score < ConnectedScore.WIFI_TRANSITION_SCORE); + } + /** * This setup causes some reports to be generated when println * methods are called, to check for "concurrent" modification -- cgit v1.2.3