From 88a742d479748d1fa248f7814591b76c436f8648 Mon Sep 17 00:00:00 2001 From: "Nate(Qiang) Jiang" Date: Tue, 5 Nov 2019 14:15:18 -0800 Subject: [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) --- service/java/com/android/server/wifi/rtt/RttNative.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'service') 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: -- cgit v1.2.3