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/bluetooth_device_android.h" | 5 #include "device/bluetooth/bluetooth_device_android.h" |
| 6 | 6 |
| 7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 int32_t status, | 209 int32_t status, |
| 210 bool connected) { | 210 bool connected) { |
| 211 gatt_connected_ = connected; | 211 gatt_connected_ = connected; |
| 212 if (gatt_connected_) { | 212 if (gatt_connected_) { |
| 213 RecordConnectionSuccessResult(status); | 213 RecordConnectionSuccessResult(status); |
| 214 DidConnectGatt(); | 214 DidConnectGatt(); |
| 215 } else if (!create_gatt_connection_error_callbacks_.empty()) { | 215 } else if (!create_gatt_connection_error_callbacks_.empty()) { |
| 216 // We assume that if there are any pending connection callbacks there | 216 // We assume that if there are any pending connection callbacks there |
| 217 // was a failed connection attempt. | 217 // was a failed connection attempt. |
| 218 RecordConnectionFailureResult(status); | 218 RecordConnectionFailureResult(status); |
| 219 // TODO(ortuno): Return an error code based on |status| | 219 |
| 220 // http://crbug.com/578191 | 220 // The following errors are based on errors seen in the wild. |
|
scheib
2017/03/07 06:20:22
I'm wondering if this patch has too many changes a
ortuno
2017/03/08 01:46:10
I think it does. Removed changes to android.
| |
| 221 DidFailToConnectGatt(ERROR_FAILED); | 221 // They are cross referenced to Android errors, BT Spec errors, |
| 222 // and Bluedroid error where relevant. | |
| 223 // - Android errors: | |
| 224 // https://developer.android.com/reference/android/bluetooth/BluetoothGa tt.html | |
| 225 // - BT Spec 5.0 [Vol 2, Part D] 2 Error Code Descriptions | |
| 226 // - Bluedroid: stack/include/gatt_api.h | |
| 227 switch (status) { | |
| 228 case 0x00000000: // Bluedroid: GATT_SUCCESS | |
| 229 case 0x00000085: // Bluedroid: GATT_ERROR | |
| 230 DidFailToConnectGatt(ERROR_FAILED); | |
| 231 return; | |
| 232 case 0x00000087: // Bluedroid GATT_PENDING | |
| 233 DidFailToConnectGatt(ERROR_INPROGRESS); | |
| 234 return; | |
| 235 default: | |
| 236 DidFailToConnectGatt(ERROR_UNKNOWN); | |
| 237 return; | |
| 238 } | |
| 222 } else { | 239 } else { |
| 223 // Otherwise an existing connection was terminated. | 240 // Otherwise an existing connection was terminated. |
| 224 RecordConnectionTerminatedResult(status); | 241 RecordConnectionTerminatedResult(status); |
| 225 DidDisconnectGatt(true /* notifyDeviceChanged */); | 242 DidDisconnectGatt(true /* notifyDeviceChanged */); |
| 226 } | 243 } |
| 227 } | 244 } |
| 228 | 245 |
| 229 void BluetoothDeviceAndroid::OnGattServicesDiscovered( | 246 void BluetoothDeviceAndroid::OnGattServicesDiscovered( |
| 230 JNIEnv* env, | 247 JNIEnv* env, |
| 231 const JavaParamRef<jobject>& jcaller) { | 248 const JavaParamRef<jobject>& jcaller) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { | 280 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { |
| 264 Java_ChromeBluetoothDevice_createGattConnectionImpl( | 281 Java_ChromeBluetoothDevice_createGattConnectionImpl( |
| 265 AttachCurrentThread(), j_device_, base::android::GetApplicationContext()); | 282 AttachCurrentThread(), j_device_, base::android::GetApplicationContext()); |
| 266 } | 283 } |
| 267 | 284 |
| 268 void BluetoothDeviceAndroid::DisconnectGatt() { | 285 void BluetoothDeviceAndroid::DisconnectGatt() { |
| 269 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_); | 286 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_); |
| 270 } | 287 } |
| 271 | 288 |
| 272 } // namespace device | 289 } // namespace device |
| OLD | NEW |