system/bt
修訂 | 461f0b4739967d60a3c6ee2b03ad86fc5abb2e99 (tree) |
---|---|
時間 | 2019-06-06 23:11:15 |
作者 | Jakub Pawlowski <jpawlowski@goog...> |
Commiter | Jakub Pawlowski |
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
@@ -719,6 +719,15 @@ constexpr uint8_t MIN_KEY_SIZE = 7; | ||
719 | 719 | |
720 | 720 | static void read_encryption_key_size_complete_after_encryption_change( |
721 | 721 | uint8_t status, uint16_t handle, uint8_t key_size) { |
722 | + if (status == HCI_ERR_INSUFFCIENT_SECURITY) { | |
723 | + /* If remote device stop the encryption before we call "Read Encryption Key | |
724 | + * Size", we might receive Insufficient Security, which means that link is | |
725 | + * no longer encrypted. */ | |
726 | + HCI_TRACE_WARNING("%s encryption stopped on link: 0x%02x", __func__, | |
727 | + handle); | |
728 | + return; | |
729 | + } | |
730 | + | |
722 | 731 | if (status != HCI_SUCCESS) { |
723 | 732 | HCI_TRACE_WARNING("%s: disconnecting, status: 0x%02x", __func__, status); |
724 | 733 | btsnd_hcic_disconnect(handle, HCI_ERR_PEER_USER); |
@@ -1679,6 +1688,15 @@ static void btu_hcif_enhanced_flush_complete_evt(void) { | ||
1679 | 1688 | |
1680 | 1689 | static void read_encryption_key_size_complete_after_key_refresh( |
1681 | 1690 | uint8_t status, uint16_t handle, uint8_t key_size) { |
1691 | + if (status == HCI_ERR_INSUFFCIENT_SECURITY) { | |
1692 | + /* If remote device stop the encryption before we call "Read Encryption Key | |
1693 | + * Size", we might receive Insufficient Security, which means that link is | |
1694 | + * no longer encrypted. */ | |
1695 | + HCI_TRACE_WARNING("%s encryption stopped on link: 0x%02x", __func__, | |
1696 | + handle); | |
1697 | + return; | |
1698 | + } | |
1699 | + | |
1682 | 1700 | if (status != HCI_SUCCESS) { |
1683 | 1701 | HCI_TRACE_WARNING("%s: disconnecting, status: 0x%02x", __func__, status); |
1684 | 1702 | btsnd_hcic_disconnect(handle, HCI_ERR_PEER_USER); |