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

Side by Side Diff: device/bluetooth/bluetooth_device_android.cc

Issue 1464443002: bluetooth: android: Add BluetoothDevice::ConnectErrorCode enums (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: I 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/bluetooth_device_android.h" 5 #include "device/bluetooth/bluetooth_device_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 202
203 void BluetoothDeviceAndroid::OnConnectionStateChange(JNIEnv* env, 203 void BluetoothDeviceAndroid::OnConnectionStateChange(JNIEnv* env,
204 jobject jcaller, 204 jobject jcaller,
205 int32_t status, 205 int32_t status,
206 bool connected) { 206 bool connected) {
207 gatt_connected_ = connected; 207 gatt_connected_ = connected;
208 if (gatt_connected_) { 208 if (gatt_connected_) {
209 DidConnectGatt(); 209 DidConnectGatt();
210 } else { 210 } else {
211 // TODO(scheib) Create new BluetoothDevice::ConnectErrorCode enums for
212 // android values not yet represented. http://crbug.com/531058
213 switch (status) { // Constants are from android.bluetooth.BluetoothGatt. 211 switch (status) { // Constants are from android.bluetooth.BluetoothGatt.
214 case 0x00000101: // GATT_FAILURE 212 case 0x00000101: // GATT_FAILURE
215 return DidFailToConnectGatt(ERROR_FAILED); 213 return DidFailToConnectGatt(ERROR_FAILED);
214 case 0x0000008f: // GATT_CONNECTION_CONGESTED
215 return DidFailToConnectGatt(ERROR_CONNECTION_CONGESTED);
216 case 0x0000000f: // GATT_INSUFFICIENT_ENCRYPTION
scheib 2015/11/19 22:25:05 'Insufficient' is more specific than 'failed', let
217 return DidFailToConnectGatt(ERROR_ENCRYPTION_FAILED);
218 case 0x0000000d: // GATT_INVALID_ATTRIBUTE_LENGTH
219 return DidFailToConnectGatt(ERROR_ATTRIBUTE_LENGTH_INVALID);
220 case 0x00000007: // GATT_INVALID_OFFSET
221 return DidFailToConnectGatt(ERROR_OFFSET_INVALID);
222 case 0x00000006: // GATT_REQUEST_NOT_SUPPORTED
223 return DidFailToConnectGatt(ERROR_REQUEST_FAILED);
scheib 2015/11/19 22:25:06 'Failed' and 'Not supported' have different meanin
216 case 0x00000005: // GATT_INSUFFICIENT_AUTHENTICATION 224 case 0x00000005: // GATT_INSUFFICIENT_AUTHENTICATION
217 return DidFailToConnectGatt(ERROR_AUTH_FAILED); 225 return DidFailToConnectGatt(ERROR_AUTH_FAILED);
226 case 0x00000003: // GATT_WRITE_NOT_PERMITTED
227 return DidFailToConnectGatt(ERROR_WRITE_FAILED);
228 case 0x00000002: // GATT_READ_NOT_PERMITTED
229 return DidFailToConnectGatt(ERROR_READ_FAILED);
218 case 0x00000000: // GATT_SUCCESS 230 case 0x00000000: // GATT_SUCCESS
219 return DidDisconnectGatt(); 231 return DidDisconnectGatt();
220 default: 232 default:
221 VLOG(1) << "Unhandled status: " << status; 233 VLOG(1) << "Unhandled status: " << status;
222 return DidFailToConnectGatt(ERROR_UNKNOWN); 234 return DidFailToConnectGatt(ERROR_UNKNOWN);
223 } 235 }
224 } 236 }
225 } 237 }
226 238
227 void BluetoothDeviceAndroid::OnGattServicesDiscovered(JNIEnv* env, 239 void BluetoothDeviceAndroid::OnGattServicesDiscovered(JNIEnv* env,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 AttachCurrentThread(), j_device_.obj(), 276 AttachCurrentThread(), j_device_.obj(),
265 base::android::GetApplicationContext()); 277 base::android::GetApplicationContext());
266 } 278 }
267 279
268 void BluetoothDeviceAndroid::DisconnectGatt() { 280 void BluetoothDeviceAndroid::DisconnectGatt() {
269 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), 281 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(),
270 j_device_.obj()); 282 j_device_.obj());
271 } 283 }
272 284
273 } // namespace device 285 } // namespace device
OLDNEW
« device/bluetooth/bluetooth_device.h ('K') | « device/bluetooth/bluetooth_device.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698