OSDN Git Service

Into the BG connection when the HA disconnects from remote side
authorweichinweng <weichinweng@google.com>
Wed, 8 Apr 2020 08:41:19 +0000 (16:41 +0800)
committerweichinweng <weichinweng@google.com>
Wed, 22 Apr 2020 06:05:53 +0000 (14:05 +0800)
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

index 75116f4..5c50c1a 100644 (file)
@@ -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);