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

Side by Side Diff: device/bluetooth/test/bluetooth_test_android.cc

Issue 2051333004: Implement BluetoothGattNotifySession::Stop on Android, 2nd attempt (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Giovanni's review comments Created 4 years, 4 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
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 ->GetDescriptorsByUUID(BluetoothRemoteGattDescriptor:: 220 ->GetDescriptorsByUUID(BluetoothRemoteGattDescriptor::
221 ClientCharacteristicConfigurationUuid()) 221 ClientCharacteristicConfigurationUuid())
222 .at(0)); 222 .at(0));
223 } 223 }
224 Java_FakeBluetoothGattDescriptor_valueWrite( 224 Java_FakeBluetoothGattDescriptor_valueWrite(
225 base::android::AttachCurrentThread(), 225 base::android::AttachCurrentThread(),
226 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr, 226 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr,
227 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code)); 227 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code));
228 } 228 }
229 229
230 void BluetoothTestAndroid::SimulateGattNotifySessionStopped(
231 BluetoothRemoteGattCharacteristic* characteristic) {
232 BluetoothRemoteGattDescriptorAndroid* descriptor_android = nullptr;
233 if (characteristic) {
234 descriptor_android = static_cast<BluetoothRemoteGattDescriptorAndroid*>(
235 characteristic
236 ->GetDescriptorsByUUID(BluetoothRemoteGattDescriptor::
237 ClientCharacteristicConfigurationUuid())
238 .at(0));
239 }
240 Java_FakeBluetoothGattDescriptor_valueWrite(
241 base::android::AttachCurrentThread(),
242 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr,
243 0); // android.bluetooth.BluetoothGatt.GATT_SUCCESS
244 }
245
246 void BluetoothTestAndroid::SimulateGattNotifySessionStopError(
247 BluetoothRemoteGattCharacteristic* characteristic,
248 BluetoothRemoteGattService::GattErrorCode error_code) {
249 BluetoothRemoteGattDescriptorAndroid* descriptor_android = nullptr;
250 if (characteristic) {
251 descriptor_android = static_cast<BluetoothRemoteGattDescriptorAndroid*>(
252 characteristic
253 ->GetDescriptorsByUUID(BluetoothRemoteGattDescriptor::
254 ClientCharacteristicConfigurationUuid())
255 .at(0));
256 }
257 Java_FakeBluetoothGattDescriptor_valueWrite(
258 base::android::AttachCurrentThread(),
259 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr,
260 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code));
261 }
262
230 void BluetoothTestAndroid:: 263 void BluetoothTestAndroid::
231 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( 264 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce(
232 BluetoothRemoteGattCharacteristic* characteristic) { 265 BluetoothRemoteGattCharacteristic* characteristic) {
233 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = 266 BluetoothRemoteGattCharacteristicAndroid* characteristic_android =
234 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); 267 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic);
235 JNIEnv* env = base::android::AttachCurrentThread(); 268 JNIEnv* env = base::android::AttachCurrentThread();
236 269
237 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync hronouslyOnce( 270 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync hronouslyOnce(
238 env, characteristic_android->GetJavaObject().obj()); 271 env, characteristic_android->GetJavaObject().obj());
239 } 272 }
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 } 510 }
478 511
479 void BluetoothTestAndroid::OnFakeAdapterStateChanged( 512 void BluetoothTestAndroid::OnFakeAdapterStateChanged(
480 JNIEnv* env, 513 JNIEnv* env,
481 const JavaParamRef<jobject>& caller, 514 const JavaParamRef<jobject>& caller,
482 const bool powered) { 515 const bool powered) {
483 adapter_->NotifyAdapterPoweredChanged(powered); 516 adapter_->NotifyAdapterPoweredChanged(powered);
484 } 517 }
485 518
486 } // namespace device 519 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698