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

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: VI Created 4 years, 11 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 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_ATTRIBUTE_LENGTH_INVALID:
90 android_error_value = 0x00000101; // GATT_FAILURE 90 android_error_value = 0x0000000d; // GATT_INVALID_ATTRIBUTE_LENGTH
91 break; 91 break;
92 case BluetoothDevice::ERROR_AUTH_FAILED: 92 case BluetoothDevice::ERROR_AUTH_FAILED:
93 android_error_value = 0x00000005; // GATT_INSUFFICIENT_AUTHENTICATION 93 android_error_value = 0x00000005; // GATT_INSUFFICIENT_AUTHENTICATION
94 break; 94 break;
95 case BluetoothDevice::ERROR_UNKNOWN: 95 case BluetoothDevice::ERROR_CONNECTION_CONGESTED:
96 case BluetoothDevice::ERROR_INPROGRESS: 96 android_error_value = 0x0000008f; // GATT_CONNECTION_CONGESTED
97 break;
98 case BluetoothDevice::ERROR_FAILED:
99 android_error_value = 0x00000101; // GATT_FAILURE
100 break;
101 case BluetoothDevice::ERROR_INSUFFICIENT_ENCRYPTION:
102 android_error_value = 0x0000000f; // GATT_INSUFFICIENT_ENCRYPTION
103 break;
104 case BluetoothDevice::ERROR_OFFSET_INVALID:
105 android_error_value = 0x00000007; // GATT_INVALID_OFFSET
106 break;
107 case BluetoothDevice::ERROR_READ_NOT_PERMITTED:
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_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:
122 case BluetoothDevice::NUM_CONNECT_ERROR_CODES:
101 NOTREACHED() << "No translation for error code: " << error; 123 NOTREACHED() << "No translation for error code: " << error;
102 } 124 }
103 125
104 BluetoothDeviceAndroid* device_android = 126 BluetoothDeviceAndroid* device_android =
105 static_cast<BluetoothDeviceAndroid*>(device); 127 static_cast<BluetoothDeviceAndroid*>(device);
106 128
107 Java_FakeBluetoothDevice_connectionStateChange( 129 Java_FakeBluetoothDevice_connectionStateChange(
108 AttachCurrentThread(), device_android->GetJavaObject().obj(), 130 AttachCurrentThread(), device_android->GetJavaObject().obj(),
109 android_error_value, 131 android_error_value,
110 false); // connected 132 false); // connected
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 318
297 void BluetoothTestAndroid::OnFakeBluetoothGattWriteCharacteristic( 319 void BluetoothTestAndroid::OnFakeBluetoothGattWriteCharacteristic(
298 JNIEnv* env, 320 JNIEnv* env,
299 const JavaParamRef<jobject>& caller, 321 const JavaParamRef<jobject>& caller,
300 const JavaParamRef<jbyteArray>& value) { 322 const JavaParamRef<jbyteArray>& value) {
301 gatt_write_characteristic_attempts_++; 323 gatt_write_characteristic_attempts_++;
302 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); 324 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_);
303 } 325 }
304 326
305 } // namespace device 327 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698