From 4beed5b72ae5e82ac0bc79d7c72e0ae4d948b92e Mon Sep 17 00:00:00 2001 From: Francis Tsui Date: Wed, 7 May 2025 16:10:37 -0700 Subject: [PATCH] Remove unused method. PiperOrigin-RevId: 756045245 --- internal/platform/ble_v2.h | 4 ---- internal/platform/ble_v2_test.cc | 14 ++++++-------- .../implementation/apple/ble_gatt_server.h | 6 ------ .../implementation/apple/ble_gatt_server.mm | 5 ----- internal/platform/implementation/ble_v2.h | 3 --- internal/platform/implementation/g3/ble_v2.h | 3 --- .../implementation/windows/ble_gatt_server.cc | 1 - .../implementation/windows/ble_gatt_server.h | 5 ----- 8 files changed, 6 insertions(+), 35 deletions(-) diff --git a/internal/platform/ble_v2.h b/internal/platform/ble_v2.h index 3397576b..7503b74a 100644 --- a/internal/platform/ble_v2.h +++ b/internal/platform/ble_v2.h @@ -257,10 +257,6 @@ class GattServer final { // it is not safe to call any other method. bool IsValid() const { return impl_ != nullptr; } - BleV2Peripheral GetBlePeripheral() { - return BleV2Peripheral(medium_, impl_->GetBlePeripheral()); - } - // Returns reference to platform implementation. // This is used to communicate with platform code, and for debugging // purposes. diff --git a/internal/platform/ble_v2_test.cc b/internal/platform/ble_v2_test.cc index 0f21f816..0d257fd6 100644 --- a/internal/platform/ble_v2_test.cc +++ b/internal/platform/ble_v2_test.cc @@ -626,7 +626,7 @@ TEST_F(BleV2MediumTest, GattClientConnectToGattServerWorks) { // Start GattClient BleV2Peripheral ble_peripheral = - ble_b.GetRemotePeripheral(*gatt_server->GetBlePeripheral().GetAddress()); + ble_b.GetRemotePeripheral(adapter_a.GetMacAddress()); std::unique_ptr gatt_client = ble_b.ConnectToGattServer(BleV2Peripheral(ble_peripheral), kTxPowerLevel, /*ClientGattConnectionCallback=*/{}); @@ -661,7 +661,7 @@ TEST_F(BleV2MediumTest, GattClientConnectToStoppedGattServerFails) { ble_a.StartGattServer(/*ServerGattConnectionCallback=*/{}); ASSERT_NE(gatt_server, nullptr); BleV2Peripheral ble_peripheral = - ble_b.GetRemotePeripheral(*gatt_server->GetBlePeripheral().GetAddress()); + ble_b.GetRemotePeripheral(adapter_a.GetMacAddress()); gatt_server->Stop(); std::unique_ptr gatt_client = @@ -685,7 +685,7 @@ TEST_F(BleV2MediumTest, GattClientNotifiedWhenServerDisconnects) { CountDownLatch disconnected_latch(1); // Start GattClient BleV2Peripheral ble_peripheral = - ble_b.GetRemotePeripheral(*gatt_server->GetBlePeripheral().GetAddress()); + ble_b.GetRemotePeripheral(adapter_a.GetMacAddress()); std::unique_ptr gatt_client = ble_b.ConnectToGattServer( BleV2Peripheral(ble_peripheral), kTxPowerLevel, /*ClientGattConnectionCallback=*/{.disconnected_cb = [&]() { @@ -721,11 +721,10 @@ TEST_F(BleV2MediumTest, GattClientOperatiosOnCharacteristic) { callback(absl::OkStatus()); }}); ASSERT_NE(gatt_server, nullptr); - BleV2Peripheral server_ble = gatt_server->GetBlePeripheral(); // Start GattClient. BleV2Peripheral ble_peripheral = - ble_b.GetRemotePeripheral(*server_ble.GetAddress()); + ble_b.GetRemotePeripheral(adapter_a.GetMacAddress()); ASSERT_TRUE(ble_peripheral.IsValid()); std::unique_ptr gatt_client = ble_b.ConnectToGattServer(BleV2Peripheral(ble_peripheral), kTxPowerLevel, @@ -798,7 +797,6 @@ TEST_F(BleV2MediumTest, GattClientSubscribeNotificationGattServerCanNotify) { ble_a.StartGattServer(/*ServerGattConnectionCallback=*/{}); ASSERT_NE(gatt_server, nullptr); - BleV2Peripheral server_ble = gatt_server->GetBlePeripheral(); // Add characteristic and its value. // NOLINTNEXTLINE(google3-legacy-absl-backports) std::optional server_characteristic = @@ -809,7 +807,7 @@ TEST_F(BleV2MediumTest, GattClientSubscribeNotificationGattServerCanNotify) { // Start GattClient BleV2Peripheral ble_peripheral = - ble_b.GetRemotePeripheral(*server_ble.GetAddress()); + ble_b.GetRemotePeripheral(adapter_a.GetMacAddress()); ASSERT_TRUE(ble_peripheral.IsValid()); std::unique_ptr gatt_client = ble_b.ConnectToGattServer(BleV2Peripheral(ble_peripheral), kTxPowerLevel, @@ -824,7 +822,7 @@ TEST_F(BleV2MediumTest, GattClientSubscribeNotificationGattServerCanNotify) { server_characteristic.value(), true, [](absl::string_view value) { EXPECT_EQ(value, "hello"); })); - // Sends notifiction + // Sends notification EXPECT_EQ(gatt_server->NotifyCharacteristicChanged( server_characteristic.value(), false, ByteArray("hello")), absl::OkStatus()); diff --git a/internal/platform/implementation/apple/ble_gatt_server.h b/internal/platform/implementation/apple/ble_gatt_server.h index 94aa8d2e..836db4c0 100644 --- a/internal/platform/implementation/apple/ble_gatt_server.h +++ b/internal/platform/implementation/apple/ble_gatt_server.h @@ -36,12 +36,6 @@ class GattServer : public api::ble_v2::GattServer { explicit GattServer(GNCBLEGATTServer *gatt_server_); ~GattServer() override = default; - // Returns an empty BlePeripheral object. - // - // Use of this method should be avoided and its only purpose seems to be a check that the GATT - // server is valid. - api::ble_v2::BlePeripheral &GetBlePeripheral() override; - // Creates a characteristic and adds it to the GATT server under the given characteristic and // service UUIDs. // diff --git a/internal/platform/implementation/apple/ble_gatt_server.mm b/internal/platform/implementation/apple/ble_gatt_server.mm index f28a2d72..7032735c 100644 --- a/internal/platform/implementation/apple/ble_gatt_server.mm +++ b/internal/platform/implementation/apple/ble_gatt_server.mm @@ -95,10 +95,5 @@ void GattServer::Stop() { [gatt_server_ stop]; } -// TODO(b/290385712): Implement. -api::ble_v2::BlePeripheral &GattServer::GetBlePeripheral() { - return BlePeripheral::DefaultBlePeripheral(); -} - } // namespace apple } // namespace nearby diff --git a/internal/platform/implementation/ble_v2.h b/internal/platform/implementation/ble_v2.h index 380d913e..ab10ee87 100644 --- a/internal/platform/implementation/ble_v2.h +++ b/internal/platform/implementation/ble_v2.h @@ -270,9 +270,6 @@ class GattServer { public: virtual ~GattServer() = default; - // Returns the local BlePeripheral. - virtual BlePeripheral& GetBlePeripheral() = 0; - // Creates a characteristic and adds it to the GATT server under the given // characteristic and service UUIDs. Returns no value upon error. // diff --git a/internal/platform/implementation/g3/ble_v2.h b/internal/platform/implementation/g3/ble_v2.h index ea2b4353..11e6d452 100644 --- a/internal/platform/implementation/g3/ble_v2.h +++ b/internal/platform/implementation/g3/ble_v2.h @@ -209,9 +209,6 @@ class BleV2Medium : public api::ble_v2::BleMedium { api::ble_v2::ServerGattConnectionCallback callback); ~GattServer() override; - api::ble_v2::BlePeripheral& GetBlePeripheral() override { - return ble_peripheral_; - } std::optional CreateCharacteristic( const Uuid& service_uuid, const Uuid& characteristic_uuid, api::ble_v2::GattCharacteristic::Permission permission, diff --git a/internal/platform/implementation/windows/ble_gatt_server.cc b/internal/platform/implementation/windows/ble_gatt_server.cc index 32ce9f95..97b8addf 100644 --- a/internal/platform/implementation/windows/ble_gatt_server.cc +++ b/internal/platform/implementation/windows/ble_gatt_server.cc @@ -115,7 +115,6 @@ std::string ConvertGattStatusToString( BleGattServer::BleGattServer(api::BluetoothAdapter* adapter, api::ble_v2::ServerGattConnectionCallback callback) : adapter_(dynamic_cast(adapter)), - peripheral_(adapter_->mac_address().address(), adapter_->mac_address()), gatt_connection_callback_(std::move(callback)) { DCHECK(adapter_ != nullptr); } diff --git a/internal/platform/implementation/windows/ble_gatt_server.h b/internal/platform/implementation/windows/ble_gatt_server.h index 69b167c4..75b02e2c 100644 --- a/internal/platform/implementation/windows/ble_gatt_server.h +++ b/internal/platform/implementation/windows/ble_gatt_server.h @@ -70,10 +70,6 @@ class BleGattServer : public api::ble_v2::GattServer { void SetCloseNotifier(absl::AnyInvocable notifier) ABSL_LOCKS_EXCLUDED(mutex_); - api::ble_v2::BlePeripheral& GetBlePeripheral() override { - return peripheral_; - } - private: // Used to save native data related to the GATT characteristic. struct GattCharacteristicData { @@ -131,7 +127,6 @@ class BleGattServer : public api::ble_v2::GattServer { absl::Mutex mutex_; BluetoothAdapter* const adapter_ = nullptr; - api::ble_v2::BlePeripheral peripheral_; api::ble_v2::ServerGattConnectionCallback gatt_connection_callback_{}; ::winrt::Windows::Devices::Bluetooth::GenericAttributeProfile::