summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/WifiScoreReport.java4
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiScoreReportTest.java15
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.