diff options
author | Michael Plass <mplass@google.com> | 2018-04-30 14:47:52 -0700 |
---|---|---|
committer | Michael Plass <mplass@google.com> | 2018-05-09 15:18:55 +0000 |
commit | 1a0ff86a3520e9b79ded4746171a883a7f72fcdf (patch) | |
tree | 2e3a07c0b8832aefc64f32ab1c12d279273e9e2f /service | |
parent | 1ba5b5858ffc04acbd317dc1f6789f1777d375e6 (diff) |
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
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/VelocityBasedConnectedScore.java | 4 |
1 files changed, 3 insertions, 1 deletions
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); |