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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc

Issue 1765773002: bluetooth: Refactor GetDescriptorForUUID to GetDescriptorsForUUID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-notify-tommyt-
Patch Set: addressed ortuno's comments Created 4 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/bluetooth_remote_gatt_characteristic_android.cc
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc b/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc
index bb7e6696e7e55bfd7a930321243befbdd1541970..c4a73ff1ea552be81bcd9c7288b04a107128f581 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc
@@ -150,21 +150,22 @@ void BluetoothRemoteGattCharacteristicAndroid::StartNotifySession(
LOG(ERROR) << "Characteristic needs NOTIFY or INDICATE";
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(error_callback,
- BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED));
+ base::Bind(error_callback, BluetoothGattService::GATT_ERROR_FAILED));
return;
}
- BluetoothGattDescriptor* descriptor = GetDescriptorForUUID(
+ std::vector<BluetoothGattDescriptor*> ccc_descriptor = GetDescriptorsByUUID(
BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid());
- if (!descriptor) {
- LOG(ERROR)
- << "Could not find client characteristic configuration descriptor";
+ if (ccc_descriptor.size() != 1u) {
+ LOG(ERROR) << "Found " << ccc_descriptor.size()
+ << " client characteristic configuration descriptors.";
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(error_callback,
- BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED));
+ (ccc_descriptor.size() == 0)
+ ? BluetoothGattService::GATT_ERROR_NOT_SUPPORTED
+ : BluetoothGattService::GATT_ERROR_FAILED));
return;
}
@@ -173,8 +174,7 @@ void BluetoothRemoteGattCharacteristicAndroid::StartNotifySession(
LOG(ERROR) << "Error enabling characteristic notification";
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(error_callback,
- BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED));
+ base::Bind(error_callback, BluetoothGattService::GATT_ERROR_FAILED));
return;
}
@@ -183,7 +183,7 @@ void BluetoothRemoteGattCharacteristicAndroid::StartNotifySession(
value.push_back(0);
pending_start_notify_calls_.push(std::make_pair(callback, error_callback));
- descriptor->WriteRemoteDescriptor(
+ ccc_descriptor[0]->WriteRemoteDescriptor(
value, base::Bind(&BluetoothRemoteGattCharacteristicAndroid::
OnStartNotifySessionSuccess,
base::Unretained(this)),
@@ -206,8 +206,7 @@ void BluetoothRemoteGattCharacteristicAndroid::ReadRemoteCharacteristic(
AttachCurrentThread(), j_characteristic_.obj())) {
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(error_callback,
- BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED));
+ base::Bind(error_callback, BluetoothGattService::GATT_ERROR_FAILED));
return;
}
@@ -233,8 +232,7 @@ void BluetoothRemoteGattCharacteristicAndroid::WriteRemoteCharacteristic(
base::android::ToJavaByteArray(env, new_value).obj())) {
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(error_callback,
- BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED));
+ base::Bind(error_callback, BluetoothGattService::GATT_ERROR_FAILED));
return;
}

Powered by Google App Engine
This is Rietveld 408576698