Cleanup platform flag

PiperOrigin-RevId: 748062326
This commit is contained in:
Guogang Li
2025-04-15 16:18:43 -07:00
committed by Copybara-Service
parent 8270e0548c
commit eeedf9f9c4
3 changed files with 6 additions and 35 deletions
@@ -33,10 +33,6 @@ namespace nearby_platform_feature {
constexpr auto kEnableHotspotWin32Socket =
flags::Flag<bool>(kConfigPackage, "45401992", true);
// Disable/Enable GATT feature in BLE V2.
constexpr auto kEnableBleV2Gatt =
flags::Flag<bool>(kConfigPackage, "45415180", false);
// The maximum scanning times for available hotspots.
constexpr auto kWifiHotspotScanMaxRetries =
flags::Flag<int64_t>(kConfigPackage, "45415883", 3);
@@ -118,21 +118,13 @@ BleGattClient::~BleGattClient() {
bool BleGattClient::DiscoverServiceAndCharacteristics(
const Uuid& service_uuid, const std::vector<Uuid>& characteristic_uuids) {
absl::MutexLock lock(&mutex_);
if (!NearbyFlags::GetInstance().GetBoolFlag(
platform::config_package_nearby::nearby_platform_feature::
kEnableBleV2Gatt)) {
BluetoothAdapter bluetooth_adapter;
if (bluetooth_adapter.IsExtendedAdvertisingSupported()) {
LOG(WARNING) << __func__ << ": GATT is disabled.";
return false;
}
if (!bluetooth_adapter.IsCentralRoleSupported()) {
LOG(ERROR) << __func__
<< ": Bluetooth Hardware does not support Central "
"Role, which is required to start GATT client.";
return false;
}
BluetoothAdapter bluetooth_adapter;
if (!bluetooth_adapter.IsCentralRoleSupported()) {
LOG(ERROR) << __func__
<< ": Bluetooth Hardware does not support Central "
"Role, which is required to start GATT client.";
return false;
}
std::string flat_characteristics =
@@ -568,14 +568,6 @@ std::unique_ptr<api::ble_v2::GattServer> BleV2Medium::StartGattServer(
absl::MutexLock lock(&mutex_);
LOG(INFO) << __func__ << ": Start GATT server.";
if (!NearbyFlags::GetInstance().GetBoolFlag(
platform::config_package_nearby::nearby_platform_feature::
kEnableBleV2Gatt)) {
if (adapter_->IsExtendedAdvertisingSupported()) {
LOG(WARNING) << __func__ << ": GATT is disabled.";
return nullptr;
}
}
auto gatt_server =
std::make_unique<BleGattServer>(adapter_, std::move(callback));
@@ -600,15 +592,6 @@ std::unique_ptr<api::ble_v2::GattClient> BleV2Medium::ConnectToGattServer(
<< peripheral.GetAddress()
<< ", power:" << TxPowerLevelToName(tx_power_level);
if (!NearbyFlags::GetInstance().GetBoolFlag(
platform::config_package_nearby::nearby_platform_feature::
kEnableBleV2Gatt)) {
if (adapter_->IsExtendedAdvertisingSupported()) {
LOG(WARNING) << __func__ << ": GATT is disabled.";
return nullptr;
}
}
try {
BluetoothLEDevice ble_device =
BluetoothLEDevice::FromBluetoothAddressAsync(