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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « device/bluetooth/test/bluetooth_test_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/bluetooth/test/bluetooth_test_android.h" 5 #include "device/bluetooth/test/bluetooth_test_android.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 void BluetoothTestAndroid::RememberCharacteristicForSubsequentAction( 167 void BluetoothTestAndroid::RememberCharacteristicForSubsequentAction(
168 BluetoothGattCharacteristic* characteristic) { 168 BluetoothGattCharacteristic* characteristic) {
169 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = 169 BluetoothRemoteGattCharacteristicAndroid* characteristic_android =
170 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); 170 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic);
171 171
172 Java_FakeBluetoothGattCharacteristic_rememberCharacteristicForSubsequentAction ( 172 Java_FakeBluetoothGattCharacteristic_rememberCharacteristicForSubsequentAction (
173 base::android::AttachCurrentThread(), 173 base::android::AttachCurrentThread(),
174 characteristic_android->GetJavaObject().obj()); 174 characteristic_android->GetJavaObject().obj());
175 } 175 }
176 176
177 void BluetoothTestAndroid::RememberCCCDescriptorForSubsequentAction(
178 BluetoothGattCharacteristic* characteristic) {
179 remembered_ccc_descriptor_ =
180 characteristic
181 ->GetDescriptorsByUUID(
182 BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid())
183 .at(0);
184 DCHECK(remembered_ccc_descriptor_);
185 RememberDescriptorForSubsequentAction(remembered_ccc_descriptor_);
186 }
187
177 void BluetoothTestAndroid::SimulateGattNotifySessionStarted( 188 void BluetoothTestAndroid::SimulateGattNotifySessionStarted(
178 BluetoothGattCharacteristic* characteristic) { 189 BluetoothGattCharacteristic* characteristic) {
179 BluetoothGattDescriptor* descriptor = 190 BluetoothRemoteGattDescriptorAndroid* descriptor_android = nullptr;
180 characteristic 191 if (characteristic) {
181 ->GetDescriptorsByUUID( 192 descriptor_android = static_cast<BluetoothRemoteGattDescriptorAndroid*>(
182 BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid()) 193 characteristic
183 .at(0); 194 ->GetDescriptorsByUUID(BluetoothGattDescriptor::
184 BluetoothRemoteGattDescriptorAndroid* descriptor_android = 195 ClientCharacteristicConfigurationUuid())
185 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); 196 .at(0));
197 }
186 Java_FakeBluetoothGattDescriptor_valueWrite( 198 Java_FakeBluetoothGattDescriptor_valueWrite(
187 base::android::AttachCurrentThread(), 199 base::android::AttachCurrentThread(),
188 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr, 200 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr,
189 0); // android.bluetooth.BluetoothGatt.GATT_SUCCESS 201 0); // android.bluetooth.BluetoothGatt.GATT_SUCCESS
190 } 202 }
191 203
204 void BluetoothTestAndroid::SimulateGattNotifySessionStartError(
205 BluetoothGattCharacteristic* characteristic,
206 BluetoothGattService::GattErrorCode error_code) {
207 BluetoothRemoteGattDescriptorAndroid* descriptor_android = nullptr;
208 if (characteristic) {
209 descriptor_android = static_cast<BluetoothRemoteGattDescriptorAndroid*>(
210 characteristic
211 ->GetDescriptorsByUUID(BluetoothGattDescriptor::
212 ClientCharacteristicConfigurationUuid())
213 .at(0));
214 }
215 Java_FakeBluetoothGattDescriptor_valueWrite(
216 base::android::AttachCurrentThread(),
217 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr,
218 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code));
219 }
220
192 void BluetoothTestAndroid:: 221 void BluetoothTestAndroid::
193 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( 222 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce(
194 BluetoothGattCharacteristic* characteristic) { 223 BluetoothGattCharacteristic* characteristic) {
195 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = 224 BluetoothRemoteGattCharacteristicAndroid* characteristic_android =
196 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); 225 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic);
197 JNIEnv* env = base::android::AttachCurrentThread(); 226 JNIEnv* env = base::android::AttachCurrentThread();
198 227
199 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync hronouslyOnce( 228 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync hronouslyOnce(
200 env, characteristic_android->GetJavaObject().obj()); 229 env, characteristic_android->GetJavaObject().obj());
201 } 230 }
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 } 468 }
440 469
441 void BluetoothTestAndroid::OnFakeAdapterStateChanged( 470 void BluetoothTestAndroid::OnFakeAdapterStateChanged(
442 JNIEnv* env, 471 JNIEnv* env,
443 const JavaParamRef<jobject>& caller, 472 const JavaParamRef<jobject>& caller,
444 const bool powered) { 473 const bool powered) {
445 adapter_->NotifyAdapterStateChanged(powered); 474 adapter_->NotifyAdapterStateChanged(powered);
446 } 475 }
447 476
448 } // namespace device 477 } // namespace device
OLDNEW
« 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