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_array.h" | 9 #include "base/android/jni_array.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 203 |
204 void BluetoothDeviceAndroid::OnConnectionStateChange( | 204 void BluetoothDeviceAndroid::OnConnectionStateChange( |
205 JNIEnv* env, | 205 JNIEnv* env, |
206 const JavaParamRef<jobject>& jcaller, | 206 const JavaParamRef<jobject>& jcaller, |
207 int32_t status, | 207 int32_t status, |
208 bool connected) { | 208 bool connected) { |
209 gatt_connected_ = connected; | 209 gatt_connected_ = connected; |
210 if (gatt_connected_) { | 210 if (gatt_connected_) { |
211 DidConnectGatt(); | 211 DidConnectGatt(); |
212 } else { | 212 } else { |
213 gatt_services_.clear(); | |
214 SetGattServicesDiscoveryComplete(false); | 213 SetGattServicesDiscoveryComplete(false); |
215 | 214 |
216 switch (status) { // Constants are from android.bluetooth.BluetoothGatt. | 215 switch (status) { // Constants are from android.bluetooth.BluetoothGatt. |
217 case 0x0000008f: // GATT_CONNECTION_CONGESTED | 216 case 0x0000008f: // GATT_CONNECTION_CONGESTED |
218 return DidFailToConnectGatt(ERROR_CONNECTION_CONGESTED); | 217 return DidFailToConnectGatt(ERROR_CONNECTION_CONGESTED); |
219 case 0x00000101: // GATT_FAILURE | 218 case 0x00000101: // GATT_FAILURE |
220 return DidFailToConnectGatt(ERROR_FAILED); | 219 return DidFailToConnectGatt(ERROR_FAILED); |
221 case 0x00000005: // GATT_INSUFFICIENT_AUTHENTICATION | 220 case 0x00000005: // GATT_INSUFFICIENT_AUTHENTICATION |
222 return DidFailToConnectGatt(ERROR_AUTH_FAILED); | 221 return DidFailToConnectGatt(ERROR_AUTH_FAILED); |
223 case 0x0000000f: // GATT_INSUFFICIENT_ENCRYPTION | 222 case 0x0000000f: // GATT_INSUFFICIENT_ENCRYPTION |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 AttachCurrentThread(), j_device_.obj(), | 283 AttachCurrentThread(), j_device_.obj(), |
285 base::android::GetApplicationContext()); | 284 base::android::GetApplicationContext()); |
286 } | 285 } |
287 | 286 |
288 void BluetoothDeviceAndroid::DisconnectGatt() { | 287 void BluetoothDeviceAndroid::DisconnectGatt() { |
289 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), | 288 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), |
290 j_device_.obj()); | 289 j_device_.obj()); |
291 } | 290 } |
292 | 291 |
293 } // namespace device | 292 } // namespace device |
OLD | NEW |