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

Commit e42b4248 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski Committed by Gerrit Code Review
Browse files

Merge "leaudio: Fix the MTU exchange request"

parents d80dfef9 b2ff4386
Loading
Loading
Loading
Loading
+21 −5
Original line number Original line Diff line number Diff line
@@ -1527,11 +1527,7 @@ class LeAudioClientImpl : public LeAudioClient {


    leAudioDevice->connecting_actively_ = false;
    leAudioDevice->connecting_actively_ = false;
    leAudioDevice->conn_id_ = conn_id;
    leAudioDevice->conn_id_ = conn_id;

    leAudioDevice->mtu_ = mtu;
    if (mtu == GATT_DEF_BLE_MTU_SIZE) {
      LOG(INFO) << __func__ << ", Configure MTU";
      BtaGattQueue::ConfigureMtu(leAudioDevice->conn_id_, 240);
    }


    if (BTM_SecIsSecurityPending(address)) {
    if (BTM_SecIsSecurityPending(address)) {
      /* if security collision happened, wait for encryption done
      /* if security collision happened, wait for encryption done
@@ -1610,6 +1606,13 @@ class LeAudioClientImpl : public LeAudioClient {
                                 leAudioDevice->address_, ase.hdls);
                                 leAudioDevice->address_, ase.hdls);
  }
  }


  void changeMtuIfPossible(LeAudioDevice* leAudioDevice) {
    if (leAudioDevice->mtu_ == GATT_DEF_BLE_MTU_SIZE) {
      LOG(INFO) << __func__ << ", Configure MTU";
      BtaGattQueue::ConfigureMtu(leAudioDevice->conn_id_, GATT_MAX_MTU_SIZE);
    }
  }

  void OnEncryptionComplete(const RawAddress& address, uint8_t status) {
  void OnEncryptionComplete(const RawAddress& address, uint8_t status) {
    LOG(INFO) << __func__ << " " << address << "status: " << int{status};
    LOG(INFO) << __func__ << " " << address << "status: " << int{status};


@@ -1636,6 +1639,8 @@ class LeAudioClientImpl : public LeAudioClient {
    if (leAudioDevice->known_service_handles_)
    if (leAudioDevice->known_service_handles_)
      RegisterKnownNotifications(leAudioDevice);
      RegisterKnownNotifications(leAudioDevice);


    changeMtuIfPossible(leAudioDevice);

    if (leAudioDevice->encrypted_) {
    if (leAudioDevice->encrypted_) {
      LOG(INFO) << __func__ << " link already encrypted, nothing to do";
      LOG(INFO) << __func__ << " link already encrypted, nothing to do";
      return;
      return;
@@ -1750,6 +1755,16 @@ class LeAudioClientImpl : public LeAudioClient {
    DeregisterNotifications(leAudioDevice);
    DeregisterNotifications(leAudioDevice);
  }
  }


  void OnMtuChanged(uint16_t conn_id, uint16_t mtu) {
    LeAudioDevice* leAudioDevice = leAudioDevices_.FindByConnId(conn_id);
    if (!leAudioDevice) {
      LOG_DEBUG("Unknown connectect id %d", conn_id);
      return;
    }

    leAudioDevice->mtu_ = mtu;
  }

  void OnGattServiceDiscoveryDone(const RawAddress& address) {
  void OnGattServiceDiscoveryDone(const RawAddress& address) {
    LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address);
    LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address);
    if (!leAudioDevice) {
    if (!leAudioDevice) {
@@ -3997,6 +4012,7 @@ void le_audio_gattc_callback(tBTA_GATTC_EVT event, tBTA_GATTC* p_data) {
      instance->OnServiceChangeEvent(p_data->remote_bda);
      instance->OnServiceChangeEvent(p_data->remote_bda);
      break;
      break;
    case BTA_GATTC_CFG_MTU_EVT:
    case BTA_GATTC_CFG_MTU_EVT:
      instance->OnMtuChanged(p_data->cfg_mtu.conn_id, p_data->cfg_mtu.mtu);
      break;
      break;


    default:
    default:
+2 −0
Original line number Original line Diff line number Diff line
@@ -60,6 +60,7 @@ class LeAudioDevice {
  bool connecting_actively_;
  bool connecting_actively_;
  bool closing_stream_for_disconnection_;
  bool closing_stream_for_disconnection_;
  uint16_t conn_id_;
  uint16_t conn_id_;
  uint16_t mtu_;
  bool encrypted_;
  bool encrypted_;
  int group_id_;
  int group_id_;
  bool csis_member_;
  bool csis_member_;
@@ -93,6 +94,7 @@ class LeAudioDevice {
        connecting_actively_(first_connection),
        connecting_actively_(first_connection),
        closing_stream_for_disconnection_(false),
        closing_stream_for_disconnection_(false),
        conn_id_(GATT_INVALID_CONN_ID),
        conn_id_(GATT_INVALID_CONN_ID),
        mtu_(0),
        encrypted_(false),
        encrypted_(false),
        group_id_(group_id),
        group_id_(group_id),
        csis_member_(false),
        csis_member_(false),