Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 AttachCurrentThread(), device_android->GetJavaObject().obj(), | 79 AttachCurrentThread(), device_android->GetJavaObject().obj(), |
| 80 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS | 80 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS |
| 81 true); // connected | 81 true); // connected |
| 82 } | 82 } |
| 83 | 83 |
| 84 void BluetoothTestAndroid::SimulateGattConnectionError( | 84 void BluetoothTestAndroid::SimulateGattConnectionError( |
| 85 BluetoothDevice* device, | 85 BluetoothDevice* device, |
| 86 BluetoothDevice::ConnectErrorCode error) { | 86 BluetoothDevice::ConnectErrorCode error) { |
| 87 int android_error_value = 0; | 87 int android_error_value = 0; |
| 88 switch (error) { // Constants are from android.bluetooth.BluetoothGatt. | 88 switch (error) { // Constants are from android.bluetooth.BluetoothGatt. |
| 89 case BluetoothDevice::ERROR_CONNECTION_CONGESTED: | |
|
scheib
2015/11/26 00:02:51
Sort list alphabetically.
Kai Jiang
2015/11/29 10:40:51
Done.
| |
| 90 android_error_value = 0x0000008f; // GATT_CONNECTION_CONGESTED | |
| 91 break; | |
| 89 case BluetoothDevice::ERROR_FAILED: | 92 case BluetoothDevice::ERROR_FAILED: |
| 90 android_error_value = 0x00000101; // GATT_FAILURE | 93 android_error_value = 0x00000101; // GATT_FAILURE |
| 91 break; | 94 break; |
| 92 case BluetoothDevice::ERROR_AUTH_FAILED: | 95 case BluetoothDevice::ERROR_AUTH_FAILED: |
| 93 android_error_value = 0x00000005; // GATT_INSUFFICIENT_AUTHENTICATION | 96 android_error_value = 0x00000005; // GATT_INSUFFICIENT_AUTHENTICATION |
| 94 break; | 97 break; |
| 95 case BluetoothDevice::ERROR_UNKNOWN: | 98 case BluetoothDevice::ERROR_INSUFFICIENT_ENCRYPTION: |
| 96 case BluetoothDevice::ERROR_INPROGRESS: | 99 android_error_value = 0x0000000f; // GATT_INSUFFICIENT_ENCRYPTION |
| 100 break; | |
| 101 case BluetoothDevice::ERROR_ATTRIBUTE_LENGTH_INVALID: | |
| 102 android_error_value = 0x0000000d; // GATT_INVALID_ATTRIBUTE_LENGTH | |
| 103 break; | |
| 104 case BluetoothDevice::ERROR_OFFSET_INVALID: | |
| 105 android_error_value = 0x00000007; // GATT_INVALID_OFFSET | |
| 106 break; | |
| 107 case BluetoothDevice::ERROR_READ_FAILED: | |
| 108 android_error_value = 0x00000002; // GATT_READ_NOT_PERMITTED | |
| 109 break; | |
| 110 case BluetoothDevice::ERROR_REQUEST_NOT_SUPPORTED: | |
| 111 android_error_value = 0x00000006; // GATT_REQUEST_NOT_SUPPORTED | |
| 112 break; | |
| 113 case BluetoothDevice::ERROR_WRITE_FAILED: | |
|
Kai Jiang
2015/11/29 10:40:51
ERROR_{READ, WRITE}_NOT_PERMITTED
| |
| 114 android_error_value = 0x00000003; // GATT_WRITE_NOT_PERMITTED | |
| 115 break; | |
| 97 case BluetoothDevice::ERROR_AUTH_CANCELED: | 116 case BluetoothDevice::ERROR_AUTH_CANCELED: |
| 98 case BluetoothDevice::ERROR_AUTH_REJECTED: | 117 case BluetoothDevice::ERROR_AUTH_REJECTED: |
| 99 case BluetoothDevice::ERROR_AUTH_TIMEOUT: | 118 case BluetoothDevice::ERROR_AUTH_TIMEOUT: |
| 119 case BluetoothDevice::ERROR_INPROGRESS: | |
| 120 case BluetoothDevice::ERROR_UNKNOWN: | |
| 100 case BluetoothDevice::ERROR_UNSUPPORTED_DEVICE: | 121 case BluetoothDevice::ERROR_UNSUPPORTED_DEVICE: |
| 101 NOTREACHED() << "No translation for error code: " << error; | 122 NOTREACHED() << "No translation for error code: " << error; |
| 102 } | 123 } |
| 103 | 124 |
| 104 BluetoothDeviceAndroid* device_android = | 125 BluetoothDeviceAndroid* device_android = |
| 105 static_cast<BluetoothDeviceAndroid*>(device); | 126 static_cast<BluetoothDeviceAndroid*>(device); |
| 106 | 127 |
| 107 Java_FakeBluetoothDevice_connectionStateChange( | 128 Java_FakeBluetoothDevice_connectionStateChange( |
| 108 AttachCurrentThread(), device_android->GetJavaObject().obj(), | 129 AttachCurrentThread(), device_android->GetJavaObject().obj(), |
| 109 android_error_value, | 130 android_error_value, |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 | 302 |
| 282 void BluetoothTestAndroid::OnFakeBluetoothGattWriteCharacteristic( | 303 void BluetoothTestAndroid::OnFakeBluetoothGattWriteCharacteristic( |
| 283 JNIEnv* env, | 304 JNIEnv* env, |
| 284 jobject caller, | 305 jobject caller, |
| 285 jbyteArray value) { | 306 jbyteArray value) { |
| 286 gatt_write_characteristic_attempts_++; | 307 gatt_write_characteristic_attempts_++; |
| 287 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); | 308 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); |
| 288 } | 309 } |
| 289 | 310 |
| 290 } // namespace device | 311 } // namespace device |
| OLD | NEW |