Merge "Add HAL support for IEEE 802.11 az ranging" into main
This commit is contained in:
commit
c1f2c5e643
16 changed files with 401 additions and 53 deletions
|
@ -42,4 +42,9 @@ parcelable RttCapabilities {
|
|||
android.hardware.wifi.RttPreamble preambleSupport;
|
||||
android.hardware.wifi.RttBw bwSupport;
|
||||
byte mcVersion;
|
||||
android.hardware.wifi.RttPreamble azPreambleSupport;
|
||||
android.hardware.wifi.RttBw azBwSupport;
|
||||
boolean ntbInitiatorSupported;
|
||||
boolean ntbResponderSupported;
|
||||
int maxTxLtfRepetitionCount;
|
||||
}
|
||||
|
|
|
@ -48,4 +48,7 @@ parcelable RttConfig {
|
|||
int burstDuration;
|
||||
android.hardware.wifi.RttPreamble preamble;
|
||||
android.hardware.wifi.RttBw bw;
|
||||
int ntbMinMeasurementTimeMillis;
|
||||
int ntbMaxMeasurementTimeMillis;
|
||||
int txLtfRepetitionCount;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
package android.hardware.wifi;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum RttPreamble {
|
||||
INVALID = 0,
|
||||
LEGACY = 0x1,
|
||||
HT = 0x2,
|
||||
VHT = 0x4,
|
||||
|
|
|
@ -59,4 +59,7 @@ parcelable RttResult {
|
|||
android.hardware.wifi.WifiInformationElement lcr;
|
||||
int channelFreqMHz;
|
||||
android.hardware.wifi.RttBw packetBw;
|
||||
int txLtfRepetitionCount;
|
||||
int ntbMinMeasurementTimeMillis;
|
||||
int ntbMaxMeasurementTimeMillis;
|
||||
}
|
||||
|
|
|
@ -36,4 +36,6 @@ package android.hardware.wifi;
|
|||
enum RttType {
|
||||
ONE_SIDED = 1,
|
||||
TWO_SIDED = 2,
|
||||
TWO_SIDED_11MC = TWO_SIDED /* 2 */,
|
||||
TWO_SIDED_11AZ_NTB = 3,
|
||||
}
|
||||
|
|
|
@ -33,24 +33,25 @@ parcelable RttCapabilities {
|
|||
*/
|
||||
boolean rttFtmSupported;
|
||||
/**
|
||||
* Whether initiator supports LCI request. Applies to 2-sided RTT.
|
||||
* Whether initiator supports Location Configuration Information (LCI) request. Applies to
|
||||
* 2-sided RTT.
|
||||
*/
|
||||
boolean lciSupported;
|
||||
/**
|
||||
* Whether initiator supports LCR request. Applies to 2-sided RTT.
|
||||
* Whether initiator supports Location Civic Report (LCR) request. Applies to 2-sided RTT.
|
||||
*/
|
||||
boolean lcrSupported;
|
||||
/**
|
||||
* Whether 11mc responder mode is supported.
|
||||
* Whether IEEE 802.11mc responder mode is supported.
|
||||
*/
|
||||
boolean responderSupported;
|
||||
/**
|
||||
* Bit mask indicating what preamble is supported by initiator.
|
||||
* Bit mask indicating what preamble is supported by IEEE 802.11mc initiator.
|
||||
* Combination of |RttPreamble| values.
|
||||
*/
|
||||
RttPreamble preambleSupport;
|
||||
/**
|
||||
* Bit mask indicating what BW is supported by initiator.
|
||||
* Bit mask indicating what BW is supported by IEEE 802.11mc initiator.
|
||||
* Combination of |RttBw| values.
|
||||
*/
|
||||
RttBw bwSupport;
|
||||
|
@ -59,4 +60,27 @@ parcelable RttCapabilities {
|
|||
* For instance, version 4.0 must be 40 and version 4.3 must be 43 etc.
|
||||
*/
|
||||
byte mcVersion;
|
||||
/**
|
||||
* Bit mask indicating what preamble is supported by IEEE 802.11az initiator.
|
||||
* Combination of |RttPreamble| values.
|
||||
*/
|
||||
RttPreamble azPreambleSupport;
|
||||
/**
|
||||
* Bit mask indicating what BW is supported by IEEE 802.11az initiator.
|
||||
* Combination of |RttBw| values.
|
||||
*/
|
||||
RttBw azBwSupport;
|
||||
/**
|
||||
* Whether the initiator supports IEEE 802.11az Non-Trigger-based (non-TB) measurement.
|
||||
*/
|
||||
boolean ntbInitiatorSupported;
|
||||
/**
|
||||
* Whether IEEE 802.11az Non-Trigger-based (non-TB) responder mode is supported.
|
||||
*/
|
||||
boolean ntbResponderSupported;
|
||||
/**
|
||||
* Maximum HE LTF repetitions the IEEE 802.11az initiator is capable of transmitting in the
|
||||
* preamble of I2R NDP.
|
||||
*/
|
||||
int maxTxLtfRepetitionCount;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ parcelable RttConfig {
|
|||
*/
|
||||
byte[6] addr;
|
||||
/**
|
||||
* 1-sided or 2-sided RTT.
|
||||
* 1-sided or 2-sided RTT (IEEE 802.11mc or IEEE 802. 11az).
|
||||
*/
|
||||
RttType type;
|
||||
/**
|
||||
|
@ -47,6 +47,8 @@ parcelable RttConfig {
|
|||
* 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).
|
||||
*
|
||||
* Note: Applicable to IEEE 802.11mc only.
|
||||
*/
|
||||
int burstPeriod;
|
||||
/**
|
||||
|
@ -60,6 +62,9 @@ parcelable RttConfig {
|
|||
* 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)
|
||||
*
|
||||
* Note: Applicable to IEEE 802.11mc only. For IEEE 802.11az refer
|
||||
* |RttConfig.txLtfRepetitionCount|.
|
||||
*/
|
||||
int numBurst;
|
||||
/**
|
||||
|
@ -70,6 +75,8 @@ parcelable RttConfig {
|
|||
* equals the number of FTM frames that the
|
||||
* initiator will request that the responder sends
|
||||
* in a single frame.
|
||||
*
|
||||
* Note: Applicable to IEEE 802.11mc only.
|
||||
*/
|
||||
int numFramesPerBurst;
|
||||
/**
|
||||
|
@ -95,8 +102,8 @@ parcelable RttConfig {
|
|||
*/
|
||||
boolean 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
|
||||
* Applies to 1-sided and 2-sided IEEE 802.11mc RTT. Valid values will
|
||||
* be 2-11 and 15 as specified by the IEEE 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
|
||||
|
@ -113,4 +120,17 @@ parcelable RttConfig {
|
|||
* RTT BW to be used in the RTT frames.
|
||||
*/
|
||||
RttBw bw;
|
||||
/**
|
||||
* IEEE 802.11az Non-Trigger-based (non-TB) minimum measurement time in milliseconds.
|
||||
*/
|
||||
int ntbMinMeasurementTimeMillis;
|
||||
/**
|
||||
* IEEE 802.11az Non-Trigger-based (non-TB) maximum measurement time in milliseconds.
|
||||
*/
|
||||
int ntbMaxMeasurementTimeMillis;
|
||||
/**
|
||||
* Multiple transmissions of HE-LTF symbols in an HE Ranging NDP. A value of 1 indicates no
|
||||
* repetition.
|
||||
*/
|
||||
int txLtfRepetitionCount;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package android.hardware.wifi;
|
|||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum RttPreamble {
|
||||
INVALID = 0,
|
||||
LEGACY = 0x1,
|
||||
HT = 0x2,
|
||||
VHT = 0x4,
|
||||
|
|
|
@ -33,6 +33,8 @@ parcelable RttResult {
|
|||
byte[6] addr;
|
||||
/**
|
||||
* Burst number in a multi-burst request.
|
||||
*
|
||||
* Note: Applicable to 1-sided RTT and 2-sided IEEE 802.11mc only.
|
||||
*/
|
||||
int burstNum;
|
||||
/**
|
||||
|
@ -45,7 +47,7 @@ parcelable RttResult {
|
|||
int successNumber;
|
||||
/**
|
||||
* Maximum number of "FTM frames per burst" supported by
|
||||
* the responder STA. Applies to 2-sided RTT only.
|
||||
* the responder STA. Applies to 2-sided IEEE 802.11mc 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
|
||||
|
@ -59,10 +61,8 @@ parcelable RttResult {
|
|||
*/
|
||||
RttStatus status;
|
||||
/**
|
||||
* If status is 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-31 sec.
|
||||
* If status is 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-31 sec.
|
||||
*/
|
||||
byte retryAfterDuration;
|
||||
/**
|
||||
|
@ -104,11 +104,13 @@ parcelable RttResult {
|
|||
*/
|
||||
int distanceInMm;
|
||||
/**
|
||||
* Standard deviation in mm (optional).
|
||||
* Standard deviation in mm.
|
||||
*/
|
||||
int distanceSdInMm;
|
||||
/**
|
||||
* Difference between max and min distance recorded in mm (optional).
|
||||
*
|
||||
* Note: Only applicable for IEEE 802.11mc
|
||||
*/
|
||||
int distanceSpreadInMm;
|
||||
/**
|
||||
|
@ -116,21 +118,20 @@ parcelable RttResult {
|
|||
*/
|
||||
long timeStampInUs;
|
||||
/**
|
||||
* Actual time taken by the FW to finish one burst
|
||||
* measurement (in ms). Applies to 1-sided and 2-sided RTT.
|
||||
* Actual time taken by the FW to finish one burst measurement (in ms). Applies to 1-sided
|
||||
* and 2-sided IEEE 802.11mc RTT.
|
||||
*/
|
||||
int burstDurationInMs;
|
||||
/**
|
||||
* Number of bursts allowed by the responder. Applies
|
||||
* to 2-sided RTT only.
|
||||
* Number of bursts allowed by the responder. Applies to 2-sided IEEE 802.11mc RTT only.
|
||||
*/
|
||||
int negotiatedBurstNum;
|
||||
/**
|
||||
* For 11mc only.
|
||||
* For IEEE 802.11mc and IEEE 802.11az only.
|
||||
*/
|
||||
WifiInformationElement lci;
|
||||
/**
|
||||
* For 11mc only.
|
||||
* For IEEE 802.11mc and IEEE 802.11az only.
|
||||
*/
|
||||
WifiInformationElement lcr;
|
||||
/**
|
||||
|
@ -140,8 +141,38 @@ parcelable RttResult {
|
|||
int channelFreqMHz;
|
||||
/**
|
||||
* RTT packet bandwidth.
|
||||
* This value is an average bandwidth of the bandwidths of measurement
|
||||
* frames. Cap the average close to a specific valid RttBw.
|
||||
* This value is an average bandwidth of the bandwidths of measurement frames. Cap the average
|
||||
* close to a specific valid RttBw.
|
||||
*/
|
||||
RttBw packetBw;
|
||||
/**
|
||||
* IEEE 802.11az Transmit LTF repetitions used to get this result.
|
||||
*/
|
||||
int txLtfRepetitionCount;
|
||||
/**
|
||||
* Minimum non-trigger based (non-TB) dynamic measurement time in milliseconds assigned by the
|
||||
* IEEE 802.11az responder.
|
||||
*
|
||||
* After initial non-TB negotiation, if the next ranging request for this peer comes in between
|
||||
* [ntbMinMeasurementTime, ntbMaxMeasurementTime], vendor software shall do the NDPA sounding
|
||||
* sequence for dynamic non-TB measurement.
|
||||
*
|
||||
* If the ranging request for this peer comes sooner than minimum measurement time, vendor
|
||||
* software shall return the cached result of the last measurement including the time stamp
|
||||
* |RttResult.timestamp|.
|
||||
*/
|
||||
int ntbMinMeasurementTimeMillis;
|
||||
/**
|
||||
* Maximum non-trigger based (non-TB) dynamic measurement time in milliseconds assigned by the
|
||||
* IEEE 802.11az responder.
|
||||
*
|
||||
* After initial non-TB negotiation, if the next ranging request for this peer comes in between
|
||||
* [ntbMinMeasurementTime, ntbMaxMeasurementTime], vendor software shall do the NDPA sounding
|
||||
* sequence for dynamic non-TB measurement.
|
||||
*
|
||||
* If the ranging request for this peer comes later than the maximum measurement time, vendor
|
||||
* software shall clean up any existing IEEE 802.11ax non-TB ranging session and re-do the
|
||||
* non-TB ranging negotiation.
|
||||
*/
|
||||
int ntbMaxMeasurementTimeMillis;
|
||||
}
|
||||
|
|
|
@ -23,5 +23,18 @@ package android.hardware.wifi;
|
|||
@Backing(type="int")
|
||||
enum RttType {
|
||||
ONE_SIDED = 1,
|
||||
/**
|
||||
* Two-sided RTT 11mc type.
|
||||
*
|
||||
* Note: TWO_SIDED was used for IEEE 802.11mc. Use TWO_SIDED_11MC for IEEE 802.11mc instead.
|
||||
*/
|
||||
TWO_SIDED = 2,
|
||||
/**
|
||||
* Two-sided RTT 11mc type is same as two-sided.
|
||||
*/
|
||||
TWO_SIDED_11MC = TWO_SIDED,
|
||||
/**
|
||||
* Two-sided RTT 11az non trigger based (non-TB) type.
|
||||
*/
|
||||
TWO_SIDED_11AZ_NTB = 3,
|
||||
}
|
||||
|
|
|
@ -2424,8 +2424,11 @@ legacy_hal::wifi_rtt_type convertAidlRttTypeToLegacy(RttType type) {
|
|||
switch (type) {
|
||||
case RttType::ONE_SIDED:
|
||||
return legacy_hal::RTT_TYPE_1_SIDED;
|
||||
case RttType::TWO_SIDED:
|
||||
return legacy_hal::RTT_TYPE_2_SIDED;
|
||||
case RttType::TWO_SIDED_11MC:
|
||||
// Same as RttType::TWO_SIDED
|
||||
return legacy_hal::RTT_TYPE_2_SIDED_11MC;
|
||||
case RttType::TWO_SIDED_11AZ_NTB:
|
||||
return legacy_hal::RTT_TYPE_2_SIDED_11AZ_NTB;
|
||||
};
|
||||
CHECK(false);
|
||||
}
|
||||
|
@ -2434,8 +2437,11 @@ RttType convertLegacyRttTypeToAidl(legacy_hal::wifi_rtt_type type) {
|
|||
switch (type) {
|
||||
case legacy_hal::RTT_TYPE_1_SIDED:
|
||||
return RttType::ONE_SIDED;
|
||||
case legacy_hal::RTT_TYPE_2_SIDED:
|
||||
return RttType::TWO_SIDED;
|
||||
case legacy_hal::RTT_TYPE_2_SIDED_11MC:
|
||||
// Same as legacy_hal::RTT_TYPE_2_SIDED
|
||||
return RttType::TWO_SIDED_11MC;
|
||||
case legacy_hal::RTT_TYPE_2_SIDED_11AZ_NTB:
|
||||
return RttType::TWO_SIDED_11AZ_NTB;
|
||||
};
|
||||
CHECK(false) << "Unknown legacy type: " << type;
|
||||
}
|
||||
|
@ -2515,6 +2521,8 @@ legacy_hal::wifi_rtt_preamble convertAidlRttPreambleToLegacy(RttPreamble type) {
|
|||
return legacy_hal::WIFI_RTT_PREAMBLE_HE;
|
||||
case RttPreamble::EHT:
|
||||
return legacy_hal::WIFI_RTT_PREAMBLE_EHT;
|
||||
case RttPreamble::INVALID:
|
||||
return legacy_hal::WIFI_RTT_PREAMBLE_INVALID;
|
||||
};
|
||||
CHECK(false);
|
||||
}
|
||||
|
@ -2531,6 +2539,8 @@ RttPreamble convertLegacyRttPreambleToAidl(legacy_hal::wifi_rtt_preamble type) {
|
|||
return RttPreamble::HE;
|
||||
case legacy_hal::WIFI_RTT_PREAMBLE_EHT:
|
||||
return RttPreamble::EHT;
|
||||
case legacy_hal::WIFI_RTT_PREAMBLE_INVALID:
|
||||
return RttPreamble::INVALID;
|
||||
};
|
||||
CHECK(false) << "Unknown legacy type: " << type;
|
||||
}
|
||||
|
@ -2720,6 +2730,21 @@ bool convertAidlRttConfigToLegacy(const RttConfig& aidl_config,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool convertAidlRttConfigToLegacyV3(const RttConfig& aidl_config,
|
||||
legacy_hal::wifi_rtt_config_v3* legacy_config) {
|
||||
if (!legacy_config) {
|
||||
return false;
|
||||
}
|
||||
*legacy_config = {};
|
||||
if (!convertAidlRttConfigToLegacy(aidl_config, &(legacy_config->rtt_config))) {
|
||||
return false;
|
||||
}
|
||||
legacy_config->tx_ltf_repetition_count = aidl_config.txLtfRepetitionCount;
|
||||
legacy_config->ntb_min_measurement_time_millis = aidl_config.ntbMinMeasurementTimeMillis;
|
||||
legacy_config->ntb_max_measurement_time_millis = aidl_config.ntbMaxMeasurementTimeMillis;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool convertAidlVectorOfRttConfigToLegacy(
|
||||
const std::vector<RttConfig>& aidl_configs,
|
||||
std::vector<legacy_hal::wifi_rtt_config>* legacy_configs) {
|
||||
|
@ -2729,7 +2754,24 @@ bool convertAidlVectorOfRttConfigToLegacy(
|
|||
*legacy_configs = {};
|
||||
for (const auto& aidl_config : aidl_configs) {
|
||||
legacy_hal::wifi_rtt_config legacy_config;
|
||||
if (!convertAidlRttConfigToLegacy(aidl_config, &legacy_config)) {
|
||||
if (!convertAidlRttConfigToLegacy(aidl_config, &(legacy_config))) {
|
||||
return false;
|
||||
}
|
||||
legacy_configs->push_back(legacy_config);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool convertAidlVectorOfRttConfigToLegacyV3(
|
||||
const std::vector<RttConfig>& aidl_configs,
|
||||
std::vector<legacy_hal::wifi_rtt_config_v3>* legacy_configs) {
|
||||
if (!legacy_configs) {
|
||||
return false;
|
||||
}
|
||||
*legacy_configs = {};
|
||||
for (const auto& aidl_config : aidl_configs) {
|
||||
legacy_hal::wifi_rtt_config_v3 legacy_config;
|
||||
if (!convertAidlRttConfigToLegacyV3(aidl_config, &legacy_config)) {
|
||||
return false;
|
||||
}
|
||||
legacy_configs->push_back(legacy_config);
|
||||
|
@ -2798,6 +2840,34 @@ bool convertLegacyRttResponderToAidl(const legacy_hal::wifi_rtt_responder& legac
|
|||
return true;
|
||||
}
|
||||
|
||||
RttPreamble convertLegacyRttPreambleBitmapToAidl(byte legacyPreambleBitmap) {
|
||||
int32_t aidlPreambleBitmap = 0;
|
||||
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,
|
||||
legacy_hal::WIFI_RTT_PREAMBLE_EHT}) {
|
||||
if (legacyPreambleBitmap & flag) {
|
||||
aidlPreambleBitmap |= static_cast<std::underlying_type<RttPreamble>::type>(
|
||||
convertLegacyRttPreambleToAidl(flag));
|
||||
}
|
||||
}
|
||||
|
||||
return static_cast<RttPreamble>(aidlPreambleBitmap);
|
||||
}
|
||||
|
||||
RttBw convertLegacyRttBwBitmapToAidl(byte legacyBwBitmap) {
|
||||
int32_t aidlBwBitmap = 0;
|
||||
for (const auto flag :
|
||||
{legacy_hal::WIFI_RTT_BW_5, legacy_hal::WIFI_RTT_BW_10, legacy_hal::WIFI_RTT_BW_20,
|
||||
legacy_hal::WIFI_RTT_BW_40, legacy_hal::WIFI_RTT_BW_80, legacy_hal::WIFI_RTT_BW_160,
|
||||
legacy_hal::WIFI_RTT_BW_320}) {
|
||||
if (legacyBwBitmap & flag) {
|
||||
aidlBwBitmap |=
|
||||
static_cast<std::underlying_type<RttBw>::type>(convertLegacyRttBwToAidl(flag));
|
||||
}
|
||||
}
|
||||
return static_cast<RttBw>(aidlBwBitmap);
|
||||
}
|
||||
|
||||
bool convertLegacyRttCapabilitiesToAidl(
|
||||
const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
|
||||
RttCapabilities* aidl_capabilities) {
|
||||
|
@ -2810,28 +2880,44 @@ bool convertLegacyRttCapabilitiesToAidl(
|
|||
aidl_capabilities->lciSupported = legacy_capabilities.lci_support;
|
||||
aidl_capabilities->lcrSupported = legacy_capabilities.lcr_support;
|
||||
aidl_capabilities->responderSupported = legacy_capabilities.responder_supported;
|
||||
int32_t preambleSupport = 0;
|
||||
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,
|
||||
legacy_hal::WIFI_RTT_PREAMBLE_EHT}) {
|
||||
if (legacy_capabilities.preamble_support & flag) {
|
||||
preambleSupport |= static_cast<std::underlying_type<RttPreamble>::type>(
|
||||
convertLegacyRttPreambleToAidl(flag));
|
||||
}
|
||||
}
|
||||
aidl_capabilities->preambleSupport = static_cast<RttPreamble>(preambleSupport);
|
||||
int32_t bwSupport = 0;
|
||||
for (const auto flag :
|
||||
{legacy_hal::WIFI_RTT_BW_5, legacy_hal::WIFI_RTT_BW_10, legacy_hal::WIFI_RTT_BW_20,
|
||||
legacy_hal::WIFI_RTT_BW_40, legacy_hal::WIFI_RTT_BW_80, legacy_hal::WIFI_RTT_BW_160,
|
||||
legacy_hal::WIFI_RTT_BW_320}) {
|
||||
if (legacy_capabilities.bw_support & flag) {
|
||||
bwSupport |=
|
||||
static_cast<std::underlying_type<RttBw>::type>(convertLegacyRttBwToAidl(flag));
|
||||
}
|
||||
}
|
||||
aidl_capabilities->bwSupport = static_cast<RttBw>(bwSupport);
|
||||
aidl_capabilities->preambleSupport =
|
||||
convertLegacyRttPreambleBitmapToAidl(legacy_capabilities.preamble_support);
|
||||
aidl_capabilities->bwSupport = convertLegacyRttBwBitmapToAidl(legacy_capabilities.bw_support);
|
||||
aidl_capabilities->mcVersion = legacy_capabilities.mc_version;
|
||||
// Initialize 11az parameters to default
|
||||
aidl_capabilities->azPreambleSupport = RttPreamble::INVALID;
|
||||
aidl_capabilities->azBwSupport = RttBw::BW_UNSPECIFIED;
|
||||
aidl_capabilities->ntbInitiatorSupported = false;
|
||||
aidl_capabilities->ntbResponderSupported = false;
|
||||
aidl_capabilities->maxTxLtfRepetitionCount = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool convertLegacyRttCapabilitiesV3ToAidl(
|
||||
const legacy_hal::wifi_rtt_capabilities_v3& legacy_capabilities_v3,
|
||||
RttCapabilities* aidl_capabilities) {
|
||||
if (!aidl_capabilities) {
|
||||
return false;
|
||||
}
|
||||
*aidl_capabilities = {};
|
||||
aidl_capabilities->rttOneSidedSupported =
|
||||
legacy_capabilities_v3.rtt_capab.rtt_one_sided_supported;
|
||||
aidl_capabilities->rttFtmSupported = legacy_capabilities_v3.rtt_capab.rtt_ftm_supported;
|
||||
aidl_capabilities->lciSupported = legacy_capabilities_v3.rtt_capab.lci_support;
|
||||
aidl_capabilities->lcrSupported = legacy_capabilities_v3.rtt_capab.lcr_support;
|
||||
aidl_capabilities->responderSupported = legacy_capabilities_v3.rtt_capab.responder_supported;
|
||||
aidl_capabilities->preambleSupport =
|
||||
convertLegacyRttPreambleBitmapToAidl(legacy_capabilities_v3.rtt_capab.preamble_support);
|
||||
aidl_capabilities->bwSupport =
|
||||
convertLegacyRttBwBitmapToAidl(legacy_capabilities_v3.rtt_capab.bw_support);
|
||||
aidl_capabilities->mcVersion = legacy_capabilities_v3.rtt_capab.mc_version;
|
||||
aidl_capabilities->azPreambleSupport =
|
||||
convertLegacyRttPreambleBitmapToAidl(legacy_capabilities_v3.az_preamble_support);
|
||||
aidl_capabilities->azBwSupport =
|
||||
convertLegacyRttBwBitmapToAidl(legacy_capabilities_v3.az_bw_support);
|
||||
aidl_capabilities->ntbInitiatorSupported = legacy_capabilities_v3.ntb_initiator_supported;
|
||||
aidl_capabilities->ntbResponderSupported = legacy_capabilities_v3.ntb_responder_supported;
|
||||
aidl_capabilities->maxTxLtfRepetitionCount = legacy_capabilities_v3.max_tx_ltf_repetition_count;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2906,6 +2992,9 @@ bool convertLegacyVectorOfRttResultToAidl(
|
|||
}
|
||||
aidl_result.channelFreqMHz = 0;
|
||||
aidl_result.packetBw = RttBw::BW_UNSPECIFIED;
|
||||
aidl_result.txLtfRepetitionCount = 0;
|
||||
aidl_result.ntbMinMeasurementTimeMillis = 0;
|
||||
aidl_result.ntbMaxMeasurementTimeMillis = 0;
|
||||
aidl_results->push_back(aidl_result);
|
||||
}
|
||||
return true;
|
||||
|
@ -2926,6 +3015,33 @@ bool convertLegacyVectorOfRttResultV2ToAidl(
|
|||
aidl_result.channelFreqMHz =
|
||||
legacy_result->frequency != UNSPECIFIED ? legacy_result->frequency : 0;
|
||||
aidl_result.packetBw = convertLegacyRttBwToAidl(legacy_result->packet_bw);
|
||||
aidl_result.txLtfRepetitionCount = 0;
|
||||
aidl_result.ntbMinMeasurementTimeMillis = 0;
|
||||
aidl_result.ntbMaxMeasurementTimeMillis = 0;
|
||||
aidl_results->push_back(aidl_result);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool convertLegacyVectorOfRttResultV3ToAidl(
|
||||
const std::vector<const legacy_hal::wifi_rtt_result_v3*>& legacy_results,
|
||||
std::vector<RttResult>* aidl_results) {
|
||||
if (!aidl_results) {
|
||||
return false;
|
||||
}
|
||||
*aidl_results = {};
|
||||
for (const auto legacy_result : legacy_results) {
|
||||
RttResult aidl_result;
|
||||
if (!convertLegacyRttResultToAidl(legacy_result->rtt_result.rtt_result, &aidl_result)) {
|
||||
return false;
|
||||
}
|
||||
aidl_result.channelFreqMHz = legacy_result->rtt_result.frequency != UNSPECIFIED
|
||||
? legacy_result->rtt_result.frequency
|
||||
: 0;
|
||||
aidl_result.packetBw = convertLegacyRttBwToAidl(legacy_result->rtt_result.packet_bw);
|
||||
aidl_result.txLtfRepetitionCount = legacy_result->tx_ltf_repetition_count;
|
||||
aidl_result.ntbMinMeasurementTimeMillis = legacy_result->ntb_min_measurement_time_millis;
|
||||
aidl_result.ntbMaxMeasurementTimeMillis = legacy_result->ntb_max_measurement_time_millis;
|
||||
aidl_results->push_back(aidl_result);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -148,6 +148,10 @@ bool convertLegacyNanDataPathScheduleUpdateIndToAidl(
|
|||
// RTT controller conversion methods.
|
||||
bool convertAidlVectorOfRttConfigToLegacy(const std::vector<RttConfig>& aidl_configs,
|
||||
std::vector<legacy_hal::wifi_rtt_config>* legacy_configs);
|
||||
bool convertAidlVectorOfRttConfigToLegacyV3(
|
||||
const std::vector<RttConfig>& aidl_configs,
|
||||
std::vector<legacy_hal::wifi_rtt_config_v3>* legacy_configs);
|
||||
|
||||
bool convertAidlRttLciInformationToLegacy(const RttLciInformation& aidl_info,
|
||||
legacy_hal::wifi_lci_information* legacy_info);
|
||||
bool convertAidlRttLcrInformationToLegacy(const RttLcrInformation& aidl_info,
|
||||
|
@ -161,12 +165,19 @@ bool convertLegacyRttResponderToAidl(const legacy_hal::wifi_rtt_responder& legac
|
|||
bool convertLegacyRttCapabilitiesToAidl(
|
||||
const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
|
||||
RttCapabilities* aidl_capabilities);
|
||||
bool convertLegacyRttCapabilitiesV3ToAidl(
|
||||
const legacy_hal::wifi_rtt_capabilities_v3& legacy_capabilities_v3,
|
||||
RttCapabilities* aidl_capabilities);
|
||||
|
||||
bool convertLegacyVectorOfRttResultToAidl(
|
||||
const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
|
||||
std::vector<RttResult>* aidl_results);
|
||||
bool convertLegacyVectorOfRttResultV2ToAidl(
|
||||
const std::vector<const legacy_hal::wifi_rtt_result_v2*>& legacy_results,
|
||||
std::vector<RttResult>* aidl_results);
|
||||
bool convertLegacyVectorOfRttResultV3ToAidl(
|
||||
const std::vector<const legacy_hal::wifi_rtt_result_v3*>& legacy_results,
|
||||
std::vector<RttResult>* aidl_results);
|
||||
uint32_t convertAidlWifiBandToLegacyMacBand(WifiBand band);
|
||||
uint32_t convertAidlWifiIfaceModeToLegacy(uint32_t aidl_iface_mask);
|
||||
uint32_t convertAidlUsableChannelFilterToLegacy(uint32_t aidl_filter_mask);
|
||||
|
|
|
@ -183,10 +183,13 @@ std::function<void(wifi_request_id, unsigned num_results, wifi_rtt_result* rtt_r
|
|||
on_rtt_results_internal_callback;
|
||||
std::function<void(wifi_request_id, unsigned num_results, wifi_rtt_result_v2* rtt_results_v2[])>
|
||||
on_rtt_results_internal_callback_v2;
|
||||
std::function<void(wifi_request_id, unsigned num_results, wifi_rtt_result_v3* rtt_results_v3[])>
|
||||
on_rtt_results_internal_callback_v3;
|
||||
|
||||
void invalidateRttResultsCallbacks() {
|
||||
on_rtt_results_internal_callback = nullptr;
|
||||
on_rtt_results_internal_callback_v2 = nullptr;
|
||||
on_rtt_results_internal_callback_v3 = nullptr;
|
||||
};
|
||||
|
||||
void onAsyncRttResults(wifi_request_id id, unsigned num_results, wifi_rtt_result* rtt_results[]) {
|
||||
|
@ -206,6 +209,15 @@ void onAsyncRttResultsV2(wifi_request_id id, unsigned num_results,
|
|||
}
|
||||
}
|
||||
|
||||
void onAsyncRttResultsV3(wifi_request_id id, unsigned num_results,
|
||||
wifi_rtt_result_v3* rtt_results_v3[]) {
|
||||
const auto lock = aidl_sync_util::acquireGlobalLock();
|
||||
if (on_rtt_results_internal_callback_v3) {
|
||||
on_rtt_results_internal_callback_v3(id, num_results, rtt_results_v3);
|
||||
invalidateRttResultsCallbacks();
|
||||
}
|
||||
}
|
||||
|
||||
// Callbacks for the various NAN operations.
|
||||
// NOTE: These have very little conversions to perform before invoking the user
|
||||
// callbacks.
|
||||
|
@ -1252,6 +1264,38 @@ wifi_error WifiLegacyHal::registerSubsystemRestartCallbackHandler(
|
|||
return status;
|
||||
}
|
||||
|
||||
wifi_error WifiLegacyHal::startRttRangeRequestV3(
|
||||
const std::string& iface_name, wifi_request_id id,
|
||||
const std::vector<wifi_rtt_config_v3>& rtt_configs,
|
||||
const on_rtt_results_callback_v3& on_results_user_callback_v3) {
|
||||
if (on_rtt_results_internal_callback_v3) {
|
||||
return WIFI_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
on_rtt_results_internal_callback_v3 = [on_results_user_callback_v3](
|
||||
wifi_request_id id, unsigned num_results,
|
||||
wifi_rtt_result_v3* rtt_results_v3[]) {
|
||||
if (num_results > 0 && !rtt_results_v3) {
|
||||
LOG(ERROR) << "Unexpected nullptr in RTT v3 results";
|
||||
return;
|
||||
}
|
||||
std::vector<const wifi_rtt_result_v3*> rtt_results_vec_v3;
|
||||
std::copy_if(rtt_results_v3, rtt_results_v3 + num_results,
|
||||
back_inserter(rtt_results_vec_v3),
|
||||
[](wifi_rtt_result_v3* rtt_result_v3) { return rtt_result_v3 != nullptr; });
|
||||
on_results_user_callback_v3(id, rtt_results_vec_v3);
|
||||
};
|
||||
|
||||
std::vector<wifi_rtt_config_v3> rtt_configs_internal(rtt_configs);
|
||||
wifi_error status = global_func_table_.wifi_rtt_range_request_v3(
|
||||
id, getIfaceHandle(iface_name), rtt_configs.size(), rtt_configs_internal.data(),
|
||||
{onAsyncRttResultsV3});
|
||||
if (status != WIFI_SUCCESS) {
|
||||
invalidateRttResultsCallbacks();
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
wifi_error WifiLegacyHal::startRttRangeRequest(
|
||||
const std::string& iface_name, wifi_request_id id,
|
||||
const std::vector<wifi_rtt_config>& rtt_configs,
|
||||
|
@ -1328,6 +1372,14 @@ std::pair<wifi_error, wifi_rtt_capabilities> WifiLegacyHal::getRttCapabilities(
|
|||
return {status, rtt_caps};
|
||||
}
|
||||
|
||||
std::pair<wifi_error, wifi_rtt_capabilities_v3> WifiLegacyHal::getRttCapabilitiesV3(
|
||||
const std::string& iface_name) {
|
||||
wifi_rtt_capabilities_v3 rtt_caps_v3;
|
||||
wifi_error status = global_func_table_.wifi_get_rtt_capabilities_v3(getIfaceHandle(iface_name),
|
||||
&rtt_caps_v3);
|
||||
return {status, rtt_caps_v3};
|
||||
}
|
||||
|
||||
std::pair<wifi_error, wifi_rtt_responder> WifiLegacyHal::getRttResponderInfo(
|
||||
const std::string& iface_name) {
|
||||
wifi_rtt_responder rtt_responder;
|
||||
|
|
|
@ -215,6 +215,8 @@ using ::RTT_STATUS_NO_WIFI;
|
|||
using ::RTT_STATUS_SUCCESS;
|
||||
using ::RTT_TYPE_1_SIDED;
|
||||
using ::RTT_TYPE_2_SIDED;
|
||||
using ::RTT_TYPE_2_SIDED_11AZ_NTB;
|
||||
using ::RTT_TYPE_2_SIDED_11MC;
|
||||
using ::RX_PKT_FATE_DRV_DROP_FILTER;
|
||||
using ::RX_PKT_FATE_DRV_DROP_INVALID;
|
||||
using ::RX_PKT_FATE_DRV_DROP_NOBUFS;
|
||||
|
@ -351,16 +353,20 @@ using ::WIFI_RTT_BW_5;
|
|||
using ::WIFI_RTT_BW_80;
|
||||
using ::WIFI_RTT_BW_UNSPECIFIED;
|
||||
using ::wifi_rtt_capabilities;
|
||||
using ::wifi_rtt_capabilities_v3;
|
||||
using ::wifi_rtt_config;
|
||||
using ::wifi_rtt_config_v3;
|
||||
using ::wifi_rtt_preamble;
|
||||
using ::WIFI_RTT_PREAMBLE_EHT;
|
||||
using ::WIFI_RTT_PREAMBLE_HE;
|
||||
using ::WIFI_RTT_PREAMBLE_HT;
|
||||
using ::WIFI_RTT_PREAMBLE_INVALID;
|
||||
using ::WIFI_RTT_PREAMBLE_LEGACY;
|
||||
using ::WIFI_RTT_PREAMBLE_VHT;
|
||||
using ::wifi_rtt_responder;
|
||||
using ::wifi_rtt_result;
|
||||
using ::wifi_rtt_result_v2;
|
||||
using ::wifi_rtt_result_v3;
|
||||
using ::wifi_rtt_status;
|
||||
using ::wifi_rtt_type;
|
||||
using ::wifi_rx_packet_fate;
|
||||
|
@ -493,6 +499,8 @@ using on_rtt_results_callback =
|
|||
std::function<void(wifi_request_id, const std::vector<const wifi_rtt_result*>&)>;
|
||||
using on_rtt_results_callback_v2 =
|
||||
std::function<void(wifi_request_id, const std::vector<const wifi_rtt_result_v2*>&)>;
|
||||
using on_rtt_results_callback_v3 =
|
||||
std::function<void(wifi_request_id, const std::vector<const wifi_rtt_result_v3*>&)>;
|
||||
|
||||
// Callback for ring buffer data.
|
||||
using on_ring_buffer_data_callback = std::function<void(
|
||||
|
@ -668,9 +676,15 @@ class WifiLegacyHal {
|
|||
const std::vector<wifi_rtt_config>& rtt_configs,
|
||||
const on_rtt_results_callback& on_results_callback,
|
||||
const on_rtt_results_callback_v2& on_results_callback_v2);
|
||||
wifi_error startRttRangeRequestV3(const std::string& iface_name, wifi_request_id id,
|
||||
const std::vector<wifi_rtt_config_v3>& rtt_configs,
|
||||
const on_rtt_results_callback_v3& on_results_callback);
|
||||
|
||||
wifi_error cancelRttRangeRequest(const std::string& iface_name, wifi_request_id id,
|
||||
const std::vector<std::array<uint8_t, ETH_ALEN>>& mac_addrs);
|
||||
std::pair<wifi_error, wifi_rtt_capabilities> getRttCapabilities(const std::string& iface_name);
|
||||
std::pair<wifi_error, wifi_rtt_capabilities_v3> getRttCapabilitiesV3(
|
||||
const std::string& iface_name);
|
||||
std::pair<wifi_error, wifi_rtt_responder> getRttResponderInfo(const std::string& iface_name);
|
||||
wifi_error enableRttResponder(const std::string& iface_name, wifi_request_id id,
|
||||
const wifi_channel_info& channel_hint, uint32_t max_duration_secs,
|
||||
|
|
|
@ -179,6 +179,8 @@ bool initHalFuncTableWithStubs(wifi_hal_fn* hal_fn) {
|
|||
populateStubFor(&hal_fn->wifi_set_scan_mode);
|
||||
populateStubFor(&hal_fn->wifi_set_mlo_mode);
|
||||
populateStubFor(&hal_fn->wifi_get_supported_iface_concurrency_matrix);
|
||||
populateStubFor(&hal_fn->wifi_get_rtt_capabilities_v3);
|
||||
populateStubFor(&hal_fn->wifi_rtt_range_request_v3);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -136,11 +136,45 @@ ndk::ScopedAStatus WifiRttController::registerEventCallbackInternal(
|
|||
|
||||
ndk::ScopedAStatus WifiRttController::rangeRequestInternal(
|
||||
int32_t cmd_id, const std::vector<RttConfig>& rtt_configs) {
|
||||
// Try 11mc & 11az ranging (v3)
|
||||
std::vector<legacy_hal::wifi_rtt_config_v3> legacy_configs_v3;
|
||||
if (!aidl_struct_util::convertAidlVectorOfRttConfigToLegacyV3(rtt_configs,
|
||||
&legacy_configs_v3)) {
|
||||
return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
|
||||
}
|
||||
std::weak_ptr<WifiRttController> weak_ptr_this = weak_ptr_this_;
|
||||
const auto& on_results_callback_v3 =
|
||||
[weak_ptr_this](legacy_hal::wifi_request_id id,
|
||||
const std::vector<const legacy_hal::wifi_rtt_result_v3*>& results) {
|
||||
const auto shared_ptr_this = weak_ptr_this.lock();
|
||||
if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
|
||||
LOG(ERROR) << "v3 Callback invoked on an invalid object";
|
||||
return;
|
||||
}
|
||||
std::vector<RttResult> aidl_results;
|
||||
if (!aidl_struct_util::convertLegacyVectorOfRttResultV3ToAidl(results,
|
||||
&aidl_results)) {
|
||||
LOG(ERROR) << "Failed to convert rtt results v3 to AIDL structs";
|
||||
return;
|
||||
}
|
||||
for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
|
||||
if (!callback->onResults(id, aidl_results).isOk()) {
|
||||
LOG(ERROR) << "Failed to invoke the v3 callback";
|
||||
}
|
||||
}
|
||||
};
|
||||
legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->startRttRangeRequestV3(
|
||||
ifname_, cmd_id, legacy_configs_v3, on_results_callback_v3);
|
||||
|
||||
if (legacy_status != legacy_hal::WIFI_ERROR_NOT_SUPPORTED) {
|
||||
return createWifiStatusFromLegacyError(legacy_status);
|
||||
}
|
||||
|
||||
// Fallback to 11mc ranging.
|
||||
std::vector<legacy_hal::wifi_rtt_config> legacy_configs;
|
||||
if (!aidl_struct_util::convertAidlVectorOfRttConfigToLegacy(rtt_configs, &legacy_configs)) {
|
||||
return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
|
||||
}
|
||||
std::weak_ptr<WifiRttController> weak_ptr_this = weak_ptr_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) {
|
||||
|
@ -181,7 +215,7 @@ ndk::ScopedAStatus WifiRttController::rangeRequestInternal(
|
|||
}
|
||||
}
|
||||
};
|
||||
legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->startRttRangeRequest(
|
||||
legacy_status = legacy_hal_.lock()->startRttRangeRequest(
|
||||
ifname_, cmd_id, legacy_configs, on_results_callback, on_results_callback_v2);
|
||||
return createWifiStatusFromLegacyError(legacy_status);
|
||||
}
|
||||
|
@ -201,13 +235,29 @@ ndk::ScopedAStatus WifiRttController::rangeCancelInternal(int32_t cmd_id,
|
|||
|
||||
std::pair<RttCapabilities, ndk::ScopedAStatus> 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_);
|
||||
legacy_hal::wifi_rtt_capabilities_v3 legacy_caps_v3;
|
||||
std::tie(legacy_status, legacy_caps_v3) = legacy_hal_.lock()->getRttCapabilitiesV3(ifname_);
|
||||
// Try v3 API first, if it is not supported fallback.
|
||||
if (legacy_status == legacy_hal::WIFI_ERROR_NOT_SUPPORTED) {
|
||||
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 {RttCapabilities{}, createWifiStatusFromLegacyError(legacy_status)};
|
||||
}
|
||||
|
||||
RttCapabilities aidl_caps;
|
||||
if (!aidl_struct_util::convertLegacyRttCapabilitiesToAidl(legacy_caps, &aidl_caps)) {
|
||||
return {RttCapabilities{}, createWifiStatus(WifiStatusCode::ERROR_UNKNOWN)};
|
||||
}
|
||||
return {aidl_caps, ndk::ScopedAStatus::ok()};
|
||||
}
|
||||
|
||||
if (legacy_status != legacy_hal::WIFI_SUCCESS) {
|
||||
return {RttCapabilities{}, createWifiStatusFromLegacyError(legacy_status)};
|
||||
}
|
||||
|
||||
RttCapabilities aidl_caps;
|
||||
if (!aidl_struct_util::convertLegacyRttCapabilitiesToAidl(legacy_caps, &aidl_caps)) {
|
||||
if (!aidl_struct_util::convertLegacyRttCapabilitiesV3ToAidl(legacy_caps_v3, &aidl_caps)) {
|
||||
return {RttCapabilities{}, createWifiStatus(WifiStatusCode::ERROR_UNKNOWN)};
|
||||
}
|
||||
return {aidl_caps, ndk::ScopedAStatus::ok()};
|
||||
|
|
Loading…
Reference in a new issue