Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(910)

Side by Side Diff: device/bluetooth/bluetooth_device_android.cc

Issue 1592733002: Clear the BLE services list on disconnect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the bluetooth/getPrimaryService.html timeout issue Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/bluetooth/bluetooth_device.cc ('k') | device/bluetooth/bluetooth_device_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
215
213 switch (status) { // Constants are from android.bluetooth.BluetoothGatt. 216 switch (status) { // Constants are from android.bluetooth.BluetoothGatt.
214 case 0x0000008f: // GATT_CONNECTION_CONGESTED 217 case 0x0000008f: // GATT_CONNECTION_CONGESTED
215 return DidFailToConnectGatt(ERROR_CONNECTION_CONGESTED); 218 return DidFailToConnectGatt(ERROR_CONNECTION_CONGESTED);
216 case 0x00000101: // GATT_FAILURE 219 case 0x00000101: // GATT_FAILURE
217 return DidFailToConnectGatt(ERROR_FAILED); 220 return DidFailToConnectGatt(ERROR_FAILED);
218 case 0x00000005: // GATT_INSUFFICIENT_AUTHENTICATION 221 case 0x00000005: // GATT_INSUFFICIENT_AUTHENTICATION
219 return DidFailToConnectGatt(ERROR_AUTH_FAILED); 222 return DidFailToConnectGatt(ERROR_AUTH_FAILED);
220 case 0x0000000f: // GATT_INSUFFICIENT_ENCRYPTION 223 case 0x0000000f: // GATT_INSUFFICIENT_ENCRYPTION
221 return DidFailToConnectGatt(ERROR_INSUFFICIENT_ENCRYPTION); 224 return DidFailToConnectGatt(ERROR_INSUFFICIENT_ENCRYPTION);
222 case 0x0000000d: // GATT_INVALID_ATTRIBUTE_LENGTH 225 case 0x0000000d: // GATT_INVALID_ATTRIBUTE_LENGTH
(...skipping 11 matching lines...) Expand all
234 default: 237 default:
235 VLOG(1) << "Unhandled status: " << status; 238 VLOG(1) << "Unhandled status: " << status;
236 return DidFailToConnectGatt(ERROR_UNKNOWN); 239 return DidFailToConnectGatt(ERROR_UNKNOWN);
237 } 240 }
238 } 241 }
239 } 242 }
240 243
241 void BluetoothDeviceAndroid::OnGattServicesDiscovered( 244 void BluetoothDeviceAndroid::OnGattServicesDiscovered(
242 JNIEnv* env, 245 JNIEnv* env,
243 const JavaParamRef<jobject>& jcaller) { 246 const JavaParamRef<jobject>& jcaller) {
247 SetGattServicesDiscoveryComplete(true);
244 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, GetAdapter()->GetObservers(), 248 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, GetAdapter()->GetObservers(),
245 GattServicesDiscovered(GetAdapter(), this)); 249 GattServicesDiscovered(GetAdapter(), this));
246 } 250 }
247 251
248 void BluetoothDeviceAndroid::CreateGattRemoteService( 252 void BluetoothDeviceAndroid::CreateGattRemoteService(
249 JNIEnv* env, 253 JNIEnv* env,
250 const JavaParamRef<jobject>& caller, 254 const JavaParamRef<jobject>& caller,
251 const JavaParamRef<jstring>& instance_id, 255 const JavaParamRef<jstring>& instance_id,
252 const JavaParamRef<jobject>& 256 const JavaParamRef<jobject>&
253 bluetooth_gatt_service_wrapper) { // BluetoothGattServiceWrapper 257 bluetooth_gatt_service_wrapper) { // BluetoothGattServiceWrapper
(...skipping 26 matching lines...) Expand all
280 AttachCurrentThread(), j_device_.obj(), 284 AttachCurrentThread(), j_device_.obj(),
281 base::android::GetApplicationContext()); 285 base::android::GetApplicationContext());
282 } 286 }
283 287
284 void BluetoothDeviceAndroid::DisconnectGatt() { 288 void BluetoothDeviceAndroid::DisconnectGatt() {
285 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), 289 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(),
286 j_device_.obj()); 290 j_device_.obj());
287 } 291 }
288 292
289 } // namespace device 293 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device.cc ('k') | device/bluetooth/bluetooth_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698