Wifi: Add 802.11ax support to RTT

This CL makes modidfication to support Wifi 802.11ax to RTT procedures.

Bug: 139354972
Test: vts test
Change-Id: I79fba504e7c7380a254a0b8c175a13e8b993fc8e
This commit is contained in:
Ahmed ElArabawy
2019-10-10 20:18:31 -07:00
parent 622c04a620
commit eeb53385b3
14 changed files with 810 additions and 118 deletions

View File

@@ -7,8 +7,12 @@ hidl_interface {
enabled: true,
},
srcs: [
"types.hal",
"IWifi.hal",
"IWifiApIface.hal",
"IWifiChip.hal",
"IWifiRttController.hal",
"IWifiRttControllerEventCallback.hal",
],
interfaces: [
"android.hardware.wifi@1.0",

View File

@@ -49,5 +49,5 @@ interface IWifiApIface extends @1.0::IWifiApIface {
* |WifiStatusCode.ERROR_UNKNOWN|
* @return mac factory MAC address of the interface
*/
getFactoryMacAddress() generates (WifiStatus status, MacAddress mac);
getFactoryMacAddress() generates (WifiStatus status, MacAddress mac);
};

46
wifi/1.4/IWifiChip.hal Normal file
View File

@@ -0,0 +1,46 @@
/*
* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.wifi@1.4;
import @1.0::WifiStatus;
import @1.0::IWifiIface;
import @1.3::IWifiChip;
import IWifiRttController;
/**
* Interface that represents a chip that must be configured as a single unit.
*/
interface IWifiChip extends @1.3::IWifiChip {
/**
* Create a RTTController instance.
*
* RTT controller can be either:
* a) Bound to a specific iface by passing in the corresponding |IWifiIface|
* object in |iface| param, OR
* b) Let the implementation decide the iface to use for RTT operations by
* passing null in |iface| param.
*
* @param boundIface HIDL interface object representing the iface if
* the responder must be bound to a specific iface, null otherwise.
* @return status WifiStatus of the operation.
* Possible status codes:
* |WifiStatusCode.SUCCESS|,
* |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|
*/
createRttController_1_4(IWifiIface boundIface)
generates (WifiStatus status, IWifiRttController rtt);
};

View File

@@ -0,0 +1,102 @@
/*
* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.wifi@1.4;
import @1.0::IWifiRttController;
import @1.0::CommandId;
import @1.0::WifiChannelInfo;
import @1.0::WifiStatus;
import IWifiRttControllerEventCallback;
/**
* Interface used to perform RTT(Round trip time) operations.
*/
interface IWifiRttController extends @1.0::IWifiRttController {
/**
* Requests notifications of significant events on this rtt controller.
* Multiple calls to this must register multiple callbacks each of which must
* receive all events.
*
* @param callback An instance of the |IWifiRttControllerEventCallback| HIDL
* interface object.
* @return status WifiStatus of the operation.
* Possible status codes:
* |WifiStatusCode.SUCCESS|,
* |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|
*/
registerEventCallback_1_4(IWifiRttControllerEventCallback callback)
generates (WifiStatus status);
/**
* API to request RTT measurement.
*
* @param cmdId command Id to use for this invocation.
* @param rttConfigs Vector of |RttConfig| parameters.
* @return status WifiStatus of the operation.
* Possible status codes:
* |WifiStatusCode.SUCCESS|,
* |WifiStatusCode.ERROR_WIFI_RTT_CONTROLLER_INVALID|,
* |WifiStatusCode.ERROR_INVALID_ARGS|,
* |WifiStatusCode.ERROR_NOT_AVAILABLE|,
* |WifiStatusCode.ERROR_UNKNOWN|
*/
rangeRequest_1_4(CommandId cmdId, vec<RttConfig> rttConfigs) generates (WifiStatus status);
/**
* RTT capabilities of the device.
*
* @return status WifiStatus of the operation.
* Possible status codes:
* |WifiStatusCode.SUCCESS|,
* |WifiStatusCode.ERROR_WIFI_RTT_CONTROLLER_INVALID|,
* |WifiStatusCode.ERROR_UNKNOWN|
* @return capabilities Instance of |RttCapabilities|.
*/
getCapabilities_1_4() generates (WifiStatus status, RttCapabilities capabilities);
/**
* Get RTT responder information e.g. WiFi channel to enable responder on.
*
* @return status WifiStatus of the operation.
* Possible status codes:
* |WifiStatusCode.SUCCESS|,
* |WifiStatusCode.ERROR_WIFI_RTT_CONTROLLER_INVALID|,
* |WifiStatusCode.ERROR_NOT_AVAILABLE|,
* |WifiStatusCode.ERROR_UNKNOWN|
* @return info Instance of |RttResponderInfo|.
*/
getResponderInfo_1_4() generates (WifiStatus status, RttResponder info);
/**
* Enable RTT responder mode.
*
* @param cmdId command Id to use for this invocation.
* @parm channelHint Hint of the channel information where RTT responder must
* be enabled on.
* @param maxDurationInSeconds Timeout of responder mode.
* @param info Instance of |RttResponderInfo|.
* @return status WifiStatus of the operation.
* Possible status codes:
* |WifiStatusCode.SUCCESS|,
* |WifiStatusCode.ERROR_WIFI_RTT_CONTROLLER_INVALID|,
* |WifiStatusCode.ERROR_INVALID_ARGS|,
* |WifiStatusCode.ERROR_NOT_AVAILABLE|,
* |WifiStatusCode.ERROR_UNKNOWN|
*/
enableResponder_1_4(CommandId cmdId, WifiChannelInfo channelHint,
uint32_t maxDurationInSeconds, RttResponder info) generates (WifiStatus status);
};

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.wifi@1.4;
import @1.0::IWifiRttControllerEventCallback;
import @1.0::CommandId;
/**
* RTT Response and Event Callbacks.
*/
interface IWifiRttControllerEventCallback extends @1.0::IWifiRttControllerEventCallback {
/*
* Invoked when an RTT result is available.
*
* @param cmdId command Id corresponding to the original request.
* @param results Vector of |RttResult| instances.
*/
oneway onResults_1_4(CommandId cmdId, vec<RttResult> results);
};

View File

@@ -2279,6 +2279,8 @@ legacy_hal::wifi_rtt_preamble convertHidlRttPreambleToLegacy(RttPreamble type) {
return legacy_hal::WIFI_RTT_PREAMBLE_HT;
case RttPreamble::VHT:
return legacy_hal::WIFI_RTT_PREAMBLE_VHT;
case RttPreamble::HE:
return legacy_hal::WIFI_RTT_PREAMBLE_HE;
};
CHECK(false);
}
@@ -2291,6 +2293,8 @@ RttPreamble convertLegacyRttPreambleToHidl(legacy_hal::wifi_rtt_preamble type) {
return RttPreamble::HT;
case legacy_hal::WIFI_RTT_PREAMBLE_VHT:
return RttPreamble::VHT;
case legacy_hal::WIFI_RTT_PREAMBLE_HE:
return RttPreamble::HE;
};
CHECK(false) << "Unknown legacy type: " << type;
}
@@ -2354,6 +2358,8 @@ WifiRatePreamble convertLegacyWifiRatePreambleToHidl(uint8_t preamble) {
return WifiRatePreamble::HT;
case 3:
return WifiRatePreamble::VHT;
case 4:
return WifiRatePreamble::HE;
default:
return WifiRatePreamble::RESERVED;
};
@@ -2579,9 +2585,10 @@ bool convertLegacyRttCapabilitiesToHidl(
hidl_capabilities->responderSupported =
legacy_capabilities.responder_supported;
hidl_capabilities->preambleSupport = 0;
for (const auto flag : {legacy_hal::WIFI_RTT_PREAMBLE_LEGACY,
legacy_hal::WIFI_RTT_PREAMBLE_HT,
legacy_hal::WIFI_RTT_PREAMBLE_VHT}) {
for (const auto flag :
{legacy_hal::WIFI_RTT_PREAMBLE_LEGACY,
legacy_hal::WIFI_RTT_PREAMBLE_HT, legacy_hal::WIFI_RTT_PREAMBLE_VHT,
legacy_hal::WIFI_RTT_PREAMBLE_HE}) {
if (legacy_capabilities.preamble_support & flag) {
hidl_capabilities->preambleSupport |=
static_cast<std::underlying_type<RttPreamble>::type>(

View File

@@ -25,6 +25,7 @@
#include <android/hardware/wifi/1.2/types.h>
#include <android/hardware/wifi/1.3/IWifiChip.h>
#include <android/hardware/wifi/1.3/types.h>
#include <android/hardware/wifi/1.4/types.h>
#include "wifi_legacy_hal.h"

View File

@@ -252,7 +252,7 @@ class WifiChipTest : public Test {
bool createRttController() {
bool success = false;
chip_->createRttController(
chip_->createRttController_1_4(
NULL, [&success](const WifiStatus& status,
const sp<IWifiRttController>& rtt) {
if (WifiStatusCode::SUCCESS == status.code) {
@@ -750,7 +750,7 @@ TEST_F(WifiChipV2_AwareIfaceCombinationTest,
// Create RTT controller
sp<IWifiRttController> rtt_controller;
chip_->createRttController(
chip_->createRttController_1_4(
NULL, [&rtt_controller](const WifiStatus& status,
const sp<IWifiRttController>& rtt) {
if (WifiStatusCode::SUCCESS == status.code) {

View File

@@ -620,6 +620,14 @@ Return<void> WifiChip::debug(const hidl_handle& handle,
return Void();
}
Return<void> WifiChip::createRttController_1_4(
const sp<IWifiIface>& bound_iface,
createRttController_1_4_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
&WifiChip::createRttControllerInternal_1_4,
hidl_status_cb, bound_iface);
}
void WifiChip::invalidateAndRemoveAllIfaces() {
invalidateAndClearAll(ap_ifaces_);
invalidateAndClearAll(nan_ifaces_);
@@ -669,30 +677,6 @@ std::pair<WifiStatus, uint32_t> WifiChip::getCapabilitiesInternal() {
return {createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED), 0};
}
std::pair<WifiStatus, uint32_t> WifiChip::getCapabilitiesInternal_1_3() {
legacy_hal::wifi_error legacy_status;
uint32_t legacy_feature_set;
uint32_t legacy_logger_feature_set;
const auto ifname = getFirstActiveWlanIfaceName();
std::tie(legacy_status, legacy_feature_set) =
legacy_hal_.lock()->getSupportedFeatureSet(ifname);
if (legacy_status != legacy_hal::WIFI_SUCCESS) {
return {createWifiStatusFromLegacyError(legacy_status), 0};
}
std::tie(legacy_status, legacy_logger_feature_set) =
legacy_hal_.lock()->getLoggerSupportedFeatureSet(ifname);
if (legacy_status != legacy_hal::WIFI_SUCCESS) {
// some devices don't support querying logger feature set
legacy_logger_feature_set = 0;
}
uint32_t hidl_caps;
if (!hidl_struct_util::convertLegacyFeaturesToHidlChipCapabilities(
legacy_feature_set, legacy_logger_feature_set, &hidl_caps)) {
return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), 0};
}
return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
}
std::pair<WifiStatus, std::vector<IWifiChip::ChipMode>>
WifiChip::getAvailableModesInternal() {
return {createWifiStatus(WifiStatusCode::SUCCESS), modes_};
@@ -996,18 +980,10 @@ WifiStatus WifiChip::removeStaIfaceInternal(const std::string& ifname) {
return createWifiStatus(WifiStatusCode::SUCCESS);
}
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(
getFirstActiveWlanIfaceName(), bound_iface, legacy_hal_);
rtt_controllers_.emplace_back(rtt);
return {createWifiStatus(WifiStatusCode::SUCCESS), rtt};
std::pair<WifiStatus, sp<V1_0::IWifiRttController>>
WifiChip::createRttControllerInternal(const sp<IWifiIface>& /*bound_iface*/) {
LOG(ERROR) << "createRttController is not supported on this HAL";
return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
}
std::pair<WifiStatus, std::vector<WifiDebugRingBufferStatus>>
@@ -1158,6 +1134,45 @@ WifiStatus WifiChip::selectTxPowerScenarioInternal_1_2(
return createWifiStatusFromLegacyError(legacy_status);
}
std::pair<WifiStatus, uint32_t> WifiChip::getCapabilitiesInternal_1_3() {
legacy_hal::wifi_error legacy_status;
uint32_t legacy_feature_set;
uint32_t legacy_logger_feature_set;
const auto ifname = getFirstActiveWlanIfaceName();
std::tie(legacy_status, legacy_feature_set) =
legacy_hal_.lock()->getSupportedFeatureSet(ifname);
if (legacy_status != legacy_hal::WIFI_SUCCESS) {
return {createWifiStatusFromLegacyError(legacy_status), 0};
}
std::tie(legacy_status, legacy_logger_feature_set) =
legacy_hal_.lock()->getLoggerSupportedFeatureSet(ifname);
if (legacy_status != legacy_hal::WIFI_SUCCESS) {
// some devices don't support querying logger feature set
legacy_logger_feature_set = 0;
}
uint32_t hidl_caps;
if (!hidl_struct_util::convertLegacyFeaturesToHidlChipCapabilities(
legacy_feature_set, legacy_logger_feature_set, &hidl_caps)) {
return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), 0};
}
return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
}
std::pair<WifiStatus, sp<IWifiRttController>>
WifiChip::createRttControllerInternal_1_4(const sp<IWifiIface>& bound_iface) {
if (sta_ifaces_.size() == 0 &&
!canCurrentModeSupportIfaceOfType(IfaceType::STA)) {
LOG(ERROR)
<< "createRttControllerInternal_1_4: Chip cannot support STAs "
"(and RTT by extension)";
return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
}
sp<WifiRttController> rtt = new WifiRttController(
getFirstActiveWlanIfaceName(), bound_iface, legacy_hal_);
rtt_controllers_.emplace_back(rtt);
return {createWifiStatus(WifiStatusCode::SUCCESS), rtt};
}
WifiStatus WifiChip::handleChipConfiguration(
/* NONNULL */ std::unique_lock<std::recursive_mutex>* lock,
ChipModeId mode_id) {

View File

@@ -21,7 +21,8 @@
#include <map>
#include <android-base/macros.h>
#include <android/hardware/wifi/1.3/IWifiChip.h>
#include <android/hardware/wifi/1.4/IWifiChip.h>
#include <android/hardware/wifi/1.4/IWifiRttController.h>
#include "hidl_callback_util.h"
#include "ringbuffer.h"
@@ -46,7 +47,7 @@ using namespace android::hardware::wifi::V1_0;
* Since there is only a single chip instance used today, there is no
* identifying handle information stored here.
*/
class WifiChip : public V1_3::IWifiChip {
class WifiChip : public V1_4::IWifiChip {
public:
WifiChip(
ChipId chip_id,
@@ -152,6 +153,9 @@ class WifiChip : public V1_3::IWifiChip {
getCapabilities_cb hidl_status_cb) override;
Return<void> debug(const hidl_handle& handle,
const hidl_vec<hidl_string>& options) override;
Return<void> createRttController_1_4(
const sp<IWifiIface>& bound_iface,
createRttController_1_4_cb hidl_status_cb) override;
private:
void invalidateAndRemoveAllIfaces();
@@ -195,8 +199,8 @@ class WifiChip : public V1_3::IWifiChip {
std::pair<WifiStatus, sp<IWifiStaIface>> getStaIfaceInternal(
const std::string& ifname);
WifiStatus removeStaIfaceInternal(const std::string& ifname);
std::pair<WifiStatus, sp<IWifiRttController>> createRttControllerInternal(
const sp<IWifiIface>& bound_iface);
std::pair<WifiStatus, sp<V1_0::IWifiRttController>>
createRttControllerInternal(const sp<IWifiIface>& bound_iface);
std::pair<WifiStatus, std::vector<WifiDebugRingBufferStatus>>
getDebugRingBuffersStatusInternal();
WifiStatus startLoggingToDebugRingBufferInternal(
@@ -217,6 +221,8 @@ class WifiChip : public V1_3::IWifiChip {
const sp<V1_2::IWifiChipEventCallback>& event_callback);
WifiStatus selectTxPowerScenarioInternal_1_2(TxPowerScenario scenario);
std::pair<WifiStatus, uint32_t> getCapabilitiesInternal_1_3();
std::pair<WifiStatus, sp<IWifiRttController>>
createRttControllerInternal_1_4(const sp<IWifiIface>& bound_iface);
WifiStatus handleChipConfiguration(
std::unique_lock<std::recursive_mutex>* lock, ChipModeId mode_id);
WifiStatus registerDebugRingBufferCallback();

View File

@@ -58,7 +58,7 @@ Return<void> WifiRttController::getBoundIface(getBoundIface_cb hidl_status_cb) {
}
Return<void> WifiRttController::registerEventCallback(
const sp<IWifiRttControllerEventCallback>& callback,
const sp<V1_0::IWifiRttControllerEventCallback>& callback,
registerEventCallback_cb hidl_status_cb) {
return validateAndCall(this,
WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
@@ -67,7 +67,7 @@ Return<void> WifiRttController::registerEventCallback(
}
Return<void> WifiRttController::rangeRequest(
uint32_t cmd_id, const hidl_vec<RttConfig>& rtt_configs,
uint32_t cmd_id, const hidl_vec<V1_0::RttConfig>& rtt_configs,
rangeRequest_cb hidl_status_cb) {
return validateAndCall(this,
WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
@@ -115,7 +115,7 @@ Return<void> WifiRttController::getResponderInfo(
Return<void> WifiRttController::enableResponder(
uint32_t cmd_id, const WifiChannelInfo& channel_hint,
uint32_t max_duration_seconds, const RttResponder& info,
uint32_t max_duration_seconds, const V1_0::RttResponder& info,
enableResponder_cb hidl_status_cb) {
return validateAndCall(
this, WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
@@ -130,49 +130,64 @@ Return<void> WifiRttController::disableResponder(
&WifiRttController::disableResponderInternal, hidl_status_cb, cmd_id);
}
Return<void> WifiRttController::registerEventCallback_1_4(
const sp<IWifiRttControllerEventCallback>& callback,
registerEventCallback_1_4_cb hidl_status_cb) {
return validateAndCall(
this, WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
&WifiRttController::registerEventCallbackInternal_1_4, hidl_status_cb,
callback);
}
Return<void> WifiRttController::rangeRequest_1_4(
uint32_t cmd_id, const hidl_vec<RttConfig>& rtt_configs,
rangeRequest_1_4_cb hidl_status_cb) {
return validateAndCall(this,
WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
&WifiRttController::rangeRequestInternal_1_4,
hidl_status_cb, cmd_id, rtt_configs);
}
Return<void> WifiRttController::getCapabilities_1_4(
getCapabilities_1_4_cb hidl_status_cb) {
return validateAndCall(
this, WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
&WifiRttController::getCapabilitiesInternal_1_4, hidl_status_cb);
}
Return<void> WifiRttController::getResponderInfo_1_4(
getResponderInfo_1_4_cb hidl_status_cb) {
return validateAndCall(
this, WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
&WifiRttController::getResponderInfoInternal_1_4, hidl_status_cb);
}
Return<void> WifiRttController::enableResponder_1_4(
uint32_t cmd_id, const WifiChannelInfo& channel_hint,
uint32_t max_duration_seconds, const RttResponder& info,
enableResponder_1_4_cb hidl_status_cb) {
return validateAndCall(
this, WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
&WifiRttController::enableResponderInternal_1_4, hidl_status_cb, cmd_id,
channel_hint, max_duration_seconds, info);
}
std::pair<WifiStatus, sp<IWifiIface>>
WifiRttController::getBoundIfaceInternal() {
return {createWifiStatus(WifiStatusCode::SUCCESS), bound_iface_};
}
WifiStatus WifiRttController::registerEventCallbackInternal(
const sp<IWifiRttControllerEventCallback>& callback) {
// TODO(b/31632518): remove the callback when the client is destroyed
event_callbacks_.emplace_back(callback);
return createWifiStatus(WifiStatusCode::SUCCESS);
const sp<V1_0::IWifiRttControllerEventCallback>& /* callback */) {
// Deprecated support for this api
return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
}
WifiStatus WifiRttController::rangeRequestInternal(
uint32_t cmd_id, const std::vector<RttConfig>& rtt_configs) {
std::vector<legacy_hal::wifi_rtt_config> legacy_configs;
if (!hidl_struct_util::convertHidlVectorOfRttConfigToLegacy(
rtt_configs, &legacy_configs)) {
return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}
android::wp<WifiRttController> weak_ptr_this(this);
const auto& on_results_callback =
[weak_ptr_this](
legacy_hal::wifi_request_id id,
const std::vector<const legacy_hal::wifi_rtt_result*>& results) {
const auto shared_ptr_this = weak_ptr_this.promote();
if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
LOG(ERROR) << "Callback invoked on an invalid object";
return;
}
std::vector<RttResult> hidl_results;
if (!hidl_struct_util::convertLegacyVectorOfRttResultToHidl(
results, &hidl_results)) {
LOG(ERROR) << "Failed to convert rtt results to HIDL structs";
return;
}
for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
callback->onResults(id, hidl_results);
}
};
legacy_hal::wifi_error legacy_status =
legacy_hal_.lock()->startRttRangeRequest(
ifname_, cmd_id, legacy_configs, on_results_callback);
return createWifiStatusFromLegacyError(legacy_status);
uint32_t /* cmd_id */,
const std::vector<V1_0::RttConfig>& /* rtt_configs */) {
// Deprecated support for this api
return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
}
WifiStatus WifiRttController::rangeCancelInternal(
@@ -187,21 +202,10 @@ WifiStatus WifiRttController::rangeCancelInternal(
return createWifiStatusFromLegacyError(legacy_status);
}
std::pair<WifiStatus, RttCapabilities>
std::pair<WifiStatus, V1_0::RttCapabilities>
WifiRttController::getCapabilitiesInternal() {
legacy_hal::wifi_error legacy_status;
legacy_hal::wifi_rtt_capabilities legacy_caps;
std::tie(legacy_status, legacy_caps) =
legacy_hal_.lock()->getRttCapabilities(ifname_);
if (legacy_status != legacy_hal::WIFI_SUCCESS) {
return {createWifiStatusFromLegacyError(legacy_status), {}};
}
RttCapabilities hidl_caps;
if (!hidl_struct_util::convertLegacyRttCapabilitiesToHidl(legacy_caps,
&hidl_caps)) {
return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
}
return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
// Deprecated support for this api
return {createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED), {}};
}
WifiStatus WifiRttController::setLciInternal(uint32_t cmd_id,
@@ -228,8 +232,84 @@ WifiStatus WifiRttController::setLcrInternal(uint32_t cmd_id,
return createWifiStatusFromLegacyError(legacy_status);
}
std::pair<WifiStatus, RttResponder>
std::pair<WifiStatus, V1_0::RttResponder>
WifiRttController::getResponderInfoInternal() {
// Deprecated support for this api
return {createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED), {}};
}
WifiStatus WifiRttController::enableResponderInternal(
uint32_t /* cmd_id */, const WifiChannelInfo& /* channel_hint */,
uint32_t /* max_duration_seconds */, const V1_0::RttResponder& /* info */) {
// Deprecated support for this api
return {createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED)};
}
WifiStatus WifiRttController::disableResponderInternal(uint32_t cmd_id) {
legacy_hal::wifi_error legacy_status =
legacy_hal_.lock()->disableRttResponder(ifname_, cmd_id);
return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiRttController::registerEventCallbackInternal_1_4(
const sp<IWifiRttControllerEventCallback>& callback) {
// TODO(b/31632518): remove the callback when the client is destroyed
event_callbacks_.emplace_back(callback);
return createWifiStatus(WifiStatusCode::SUCCESS);
}
WifiStatus WifiRttController::rangeRequestInternal_1_4(
uint32_t cmd_id, const std::vector<RttConfig>& rtt_configs) {
std::vector<legacy_hal::wifi_rtt_config> legacy_configs;
if (!hidl_struct_util::convertHidlVectorOfRttConfigToLegacy(
rtt_configs, &legacy_configs)) {
return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}
android::wp<WifiRttController> weak_ptr_this(this);
const auto& on_results_callback =
[weak_ptr_this](
legacy_hal::wifi_request_id id,
const std::vector<const legacy_hal::wifi_rtt_result*>& results) {
const auto shared_ptr_this = weak_ptr_this.promote();
if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
LOG(ERROR) << "Callback invoked on an invalid object";
return;
}
std::vector<RttResult> hidl_results;
if (!hidl_struct_util::convertLegacyVectorOfRttResultToHidl(
results, &hidl_results)) {
LOG(ERROR) << "Failed to convert rtt results to HIDL structs";
return;
}
for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
callback->onResults_1_4(id, hidl_results);
}
};
legacy_hal::wifi_error legacy_status =
legacy_hal_.lock()->startRttRangeRequest(
ifname_, cmd_id, legacy_configs, on_results_callback);
return createWifiStatusFromLegacyError(legacy_status);
}
std::pair<WifiStatus, RttCapabilities>
WifiRttController::getCapabilitiesInternal_1_4() {
legacy_hal::wifi_error legacy_status;
legacy_hal::wifi_rtt_capabilities legacy_caps;
std::tie(legacy_status, legacy_caps) =
legacy_hal_.lock()->getRttCapabilities(ifname_);
if (legacy_status != legacy_hal::WIFI_SUCCESS) {
return {createWifiStatusFromLegacyError(legacy_status), {}};
}
RttCapabilities hidl_caps;
if (!hidl_struct_util::convertLegacyRttCapabilitiesToHidl(legacy_caps,
&hidl_caps)) {
return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
}
return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
}
std::pair<WifiStatus, RttResponder>
WifiRttController::getResponderInfoInternal_1_4() {
legacy_hal::wifi_error legacy_status;
legacy_hal::wifi_rtt_responder legacy_responder;
std::tie(legacy_status, legacy_responder) =
@@ -245,7 +325,7 @@ WifiRttController::getResponderInfoInternal() {
return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_responder};
}
WifiStatus WifiRttController::enableResponderInternal(
WifiStatus WifiRttController::enableResponderInternal_1_4(
uint32_t cmd_id, const WifiChannelInfo& channel_hint,
uint32_t max_duration_seconds, const RttResponder& info) {
legacy_hal::wifi_channel_info legacy_channel_info;
@@ -264,12 +344,6 @@ WifiStatus WifiRttController::enableResponderInternal(
legacy_responder);
return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiRttController::disableResponderInternal(uint32_t cmd_id) {
legacy_hal::wifi_error legacy_status =
legacy_hal_.lock()->disableRttResponder(ifname_, cmd_id);
return createWifiStatusFromLegacyError(legacy_status);
}
} // namespace implementation
} // namespace V1_4
} // namespace wifi

View File

@@ -19,8 +19,8 @@
#include <android-base/macros.h>
#include <android/hardware/wifi/1.0/IWifiIface.h>
#include <android/hardware/wifi/1.0/IWifiRttController.h>
#include <android/hardware/wifi/1.0/IWifiRttControllerEventCallback.h>
#include <android/hardware/wifi/1.4/IWifiRttController.h>
#include <android/hardware/wifi/1.4/IWifiRttControllerEventCallback.h>
#include "wifi_legacy_hal.h"
@@ -33,7 +33,7 @@ namespace implementation {
/**
* HIDL interface object used to control all RTT operations.
*/
class WifiRttController : public V1_0::IWifiRttController {
class WifiRttController : public V1_4::IWifiRttController {
public:
WifiRttController(
const std::string& iface_name, const sp<IWifiIface>& bound_iface,
@@ -47,10 +47,10 @@ class WifiRttController : public V1_0::IWifiRttController {
// HIDL methods exposed.
Return<void> getBoundIface(getBoundIface_cb hidl_status_cb) override;
Return<void> registerEventCallback(
const sp<IWifiRttControllerEventCallback>& callback,
const sp<V1_0::IWifiRttControllerEventCallback>& callback,
registerEventCallback_cb hidl_status_cb) override;
Return<void> rangeRequest(uint32_t cmd_id,
const hidl_vec<RttConfig>& rtt_configs,
const hidl_vec<V1_0::RttConfig>& rtt_configs,
rangeRequest_cb hidl_status_cb) override;
Return<void> rangeCancel(uint32_t cmd_id,
const hidl_vec<hidl_array<uint8_t, 6>>& addrs,
@@ -64,29 +64,53 @@ class WifiRttController : public V1_0::IWifiRttController {
Return<void> enableResponder(uint32_t cmd_id,
const WifiChannelInfo& channel_hint,
uint32_t max_duration_seconds,
const RttResponder& info,
const V1_0::RttResponder& info,
enableResponder_cb hidl_status_cb) override;
Return<void> disableResponder(uint32_t cmd_id,
disableResponder_cb hidl_status_cb) override;
Return<void> registerEventCallback_1_4(
const sp<IWifiRttControllerEventCallback>& callback,
registerEventCallback_1_4_cb hidl_status_cb) override;
Return<void> rangeRequest_1_4(uint32_t cmd_id,
const hidl_vec<RttConfig>& rtt_configs,
rangeRequest_1_4_cb hidl_status_cb) override;
Return<void> getCapabilities_1_4(
getCapabilities_1_4_cb hidl_status_cb) override;
Return<void> getResponderInfo_1_4(
getResponderInfo_1_4_cb hidl_status_cb) override;
Return<void> enableResponder_1_4(
uint32_t cmd_id, const WifiChannelInfo& channel_hint,
uint32_t max_duration_seconds, const RttResponder& info,
enableResponder_1_4_cb hidl_status_cb) override;
private:
// Corresponding worker functions for the HIDL methods.
std::pair<WifiStatus, sp<IWifiIface>> getBoundIfaceInternal();
WifiStatus registerEventCallbackInternal(
const sp<IWifiRttControllerEventCallback>& callback);
WifiStatus rangeRequestInternal(uint32_t cmd_id,
const std::vector<RttConfig>& rtt_configs);
const sp<V1_0::IWifiRttControllerEventCallback>& callback);
WifiStatus rangeRequestInternal(
uint32_t cmd_id, const std::vector<V1_0::RttConfig>& rtt_configs);
WifiStatus rangeCancelInternal(
uint32_t cmd_id, const std::vector<hidl_array<uint8_t, 6>>& addrs);
std::pair<WifiStatus, RttCapabilities> getCapabilitiesInternal();
std::pair<WifiStatus, V1_0::RttCapabilities> getCapabilitiesInternal();
WifiStatus setLciInternal(uint32_t cmd_id, const RttLciInformation& lci);
WifiStatus setLcrInternal(uint32_t cmd_id, const RttLcrInformation& lcr);
std::pair<WifiStatus, RttResponder> getResponderInfoInternal();
std::pair<WifiStatus, V1_0::RttResponder> getResponderInfoInternal();
WifiStatus enableResponderInternal(uint32_t cmd_id,
const WifiChannelInfo& channel_hint,
uint32_t max_duration_seconds,
const RttResponder& info);
const V1_0::RttResponder& info);
WifiStatus disableResponderInternal(uint32_t cmd_id);
WifiStatus registerEventCallbackInternal_1_4(
const sp<IWifiRttControllerEventCallback>& callback);
WifiStatus rangeRequestInternal_1_4(
uint32_t cmd_id, const std::vector<RttConfig>& rtt_configs);
std::pair<WifiStatus, RttCapabilities> getCapabilitiesInternal_1_4();
std::pair<WifiStatus, RttResponder> getResponderInfoInternal_1_4();
WifiStatus enableResponderInternal_1_4(uint32_t cmd_id,
const WifiChannelInfo& channel_hint,
uint32_t max_duration_seconds,
const RttResponder& info);
std::string ifname_;
sp<IWifiIface> bound_iface_;

View File

@@ -17,7 +17,7 @@
#ifndef WIFI_STATUS_UTIL_H_
#define WIFI_STATUS_UTIL_H_
#include <android/hardware/wifi/1.0/IWifi.h>
#include <android/hardware/wifi/1.4/IWifi.h>
#include "wifi_legacy_hal.h"

380
wifi/1.4/types.hal Normal file
View File

@@ -0,0 +1,380 @@
/*
* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.wifi@1.4;
import @1.0::MacAddress;
import @1.0::Rssi;
import @1.0::RttBw;
import @1.0::RttConfig;
import @1.0::RttPeerType;
import @1.0::RttPreamble;
import @1.0::RttStatus;
import @1.0::RttType;
import @1.0::TimeSpanInPs;
import @1.0::TimeStampInUs;
import @1.0::WifiChannelInfo;
import @1.0::WifiChannelWidthInMhz;
import @1.0::WifiInformationElement;
import @1.0::WifiRateNss;
import @1.0::WifiRatePreamble;
/**
* Wifi Rate Preamble
*/
enum WifiRatePreamble : @1.0::WifiRatePreamble {
/**
* Preamble type for 11ax
*/
HE = 5,
};
/**
* RTT Measurement Preamble.
*/
enum RttPreamble : @1.0::RttPreamble {
/**
* Preamble type for 11ax
*/
HE = 0x8,
};
/**
* RTT configuration.
*/
struct RttConfig {
/**
* Peer device mac address.
*/
MacAddress addr;
/**
* 1-sided or 2-sided RTT.
*/
RttType type;
/**
* Optional - peer device hint (STA, P2P, AP).
*/
RttPeerType peer;
/**
* Required for STA-AP mode, optional for P2P, NBD etc.
*/
WifiChannelInfo channel;
/**
* Time interval between bursts (units: 100 ms).
* Applies to 1-sided and 2-sided RTT multi-burst requests.
* Range: 0-31, 0: no preference by initiator (2-sided RTT).
*/
uint32_t burstPeriod;
/**
* Total number of RTT bursts to be executed. It will be
* specified in the same way as the parameter "Number of
* Burst Exponent" found in the FTM frame format. It
* applies to both: 1-sided RTT and 2-sided RTT. Valid
* values are 0 to 15 as defined in 802.11mc std.
* 0 means single shot
* The implication of this parameter on the maximum
* number of RTT results is the following:
* for 1-sided RTT: max num of RTT results = (2^num_burst)*(num_frames_per_burst)
* for 2-sided RTT: max num of RTT results = (2^num_burst)*(num_frames_per_burst - 1)
*/
uint32_t numBurst;
/**
* Num of frames per burst.
* Minimum value = 1, Maximum value = 31
* For 2-sided this equals the number of FTM frames
* to be attempted in a single burst. This also
* equals the number of FTM frames that the
* initiator will request that the responder send
* in a single frame.
*/
uint32_t numFramesPerBurst;
/**
* Number of retries for a failed RTT frame.
* Applies to 1-sided RTT only. Minimum value = 0, Maximum value = 3
*/
uint32_t numRetriesPerRttFrame;
/**
* Following fields are only valid for 2-side RTT.
*
*
* Maximum number of retries that the initiator can
* retry an FTMR frame.
* Minimum value = 0, Maximum value = 3
*/
uint32_t numRetriesPerFtmr;
/**
* Whether to request location civic info or not.
*/
bool mustRequestLci;
/**
* Whether to request location civic records or not.
*/
bool mustRequestLcr;
/**
* Applies to 1-sided and 2-sided RTT. Valid values will
* be 2-11 and 15 as specified by the 802.11mc std for
* the FTM parameter burst duration. In a multi-burst
* request, if responder overrides with larger value,
* the initiator will return failure. In a single-burst
* request if responder overrides with larger value,
* the initiator will sent TMR_STOP to terminate RTT
* at the end of the burst_duration it requested.
*/
uint32_t burstDuration;
/**
* RTT preamble to be used in the RTT frames.
*/
RttPreamble preamble;
/**
* RTT BW to be used in the RTT frames.
*/
RttBw bw;
};
/**
* RTT Capabilities.
*/
struct RttCapabilities {
/**
* if 1-sided rtt data collection is supported.
*/
bool rttOneSidedSupported;
/**
* if ftm rtt data collection is supported.
*/
bool rttFtmSupported;
/**
* if initiator supports LCI request. Applies to 2-sided RTT.
*/
bool lciSupported;
/**
* if initiator supports LCR request. Applies to 2-sided RTT.
*/
bool lcrSupported;
/**
* if 11mc responder mode is supported.
*/
bool responderSupported;
/**
* Bit mask indicates what preamble is supported by initiator.
* Combination of |RttPreamble| values.
*/
bitfield<RttPreamble> preambleSupport;
/**
* Bit mask indicates what BW is supported by initiator.
* Combination of |RttBw| values.
*/
bitfield<RttBw> bwSupport;
/**
* Draft 11mc spec version supported by chip.
* For instance, version 4.0 must be 40 and version 4.3 must be 43 etc.
*/
uint8_t mcVersion;
};
/**
* RTT Responder information
*/
struct RttResponder {
WifiChannelInfo channel;
RttPreamble preamble;
};
/**
* Wifi rate info.
*/
struct WifiRateInfo {
/**
* Preamble used for RTT measurements.
*/
WifiRatePreamble preamble;
/**
* Number of spatial streams.
*/
WifiRateNss nss;
/**
* Bandwidth of channel.
*/
WifiChannelWidthInMhz bw;
/**
* OFDM/CCK rate code would be as per ieee std in the units of 0.5mbps.
* HT/VHT/HE it would be mcs index.
*/
uint8_t rateMcsIdx;
/**
* Bitrate in units of 100 Kbps.
*/
uint32_t bitRateInKbps;
};
/**
* RTT results.
*/
struct RttResult {
/**
* Peer device mac address.
*/
MacAddress addr;
/**
* Burst number in a multi-burst request.
*/
uint32_t burstNum;
/**
* Total RTT measurement frames attempted.
*/
uint32_t measurementNumber;
/**
* Total successful RTT measurement frames.
*/
uint32_t successNumber;
/**
* Maximum number of "FTM frames per burst" supported by
* the responder STA. Applies to 2-sided RTT only.
* If reponder overrides with larger value:
* - for single-burst request initiator will truncate the
* larger value and send a TMR_STOP after receiving as
* many frames as originally requested.
* - for multi-burst request, initiator will return
* failure right away.
*/
uint8_t numberPerBurstPeer;
/**
* Ranging status.
*/
RttStatus status;
/**
* When status == RTT_STATUS_FAIL_BUSY_TRY_LATER,
* this will be the time provided by the responder as to
* when the request can be tried again. Applies to 2-sided
* RTT only. In sec, 1-31sec.
*/
uint8_t retryAfterDuration;
/**
* RTT type.
*/
RttType type;
/**
* Average rssi in 0.5 dB steps e.g. 143 implies -71.5 dB.
*/
Rssi rssi;
/**
* Rssi spread in 0.5 dB steps e.g. 5 implies 2.5 dB spread (optional).
*/
Rssi rssiSpread;
/**
* 1-sided RTT: TX rate of RTT frame.
* 2-sided RTT: TX rate of initiator's Ack in response to FTM frame.
*/
WifiRateInfo txRate;
/**
* 1-sided RTT: TX rate of Ack from other side.
* 2-sided RTT: TX rate of FTM frame coming from responder.
*/
WifiRateInfo rxRate;
/**
* Round trip time in picoseconds
*/
TimeSpanInPs rtt;
/**
* Rtt standard deviation in picoseconds.
*/
TimeSpanInPs rttSd;
/**
* Difference between max and min rtt times recorded in picoseconds.
*/
TimeSpanInPs rttSpread;
/**
* Distance in mm (optional).
*/
int32_t distanceInMm;
/**
* Standard deviation in mm (optional).
*/
int32_t distanceSdInMm;
/**
* Difference between max and min distance recorded in mm (optional).
*/
int32_t distanceSpreadInMm;
/**
* Time of the measurement (in microseconds since boot).
*/
TimeStampInUs timeStampInUs;
/**
* in ms, actual time taken by the FW to finish one burst
* measurement. Applies to 1-sided and 2-sided RTT.
*/
uint32_t burstDurationInMs;
/**
* Number of bursts allowed by the responder. Applies
* to 2-sided RTT only.
*/
uint32_t negotiatedBurstNum;
/**
* for 11mc only.
*/
WifiInformationElement lci;
/**
* for 11mc only.
*/
WifiInformationElement lcr;
};