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

Commit cd11a79c authored by Łukasz Rymanowski's avatar Łukasz Rymanowski Committed by Automerger Merge Worker
Browse files

Merge "leaudio: Move canceling background connect to OnGattDisconnect" into main am: 838fa750

parents bcbaa116 838fa750
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -1854,12 +1854,10 @@ class LeAudioClientImpl : public LeAudioClient {

    LOG_INFO("%s, status 0x%02x", ADDRESS_TO_LOGGABLE_CSTR(address), status);

    /* Remove device from the background connect (it might be either Allow list
     * or TA) and it will be added back on disconnection
     */
    if (status != GATT_SUCCESS) {
      /* Clear current connection request and let it be set again if needed */
      BTA_GATTC_CancelOpen(gatt_if_, address, false);

    if (status != GATT_SUCCESS) {
      /* autoconnect connection failed, that's ok */
      if (status != GATT_ILLEGAL_PARAMETER &&
          (leAudioDevice->GetConnectionState() ==
@@ -1885,6 +1883,8 @@ class LeAudioClientImpl : public LeAudioClient {
    if (leAudioDevice->group_id_ != bluetooth::groups::kGroupUnknown) {
      auto group = GetGroupIfEnabled(leAudioDevice->group_id_);
      if (group == nullptr) {
        BTA_GATTC_CancelOpen(gatt_if_, address, false);

        LOG_WARN(
            "LeAudio profile is disabled for group_id: %d. %s is not connected",
            leAudioDevice->group_id_, ADDRESS_TO_LOGGABLE_CSTR(address));
@@ -2209,6 +2209,11 @@ class LeAudioClientImpl : public LeAudioClient {
      return;
    }

    /* Remove device from the background connect (it might be either Allow list
     * or TA) and it will be added back depends on needs.
     */
    BTA_GATTC_CancelOpen(gatt_if_, address, false);

    BtaGattQueue::Clean(leAudioDevice->conn_id_);
    LeAudioDeviceGroup* group = aseGroups_.FindById(leAudioDevice->group_id_);

+12 −2
Original line number Diff line number Diff line
@@ -4044,14 +4044,21 @@ TEST_F(UnicastTest, RemoveDeviceWhenGettingConnectionReady) {
  EXPECT_CALL(mock_audio_hal_client_callbacks_,
              OnConnectionState(ConnectionState::CONNECTED, test_address0))
      .Times(0);
  EXPECT_CALL(mock_gatt_interface_, CancelOpen(gatt_if, test_address0, false))
      .Times(0);
  ConnectLeAudio(test_address0);

  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
  Mock::VerifyAndClearExpectations(&mock_gatt_interface_);

  EXPECT_CALL(mock_gatt_queue_, Clean(conn_id)).Times(AtLeast(1));
  EXPECT_CALL(mock_gatt_interface_, Close(conn_id)).Times(1);

  /* First time called when RemoveDevice is called and then second time
   * OnGattDisconnected. We accept this spare call.
   */
  EXPECT_CALL(mock_gatt_interface_, CancelOpen(gatt_if, test_address0, false))
      .Times(1);
      .Times(2);

  /*
   * StopStream will put calls on main_loop so to keep the correct order
@@ -4167,14 +4174,17 @@ TEST_F(UnicastTest, DisconnectDeviceWhenGettingConnectionReady) {
  EXPECT_CALL(mock_audio_hal_client_callbacks_,
              OnConnectionState(ConnectionState::CONNECTED, test_address0))
      .Times(0);
  EXPECT_CALL(mock_gatt_interface_, CancelOpen(gatt_if, test_address0, false))
      .Times(0);
  ConnectLeAudio(test_address0);

  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
  Mock::VerifyAndClearExpectations(&mock_gatt_interface_);

  EXPECT_CALL(mock_gatt_queue_, Clean(conn_id)).Times(AtLeast(1));
  EXPECT_CALL(mock_gatt_interface_, Close(conn_id)).Times(1);
  EXPECT_CALL(mock_gatt_interface_, CancelOpen(gatt_if, test_address0, false))
      .Times(0);
      .Times(1);

  LeAudioClient::Get()->Disconnect(test_address0);
  SyncOnMainLoop();