summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-11-22 21:23:56 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-11-22 21:23:56 +0000
commit5fc26449f4f04407de25a6d548dc30549182fb21 (patch)
treec335130874b7dfeeeee2a95bbe87008a0eb090e9
parent5ca46201785cda45443f3cea5b6f3f37e6944915 (diff)
parentec562c33c1705e4942f0da40200c27b140304ebb (diff)
Merge "pass CS config parameters to hal" into main
-rw-r--r--system/gd/Android.bp2
-rw-r--r--system/gd/hal/ranging_hal.h9
-rw-r--r--system/gd/hal/ranging_hal_android.cc86
-rw-r--r--system/gd/hal/ranging_hal_host.cc9
-rw-r--r--system/gd/hci/distance_measurement_manager.cc8
5 files changed, 112 insertions, 2 deletions
diff --git a/system/gd/Android.bp b/system/gd/Android.bp
index b9e029a719..1f085d9871 100644
--- a/system/gd/Android.bp
+++ b/system/gd/Android.bp
@@ -116,7 +116,7 @@ cc_defaults {
],
whole_static_libs: [
"android.hardware.bluetooth-V1-ndk",
- "android.hardware.bluetooth.ranging-V1-ndk",
+ "android.hardware.bluetooth.ranging-V2-ndk",
],
},
},
diff --git a/system/gd/hal/ranging_hal.h b/system/gd/hal/ranging_hal.h
index 40afe0bbc9..19b2497905 100644
--- a/system/gd/hal/ranging_hal.h
+++ b/system/gd/hal/ranging_hal.h
@@ -18,11 +18,11 @@
#include <complex>
+#include "hci/hci_packets.h"
#include "module.h"
namespace bluetooth {
namespace hal {
-
enum RangingHalVersion {
V_UNKNOWN = 0,
V_1 = 1,
@@ -70,6 +70,7 @@ public:
virtual ~RangingHal() = default;
virtual bool IsBound() = 0;
+ virtual RangingHalVersion GetRangingHalVersion() = 0;
virtual void RegisterCallback(RangingHalCallback* callback) = 0;
virtual std::vector<VendorSpecificCharacteristic> GetVendorSpecificCharacteristics() = 0;
virtual void OpenSession(
@@ -79,6 +80,12 @@ public:
uint16_t connection_handle,
const std::vector<hal::VendorSpecificCharacteristic>& vendor_specific_reply) = 0;
virtual void WriteRawData(uint16_t connection_handle, const ChannelSoundingRawData& raw_data) = 0;
+ virtual void UpdateChannelSoundingConfig(
+ uint16_t connection_handle,
+ const hci::LeCsConfigCompleteView& leCsConfigCompleteView) = 0;
+ virtual void UpdateProcedureEnableConfig(
+ uint16_t connection_handle,
+ const hci::LeCsProcedureEnableCompleteView& leCsProcedureEnableCompleteView) = 0;
};
} // namespace hal
diff --git a/system/gd/hal/ranging_hal_android.cc b/system/gd/hal/ranging_hal_android.cc
index c24a40ca31..1b0df4a9a6 100644
--- a/system/gd/hal/ranging_hal_android.cc
+++ b/system/gd/hal/ranging_hal_android.cc
@@ -32,13 +32,24 @@
using aidl::android::hardware::bluetooth::ranging::BluetoothChannelSoundingParameters;
using aidl::android::hardware::bluetooth::ranging::BnBluetoothChannelSoundingSessionCallback;
+using aidl::android::hardware::bluetooth::ranging::Ch3cShapeType;
+using aidl::android::hardware::bluetooth::ranging::ChannelSelectionType;
using aidl::android::hardware::bluetooth::ranging::ChannelSoudingRawData;
+using aidl::android::hardware::bluetooth::ranging::ChannelSoundingProcedureData;
using aidl::android::hardware::bluetooth::ranging::ComplexNumber;
+using aidl::android::hardware::bluetooth::ranging::Config;
+using aidl::android::hardware::bluetooth::ranging::CsSyncPhyType;
using aidl::android::hardware::bluetooth::ranging::IBluetoothChannelSounding;
using aidl::android::hardware::bluetooth::ranging::IBluetoothChannelSoundingSession;
using aidl::android::hardware::bluetooth::ranging::IBluetoothChannelSoundingSessionCallback;
+using aidl::android::hardware::bluetooth::ranging::ModeType;
+using aidl::android::hardware::bluetooth::ranging::ProcedureEnableConfig;
+using aidl::android::hardware::bluetooth::ranging::Role;
+using aidl::android::hardware::bluetooth::ranging::RttType;
using aidl::android::hardware::bluetooth::ranging::StepTonePct;
+using aidl::android::hardware::bluetooth::ranging::SubModeType;
using aidl::android::hardware::bluetooth::ranging::VendorSpecificData;
+// using aidl::android::hardware::bluetooth::ranging::
namespace bluetooth {
namespace hal {
@@ -236,6 +247,81 @@ public:
session_trackers_[connection_handle]->GetSession()->writeRawData(hal_raw_data);
}
+ void UpdateChannelSoundingConfig(
+ uint16_t connection_handle,
+ const hci::LeCsConfigCompleteView& leCsConfigCompleteView) override {
+ auto it = session_trackers_.find(connection_handle);
+ if (it == session_trackers_.end()) {
+ log::error("Can't find session for connection_handle:0x{:04x}", connection_handle);
+ return;
+ } else if (it->second->GetSession() == nullptr) {
+ log::error("Session not opened");
+ return;
+ }
+
+ Config csConfig{
+ .modeType = static_cast<ModeType>(
+ static_cast<int>(leCsConfigCompleteView.GetMainModeType())),
+ .subModeType = static_cast<SubModeType>(
+ static_cast<int>(leCsConfigCompleteView.GetSubModeType())),
+ .rttType = static_cast<RttType>(static_cast<int>(leCsConfigCompleteView.GetRttType())),
+ .channelMap = leCsConfigCompleteView.GetChannelMap(),
+ .minMainModeSteps = leCsConfigCompleteView.GetMinMainModeSteps(),
+ .maxMainModeSteps = leCsConfigCompleteView.GetMaxMainModeSteps(),
+ .mainModeRepetition =
+ static_cast<int8_t>(leCsConfigCompleteView.GetMainModeRepetition()),
+ .mode0Steps = static_cast<int8_t>(leCsConfigCompleteView.GetMode0Steps()),
+ .role = static_cast<Role>(static_cast<int>(leCsConfigCompleteView.GetRole())),
+ .csSyncPhyType = static_cast<CsSyncPhyType>(
+ static_cast<int>(leCsConfigCompleteView.GetCsSyncPhy())),
+ .channelSelectionType = static_cast<ChannelSelectionType>(
+ static_cast<int>(leCsConfigCompleteView.GetChannelSelectionType())),
+ .ch3cShapeType = static_cast<Ch3cShapeType>(
+ static_cast<int>(leCsConfigCompleteView.GetCh3cShape())),
+ .ch3cJump = static_cast<int8_t>(leCsConfigCompleteView.GetCh3cJump()),
+ .channelMapRepetition = leCsConfigCompleteView.GetChannelMapRepetition(),
+ .tIp1TimeUs = leCsConfigCompleteView.GetTIp1Time(),
+ .tIp2TimeUs = leCsConfigCompleteView.GetTIp2Time(),
+ .tFcsTimeUs = leCsConfigCompleteView.GetTFcsTime(),
+ .tPmTimeUs = static_cast<int8_t>(leCsConfigCompleteView.GetTPmTime()),
+ // TODO(b/378942784): specify the following values.
+ .tSwTimeUsSupportedByLocal = 0,
+ .tSwTimeUsSupportedByRemote = 0,
+ .bleConnInterval = 0,
+ };
+ it->second->GetSession()->updateChannelSoundingConfig(csConfig);
+ }
+
+ void UpdateProcedureEnableConfig(
+ uint16_t connection_handle,
+ const hci::LeCsProcedureEnableCompleteView& leCsProcedureEnableCompleteView) override {
+ auto it = session_trackers_.find(connection_handle);
+ if (it == session_trackers_.end()) {
+ log::error("Can't find session for connection_handle:0x{:04x}", connection_handle);
+ return;
+ } else if (it->second->GetSession() == nullptr) {
+ log::error("Session not opened");
+ return;
+ }
+
+ ProcedureEnableConfig pConfig{
+ .toneAntennaConfigSelection = static_cast<int8_t>(
+ leCsProcedureEnableCompleteView.GetToneAntennaConfigSelection()),
+ .subeventLenUs = static_cast<int>(leCsProcedureEnableCompleteView.GetSubeventLen()),
+ .subeventsPerEvent =
+ static_cast<int8_t>(leCsProcedureEnableCompleteView.GetSubeventsPerEvent()),
+ .subeventInterval = leCsProcedureEnableCompleteView.GetSubeventInterval(),
+ .eventInterval = leCsProcedureEnableCompleteView.GetEventInterval(),
+ .procedureInterval = leCsProcedureEnableCompleteView.GetProcedureInterval(),
+ .procedureCount = leCsProcedureEnableCompleteView.GetProcedureCount(),
+ // TODO(b/378942784): update the max procedure len, the current complete view does not
+ // have it.
+ .maxProcedureLen = 0,
+ };
+
+ it->second->GetSession()->updateProcedureEnableConfig(pConfig);
+ }
+
void CopyVendorSpecificData(const std::vector<hal::VendorSpecificCharacteristic>& source,
std::optional<std::vector<std::optional<VendorSpecificData>>>& dist) {
dist = std::make_optional<std::vector<std::optional<VendorSpecificData>>>();
diff --git a/system/gd/hal/ranging_hal_host.cc b/system/gd/hal/ranging_hal_host.cc
index b11d20dd65..7530be84ee 100644
--- a/system/gd/hal/ranging_hal_host.cc
+++ b/system/gd/hal/ranging_hal_host.cc
@@ -45,6 +45,15 @@ public:
void WriteRawData(uint16_t /* connection_handle */,
const ChannelSoundingRawData& /* raw_data */) override {}
+ void UpdateChannelSoundingConfig(
+ uint16_t /* connection_handle */,
+ const hci::LeCsConfigCompleteView& /* leCsConfigCompleteView */) override {}
+
+ void UpdateProcedureEnableConfig(
+ uint16_t /* connection_handle */,
+ const hci::LeCsProcedureEnableCompleteView& /* leCsProcedureEnableCompleteView */)
+ override {}
+
protected:
void ListDependencies(ModuleList* /*list*/) const {}
diff --git a/system/gd/hci/distance_measurement_manager.cc b/system/gd/hci/distance_measurement_manager.cc
index fd15f66b0d..d98778ecb2 100644
--- a/system/gd/hci/distance_measurement_manager.cc
+++ b/system/gd/hci/distance_measurement_manager.cc
@@ -939,6 +939,10 @@ struct DistanceMeasurementManager::impl : bluetooth::hal::RangingHalCallback {
live_tracker->main_mode_type = event_view.GetMainModeType();
live_tracker->sub_mode_type = event_view.GetSubModeType();
live_tracker->rtt_type = event_view.GetRttType();
+ if (com::android::bluetooth::flags::channel_sounding_25q2_apis() && live_tracker->local_start &&
+ ranging_hal_->GetRangingHalVersion() == hal::V_2) {
+ ranging_hal_->UpdateChannelSoundingConfig(connection_handle, event_view);
+ }
if (live_tracker->local_hci_role == hci::Role::CENTRAL) {
// send the cmd from the BLE central only.
send_le_cs_security_enable(connection_handle);
@@ -1091,6 +1095,10 @@ struct DistanceMeasurementManager::impl : bluetooth::hal::RangingHalCallback {
distance_measurement_callbacks_->OnDistanceMeasurementStarted(live_tracker->address,
METHOD_CS);
}
+ if (com::android::bluetooth::flags::channel_sounding_25q2_apis() &&
+ live_tracker->local_start && ranging_hal_->GetRangingHalVersion() == hal::V_2) {
+ ranging_hal_->UpdateProcedureEnableConfig(connection_handle, event_view);
+ }
} else if (event_view.GetState() == Enable::DISABLED) {
uint8_t valid_requester_states = static_cast<uint8_t>(CsTrackerState::STARTED);
uint8_t valid_responder_states = static_cast<uint8_t>(CsTrackerState::STARTED);