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

Unified Diff: device/bluetooth/test/bluetooth_test_android.cc

Issue 1779083002: bluetooth: Test & make StartNotifySession reentrant. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-notify-followup-descriptors-
Patch Set: addressed ortuno 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
« no previous file with comments | « device/bluetooth/test/bluetooth_test_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/test/bluetooth_test_android.cc
diff --git a/device/bluetooth/test/bluetooth_test_android.cc b/device/bluetooth/test/bluetooth_test_android.cc
index a3dfa4d16db9a4c130ba9655abe3974a270d9c7d..79961e8fd5a19a1a410265a264b3a08840bd84fb 100644
--- a/device/bluetooth/test/bluetooth_test_android.cc
+++ b/device/bluetooth/test/bluetooth_test_android.cc
@@ -174,21 +174,50 @@ void BluetoothTestAndroid::RememberCharacteristicForSubsequentAction(
characteristic_android->GetJavaObject().obj());
}
-void BluetoothTestAndroid::SimulateGattNotifySessionStarted(
+void BluetoothTestAndroid::RememberCCCDescriptorForSubsequentAction(
BluetoothGattCharacteristic* characteristic) {
- BluetoothGattDescriptor* descriptor =
+ remembered_ccc_descriptor_ =
characteristic
->GetDescriptorsByUUID(
BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid())
.at(0);
- BluetoothRemoteGattDescriptorAndroid* descriptor_android =
- static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor);
+ DCHECK(remembered_ccc_descriptor_);
+ RememberDescriptorForSubsequentAction(remembered_ccc_descriptor_);
+}
+
+void BluetoothTestAndroid::SimulateGattNotifySessionStarted(
+ BluetoothGattCharacteristic* characteristic) {
+ BluetoothRemoteGattDescriptorAndroid* descriptor_android = nullptr;
+ if (characteristic) {
+ descriptor_android = static_cast<BluetoothRemoteGattDescriptorAndroid*>(
+ characteristic
+ ->GetDescriptorsByUUID(BluetoothGattDescriptor::
+ ClientCharacteristicConfigurationUuid())
+ .at(0));
+ }
Java_FakeBluetoothGattDescriptor_valueWrite(
base::android::AttachCurrentThread(),
descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr,
0); // android.bluetooth.BluetoothGatt.GATT_SUCCESS
}
+void BluetoothTestAndroid::SimulateGattNotifySessionStartError(
+ BluetoothGattCharacteristic* characteristic,
+ BluetoothGattService::GattErrorCode error_code) {
+ BluetoothRemoteGattDescriptorAndroid* descriptor_android = nullptr;
+ if (characteristic) {
+ descriptor_android = static_cast<BluetoothRemoteGattDescriptorAndroid*>(
+ characteristic
+ ->GetDescriptorsByUUID(BluetoothGattDescriptor::
+ ClientCharacteristicConfigurationUuid())
+ .at(0));
+ }
+ Java_FakeBluetoothGattDescriptor_valueWrite(
+ base::android::AttachCurrentThread(),
+ descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr,
+ BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code));
+}
+
void BluetoothTestAndroid::
SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce(
BluetoothGattCharacteristic* characteristic) {
« no previous file with comments | « device/bluetooth/test/bluetooth_test_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698