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

Unified Diff: device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.cc

Issue 2728623004: Fix getting notified twice after subscribe to notifications and call readValue (Closed)
Patch Set: updated test code Created 3 years, 9 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/bluez/bluetooth_remote_gatt_characteristic_bluez.cc
diff --git a/device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.cc b/device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.cc
index ce386daaa9a9019601770fc70ccdc2500d9a4f0c..f9a2e23760183ca1782f2bf64e13ef7e528672c2 100644
--- a/device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.cc
+++ b/device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.cc
@@ -45,6 +45,7 @@ BluetoothRemoteGattCharacteristicBlueZ::BluetoothRemoteGattCharacteristicBlueZ(
: BluetoothGattCharacteristicBlueZ(object_path),
has_notify_session_(false),
service_(service),
+ num_of_characteristic_value_read_in_progress_(0),
weak_ptr_factory_(this) {
VLOG(1) << "Creating remote GATT characteristic with identifier: "
<< GetIdentifier() << ", UUID: " << GetUUID().canonical_value();
@@ -184,11 +185,15 @@ void BluetoothRemoteGattCharacteristicBlueZ::ReadRemoteCharacteristic(
<< GetIdentifier() << ", UUID: " << GetUUID().canonical_value()
<< ".";
+ DCHECK_GE(num_of_characteristic_value_read_in_progress_, 0);
+ ++num_of_characteristic_value_read_in_progress_;
+
bluez::BluezDBusManager::Get()
->GetBluetoothGattCharacteristicClient()
- ->ReadValue(object_path(), callback,
- base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnError,
- weak_ptr_factory_.GetWeakPtr(), error_callback));
+ ->ReadValue(
+ object_path(), callback,
+ base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnReadError,
+ weak_ptr_factory_.GetWeakPtr(), error_callback));
}
void BluetoothRemoteGattCharacteristicBlueZ::WriteRemoteCharacteristic(
@@ -201,9 +206,10 @@ void BluetoothRemoteGattCharacteristicBlueZ::WriteRemoteCharacteristic(
bluez::BluezDBusManager::Get()
->GetBluetoothGattCharacteristicClient()
- ->WriteValue(object_path(), value, callback,
- base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnError,
- weak_ptr_factory_.GetWeakPtr(), error_callback));
+ ->WriteValue(
+ object_path(), value, callback,
+ base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnWriteError,
+ weak_ptr_factory_.GetWeakPtr(), error_callback));
}
void BluetoothRemoteGattCharacteristicBlueZ::SubscribeToNotifications(
@@ -353,7 +359,19 @@ void BluetoothRemoteGattCharacteristicBlueZ::OnStopNotifyError(
OnStopNotifySuccess(callback);
}
-void BluetoothRemoteGattCharacteristicBlueZ::OnError(
+void BluetoothRemoteGattCharacteristicBlueZ::OnReadError(
+ const ErrorCallback& error_callback,
+ const std::string& error_name,
+ const std::string& error_message) {
+ VLOG(1) << "Operation failed: " << error_name
+ << ", message: " << error_message;
+ --num_of_characteristic_value_read_in_progress_;
+ DCHECK_GE(num_of_characteristic_value_read_in_progress_, 0);
+ error_callback.Run(
+ BluetoothGattServiceBlueZ::DBusErrorToServiceError(error_name));
+}
+
+void BluetoothRemoteGattCharacteristicBlueZ::OnWriteError(
const ErrorCallback& error_callback,
const std::string& error_name,
const std::string& error_message) {

Powered by Google App Engine
This is Rietveld 408576698