Index: device/bluetooth/bluetooth_low_energy_device_mac.mm |
diff --git a/device/bluetooth/bluetooth_low_energy_device_mac.mm b/device/bluetooth/bluetooth_low_energy_device_mac.mm |
index 20694e4953b97d7ca5d4edc882a0a4b0aab06864..cff6ee533c6ecba3f9d00664ee6a6913532e4be5 100644 |
--- a/device/bluetooth/bluetooth_low_energy_device_mac.mm |
+++ b/device/bluetooth/bluetooth_low_energy_device_mac.mm |
@@ -189,7 +189,7 @@ void BluetoothLowEnergyDeviceMac::DisconnectGatt() { |
void BluetoothLowEnergyDeviceMac::DidDiscoverPrimaryServices(NSError* error) { |
--discovery_pending_count_; |
if (discovery_pending_count_ < 0) { |
- // This should never happens, just in case it happens with a device, |
+ // This should never happen, just in case it happens with a device, |
// discovery_pending_count_ is set back to 0. |
VLOG(1) << *this |
<< ": BluetoothLowEnergyDeviceMac::discovery_pending_count_ " |
@@ -256,6 +256,13 @@ void BluetoothLowEnergyDeviceMac::DidDiscoverCharacteristics( |
// Don't create characteristics if the device disconnected. |
return; |
} |
+ if (IsGattServicesDiscoveryComplete()) { |
+ // This should never happen, just in case it happens with a device, this |
+ // notification should be ignored. |
+ VLOG(1) << *this |
+ << ": Discovery complete, ignoring DidDiscoverCharacteristics."; |
+ return; |
+ } |
BluetoothRemoteGattServiceMac* gatt_service = |
GetBluetoothRemoteGattService(cb_service); |
@@ -327,6 +334,13 @@ void BluetoothLowEnergyDeviceMac::DidDiscoverDescriptors( |
// Don't discover descriptors if the device disconnected. |
return; |
} |
+ if (IsGattServicesDiscoveryComplete()) { |
+ // This should never happen, just in case it happens with a device, this |
+ // notification should be ignored. |
+ VLOG(1) << *this |
+ << ": Discovery complete, ignoring DidDiscoverDescriptors."; |
+ return; |
+ } |
BluetoothRemoteGattServiceMac* gatt_service = |
GetBluetoothRemoteGattService(cb_characteristic.service); |
DCHECK(gatt_service); |
@@ -380,6 +394,7 @@ void BluetoothLowEnergyDeviceMac::DiscoverPrimaryServices() { |
} |
void BluetoothLowEnergyDeviceMac::SendNotificationIfDiscoveryComplete() { |
+ DCHECK(!IsGattServicesDiscoveryComplete()); |
// Notify when all services have been discovered. |
bool discovery_complete = |
discovery_pending_count_ == 0 && |