From 399250bea3e11e1547ccb6d39eaea5039ca6364e Mon Sep 17 00:00:00 2001
From: Chienyuan Huang <chienyuanhuang@google.com>
Date: Wed, 7 Feb 2024 09:58:12 +0000
Subject: [PATCH] Add a flag for Channel Sounding in stack

Bug: 324185011
Bug: 315241296
Test: m com.android.btservices
Change-Id: I7e6c15a97b29bfd91cb2633bbec4ec1a3c4df83d
---
 flags/ranging.aconfig                         | 7 +++++++
 system/gd/hci/distance_measurement_manager.cc | 6 +++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/flags/ranging.aconfig b/flags/ranging.aconfig
index 1be1b6edf74..16c7701ad79 100644
--- a/flags/ranging.aconfig
+++ b/flags/ranging.aconfig
@@ -6,3 +6,10 @@ flag {
     description: "Enable Channel Sounding"
     bug: "317683528"
 }
+
+flag {
+    name: "channel_sounding_in_stack"
+    namespace: "bluetooth"
+    description: "Enable Channel Sounding in the Bluetooth stack"
+    bug: "324185011"
+}
\ No newline at end of file
diff --git a/system/gd/hci/distance_measurement_manager.cc b/system/gd/hci/distance_measurement_manager.cc
index f8a26c575ab..dac1d9a9370 100644
--- a/system/gd/hci/distance_measurement_manager.cc
+++ b/system/gd/hci/distance_measurement_manager.cc
@@ -110,8 +110,8 @@ struct DistanceMeasurementManager::impl {
     hci_layer_->RegisterLeEventHandler(
         hci::SubeventCode::TRANSMIT_POWER_REPORTING,
         handler_->BindOn(this, &impl::on_transmit_power_reporting));
-    if (!IS_FLAG_ENABLED(channel_sounding)) {
-      LOG_INFO("IS_FLAG_ENABLED channel_sounding: false");
+    if (!IS_FLAG_ENABLED(channel_sounding_in_stack)) {
+      LOG_INFO("IS_FLAG_ENABLED channel_sounding_in_stack: false");
       return;
     }
     distance_measurement_interface_ = hci_layer_->GetDistanceMeasurementInterface(
@@ -172,7 +172,7 @@ struct DistanceMeasurementManager::impl {
         "connection_handle: %d, address: %s",
         connection_handle,
         ADDRESS_TO_LOGGABLE_CSTR(cs_remote_address));
-    if (!IS_FLAG_ENABLED(channel_sounding)) {
+    if (!IS_FLAG_ENABLED(channel_sounding_in_stack)) {
       LOG_ERROR("Channel Sounding is not enabled");
       distance_measurement_callbacks_->OnDistanceMeasurementStartFail(
           cs_remote_address, REASON_INTERNAL_ERROR, METHOD_CS);
-- 
GitLab