Commit acfce3df authored by sonnysasaka's avatar sonnysasaka Committed by Commit bot

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

Doesn't fix the original issue of notifications failing after reconnect
https://crbug.com/680099 correctly.

Introduces new issue:
startCharacteristicNotifications returns 'Operation failed' after disconnect
https://crbug.com/719581

This reverts commit db614933.
originally from https://codereview.chromium.org/2625013003/

TBR=ortuno@chromium.org,rkc@google.com,scheib@chromium.org,perja@opera.com
BUG=680099,719581

Review-Url: https://codereview.chromium.org/2888663002
Cr-Commit-Position: refs/heads/master@{#472290}
parent 75d512cf
...@@ -485,11 +485,7 @@ void BluetoothDevice::DidFailToConnectGatt(ConnectErrorCode error) { ...@@ -485,11 +485,7 @@ void BluetoothDevice::DidFailToConnectGatt(ConnectErrorCode error) {
create_gatt_connection_error_callbacks_.clear(); create_gatt_connection_error_callbacks_.clear();
} }
void BluetoothDevice::DidDisconnectGatt(bool notifyDeviceChanged) { void BluetoothDevice::DidDisconnectGatt() {
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());
...@@ -499,8 +495,7 @@ void BluetoothDevice::DidDisconnectGatt(bool notifyDeviceChanged) { ...@@ -499,8 +495,7 @@ void BluetoothDevice::DidDisconnectGatt(bool notifyDeviceChanged) {
connection->InvalidateConnectionReference(); connection->InvalidateConnectionReference();
} }
gatt_connections_.clear(); gatt_connections_.clear();
if (notifyDeviceChanged) GetAdapter()->NotifyDeviceChanged(this);
GetAdapter()->NotifyDeviceChanged(this);
} }
void BluetoothDevice::AddGattConnection(BluetoothGattConnection* connection) { void BluetoothDevice::AddGattConnection(BluetoothGattConnection* connection) {
......
...@@ -617,7 +617,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDevice { ...@@ -617,7 +617,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDevice {
// DidDisconnectGatt. // DidDisconnectGatt.
void DidConnectGatt(); void DidConnectGatt();
void DidFailToConnectGatt(ConnectErrorCode); void DidFailToConnectGatt(ConnectErrorCode);
void DidDisconnectGatt(bool notifyDeviceChanged); void DidDisconnectGatt();
// 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,7 +222,10 @@ void BluetoothDeviceAndroid::OnConnectionStateChange( ...@@ -222,7 +222,10 @@ void BluetoothDeviceAndroid::OnConnectionStateChange(
} else { } else {
// Otherwise an existing connection was terminated. // Otherwise an existing connection was terminated.
RecordConnectionTerminatedResult(status); RecordConnectionTerminatedResult(status);
DidDisconnectGatt(true /* notifyDeviceChanged */); gatt_services_.clear();
device_uuids_.ClearServiceUUIDs();
SetGattServicesDiscoveryComplete(false);
DidDisconnectGatt();
} }
} }
......
...@@ -490,7 +490,7 @@ void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral(NSError* error) { ...@@ -490,7 +490,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(true /* notifyDeviceChanged */); DidDisconnectGatt();
return; return;
} }
// Else we canceled the connection request (#2). // Else we canceled the connection request (#2).
......
...@@ -951,9 +951,6 @@ void BluetoothDeviceBlueZ::OnSetTrusted(bool success) { ...@@ -951,9 +951,6 @@ void BluetoothDeviceBlueZ::OnSetTrusted(bool success) {
void BluetoothDeviceBlueZ::OnDisconnect(const base::Closure& callback) { void BluetoothDeviceBlueZ::OnDisconnect(const base::Closure& callback) {
BLUETOOTH_LOG(EVENT) << object_path_.value() << ": Disconnected"; BLUETOOTH_LOG(EVENT) << 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