diff options
author | Kai Shi <kaishi@google.com> | 2020-02-13 20:24:15 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-02-13 20:24:15 +0000 |
commit | 9ca5a707244962f7c0b52273d1277b2c52c06d9f (patch) | |
tree | 84b299c17c69907a8e77cbe53804fc75fee7f1c8 | |
parent | 8559f4079feb60ac6694da5566442d243b0b778a (diff) | |
parent | 990435711bb3917cfe92ada2f6a09224aed5356a (diff) |
Merge "Add one more boundary check of maxNumSpatialStream"
-rw-r--r-- | service/java/com/android/server/wifi/ThroughputPredictor.java | 4 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java | 20 |
2 files changed, 24 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/ThroughputPredictor.java b/service/java/com/android/server/wifi/ThroughputPredictor.java index 8cda4c288..80df9aa43 100644 --- a/service/java/com/android/server/wifi/ThroughputPredictor.java +++ b/service/java/com/android/server/wifi/ThroughputPredictor.java @@ -228,6 +228,10 @@ public class ThroughputPredictor { int numTonePerSym; int symDurationNs; int maxBitsPerTone; + if (maxNumSpatialStream < 1) { + Log.e(TAG, "maxNumSpatialStream < 1 due to wrong implementation. Overridden to 1"); + maxNumSpatialStream = 1; + } if (wifiStandard == ScanResult.WIFI_STANDARD_UNKNOWN) { return WifiInfo.LINK_SPEED_UNKNOWN; } else if (wifiStandard == ScanResult.WIFI_STANDARD_LEGACY) { diff --git a/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java b/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java index 2043bf1c8..3844687a3 100644 --- a/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java @@ -201,6 +201,17 @@ public class ThroughputPredictorTest extends WifiBaseTest { } @Test + public void verifyHighRssiMinChannelUtilizationHt2g20MhzIncorrectNss() { + when(mDeviceCapabilities.getMaxNumberTxSpatialStreams()).thenReturn(0); + when(mDeviceCapabilities.getMaxNumberRxSpatialStreams()).thenReturn(0); + int predictedThroughputMbps = mThroughputPredictor.predictThroughput(mDeviceCapabilities, + ScanResult.WIFI_STANDARD_11N, ScanResult.CHANNEL_WIDTH_20MHZ, -50, 2437, 2, + MIN_CHANNEL_UTILIZATION, INVALID, false); + // Expect to 1SS peak rate because maxNumberSpatialStream is overridden to 1. + assertEquals(72, predictedThroughputMbps); + } + + @Test public void verifyLowRssiDefaultChannelUtilizationHt2g20Mhz1ss() { int predictedThroughputMbps = mThroughputPredictor.predictThroughput(mDeviceCapabilities, ScanResult.WIFI_STANDARD_11N, ScanResult.CHANNEL_WIDTH_20MHZ, -80, 2437, 1, @@ -253,6 +264,15 @@ public class ThroughputPredictorTest extends WifiBaseTest { } @Test + public void verifyMaxThroughputAc80MhzIncorrectNss() { + mConnectionCap.wifiStandard = ScanResult.WIFI_STANDARD_11AC; + mConnectionCap.channelBandwidth = ScanResult.CHANNEL_WIDTH_80MHZ; + mConnectionCap.maxNumberRxSpatialStreams = -5; + // Expect to 1SS peak rate because maxNumberSpatialStream is overridden to 1. + assertEquals(433, mThroughputPredictor.predictMaxRxThroughput(mConnectionCap)); + } + + @Test public void verifyMaxThroughputN20Mhz1ss() { mConnectionCap.wifiStandard = ScanResult.WIFI_STANDARD_11N; mConnectionCap.channelBandwidth = ScanResult.CHANNEL_WIDTH_20MHZ; |