system/bt
Révision | 06dd68690a893a906f4c40d245b531f77d741e6f (tree) |
---|---|
l'heure | 2019-08-08 00:09:29 |
Auteur | Jakub Pawlowski <jpawlowski@goog...> |
Commiter | Vasyl Gello |
DO NOT MERGE Fix for Bluetooth connection being dropped after HCI Read Encryption Key Size
If remote device stop the encryption before we call "Read Encryption Key Size",
we might receive Insufficient Security, which means that link is no longer
encrypted.
In such cases we should stay connected, rather than disconnecting the
link.
Test: Connect to device that stop encryption right after encryption is
complete, i.e. to change roles.
Bug: 124301137
Bug: 132626699
Change-Id: Iab0fd9f357d18a6b048b971d0393fbb47fd4d793
Merged-In: Iab0fd9f357d18a6b048b971d0393fbb47fd4d793
(cherry picked from commit c5aa5feebf558df160772fefaf271a6f3251e261)
@@ -611,6 +611,15 @@ bool read_key_send_from_key_refresh = false; | ||
611 | 611 | |
612 | 612 | static void read_encryption_key_size_complete_after_key_refresh( |
613 | 613 | uint8_t status, uint16_t handle, uint8_t key_size) { |
614 | + if (status == HCI_ERR_INSUFFCIENT_SECURITY) { | |
615 | + /* If remote device stop the encryption before we call "Read Encryption Key | |
616 | + * Size", we might receive Insufficient Security, which means that link is | |
617 | + * no longer encrypted. */ | |
618 | + HCI_TRACE_WARNING("%s encryption stopped on link: 0x%02x", __func__, | |
619 | + handle); | |
620 | + return; | |
621 | + } | |
622 | + | |
614 | 623 | if (status != HCI_SUCCESS) { |
615 | 624 | HCI_TRACE_WARNING("%s: disconnecting, status: 0x%02x", __func__, status); |
616 | 625 | btsnd_hcic_disconnect(handle, HCI_ERR_PEER_USER); |
@@ -633,6 +642,15 @@ static void read_encryption_key_size_complete_after_key_refresh( | ||
633 | 642 | |
634 | 643 | static void read_encryption_key_size_complete_after_encryption_change( |
635 | 644 | uint8_t status, uint16_t handle, uint8_t key_size) { |
645 | + if (status == HCI_ERR_INSUFFCIENT_SECURITY) { | |
646 | + /* If remote device stop the encryption before we call "Read Encryption Key | |
647 | + * Size", we might receive Insufficient Security, which means that link is | |
648 | + * no longer encrypted. */ | |
649 | + HCI_TRACE_WARNING("%s encryption stopped on link: 0x%02x", __func__, | |
650 | + handle); | |
651 | + return; | |
652 | + } | |
653 | + | |
636 | 654 | if (status != HCI_SUCCESS) { |
637 | 655 | HCI_TRACE_WARNING("%s: disconnecting, status: 0x%02x", __func__, status); |
638 | 656 | btsnd_hcic_disconnect(handle, HCI_ERR_PEER_USER); |