Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23ade73c authored by weichinweng's avatar weichinweng
Browse files

Move SetPhy and SetDataLength after connection open

Since other patch was merged in. Move these action to origin place
for keeping origin flow.

Other patch information:
Remove unused entry into l2cap
I77f5e61be5162e6539b47823512f4537fedec392

Tag: #feature
Bug: 233028500
Test: manual
Ignore-AOSP-First: cherry-pick
Merged-In: Iec667cc5f3bd228c7ce72409b90bc3925cd636f9
Change-Id: Iec667cc5f3bd228c7ce72409b90bc3925cd636f9
parent df41271b
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -359,8 +359,6 @@ class HearingAidImpl : public HearingAid {
  void OnGattConnected(tGATT_STATUS status, uint16_t conn_id,
                       tGATT_IF client_if, RawAddress address,
                       tBT_TRANSPORT transport, uint16_t mtu) {
    VLOG(2) << __func__ << ": address=" << address << ", conn_id=" << conn_id;

    HearingDevice* hearingDevice = hearingDevices.FindByAddress(address);
    if (!hearingDevice) {
      /* When Hearing Aid is quickly disabled and enabled in settings, this case
@@ -371,6 +369,8 @@ class HearingAidImpl : public HearingAid {
      return;
    }

    LOG(INFO) << __func__ << ": address=" << address << ", conn_id=" << conn_id;

    if (status != GATT_SUCCESS) {
      if (!hearingDevice->connecting_actively) {
        // acceptlist connection failed, that's ok.
@@ -402,6 +402,15 @@ class HearingAidImpl : public HearingAid {
      hearingDevice->connection_update_status = AWAITING;
    }

    if (controller_get_interface()->supports_ble_2m_phy()) {
      LOG(INFO) << address << " set preferred 2M PHY";
      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);

    if (BTM_SecIsSecurityPending(address)) {
      /* if security collision happened, wait for encryption done
       * (BTA_GATTC_ENC_CMPL_CB_EVT) */
@@ -890,15 +899,6 @@ class HearingAidImpl : public HearingAid {
  void ConnectSocket(HearingDevice* hearingDevice, uint16_t psm) {
    tL2CAP_CFG_INFO cfg_info = tL2CAP_CFG_INFO{.mtu = 512};

    if (controller_get_interface()->supports_ble_2m_phy()) {
      LOG(INFO) << hearingDevice->address << " set preferred PHY to 2M";
      BTM_BleSetPhy(hearingDevice->address, PHY_LE_2M, PHY_LE_2M, 0);
    }

    // Set data length
    // TODO(jpawlowski: for 16khz only 87 is required, optimize
    BTM_SetBleDataLength(hearingDevice->address, 167);

    SendEnableServiceChangedInd(hearingDevice);

    uint8_t service_id = hearingDevice->isLeft()