| 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 4b55498dda947984fbe682123bfdb9aba781d373..58c51c90cb8ac6b66ee45c2bc57f2baed91f05bb 100644
|
| --- a/device/bluetooth/test/bluetooth_test_android.cc
|
| +++ b/device/bluetooth/test/bluetooth_test_android.cc
|
| @@ -116,17 +116,47 @@ void BluetoothTestAndroid::SimulateGattConnection(BluetoothDevice* device) {
|
|
|
| void BluetoothTestAndroid::SimulateGattConnectionError(
|
| BluetoothDevice* device,
|
| - BluetoothDevice::ConnectErrorCode) {
|
| + BluetoothDevice::ConnectErrorCode error_code) {
|
| BluetoothDeviceAndroid* device_android =
|
| static_cast<BluetoothDeviceAndroid*>(device);
|
| + int32_t android_error = 0;
|
| +
|
| + switch (error_code) {
|
| + case BluetoothDevice::ERROR_AUTH_CANCELED:
|
| + case BluetoothDevice::ERROR_AUTH_FAILED:
|
| + case BluetoothDevice::ERROR_AUTH_REJECTED:
|
| + case BluetoothDevice::ERROR_AUTH_TIMEOUT:
|
| + // These errors are only relevant for pairing and therefore not relevant
|
| + // to our Android implementation, so we just return Unspecified Error
|
| + // (0x1f) from BT Spec 5.0 [Vol 2, Part D] 2.31.
|
| + android_error = 0x1f;
|
| + break;
|
| + case BluetoothDevice::ERROR_FAILED:
|
| + // 0x85 is the number returned by Bluedroid in gatt_api.h for GATT_ERROR
|
| + // which we map to ERROR_FAILED.
|
| + android_error = 0x85;
|
| + break;
|
| + case BluetoothDevice::ERROR_INPROGRESS:
|
| + // 0x87 is the number returned by Bluedroid in gatt_api.h for GATT_PENDING
|
| + // which we map to ERROR_INPROGRESS.
|
| + android_error = 0x87;
|
| + break;
|
| + case BluetoothDevice::ERROR_UNKNOWN:
|
| + case BluetoothDevice::ERROR_UNSUPPORTED_DEVICE:
|
| + // We don't know of any instances of Android returning errors that would
|
| + // map to these errors so we just return Unspecified Error
|
| + // (0x1f) from BT Spec 5.0 [Vol 2, Part D] 2.31.
|
| + android_error = 0x1f;
|
| + break;
|
| + case BluetoothDevice::NUM_CONNECT_ERROR_CODES:
|
| + NOTREACHED();
|
| + android_error = 0x1f;
|
| + break;
|
| + }
|
|
|
| Java_FakeBluetoothDevice_connectionStateChange(
|
| - AttachCurrentThread(), device_android->GetJavaObject(),
|
| - // TODO(ortuno): Add all types of errors Android can produce. For now we
|
| - // just return a timeout error.
|
| - // http://crbug.com/578191
|
| - 0x08, // Connection Timeout from Bluetooth Spec.
|
| - false); // connected
|
| + AttachCurrentThread(), device_android->GetJavaObject(), android_error,
|
| + false /* connected */);
|
| }
|
|
|
| void BluetoothTestAndroid::SimulateGattDisconnection(BluetoothDevice* device) {
|
| @@ -135,7 +165,7 @@ void BluetoothTestAndroid::SimulateGattDisconnection(BluetoothDevice* device) {
|
|
|
| Java_FakeBluetoothDevice_connectionStateChange(
|
| AttachCurrentThread(), device_android->GetJavaObject(),
|
| - 0x13, // Connection terminate by peer user from Bluetooth Spec.
|
| + 0x85, // GATT_ERROR from Bluedroid in gatt_api.h
|
| false); // disconnected
|
| }
|
|
|
|
|