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) { ...@@ -517,7 +517,11 @@ void BluetoothDevice::DidFailToConnectGatt(ConnectErrorCode error) {
create_gatt_connection_error_callbacks_.clear(); 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 // Pending calls to connect GATT are not expected, if they were then
// DidFailToConnectGatt should have been called. // DidFailToConnectGatt should have been called.
DCHECK(create_gatt_connection_error_callbacks_.empty()); DCHECK(create_gatt_connection_error_callbacks_.empty());
...@@ -527,6 +531,7 @@ void BluetoothDevice::DidDisconnectGatt() { ...@@ -527,6 +531,7 @@ void BluetoothDevice::DidDisconnectGatt() {
connection->InvalidateConnectionReference(); connection->InvalidateConnectionReference();
} }
gatt_connections_.clear(); gatt_connections_.clear();
if (notifyDeviceChanged)
GetAdapter()->NotifyDeviceChanged(this); GetAdapter()->NotifyDeviceChanged(this);
} }
......
...@@ -636,7 +636,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDevice { ...@@ -636,7 +636,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDevice {
// DidDisconnectGatt. // DidDisconnectGatt.
void DidConnectGatt(); void DidConnectGatt();
void DidFailToConnectGatt(ConnectErrorCode); void DidFailToConnectGatt(ConnectErrorCode);
void DidDisconnectGatt(); void DidDisconnectGatt(bool notifyDeviceChanged);
// Tracks BluetoothGattConnection instances that act as a reference count // Tracks BluetoothGattConnection instances that act as a reference count
// keeping the GATT connection open. Instances call Add/RemoveGattConnection // keeping the GATT connection open. Instances call Add/RemoveGattConnection
......
...@@ -222,10 +222,7 @@ void BluetoothDeviceAndroid::OnConnectionStateChange( ...@@ -222,10 +222,7 @@ void BluetoothDeviceAndroid::OnConnectionStateChange(
} else { } else {
// Otherwise an existing connection was terminated. // Otherwise an existing connection was terminated.
RecordConnectionTerminatedResult(status); RecordConnectionTerminatedResult(status);
gatt_services_.clear(); DidDisconnectGatt(true /* notifyDeviceChanged */);
device_uuids_.ClearServiceUUIDs();
SetGattServicesDiscoveryComplete(false);
DidDisconnectGatt();
} }
} }
......
...@@ -390,7 +390,7 @@ void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral(NSError* error) { ...@@ -390,7 +390,7 @@ void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral(NSError* error) {
// 2. When we cancel a pending connection request. // 2. When we cancel a pending connection request.
if (create_gatt_connection_error_callbacks_.empty()) { if (create_gatt_connection_error_callbacks_.empty()) {
// If there are no pending callbacks then the connection broke (#1). // If there are no pending callbacks then the connection broke (#1).
DidDisconnectGatt(); DidDisconnectGatt(true /* notifyDeviceChanged */);
return; return;
} }
// Else we canceled the connection request (#2). // Else we canceled the connection request (#2).
......
...@@ -928,6 +928,9 @@ void BluetoothDeviceBlueZ::OnSetTrusted(bool success) { ...@@ -928,6 +928,9 @@ void BluetoothDeviceBlueZ::OnSetTrusted(bool success) {
void BluetoothDeviceBlueZ::OnDisconnect(const base::Closure& callback) { void BluetoothDeviceBlueZ::OnDisconnect(const base::Closure& callback) {
VLOG(1) << object_path_.value() << ": Disconnected"; 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(); 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