diff options
author | 2025-02-05 13:24:20 -0800 | |
---|---|---|
committer | 2025-02-05 13:24:20 -0800 | |
commit | 32a8b6b9dddc0411681e0aa6d38f096789a04b94 (patch) | |
tree | dff8f5d6e3838dd519b70261fad11e950936bf29 | |
parent | efe359a1abf2b0317d82f0b0aa3fea6a7d115b38 (diff) | |
parent | 5eec0acd38359b809ff2ec5684aefc9761cf61d2 (diff) |
Merge "Fix RTT preamble based on band and RTT type" into main
5 files changed, 178 insertions, 23 deletions
diff --git a/framework/java/android/net/wifi/rtt/ResponderConfig.java b/framework/java/android/net/wifi/rtt/ResponderConfig.java index 213c8ed801..5b4f2da08a 100644 --- a/framework/java/android/net/wifi/rtt/ResponderConfig.java +++ b/framework/java/android/net/wifi/rtt/ResponderConfig.java @@ -439,6 +439,10 @@ public final class ResponderConfig implements Parcelable { int centerFreq1 = scanResult.centerFreq1; int preamble; + // The IEEE 802.11mc is only compatible with HE and EHT when using the 6 GHz band. + // However, the IEEE 802.11az supports HE and EHT across all Wi-Fi bands (2.4GHz, 5 GHz, + // and 6 GHz). + boolean isHeOrEhtAllowed = supports80211azNtbRanging || ScanResult.is6GHz(frequency); if (scanResult.informationElements != null && scanResult.informationElements.length != 0) { boolean htCapabilitiesPresent = false; boolean vhtCapabilitiesPresent = false; @@ -457,9 +461,9 @@ public final class ResponderConfig implements Parcelable { } } - if (ehtCapabilitiesPresent && ScanResult.is6GHz(frequency)) { + if (ehtCapabilitiesPresent && isHeOrEhtAllowed) { preamble = ScanResult.PREAMBLE_EHT; - } else if (heCapabilitiesPresent && ScanResult.is6GHz(frequency)) { + } else if (heCapabilitiesPresent && isHeOrEhtAllowed) { preamble = ScanResult.PREAMBLE_HE; } else if (vhtCapabilitiesPresent) { preamble = ScanResult.PREAMBLE_VHT; @@ -470,9 +474,10 @@ public final class ResponderConfig implements Parcelable { } } else { Log.e(TAG, "Scan Results do not contain IEs - using backup method to select preamble"); - if (channelWidth == ScanResult.CHANNEL_WIDTH_320MHZ) { + if (channelWidth == ScanResult.CHANNEL_WIDTH_320MHZ && isHeOrEhtAllowed) { preamble = ScanResult.PREAMBLE_EHT; - } else if (channelWidth == ScanResult.CHANNEL_WIDTH_80MHZ + } else if (channelWidth == ScanResult.CHANNEL_WIDTH_320MHZ + || channelWidth == ScanResult.CHANNEL_WIDTH_80MHZ || channelWidth == ScanResult.CHANNEL_WIDTH_160MHZ) { preamble = ScanResult.PREAMBLE_VHT; } else { diff --git a/framework/tests/src/android/net/wifi/rtt/WifiRttManagerTest.java b/framework/tests/src/android/net/wifi/rtt/WifiRttManagerTest.java index 5514224ce6..f59fbc9243 100644 --- a/framework/tests/src/android/net/wifi/rtt/WifiRttManagerTest.java +++ b/framework/tests/src/android/net/wifi/rtt/WifiRttManagerTest.java @@ -634,6 +634,10 @@ public class WifiRttManagerTest { heCap.id = ScanResult.InformationElement.EID_EXTENSION_PRESENT; heCap.idExt = ScanResult.InformationElement.EID_EXT_HE_CAPABILITIES; + ScanResult.InformationElement ehtCap = new ScanResult.InformationElement(); + ehtCap.id = ScanResult.InformationElement.EID_EXTENSION_PRESENT; + ehtCap.idExt = ScanResult.InformationElement.EID_EXT_EHT_CAPABILITIES; + // no IE ScanResult scan = new ScanResult(); scan.BSSID = "00:01:02:03:04:05"; @@ -689,6 +693,57 @@ public class WifiRttManagerTest { config = ResponderConfig.fromScanResult(scan); assertEquals(ResponderConfig.PREAMBLE_HE, config.preamble); + + ScanResult.InformationElement[] ie = new ScanResult.InformationElement[3]; + ie[0] = vhtCap; + ie[1] = heCap; + ie[2] = ehtCap; + + ScanResult.Builder builder = new ScanResult.Builder() + .setBssid("00:01:02:03:04:05") + .setChannelWidth(ResponderConfig.CHANNEL_WIDTH_80MHZ); + + // Validate 11az & 11mc ranging in 5 Ghz and EHT + scan = builder.setFrequency(5200).setIs80211azNtbRTTResponder(true) + .setIs80211McRTTResponder(true).build(); + scan.informationElements = ie; + config = ResponderConfig.fromScanResult(scan); + assertEquals(ResponderConfig.PREAMBLE_EHT, config.preamble); + + // Validate 11az & 11mc ranging in 6 Ghz and EHT + scan = builder.setFrequency(5935).setIs80211azNtbRTTResponder(true) + .setIs80211McRTTResponder(true).build(); + scan.informationElements = ie; + config = ResponderConfig.fromScanResult(scan); + assertEquals(ResponderConfig.PREAMBLE_EHT, config.preamble); + + // Validate 11mc ranging in 5 Ghz with EHT + scan = builder.setFrequency(5200).setIs80211azNtbRTTResponder(false) + .setIs80211McRTTResponder(true).build(); + scan.informationElements = ie; + config = ResponderConfig.fromScanResult(scan); + assertEquals(ResponderConfig.PREAMBLE_VHT, config.preamble); + + // Validate one-sided ranging in 5 Ghz with EHT; Same result as 11mc. + scan = builder.setFrequency(5200).setIs80211azNtbRTTResponder(false) + .setIs80211McRTTResponder(false).build(); + scan.informationElements = ie; + config = ResponderConfig.fromScanResult(scan); + assertEquals(ResponderConfig.PREAMBLE_VHT, config.preamble); + + // Validate 11mc ranging in 6 Ghz with EHT + scan = builder.setFrequency(5935).setIs80211azNtbRTTResponder(false) + .setIs80211McRTTResponder(true).build(); + scan.informationElements = ie; + config = ResponderConfig.fromScanResult(scan); + assertEquals(ResponderConfig.PREAMBLE_EHT, config.preamble); + + // Validate one-sided ranging in 6 Ghz with EHT; Same result as 11mc. + scan = builder.setFrequency(5935).setIs80211azNtbRTTResponder(false) + .setIs80211McRTTResponder(false).build(); + scan.informationElements = ie; + config = ResponderConfig.fromScanResult(scan); + assertEquals(ResponderConfig.PREAMBLE_EHT, config.preamble); } @Test diff --git a/service/java/com/android/server/wifi/hal/WifiRttControllerAidlImpl.java b/service/java/com/android/server/wifi/hal/WifiRttControllerAidlImpl.java index 9656e73d98..6611e60562 100644 --- a/service/java/com/android/server/wifi/hal/WifiRttControllerAidlImpl.java +++ b/service/java/com/android/server/wifi/hal/WifiRttControllerAidlImpl.java @@ -497,7 +497,7 @@ public class WifiRttControllerAidlImpl implements IWifiRttController { config.bw = halRttChannelBandwidthCapabilityLimiter(config.bw, cap, config.type); config.preamble = halRttPreambleCapabilityLimiter(config.preamble, cap, - config.type); + config.type, responder.frequency); } // Update secure ranging configuration @@ -726,17 +726,33 @@ public class WifiRttControllerAidlImpl implements IWifiRttController { } /** - * Check whether the selected RTT preamble is supported by the device. - * If supported, return the requested preamble. - * If not supported, return the next "lower" preamble which is supported. - * If none, throw an IllegalArgumentException. + * Check whether the selected RTT preamble is supported by the device and the RTT type. + * <ul> + * <li>If supported, return the requested preamble. + * <li>If not supported, return the next "lower" preamble which is supported. + * <li>If none, throw an IllegalArgumentException. + * </ul> + * + * <p>Note: the halRttPreamble is a single bit flag from the HAL RttPreamble type. * - * Note: the halRttPreamble is a single bit flag from the HAL RttPreamble type. + * <p>Note: The IEEE 802.11mc is only compatible with HE and EHT when using the 6 GHz band. + * However, the IEEE 802.11az supports HE and EHT across all Wi-Fi bands (2.4GHz, 5 GHz, and + * 6 GHz). */ private static int halRttPreambleCapabilityLimiter(int halRttPreamble, - WifiRttController.Capabilities cap, @RttType int rttType) + WifiRttController.Capabilities cap, @RttType int rttType, int frequency) throws IllegalArgumentException { + // Note: requestedPreamble is only used for the error logging int requestedPreamble = halRttPreamble; + // Since RTT type is limited based on device capability, check preamble for any adjustment. + // The IEEE 802.11mc is only compatible with HE and EHT when using the 6 GHz band. So + // adjust the preamble accordingly. + if (rttType <= RttType.TWO_SIDED_11MC && !ScanResult.is6GHz(frequency)) { + if (halRttPreamble >= RttPreamble.HE) { + halRttPreamble = RttPreamble.VHT; + } + } + // Check device capability whether preamble is supported by the device, otherwise adjust it. int preambleSupported = (rttType == RttType.TWO_SIDED_11AZ_NTB) ? cap.azPreambleSupported : cap.preambleSupported; while ((halRttPreamble != 0) && ((halRttPreamble & preambleSupported) == 0)) { diff --git a/service/tests/wifitests/src/com/android/server/wifi/hal/WifiRttControllerAidlImplTest.java b/service/tests/wifitests/src/com/android/server/wifi/hal/WifiRttControllerAidlImplTest.java index 199b0e3313..bae5001594 100644 --- a/service/tests/wifitests/src/com/android/server/wifi/hal/WifiRttControllerAidlImplTest.java +++ b/service/tests/wifitests/src/com/android/server/wifi/hal/WifiRttControllerAidlImplTest.java @@ -259,6 +259,61 @@ public class WifiRttControllerAidlImplTest extends WifiBaseTest { } /** + * Validate IEEE 802.11az ranging request on an IEEE 802.11mc capable device. Expectation is + * RTT type has to be downgraded to 11mc and pre-amble needs to be adjusted based on the band + * of operation. + */ + @Test + public void test11azRangeRequestOn11mcCapableDevice() throws Exception { + int cmdId = 55; + RangingRequest request = RttTestUtils.getDummyRangingRequestWith11az((byte) 0); + + // update capabilities to enable 11mc only + RttCapabilities cap = getFullRttCapabilities(); + cap.ntbInitiatorSupported = false; + reset(mIWifiRttControllerMock); + when(mIWifiRttControllerMock.getCapabilities()).thenReturn(cap); + createAndInitializeDut(); + + mDut.rangeRequest(cmdId, request); + verify(mIWifiRttControllerMock).rangeRequest(eq(cmdId), mRttConfigCaptor.capture()); + RttConfig[] halRequest = mRttConfigCaptor.getValue(); + + collector.checkThat("number of entries", halRequest.length, + equalTo(request.mRttPeers.size())); + + RttConfig rttConfig = halRequest[0]; + collector.checkThat("entry 0: MAC", rttConfig.addr, + equalTo(MacAddress.fromString("00:01:02:03:04:00").toByteArray())); + collector.checkThat("entry 0: rtt type", rttConfig.type, equalTo(RttType.TWO_SIDED)); + collector.checkThat("entry 0: peer type", rttConfig.peer, equalTo(RttPeerType.AP)); + collector.checkThat("", rttConfig.preamble, equalTo(RttPreamble.VHT)); + + rttConfig = halRequest[1]; + collector.checkThat("entry 1: MAC", rttConfig.addr, + equalTo(MacAddress.fromString("0A:0B:0C:0D:0E:00").toByteArray())); + collector.checkThat("entry 1: rtt type", rttConfig.type, equalTo(RttType.ONE_SIDED)); + collector.checkThat("entry 1: peer type", rttConfig.peer, equalTo(RttPeerType.AP)); + collector.checkThat("", rttConfig.preamble, equalTo(RttPreamble.HT)); + + rttConfig = halRequest[2]; + collector.checkThat("entry 2: MAC", rttConfig.addr, + equalTo(MacAddress.fromString("08:09:08:07:06:05").toByteArray())); + collector.checkThat("entry 2: rtt type", rttConfig.type, equalTo(RttType.TWO_SIDED)); + collector.checkThat("entry 2: peer type", rttConfig.peer, equalTo(RttPeerType.NAN_TYPE)); + collector.checkThat("", rttConfig.preamble, equalTo(RttPreamble.HT)); + + rttConfig = halRequest[3]; + collector.checkThat("entry 3: MAC", rttConfig.addr, + equalTo(MacAddress.fromString("00:11:22:33:44:00").toByteArray())); + collector.checkThat("entry 3: rtt type", rttConfig.type, equalTo(RttType.TWO_SIDED_11MC)); + collector.checkThat("entry 3: peer type", rttConfig.peer, equalTo(RttPeerType.AP)); + collector.checkThat("entry 3: preamble", rttConfig.preamble, equalTo(RttPreamble.VHT)); + + verifyNoMoreInteractions(mIWifiRttControllerMock); + + } + /** * Validate successful ranging flow - with privileges access but with limited capabilities: * - Very limited BW * - Very limited Preamble diff --git a/service/tests/wifitests/src/com/android/server/wifi/rtt/RttTestUtils.java b/service/tests/wifitests/src/com/android/server/wifi/rtt/RttTestUtils.java index 1e7df0db7a..edcbaec843 100644 --- a/service/tests/wifitests/src/com/android/server/wifi/rtt/RttTestUtils.java +++ b/service/tests/wifitests/src/com/android/server/wifi/rtt/RttTestUtils.java @@ -85,26 +85,50 @@ public class RttTestUtils { */ public static RangingRequest getDummyRangingRequestWith11az(byte lastMacByte) { RangingRequest.Builder builder = new RangingRequest.Builder(); + ScanResult.InformationElement vhtCap = new ScanResult.InformationElement(); + vhtCap.id = ScanResult.InformationElement.EID_VHT_CAPABILITIES; - ScanResult scan1 = new ScanResult(); - scan1.BSSID = "00:01:02:03:04:" + String.format("%02d", lastMacByte); - scan1.setFlag(ScanResult.FLAG_80211mc_RESPONDER); - scan1.channelWidth = ScanResult.CHANNEL_WIDTH_40MHZ; + ScanResult.InformationElement heCap = new ScanResult.InformationElement(); + heCap.id = ScanResult.InformationElement.EID_EXTENSION_PRESENT; + heCap.idExt = ScanResult.InformationElement.EID_EXT_HE_CAPABILITIES; + + ScanResult.InformationElement ehtCap = new ScanResult.InformationElement(); + ehtCap.id = ScanResult.InformationElement.EID_EXTENSION_PRESENT; + ehtCap.idExt = ScanResult.InformationElement.EID_EXT_EHT_CAPABILITIES; + + ScanResult.InformationElement[] ie = new ScanResult.InformationElement[3]; + ie[0] = vhtCap; + ie[1] = heCap; + ie[2] = ehtCap; + + // peer 0: 11mc only + ScanResult scan1 = new ScanResult.Builder() + .setBssid("00:01:02:03:04:" + String.format("%02d", lastMacByte)) + .setIs80211McRTTResponder(true) + .setChannelWidth(ScanResult.CHANNEL_WIDTH_40MHZ) + .setFrequency(5200) + .build(); + scan1.informationElements = ie; + builder.addAccessPoint(scan1); + // peer 1: one-sided only ScanResult scan2 = new ScanResult(); scan2.BSSID = "0A:0B:0C:0D:0E:" + String.format("%02d", lastMacByte); scan2.channelWidth = ScanResult.CHANNEL_WIDTH_20MHZ; MacAddress mac1 = MacAddress.fromString("08:09:08:07:06:05"); - - builder.addAccessPoint(scan1); builder.addNon80211mcCapableAccessPoint(scan2); - // Changing default RTT burst size to a valid, but maximum, value + // peer 2: Aware builder.setRttBurstSize(RangingRequest.getMaxRttBurstSize()); builder.addWifiAwarePeer(mac1); - // Add 11az & 11mc supported AP - scan1.BSSID = "00:11:22:33:44:" + String.format("%02d", lastMacByte); - scan1.setFlag(ScanResult.FLAG_80211mc_RESPONDER); - scan1.setFlag(ScanResult.FLAG_80211az_NTB_RESPONDER); - scan1.channelWidth = ScanResult.CHANNEL_WIDTH_40MHZ; + // peer 3: 11az & 11mc supported AP. Since the device supports 11mc only, the expectation is + // preamble will be adjusted as VHT since ranging request is in 5 Ghz. + scan1 = new ScanResult.Builder() + .setBssid("00:11:22:33:44:" + String.format("%02d", lastMacByte)) + .setIs80211McRTTResponder(true) + .setIs80211azNtbRTTResponder(true) + .setChannelWidth(ScanResult.CHANNEL_WIDTH_40MHZ) + .setFrequency(5200) + .build(); + scan1.informationElements = ie; builder.addAccessPoint(scan1); return builder.build(); } |