OSDN Git Service

Hearing Aid: set BLE phy to 2M if local and peer indicate PHY 2M support
authorweichinweng <weichinweng@google.com>
Wed, 3 Jul 2019 09:52:19 +0000 (17:52 +0800)
committerWeichin Weng <weichinweng@google.com>
Wed, 3 Jul 2019 10:15:56 +0000 (10:15 +0000)
Set the BLE phy to 2M if the BT controller and peer Hearing Aid device
indicate phy 2M support, otherwise, use default phy channel.

Bug: 135769508
Test: 1.Forget/Repair Hearing Aid device check whether phy is expected.
2.Disconnect/Reconnect Hearing Aid device check whether phy is expected.
3.HearingAid device power off/on, check whether phy is expected.

Change-Id: Ib410a8885f3a68c361bb97d5c9a3833f2a1be528

bta/hearing_aid/hearing_aid.cc

index 187c0ab..0767921 100644 (file)
@@ -390,6 +390,13 @@ class HearingAidImpl : public HearingAid {
       hearingDevice->connection_update_status = AWAITING;
     }
 
+    tACL_CONN* p_acl = btm_bda_to_acl(address, BT_TRANSPORT_LE);
+    if (p_acl != nullptr && controller_get_interface()->supports_ble_2m_phy() &&
+        HCI_LE_2M_PHY_SUPPORTED(p_acl->peer_le_features)) {
+      LOG(INFO) << address << " set preferred PHY to 2M";
+      BTM_BleSetPhy(address, PHY_LE_2M, PHY_LE_2M, 0);
+    }
+
     // Set data length
     // TODO(jpawlowski: for 16khz only 87 is required, optimize
     BTM_SetBleDataLength(address, 167);