[RTT] Condition RTT Controller on availability of a STA mode
Condition creation of the RTT controller on the chip being in a mode
which can support a STA (whether one is already created or one could
be created).
This is the default behavior on currently supported Wi-Fi devices.
Note: this is part of the reference HAL implementation - it is not
expected to reflect behavior of all devices. Vendors may and should
replace or modify the reference HAL implementation.
Bug: 79565105
Bug: 111218083
Test: ACTS RangeApSupporting11McTest:test_rtt_in_and_after_softap_mode
Change-Id: If76b6598acb22f7821b34f7f1c8ae2873a6dac1d
diff --git a/wifi/1.3/default/wifi_chip.cpp b/wifi/1.3/default/wifi_chip.cpp
index cf64e51..faf1862 100644
--- a/wifi/1.3/default/wifi_chip.cpp
+++ b/wifi/1.3/default/wifi_chip.cpp
@@ -930,6 +930,12 @@
std::pair<WifiStatus, sp<IWifiRttController>>
WifiChip::createRttControllerInternal(const sp<IWifiIface>& bound_iface) {
+ if (sta_ifaces_.size() == 0 &&
+ !canCurrentModeSupportIfaceOfType(IfaceType::STA)) {
+ LOG(ERROR) << "createRttControllerInternal: Chip cannot support STAs "
+ "(and RTT by extension)";
+ return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
+ }
sp<WifiRttController> rtt =
new WifiRttController(getWlan0IfaceName(), bound_iface, legacy_hal_);
rtt_controllers_.emplace_back(rtt);