summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNate(Qiang) Jiang <qiangjiang@google.com>2019-11-05 14:15:18 -0800
committerNate Jiang <qiangjiang@google.com>2019-11-08 15:25:50 -0800
commit88a742d479748d1fa248f7814591b76c436f8648 (patch)
tree0a0963fccc5ed848a2e93a4689171d4087f75f6a
parent168106625ef6c9c5b8211b9cf6348eab14ca7cc9 (diff)
[WifiRtt] add check to verify bw and preamble combination valid
check the combination before send the request to the FW Bug: 142147874 Test: atest android.net.wifi Test: atest com.android.server.wifi Change-Id: I98961412cc582ca7b2f1e596017ddc8cd3fee7ab Merged-In: I98961412cc582ca7b2f1e596017ddc8cd3fee7ab (cherry picked from commit 27544a5140b9b33f9c77690d524dea21235744f3)
-rw-r--r--service/java/com/android/server/wifi/rtt/RttNative.java15
-rw-r--r--tests/wifitests/src/com/android/server/wifi/rtt/RttNativeTest.java24
2 files changed, 39 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/rtt/RttNative.java b/service/java/com/android/server/wifi/rtt/RttNative.java
index eaf947062..ffbf5bef9 100644
--- a/service/java/com/android/server/wifi/rtt/RttNative.java
+++ b/service/java/com/android/server/wifi/rtt/RttNative.java
@@ -311,6 +311,7 @@ public class RttNative extends IWifiRttControllerEventCallback.Stub {
config.channel.centerFreq1 = responder.centerFreq1;
config.bw = halRttChannelBandwidthFromResponderChannelWidth(responder.channelWidth);
config.preamble = halRttPreambleFromResponderPreamble(responder.preamble);
+ validateBwAndPreambleCombination(config.bw, config.preamble);
if (config.peer == RttPeerType.NAN) {
config.mustRequestLci = false;
@@ -349,6 +350,20 @@ public class RttNative extends IWifiRttControllerEventCallback.Stub {
return rttConfigs;
}
+ private static void validateBwAndPreambleCombination(int bw, int preamble) {
+ if (bw <= RttBw.BW_20MHZ) {
+ return;
+ }
+ if (bw == RttBw.BW_40MHZ && preamble >= RttPreamble.HT) {
+ return;
+ }
+ if (bw >= RttBw.BW_80MHZ && preamble >= RttPreamble.VHT) {
+ return;
+ }
+ throw new IllegalArgumentException(
+ "bw and preamble combination is invalid, bw: " + bw + " preamble: " + preamble);
+ }
+
private static int halRttPeerTypeFromResponderType(int responderType) {
switch (responderType) {
case ResponderConfig.RESPONDER_AP:
diff --git a/tests/wifitests/src/com/android/server/wifi/rtt/RttNativeTest.java b/tests/wifitests/src/com/android/server/wifi/rtt/RttNativeTest.java
index d2f22da6a..bd0ad321d 100644
--- a/tests/wifitests/src/com/android/server/wifi/rtt/RttNativeTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/rtt/RttNativeTest.java
@@ -18,6 +18,7 @@
package com.android.server.wifi.rtt;
import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
@@ -42,6 +43,7 @@ import android.hardware.wifi.V1_0.WifiStatus;
import android.hardware.wifi.V1_0.WifiStatusCode;
import android.net.MacAddress;
import android.net.wifi.rtt.RangingRequest;
+import android.net.wifi.rtt.ResponderConfig;
import androidx.test.filters.SmallTest;
@@ -465,6 +467,28 @@ public class RttNativeTest {
}
}
+ /**
+ * Validation ranging with invalid bw and preamble combination will be ignored.
+ */
+ @Test
+ public void testRangingWithInvalidParameterCombination() throws Exception {
+ int cmdId = 88;
+ RangingRequest request = new RangingRequest.Builder().build();
+ ResponderConfig invalidConfig = new ResponderConfig(
+ MacAddress.fromString("08:09:08:07:06:88"), ResponderConfig.RESPONDER_AP, true,
+ ResponderConfig.CHANNEL_WIDTH_80MHZ, 0, 0, 0, ResponderConfig.PREAMBLE_HT);
+ ResponderConfig config = new ResponderConfig(MacAddress.fromString("08:09:08:07:06:89"),
+ ResponderConfig.RESPONDER_AP, true,
+ ResponderConfig.CHANNEL_WIDTH_80MHZ, 0, 0, 0, ResponderConfig.PREAMBLE_VHT);
+
+ // Add a ResponderConfig with invalid parameter, should be ignored.
+ request.mRttPeers.add(invalidConfig);
+ request.mRttPeers.add(config);
+ mDut.rangeRequest(cmdId, request, true);
+ verify(mockRttController).rangeRequest(eq(cmdId), mRttConfigCaptor.capture());
+ assertEquals(request.mRttPeers.size() - 1, mRttConfigCaptor.getValue().size());
+ }
+
// Utilities
/**