diff options
author | Michael Plass <mplass@google.com> | 2018-05-22 17:17:17 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-05-22 17:17:17 +0000 |
commit | 76b64fecb6dd8ef593582295f01e543eb41f46a7 (patch) | |
tree | d20f232bb3646571f8f66d04817ca1f3f8d4edfa | |
parent | 7b885be3a672a10babcfb6868d73c766c91d8d43 (diff) | |
parent | 1ee61b2af7ff4079416d863dd55b5383d3950f15 (diff) |
Merge "[WifiScoreReport] Don't report score if RSSI is invalid" into pi-dev
-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. |