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/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.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 DidDisconnectGatt(true /* notifyDeviceChanged */); | 225 gatt_services_.clear(); |
| 226 device_uuids_.ClearServiceUUIDs(); |
| 227 SetGattServicesDiscoveryComplete(false); |
| 228 DidDisconnectGatt(); |
226 } | 229 } |
227 } | 230 } |
228 | 231 |
229 void BluetoothDeviceAndroid::OnGattServicesDiscovered( | 232 void BluetoothDeviceAndroid::OnGattServicesDiscovered( |
230 JNIEnv* env, | 233 JNIEnv* env, |
231 const JavaParamRef<jobject>& jcaller) { | 234 const JavaParamRef<jobject>& jcaller) { |
232 device_uuids_.ReplaceServiceUUIDs(gatt_services_); | 235 device_uuids_.ReplaceServiceUUIDs(gatt_services_); |
233 SetGattServicesDiscoveryComplete(true); | 236 SetGattServicesDiscoveryComplete(true); |
234 adapter_->NotifyGattServicesDiscovered(this); | 237 adapter_->NotifyGattServicesDiscovered(this); |
235 adapter_->NotifyDeviceChanged(this); | 238 adapter_->NotifyDeviceChanged(this); |
(...skipping 27 matching lines...) Expand all Loading... |
263 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { | 266 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { |
264 Java_ChromeBluetoothDevice_createGattConnectionImpl(AttachCurrentThread(), | 267 Java_ChromeBluetoothDevice_createGattConnectionImpl(AttachCurrentThread(), |
265 j_device_); | 268 j_device_); |
266 } | 269 } |
267 | 270 |
268 void BluetoothDeviceAndroid::DisconnectGatt() { | 271 void BluetoothDeviceAndroid::DisconnectGatt() { |
269 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_); | 272 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_); |
270 } | 273 } |
271 | 274 |
272 } // namespace device | 275 } // namespace device |
OLD | NEW |