OSDN Git Service

Fix race condition around Le Start Encryption handling.
authorJakub Pawlowski <jpawlowski@google.com>
Mon, 1 Oct 2018 11:25:11 +0000 (13:25 +0200)
committerJakub Pawlowski <jpawlowski@google.com>
Mon, 8 Oct 2018 20:37:09 +0000 (22:37 +0200)
commitd78b1dd8fa4f6cb7faa11c589c82fb43312956da
tree805f0ec0b70d21e631cc77ef8ade82bb1461d346
parent68e05e155ecfca72b50bbc5f46efc2fae6f6d01c
Fix race condition around Le Start Encryption handling.

When sending Le Start Encryption, it's possible that at the same exact
moment the connection was disconnected, and there is an incoming
"Disconnection Complete Event". The controller would send error 0x02
"unknown connection identifier" in such case. This can happen
sporadically when reconnecting device multiple times.

Currently, we don't handle this error code. This lead to the timeout
when waiting for "Encryption Complete", and unbonding of the device.

From now on, if 0x02 error code is returned, we'll cancel current SMP
operation, which is the "LE Start Encryption". This will stop the SMP
timer, and make sure the bond to remote device is not lost.

Test: Manual test reconnecting with HID device multiple time in a row,
causing the link drop right after connection, by removing battery, or
closing the shield box.
Bug: 113652889
Change-Id: I2ff9c13dbc8e7b71505908996e26b89fa1ea6a42
bta/dm/bta_dm_act.cc
btif/src/btif_dm.cc
stack/btu/btu_hcif.cc
stack/smp/smp_act.cc