From 645730da0a3fc477bc3d20497eb1ac4403c66e7c Mon Sep 17 00:00:00 2001 From: weichinweng Date: Wed, 8 Apr 2020 16:41:19 +0800 Subject: [PATCH] Into the BG connection when the HA disconnects from remote side In some cases, it will add the random address into the BG connection after the HA device is connected via a random address. Then the ble_bgconn will add the public address into the controller white list if the random address has the public address. Finally, it will get a second connection handle with the public address on the same HearingAid device. The patch changes the behavior that when the HearingAid device disconnects from the remote side, add the device into the BG connection. Bug: 152517031 Test: 1.run unit test. 2.Forget/Repair HearingAid device from Bluetooth UI. 3.Disconnect/Reconnect HearingAid device from Bluetooth UI. 4.HearingAid device power off/on, check them can reconnect. Change-Id: Id491faeaddaa32bbea0c88c7f0563d299f7f33f8 Merged-In: Id491faeaddaa32bbea0c88c7f0563d299f7f33f8 --- bta/hearing_aid/hearing_aid.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bta/hearing_aid/hearing_aid.cc b/bta/hearing_aid/hearing_aid.cc index 75116f49c..5c50c1aa3 100644 --- a/bta/hearing_aid/hearing_aid.cc +++ b/bta/hearing_aid/hearing_aid.cc @@ -921,9 +921,6 @@ class HearingAidImpl : public HearingAid { } if (hearingDevice->first_connection) { - /* add device into BG connection to accept remote initiated connection */ - BTA_GATTC_Open(gatt_if, address, false, GATT_TRANSPORT_LE, false); - btif_storage_add_hearing_aid(*hearingDevice); hearingDevice->first_connection = false; @@ -1507,7 +1504,10 @@ class HearingAidImpl : public HearingAid { DoDisconnectCleanUp(hearingDevice); - // Keep this hearing aid in the list, and allow to reconnect back. + // This is needed just for the first connection. After stack is restarted, + // code that loads device will add them to whitelist. + BTA_GATTC_Open(gatt_if, hearingDevice->address, false, GATT_TRANSPORT_LE, + false); callbacks->OnConnectionState(ConnectionState::DISCONNECTED, remote_bda); -- 2.11.0