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

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

Issue 1464443002: bluetooth: android: Add BluetoothDevice::ConnectErrorCode enums (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: II Created 5 years, 1 month 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_FAILED: 89 case BluetoothDevice::ERROR_FAILED:
scheib 2015/11/24 01:30:48 Please sort into two groups ordered BluetoothDevic
Kai Jiang 2015/11/25 14:17:13 Done.
90 android_error_value = 0x00000101; // GATT_FAILURE 90 android_error_value = 0x00000101; // GATT_FAILURE
91 break; 91 break;
92 case BluetoothDevice::ERROR_CONNECTION_CONGESTED:
93 android_error_value = 0x0000008f; // GATT_CONNECTION_CONGESTED
94 break;
95 case BluetoothDevice::ERROR_INSUFFICIENT_ENCRYPTION:
96 android_error_value = 0x0000000f; // GATT_INSUFFICIENT_ENCRYPTION
97 break;
98 case BluetoothDevice::ERROR_ATTRIBUTE_LENGTH_INVALID:
99 android_error_value = 0x0000000d; // GATT_INVALID_ATTRIBUTE_LENGTH
100 break;
101 case BluetoothDevice::ERROR_OFFSET_INVALID:
102 android_error_value = 0x00000007; // GATT_INVALID_OFFSET
103 break;
104 case BluetoothDevice::ERROR_REQUEST_NOT_SUPPORTED:
105 android_error_value = 0x00000006; // GATT_REQUEST_NOT_SUPPORTED
106 break;
92 case BluetoothDevice::ERROR_AUTH_FAILED: 107 case BluetoothDevice::ERROR_AUTH_FAILED:
93 android_error_value = 0x00000005; // GATT_INSUFFICIENT_AUTHENTICATION 108 android_error_value = 0x00000005; // GATT_INSUFFICIENT_AUTHENTICATION
94 break; 109 break;
110 case BluetoothDevice::ERROR_WRITE_FAILED:
111 android_error_value = 0x00000003; // GATT_WRITE_NOT_PERMITTED
112 break;
113 case BluetoothDevice::ERROR_READ_FAILED:
114 android_error_value = 0x00000002; // GATT_READ_NOT_PERMITTED
115 break;
95 case BluetoothDevice::ERROR_UNKNOWN: 116 case BluetoothDevice::ERROR_UNKNOWN:
96 case BluetoothDevice::ERROR_INPROGRESS: 117 case BluetoothDevice::ERROR_INPROGRESS:
97 case BluetoothDevice::ERROR_AUTH_CANCELED: 118 case BluetoothDevice::ERROR_AUTH_CANCELED:
98 case BluetoothDevice::ERROR_AUTH_REJECTED: 119 case BluetoothDevice::ERROR_AUTH_REJECTED:
99 case BluetoothDevice::ERROR_AUTH_TIMEOUT: 120 case BluetoothDevice::ERROR_AUTH_TIMEOUT:
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 =
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698