From 1a0ff86a3520e9b79ded4746171a883a7f72fcdf Mon Sep 17 00:00:00 2001 From: Michael Plass Date: Mon, 30 Apr 2018 14:47:52 -0700 Subject: Fix VelocityBasedConnectedScore fault Fix a fault that happened while adding unit tests. This would not happen in practice, but fix it anyway. Bug: 78592561 Test: Unit tests (one added) Change-Id: I71f88aa1c8872b631ae9daa100e829b3274a7ac3 --- service/java/com/android/server/wifi/VelocityBasedConnectedScore.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/VelocityBasedConnectedScore.java b/service/java/com/android/server/wifi/VelocityBasedConnectedScore.java index e7d61f733..71f18fc7e 100644 --- a/service/java/com/android/server/wifi/VelocityBasedConnectedScore.java +++ b/service/java/com/android/server/wifi/VelocityBasedConnectedScore.java @@ -63,6 +63,7 @@ public class VelocityBasedConnectedScore extends ConnectedScore { public void reset() { mLastMillis = 0; mThresholdAdjustment = 0; + mFilter.mx = null; } /** @@ -78,7 +79,7 @@ public class VelocityBasedConnectedScore extends ConnectedScore { @Override public void updateUsingRssi(int rssi, long millis, double standardDeviation) { if (millis <= 0) return; - if (mLastMillis <= 0 || millis < mLastMillis) { + if (mLastMillis <= 0 || millis < mLastMillis || mFilter.mx == null) { double initialVariance = 9.0 * standardDeviation * standardDeviation; mFilter.mx = new Matrix(1, new double[]{rssi, 0.0}); mFilter.mP = new Matrix(2, new double[]{initialVariance, 0.0, 0.0, 0.0}); @@ -167,6 +168,7 @@ public class VelocityBasedConnectedScore extends ConnectedScore { */ @Override public int generateScore() { + if (mFilter.mx == null) return WIFI_TRANSITION_SCORE + 1; double badRssi = getAdjustedRssiThreshold(); double horizonSeconds = mScoringParams.getHorizonSeconds(); Matrix x = new Matrix(mFilter.mx); -- cgit v1.2.3