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

Commit e6f43224 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

leaudio: Improve connecting other set members

If user connects group, Java will start connecting all the devices in
the group. However if some devices are not in range, timer will fire and
connect will be canceled.
With this patch, in such a case, we will put device into white list and
start background connect, so device will get connected when ready

Bug: 150670922
Tag: #feature
Sponsor: jpawlowski@
Test: atest --host bluetooth_le_audio_test bluetooth_le_audio_client_test

Change-Id: I3f36c78502b5ac858ec158bc2a43d1baac9e008a
parent fae37c18
Loading
Loading
Loading
Loading
+27 −4
Original line number Diff line number Diff line
@@ -723,6 +723,27 @@ class LeAudioClientImpl : public LeAudioClient {
    }
  }

  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 {
    LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address);

@@ -741,13 +762,15 @@ class LeAudioClientImpl : public LeAudioClient {
    /* 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,