system/bt
Revision | a950098d66721ad689daef1c6ed2ee615a9d7feb (tree) |
---|---|
Zeit | 2019-06-11 10:52:39 |
Autor | Jakub Pawlowski <jpawlowski@goog...> |
Commiter | Nikoli Cartagena |
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 c978f86b506f31567b5991c91cdbe4c142ca8edd)
@@ -733,6 +733,14 @@ static void read_encryption_key_size_complete_after_encryption_change( | ||
733 | 733 | << std::to_string(key_size); |
734 | 734 | } |
735 | 735 | |
736 | + if (status == HCI_ERR_INSUFFCIENT_SECURITY) { | |
737 | + /* If remote device stop the encryption before we call "Read Encryption Key | |
738 | + * Size", we might receive Insufficient Security, which means that link is | |
739 | + * no longer encrypted. */ | |
740 | + LOG(INFO) << __func__ << ": encryption stopped on link: " << loghex(handle); | |
741 | + return; | |
742 | + } | |
743 | + | |
736 | 744 | if (status != HCI_SUCCESS) { |
737 | 745 | LOG(INFO) << __func__ << ": disconnecting, status: " << loghex(status); |
738 | 746 | btsnd_hcic_disconnect(handle, HCI_ERR_PEER_USER); |
@@ -1694,6 +1702,14 @@ static void read_encryption_key_size_complete_after_key_refresh( | ||
1694 | 1702 | << std::to_string(key_size); |
1695 | 1703 | } |
1696 | 1704 | |
1705 | + if (status == HCI_ERR_INSUFFCIENT_SECURITY) { | |
1706 | + /* If remote device stop the encryption before we call "Read Encryption Key | |
1707 | + * Size", we might receive Insufficient Security, which means that link is | |
1708 | + * no longer encrypted. */ | |
1709 | + LOG(INFO) << __func__ << ": encryption stopped on link: " << loghex(handle); | |
1710 | + return; | |
1711 | + } | |
1712 | + | |
1697 | 1713 | if (status != HCI_SUCCESS) { |
1698 | 1714 | LOG(INFO) << __func__ << ": disconnecting, status: " << loghex(status); |
1699 | 1715 | btsnd_hcic_disconnect(handle, HCI_ERR_PEER_USER); |