| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } else if (!create_gatt_connection_error_callbacks_.empty()) { | 216 } else if (!create_gatt_connection_error_callbacks_.empty()) { |
| 217 // We assume that if there are any pending connection callbacks there | 217 // We assume that if there are any pending connection callbacks there |
| 218 // was a failed connection attempt. | 218 // was a failed connection attempt. |
| 219 RecordConnectionFailureResult(status); | 219 RecordConnectionFailureResult(status); |
| 220 // TODO(ortuno): Return an error code based on |status| | 220 // TODO(ortuno): Return an error code based on |status| |
| 221 // http://crbug.com/578191 | 221 // http://crbug.com/578191 |
| 222 DidFailToConnectGatt(ERROR_FAILED); | 222 DidFailToConnectGatt(ERROR_FAILED); |
| 223 } else { | 223 } else { |
| 224 // Otherwise an existing connection was terminated. | 224 // Otherwise an existing connection was terminated. |
| 225 RecordConnectionTerminatedResult(status); | 225 RecordConnectionTerminatedResult(status); |
| 226 DidDisconnectGatt(true /* notifyDeviceChanged */); | 226 gatt_services_.clear(); |
| 227 device_uuids_.ClearServiceUUIDs(); |
| 228 SetGattServicesDiscoveryComplete(false); |
| 229 DidDisconnectGatt(); |
| 227 } | 230 } |
| 228 } | 231 } |
| 229 | 232 |
| 230 void BluetoothDeviceAndroid::OnGattServicesDiscovered( | 233 void BluetoothDeviceAndroid::OnGattServicesDiscovered( |
| 231 JNIEnv* env, | 234 JNIEnv* env, |
| 232 const JavaParamRef<jobject>& jcaller) { | 235 const JavaParamRef<jobject>& jcaller) { |
| 233 device_uuids_.ReplaceServiceUUIDs(gatt_services_); | 236 device_uuids_.ReplaceServiceUUIDs(gatt_services_); |
| 234 SetGattServicesDiscoveryComplete(true); | 237 SetGattServicesDiscoveryComplete(true); |
| 235 adapter_->NotifyGattServicesDiscovered(this); | 238 adapter_->NotifyGattServicesDiscovered(this); |
| 236 adapter_->NotifyDeviceChanged(this); | 239 adapter_->NotifyDeviceChanged(this); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 264 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { | 267 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { |
| 265 Java_ChromeBluetoothDevice_createGattConnectionImpl( | 268 Java_ChromeBluetoothDevice_createGattConnectionImpl( |
| 266 AttachCurrentThread(), j_device_, base::android::GetApplicationContext()); | 269 AttachCurrentThread(), j_device_, base::android::GetApplicationContext()); |
| 267 } | 270 } |
| 268 | 271 |
| 269 void BluetoothDeviceAndroid::DisconnectGatt() { | 272 void BluetoothDeviceAndroid::DisconnectGatt() { |
| 270 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_); | 273 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_); |
| 271 } | 274 } |
| 272 | 275 |
| 273 } // namespace device | 276 } // namespace device |
| OLD | NEW |