mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Remove deprecated methods.
PiperOrigin-RevId: 829640164
This commit is contained in:
committed by
Copybara-Service
parent
f58e9820d5
commit
48ddaf0a95
@@ -46,7 +46,14 @@ class InjectedBluetoothDevice : public api::BluetoothDevice {
|
||||
// api::BluetoothDevice:
|
||||
std::string GetName() const override { return name_; }
|
||||
|
||||
std::string GetMacAddress() const override { return mac_address_; }
|
||||
MacAddress GetAddress() const override {
|
||||
if (mac_address_.empty()) {
|
||||
return MacAddress();
|
||||
}
|
||||
MacAddress address;
|
||||
MacAddress::FromString(mac_address_, address);
|
||||
return address;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string name_;
|
||||
|
||||
@@ -62,11 +62,6 @@
|
||||
XCTAssertFalse(_adapter.SetName("TestName", true));
|
||||
}
|
||||
|
||||
- (void)testGetMacAddress {
|
||||
// Currently hardcoded to return "".
|
||||
XCTAssertEqual(_adapter.GetMacAddress(), "");
|
||||
}
|
||||
|
||||
- (void)testGetAddress {
|
||||
// Currently hardcoded to return an empty MacAddress.
|
||||
nearby::MacAddress emptyAddress;
|
||||
|
||||
@@ -84,8 +84,6 @@ class BluetoothAdapter : public api::BluetoothAdapter {
|
||||
bool SetName(absl::string_view name, bool persist) override;
|
||||
|
||||
// Returns BT MAC address assigned to this adapter.
|
||||
std::string GetMacAddress() const override;
|
||||
|
||||
MacAddress GetAddress() const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -64,10 +64,6 @@ bool BluetoothAdapter::SetName(absl::string_view name, bool persist) {
|
||||
}
|
||||
|
||||
// TODO(b/290385712): Implement.
|
||||
std::string BluetoothAdapter::GetMacAddress() const {
|
||||
return "";
|
||||
}
|
||||
|
||||
MacAddress BluetoothAdapter::GetAddress() const {
|
||||
return MacAddress();
|
||||
}
|
||||
|
||||
@@ -66,21 +66,7 @@ class BluetoothAdapter {
|
||||
virtual bool SetName(absl::string_view name) = 0;
|
||||
virtual bool SetName(absl::string_view name, bool persist) = 0;
|
||||
|
||||
// Returns BT MAC address assigned to this adapter.
|
||||
ABSL_DEPRECATED("Use GetAddress() instead.")
|
||||
virtual std::string GetMacAddress() const = 0;
|
||||
|
||||
// Implementation for migration only. Once subclasses implement this, the
|
||||
// above GetMacAddress() can be removed.
|
||||
virtual MacAddress GetAddress() const {
|
||||
std::string mac_address = GetMacAddress();
|
||||
if (mac_address.empty()) {
|
||||
return MacAddress();
|
||||
}
|
||||
MacAddress address;
|
||||
MacAddress::FromString(mac_address, address);
|
||||
return address;
|
||||
}
|
||||
virtual MacAddress GetAddress() const = 0;
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -40,21 +40,7 @@ class BluetoothDevice {
|
||||
// https://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#getName()
|
||||
virtual std::string GetName() const = 0;
|
||||
|
||||
// Returns BT MAC address assigned to this device.
|
||||
ABSL_DEPRECATED("Use GetAddress() instead.")
|
||||
virtual std::string GetMacAddress() const = 0;
|
||||
|
||||
// Implementation for migration only. Once subclasses implement this, the
|
||||
// above GetMacAddress() can be removed.
|
||||
virtual MacAddress GetAddress() const {
|
||||
std::string mac_address = GetMacAddress();
|
||||
if (mac_address.empty()) {
|
||||
return MacAddress();
|
||||
}
|
||||
MacAddress address;
|
||||
MacAddress::FromString(mac_address, address);
|
||||
return address;
|
||||
}
|
||||
virtual MacAddress GetAddress() const = 0;
|
||||
};
|
||||
|
||||
// https://developer.android.com/reference/android/bluetooth/BluetoothSocket.html.
|
||||
|
||||
@@ -140,6 +140,7 @@ cc_test(
|
||||
":g3",
|
||||
"//internal/platform:base",
|
||||
"//internal/platform:cancellation_flag",
|
||||
"//internal/platform:mac_address",
|
||||
"//internal/platform:test_util",
|
||||
"//internal/platform:uuid",
|
||||
"//internal/platform/implementation:comm",
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "internal/platform/implementation/ble.h"
|
||||
#include "internal/platform/implementation/bluetooth_adapter.h"
|
||||
#include "internal/platform/implementation/g3/bluetooth_adapter.h"
|
||||
#include "internal/platform/mac_address.h"
|
||||
#include "internal/platform/uuid.h"
|
||||
|
||||
namespace nearby {
|
||||
@@ -47,7 +48,7 @@ class MockBluetoothAdapter : public BluetoothAdapter {
|
||||
MOCK_METHOD(bool, SetName, (absl::string_view name, bool persist),
|
||||
(override));
|
||||
MOCK_METHOD(std::string, GetName, (), (const, override));
|
||||
MOCK_METHOD(std::string, GetMacAddress, (), (const, override));
|
||||
MOCK_METHOD(MacAddress, GetAddress, (), (const, override));
|
||||
MOCK_METHOD(bool, SetScanMode, (api::BluetoothAdapter::ScanMode scan_mode),
|
||||
(override));
|
||||
MOCK_METHOD(api::BluetoothAdapter::ScanMode, GetScanMode, (),
|
||||
|
||||
@@ -37,10 +37,6 @@ BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter)
|
||||
|
||||
std::string BluetoothDevice::GetName() const { return adapter_.GetName(); }
|
||||
|
||||
std::string BluetoothDevice::GetMacAddress() const {
|
||||
return GetAddress().ToString();
|
||||
}
|
||||
|
||||
MacAddress BluetoothDevice::GetAddress() const { return adapter_.GetAddress(); }
|
||||
|
||||
BluetoothAdapter::BluetoothAdapter() {
|
||||
|
||||
@@ -39,7 +39,6 @@ class BluetoothDevice : public api::BluetoothDevice {
|
||||
|
||||
// https://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#getName()
|
||||
std::string GetName() const override;
|
||||
std::string GetMacAddress() const override;
|
||||
MacAddress GetAddress() const override;
|
||||
BluetoothAdapter& GetAdapter() { return adapter_; }
|
||||
|
||||
@@ -88,7 +87,6 @@ class BluetoothAdapter : public api::BluetoothAdapter {
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Returns BT MAC address assigned to this adapter.
|
||||
std::string GetMacAddress() const override { return mac_address_.ToString(); }
|
||||
MacAddress GetAddress() const override { return mac_address_; }
|
||||
|
||||
BluetoothDevice& GetDevice() { return device_; }
|
||||
|
||||
@@ -414,6 +414,7 @@ cc_test(
|
||||
":windows",
|
||||
"//internal/platform:base",
|
||||
"//internal/platform:logging",
|
||||
"//internal/platform:mac_address",
|
||||
"//internal/platform/implementation:comm",
|
||||
"//internal/platform/implementation:platform",
|
||||
"//internal/platform/implementation:types",
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "absl/synchronization/notification.h"
|
||||
#include "internal/platform/implementation/ble.h"
|
||||
#include "internal/platform/implementation/windows/bluetooth_adapter.h"
|
||||
#include "internal/platform/mac_address.h"
|
||||
#include "internal/platform/uuid.h"
|
||||
|
||||
namespace nearby {
|
||||
@@ -50,7 +51,7 @@ class MockBluetoothAdapter : public BluetoothAdapter {
|
||||
MOCK_METHOD(bool, SetName, (absl::string_view name), (override));
|
||||
MOCK_METHOD(bool, SetName, (absl::string_view name, bool persist),
|
||||
(override));
|
||||
MOCK_METHOD(std::string, GetMacAddress, (), (const, override));
|
||||
MOCK_METHOD(MacAddress, GetAddress, (), (const, override));
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -841,14 +841,6 @@ MacAddress BluetoothAdapter::GetAddress() const {
|
||||
return mac_address;
|
||||
}
|
||||
|
||||
std::string BluetoothAdapter::GetMacAddress() const {
|
||||
MacAddress address = GetAddress();
|
||||
if (!address.IsSet()) {
|
||||
return "";
|
||||
}
|
||||
return address.ToString();
|
||||
}
|
||||
|
||||
std::string BluetoothAdapter::GetNameFromRegistry(PHKEY hKey) const {
|
||||
DWORD local_name_size = 0;
|
||||
DWORD value_type;
|
||||
|
||||
@@ -83,8 +83,6 @@ class BluetoothAdapter : public api::BluetoothAdapter {
|
||||
bool SetName(absl::string_view name, bool persist) override;
|
||||
|
||||
// Returns BT MAC address assigned to this adapter.
|
||||
std::string GetMacAddress() const override;
|
||||
|
||||
MacAddress GetAddress() const override;
|
||||
|
||||
// Returns bluetooth device name from registry
|
||||
|
||||
@@ -144,9 +144,9 @@ TEST(BluetoothAdapter, DISABLED_SetName_Exceeded) {
|
||||
EXPECT_EQ(bluetooth_adapter.GetName(), original_bluetooth_device_name);
|
||||
}
|
||||
|
||||
TEST(BluetoothAdapter, DISABLED_GetMacAddress) {
|
||||
TEST(BluetoothAdapter, DISABLED_GetAddress) {
|
||||
BluetoothAdapter bluetooth_adapter;
|
||||
EXPECT_TRUE(!bluetooth_adapter.GetMacAddress().empty());
|
||||
EXPECT_TRUE(bluetooth_adapter.GetAddress().IsSet());
|
||||
}
|
||||
|
||||
TEST(BluetoothAdapter, DISABLED_SetOnScanModeChanged) {
|
||||
|
||||
@@ -72,10 +72,6 @@ BluetoothDevice::BluetoothDevice(
|
||||
}
|
||||
|
||||
// Returns BT MAC address assigned to this device.
|
||||
std::string BluetoothDevice::GetMacAddress() const {
|
||||
return mac_address_.ToString();
|
||||
}
|
||||
|
||||
MacAddress BluetoothDevice::GetAddress() const { return mac_address_; }
|
||||
|
||||
// Checks cache first, will check uncached if no result.
|
||||
|
||||
@@ -70,7 +70,6 @@ class BluetoothDevice : public api::BluetoothDevice {
|
||||
std::string GetName() const override { return name_; }
|
||||
|
||||
// Returns BT MAC address assigned to this device.
|
||||
std::string GetMacAddress() const override;
|
||||
MacAddress GetAddress() const override;
|
||||
|
||||
std::string GetId() { return id_; }
|
||||
|
||||
@@ -293,7 +293,7 @@ api::BluetoothDevice* BluetoothClassicMedium::GetRemoteDevice(
|
||||
std::unique_ptr<api::BluetoothPairing> BluetoothClassicMedium::CreatePairing(
|
||||
api::BluetoothDevice& remote_device) {
|
||||
VLOG(1) << __func__ << ": Start to createPairing with device: "
|
||||
<< remote_device.GetMacAddress();
|
||||
<< remote_device.GetAddress().ToString();
|
||||
try {
|
||||
winrt::Windows::Devices::Bluetooth::BluetoothDevice bluetooth_device =
|
||||
winrt::Windows::Devices::Bluetooth::BluetoothDevice::
|
||||
|
||||
Reference in New Issue
Block a user