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