Commit db614933 authored by perja's avatar perja Committed by Commit bot

bluetooth: bluez: Fixed issue with missing notifications after reconnect.

BUG=680099

Review-Url: https://codereview.chromium.org/2625013003
Cr-Commit-Position: refs/heads/master@{#443451}
parent 63db4c77
......@@ -517,7 +517,11 @@ void BluetoothDevice::DidFailToConnectGatt(ConnectErrorCode error) {
create_gatt_connection_error_callbacks_.clear();
}
void BluetoothDevice::DidDisconnectGatt() {
void BluetoothDevice::DidDisconnectGatt(bool notifyDeviceChanged) {
gatt_services_.clear();
device_uuids_.ClearServiceUUIDs();
SetGattServicesDiscoveryComplete(false);
// Pending calls to connect GATT are not expected, if they were then
// DidFailToConnectGatt should have been called.
DCHECK(create_gatt_connection_error_callbacks_.empty());
......@@ -527,7 +531,8 @@ void BluetoothDevice::DidDisconnectGatt() {
connection->InvalidateConnectionReference();
}
gatt_connections_.clear();
GetAdapter()->NotifyDeviceChanged(this);
if (notifyDeviceChanged)
GetAdapter()->NotifyDeviceChanged(this);
}
void BluetoothDevice::AddGattConnection(BluetoothGattConnection* connection) {
......
......@@ -636,7 +636,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDevice {
// DidDisconnectGatt.
void DidConnectGatt();
void DidFailToConnectGatt(ConnectErrorCode);
void DidDisconnectGatt();
void DidDisconnectGatt(bool notifyDeviceChanged);
// Tracks BluetoothGattConnection instances that act as a reference count
// keeping the GATT connection open. Instances call Add/RemoveGattConnection
......
......@@ -222,10 +222,7 @@ void BluetoothDeviceAndroid::OnConnectionStateChange(
} else {
// Otherwise an existing connection was terminated.
RecordConnectionTerminatedResult(status);
gatt_services_.clear();
device_uuids_.ClearServiceUUIDs();
SetGattServicesDiscoveryComplete(false);
DidDisconnectGatt();
DidDisconnectGatt(true /* notifyDeviceChanged */);
}
}
......
......@@ -390,7 +390,7 @@ void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral(NSError* error) {
// 2. When we cancel a pending connection request.
if (create_gatt_connection_error_callbacks_.empty()) {
// If there are no pending callbacks then the connection broke (#1).
DidDisconnectGatt();
DidDisconnectGatt(true /* notifyDeviceChanged */);
return;
}
// Else we canceled the connection request (#2).
......
......@@ -928,6 +928,9 @@ void BluetoothDeviceBlueZ::OnSetTrusted(bool success) {
void BluetoothDeviceBlueZ::OnDisconnect(const base::Closure& callback) {
VLOG(1) << object_path_.value() << ": Disconnected";
// Do not notify about changed device since this is already done by
// the dbus::PropertySet and the property change callback for BlueZ.
DidDisconnectGatt(false /* notifyDeviceChanged */);
callback.Run();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment