Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Unified Diff: device/bluetooth/bluetooth_adapter_chromeos.cc

Issue 1341103004: Handle change of BLE address after pairing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased onto latest master Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_adapter_chromeos.cc
diff --git a/device/bluetooth/bluetooth_adapter_chromeos.cc b/device/bluetooth/bluetooth_adapter_chromeos.cc
index 597eb6dcbcb12d11085ec22f016e086b3b3f219e..6894a56c26ddd62355a85a52bc05b72ade43164c 100644
--- a/device/bluetooth/bluetooth_adapter_chromeos.cc
+++ b/device/bluetooth/bluetooth_adapter_chromeos.cc
@@ -441,6 +441,23 @@ void BluetoothAdapterChromeOS::DevicePropertyChanged(
DBusThreadManager::Get()->GetBluetoothDeviceClient()->
GetProperties(object_path);
+ if (property_name == properties->address.name()) {
+ for (DevicesMap::const_iterator iter = devices_.begin();
+ iter != devices_.end(); ++iter) {
armansito 2015/09/25 18:42:30 nit: for (const auto& iter : devices_)
jpawlowski1 2015/09/25 19:25:45 I need iterator, want to call erase() with iterato
+ if (iter->second->GetAddress() == device_chromeos->GetAddress()) {
+ std::string old_address = iter->first;
+ VLOG(1) << "Device changed address, old: " << old_address
+ << " new: " << device_chromeos->GetAddress();
+ devices_.erase(iter);
+
+ DCHECK(devices_.find(device_chromeos->GetAddress()) == devices_.end());
+ devices_[device_chromeos->GetAddress()] = device_chromeos;
+ NotifyDeviceAddressChanged(device_chromeos, old_address);
+ break;
+ }
+ }
+ }
+
if (property_name == properties->bluetooth_class.name() ||
property_name == properties->address.name() ||
property_name == properties->alias.name() ||
@@ -869,6 +886,15 @@ void BluetoothAdapterChromeOS::NotifyDeviceChanged(
DeviceChanged(this, device));
}
+void BluetoothAdapterChromeOS::NotifyDeviceAddressChanged(
+ BluetoothDeviceChromeOS* device,
+ const std::string& old_address) {
+ DCHECK(device->adapter_ == this);
+
+ FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
+ DeviceAddressChanged(this, device, old_address));
+}
+
void BluetoothAdapterChromeOS::NotifyGattServiceAdded(
BluetoothRemoteGattServiceChromeOS* service) {
DCHECK_EQ(service->GetAdapter(), this);

Powered by Google App Engine
This is Rietveld 408576698