diff options
author | Michael Plass <mplass@google.com> | 2018-05-21 11:49:44 -0700 |
---|---|---|
committer | Michael Plass <mplass@google.com> | 2018-05-21 13:32:43 -0700 |
commit | 1ee61b2af7ff4079416d863dd55b5383d3950f15 (patch) | |
tree | a7ec13a66dacc35fabb6fdcb617535f4f8ff16cc | |
parent | e93744bec9cb63b00b4597d49a20378749634358 (diff) |
[WifiScoreReport] Don't report score if RSSI is invalid
Bug: 79338641
Test: Unit tests
Change-Id: I392a1c021e34b9d30c53739a9d6a923a38ad00c2
-rw-r--r-- | service/java/com/android/server/wifi/WifiScoreReport.java | 4 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiScoreReport.java b/service/java/com/android/server/wifi/WifiScoreReport.java index c6a7105be..d4d443bb2 100644 --- a/service/java/com/android/server/wifi/WifiScoreReport.java +++ b/service/java/com/android/server/wifi/WifiScoreReport.java @@ -89,6 +89,10 @@ public class WifiScoreReport { */ public void calculateAndReportScore(WifiInfo wifiInfo, NetworkAgent networkAgent, WifiMetrics wifiMetrics) { + if (wifiInfo.getRssi() == WifiInfo.INVALID_RSSI) { + Log.d(TAG, "Not reporting score because RSSI is invalid"); + return; + } int score; long millis = mClock.getWallClockMillis(); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java index 38e45d306..3e9e9217c 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java @@ -25,6 +25,7 @@ import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.atMost; import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -160,6 +161,20 @@ public class WifiScoreReportTest { } /** + * Test for no score report if rssi is invalid + * + * The score should be sent to neither the NetworkAgent nor the + * WifiMetrics + */ + @Test + public void calculateAndReportScoreDoesNotReportWhenRssiIsNotValid() throws Exception { + mWifiInfo.setRssi(WifiInfo.INVALID_RSSI); + mWifiScoreReport.calculateAndReportScore(mWifiInfo, mNetworkAgent, mWifiMetrics); + verify(mNetworkAgent, never()).sendNetworkScore(anyInt()); + verify(mWifiMetrics, never()).incrementWifiScoreCount(anyInt()); + } + + /** * Test for operation with null NetworkAgent * * Expect to not die, and to calculate the score and report to metrics. |