mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Remove unused BluetoothClassicMedium::Observer.
PiperOrigin-RevId: 953415728
This commit is contained in:
committed by
Copybara-Service
parent
8a1bbd074e
commit
a7f6ed3fa7
@@ -19,7 +19,6 @@
|
||||
#include <utility>
|
||||
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/platform/bluetooth_adapter.h"
|
||||
#include "internal/platform/cancellation_flag.h"
|
||||
#include "internal/platform/implementation/bluetooth_classic.h"
|
||||
@@ -57,11 +56,6 @@ MediumSocket* BluetoothSocket::CreateVirtualSocket(
|
||||
}
|
||||
|
||||
BluetoothClassicMedium::~BluetoothClassicMedium() {
|
||||
LOG(INFO) << "~BluetoothClassicMedium: observer_list_ size: "
|
||||
<< observer_list_.size();
|
||||
if (!observer_list_.empty()) {
|
||||
impl_->RemoveObserver(this);
|
||||
}
|
||||
StopDiscovery();
|
||||
LOG(INFO) << "eof ~BluetoothClassicMedium";
|
||||
}
|
||||
@@ -160,71 +154,4 @@ bool BluetoothClassicMedium::StopDiscovery() {
|
||||
return impl_->StopDiscovery();
|
||||
}
|
||||
|
||||
void BluetoothClassicMedium::AddObserver(Observer* observer) {
|
||||
LOG(INFO) << "BT AddObserver; impl=" << &GetImpl();
|
||||
MutexLock lock(&mutex_);
|
||||
if (observer_list_.empty()) {
|
||||
impl_->AddObserver(this);
|
||||
}
|
||||
observer_list_.AddObserver(observer);
|
||||
LOG(INFO) << "BT AddObserver done";
|
||||
}
|
||||
void BluetoothClassicMedium::RemoveObserver(Observer* observer) {
|
||||
LOG(INFO) << "BT RemoveObserver; impl=" << &GetImpl();
|
||||
MutexLock lock(&mutex_);
|
||||
observer_list_.RemoveObserver(observer);
|
||||
if (observer_list_.empty()) {
|
||||
impl_->RemoveObserver(this);
|
||||
}
|
||||
LOG(INFO) << "BT RemoveObserver done";
|
||||
}
|
||||
|
||||
// api::BluetoothClassicMedium::Observer methods
|
||||
void BluetoothClassicMedium::DeviceAdded(api::BluetoothDevice& device) {
|
||||
VLOG(1) << "BT DeviceAdded; name=" << device.GetName()
|
||||
<< ", address=" << device.GetMacAddress().ToString();
|
||||
BluetoothDevice bt_device(&device);
|
||||
for (auto* observer : observer_list_.GetObservers()) {
|
||||
observer->DeviceAdded(bt_device);
|
||||
}
|
||||
}
|
||||
void BluetoothClassicMedium::DeviceRemoved(api::BluetoothDevice& device) {
|
||||
VLOG(1) << "BT DeviceRemoved; name=" << device.GetName()
|
||||
<< ", address=" << device.GetMacAddress().ToString();
|
||||
BluetoothDevice bt_device(&device);
|
||||
for (auto* observer : observer_list_.GetObservers()) {
|
||||
observer->DeviceRemoved(bt_device);
|
||||
}
|
||||
}
|
||||
void BluetoothClassicMedium::DeviceAddressChanged(
|
||||
api::BluetoothDevice& device, absl::string_view old_address) {
|
||||
VLOG(1) << "BT DeviceAddressChanged; name=" << device.GetName()
|
||||
<< ", address=" << device.GetMacAddress().ToString()
|
||||
<< ", old_address=" << old_address;
|
||||
BluetoothDevice bt_device(&device);
|
||||
for (auto* observer : observer_list_.GetObservers()) {
|
||||
observer->DeviceAddressChanged(bt_device, old_address);
|
||||
}
|
||||
}
|
||||
void BluetoothClassicMedium::DevicePairedChanged(api::BluetoothDevice& device,
|
||||
bool new_paired_status) {
|
||||
VLOG(1) << "BT DevicePairedChanged; name=" << device.GetName()
|
||||
<< ", address=" << device.GetMacAddress().ToString()
|
||||
<< ", status=" << new_paired_status;
|
||||
BluetoothDevice bt_device(&device);
|
||||
for (auto* observer : observer_list_.GetObservers()) {
|
||||
observer->DevicePairedChanged(bt_device, new_paired_status);
|
||||
}
|
||||
}
|
||||
void BluetoothClassicMedium::DeviceConnectedStateChanged(
|
||||
api::BluetoothDevice& device, bool connected) {
|
||||
VLOG(1) << "BT DeviceConnectedStateChanged: name=" << device.GetName()
|
||||
<< ", address=" << device.GetMacAddress().ToString()
|
||||
<< ", connected=" << connected;
|
||||
BluetoothDevice bt_device(&device);
|
||||
for (auto* observer : observer_list_.GetObservers()) {
|
||||
observer->DeviceConnectedStateChanged(bt_device, connected);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
Reference in New Issue
Block a user