OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h" | 5 #include "device/bluetooth/bluetooth_device.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
463 // Connection request should only be made if there are no active | 463 // Connection request should only be made if there are no active |
464 // connections. | 464 // connections. |
465 DCHECK(gatt_connections_.empty()); | 465 DCHECK(gatt_connections_.empty()); |
466 | 466 |
467 for (const auto& error_callback : create_gatt_connection_error_callbacks_) | 467 for (const auto& error_callback : create_gatt_connection_error_callbacks_) |
468 error_callback.Run(error); | 468 error_callback.Run(error); |
469 create_gatt_connection_success_callbacks_.clear(); | 469 create_gatt_connection_success_callbacks_.clear(); |
470 create_gatt_connection_error_callbacks_.clear(); | 470 create_gatt_connection_error_callbacks_.clear(); |
471 } | 471 } |
472 | 472 |
473 void BluetoothDevice::DidDisconnectGatt() { | 473 void BluetoothDevice::DidDisconnectGatt(bool notifyDeviceChanged) { |
474 gatt_services_.clear(); | |
475 device_uuids_.ClearServiceUUIDs(); | |
476 SetGattServicesDiscoveryComplete(false); | |
rkc1
2017/05/15 23:56:59
What is the purpose of doing this? This doesn't ac
ortuno
2017/05/16 00:04:27
This line has no effect on BlueZ since the variabl
rkc1
2017/05/16 00:10:09
Right, and since this function is being called fro
ortuno
2017/05/16 00:40:41
I agree. It's unclear what the issue was and how t
perja
2017/05/16 08:23:23
Sure, that sounds like a good approach now.
perja
2017/05/16 08:23:23
It's been a while since I looked into this, but wh
| |
477 | |
474 // Pending calls to connect GATT are not expected, if they were then | 478 // Pending calls to connect GATT are not expected, if they were then |
475 // DidFailToConnectGatt should have been called. | 479 // DidFailToConnectGatt should have been called. |
476 DCHECK(create_gatt_connection_error_callbacks_.empty()); | 480 DCHECK(create_gatt_connection_error_callbacks_.empty()); |
477 | 481 |
478 // Invalidate all BluetoothGattConnection objects. | 482 // Invalidate all BluetoothGattConnection objects. |
479 for (BluetoothGattConnection* connection : gatt_connections_) { | 483 for (BluetoothGattConnection* connection : gatt_connections_) { |
480 connection->InvalidateConnectionReference(); | 484 connection->InvalidateConnectionReference(); |
481 } | 485 } |
482 gatt_connections_.clear(); | 486 gatt_connections_.clear(); |
483 GetAdapter()->NotifyDeviceChanged(this); | 487 if (notifyDeviceChanged) |
488 GetAdapter()->NotifyDeviceChanged(this); | |
484 } | 489 } |
485 | 490 |
486 void BluetoothDevice::AddGattConnection(BluetoothGattConnection* connection) { | 491 void BluetoothDevice::AddGattConnection(BluetoothGattConnection* connection) { |
487 auto result = gatt_connections_.insert(connection); | 492 auto result = gatt_connections_.insert(connection); |
488 DCHECK(result.second); // Check insert happened; there was no duplicate. | 493 DCHECK(result.second); // Check insert happened; there was no duplicate. |
489 } | 494 } |
490 | 495 |
491 void BluetoothDevice::RemoveGattConnection( | 496 void BluetoothDevice::RemoveGattConnection( |
492 BluetoothGattConnection* connection) { | 497 BluetoothGattConnection* connection) { |
493 size_t erased_count = gatt_connections_.erase(connection); | 498 size_t erased_count = gatt_connections_.erase(connection); |
(...skipping 27 matching lines...) Expand all Loading... | |
521 if (power < INT8_MIN) { | 526 if (power < INT8_MIN) { |
522 return INT8_MIN; | 527 return INT8_MIN; |
523 } | 528 } |
524 if (power > INT8_MAX) { | 529 if (power > INT8_MAX) { |
525 return INT8_MAX; | 530 return INT8_MAX; |
526 } | 531 } |
527 return static_cast<int8_t>(power); | 532 return static_cast<int8_t>(power); |
528 } | 533 } |
529 | 534 |
530 } // namespace device | 535 } // namespace device |
OLD | NEW |