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

Commit 9ded4ec4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I14093b5d,I9609b25d,Ic06c7a3d,I3f36c785,I6200c494, ...

* changes:
  leaudio: Workaround for the audio configuration change
  vc: Fix for incorrect encryption state
  vc: Call remove device on unbonding event
  leaudio: Improve connecting other set members
  leaudio: Fix background connection
  leaudio: Clean connecting_actively_ flag
parents f64a1921 e97e9c15
Loading
Loading
Loading
Loading
+50 −8
Original line number Diff line number Diff line
@@ -718,7 +718,30 @@ class LeAudioClientImpl : public LeAudioClient {
      group_add_node(group_id, address);
    }

    if (autoconnect) Connect(address);
    if (autoconnect) {
      BTA_GATTC_Open(gatt_if_, address, false, false);
    }
  }

  void BackgroundConnectIfGroupConnected(LeAudioDevice* leAudioDevice) {
    DLOG(INFO) << __func__ << leAudioDevice->address_ ;
    auto group = aseGroups_.FindById(leAudioDevice->group_id_);
    if (!group) {
      DLOG(INFO) << __func__ << " Device is not yet part of the group. ";
      return;
    }

    if (!group->IsAnyDeviceConnected()) {
      DLOG(INFO) << __func__ << " group: " << leAudioDevice->group_id_
                 << " is not connected";
      return;
    }

    DLOG(INFO) << __func__ << "Add " << leAudioDevice->address_
               << " to background connect to connected group: "
               << leAudioDevice->group_id_;

    BTA_GATTC_Open(gatt_if_, leAudioDevice->address_, false, false);
  }

  void Disconnect(const RawAddress& address) override {
@@ -731,19 +754,23 @@ class LeAudioClientImpl : public LeAudioClient {
    }

    /* cancel pending direct connect */
    if (leAudioDevice->connecting_actively_)
    if (leAudioDevice->connecting_actively_) {
      BTA_GATTC_CancelOpen(gatt_if_, address, true);
      leAudioDevice->connecting_actively_ = false;
    }

    /* Removes all registrations for connection */
    BTA_GATTC_CancelOpen(0, address, false);

    if (leAudioDevice->conn_id_ == GATT_INVALID_CONN_ID) {
      LOG(ERROR) << __func__ << ", leAudioDevice not connected (" << address
                 << ")";
    if (leAudioDevice->conn_id_ != GATT_INVALID_CONN_ID) {
      DisconnectDevice(leAudioDevice);
      return;
    }

    DisconnectDevice(leAudioDevice);
    /* If this is a device which is a part of the group which is connected,
     * lets start backgroup connect
     */
    BackgroundConnectIfGroupConnected(leAudioDevice);
  }

  void DisconnectDevice(LeAudioDevice* leAudioDevice,
@@ -2130,15 +2157,23 @@ class LeAudioClientImpl : public LeAudioClient {
            context_type, le_audio::types::kLeAudioDirectionSource);

    if (source_configuration) {
      bool send_active = false;
      /* Stream configuration differs from previous one */
      if (!current_source_codec_config.IsInvalid() &&
          (*source_configuration != current_source_codec_config))
          (*source_configuration != current_source_codec_config)) {
        callbacks_->OnGroupStatus(group_id, GroupStatus::INACTIVE);
        send_active = true;
        LeAudioClientAudioSource::Stop();
      }

      current_source_codec_config = *source_configuration;

      LeAudioClientAudioSource::Start(current_source_codec_config,
                                      audioSinkReceiver);
      if (send_active) {
        callbacks_->OnGroupStatus(group_id, GroupStatus::ACTIVE);
      }

    } else {
      if (!current_source_codec_config.IsInvalid()) {
        LeAudioClientAudioSource::Stop();
@@ -2152,15 +2187,22 @@ class LeAudioClientImpl : public LeAudioClient {
    }

    if (sink_configuration) {
      bool send_active = false;
      /* Stream configuration differs from previous one */
      if (!current_sink_codec_config.IsInvalid() &&
          (*sink_configuration != current_sink_codec_config))
          (*sink_configuration != current_sink_codec_config)) {
        callbacks_->OnGroupStatus(group_id, GroupStatus::INACTIVE);
        send_active = true;
        LeAudioClientAudioSink::Stop();
      }

      current_sink_codec_config = *sink_configuration;

      LeAudioClientAudioSink::Start(current_sink_codec_config,
                                    audioSourceReceiver);
      if (send_active) {
        callbacks_->OnGroupStatus(group_id, GroupStatus::ACTIVE);
      }
    } else {
      if (!current_sink_codec_config.IsInvalid()) {
        LeAudioClientAudioSink::Stop();
+2 −2
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ class VolumeControlImpl : public VolumeControl {
      return;
    }

    LOG(INFO) << __func__ << " " << address << " status: " << success;
    LOG(INFO) << __func__ << " " << address << " status: " << +success;

    if (device->HasHandles()) {
      device->EnqueueInitialRequests(gatt_if_, chrc_read_callback_static,
@@ -743,7 +743,7 @@ class VolumeControlImpl : public VolumeControl {
      } break;

      case BTA_GATTC_ENC_CMPL_CB_EVT:
        OnEncryptionComplete(p_data->enc_cmpl.remote_bda, true);
        OnEncryptionComplete(p_data->enc_cmpl.remote_bda, BTM_SUCCESS);
        break;

      case BTA_GATTC_SRVC_CHG_EVT:
+8 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include <hardware/bt_csis.h>
#include <hardware/bt_hearing_aid.h>
#include <hardware/bt_le_audio.h>
#include <hardware/bt_vc.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -51,6 +52,7 @@
#include "bta_dm_int.h"
#include "bta_gatt_api.h"
#include "bta_le_audio_api.h"
#include "bta_vc_api.h"
#include "btif/include/stack_manager.h"
#include "btif_api.h"
#include "btif_av.h"
@@ -250,6 +252,8 @@ btif_hearing_aid_get_interface();
extern bluetooth::csis::CsisClientInterface* btif_csis_client_get_interface();
extern bluetooth::le_audio::LeAudioClientInterface*
btif_le_audio_get_interface();
extern bluetooth::vc::VolumeControlInterface*
btif_volume_control_get_interface();

/******************************************************************************
 *  Functions
@@ -1598,6 +1602,10 @@ static void btif_dm_upstreams_evt(uint16_t event, char* p_param) {
      if (LeAudioClient::IsLeAudioClientRunning())
        btif_le_audio_get_interface()->RemoveDevice(bd_addr);

      if (VolumeControl::IsVolumeControlRunning()) {
        btif_volume_control_get_interface()->RemoveDevice(bd_addr);
      }

      btif_storage_remove_bonded_device(&bd_addr);
      bond_state_changed(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_NONE);
      break;