Properly disconnect GATT connection during noisy scans
This patch fixes an issue that is reproducible in highly noisy environments
(massive deployment of BLE beacons), through repeated connect/disconnect
attempts on a remote peripheral while scanning for beacons in the background.
The state machine in bta/gatt has a special control flow for handling disconnect
requests during discovery, which in this case failed to resolve the original
request by issuing an HCI_Disconnect command. This is now fixed by always
explicitly triggering the connection close sequence once the discovery state has
been cleaned up.
This patch also includes a fix for a crash that occurred as a side-effect of the
scenario described above.
Bug:
22350508
Change-Id: Ie9cbd3c8f54239b142bfb8dde80d9581ae70ed43