Loading system/bta/le_audio/client.cc +10 −5 Original line number Original line Diff line number Diff line Loading @@ -1854,12 +1854,10 @@ class LeAudioClientImpl : public LeAudioClient { LOG_INFO("%s, status 0x%02x", ADDRESS_TO_LOGGABLE_CSTR(address), status); LOG_INFO("%s, status 0x%02x", ADDRESS_TO_LOGGABLE_CSTR(address), status); /* Remove device from the background connect (it might be either Allow list if (status != GATT_SUCCESS) { * or TA) and it will be added back on disconnection /* Clear current connection request and let it be set again if needed */ */ BTA_GATTC_CancelOpen(gatt_if_, address, false); BTA_GATTC_CancelOpen(gatt_if_, address, false); if (status != GATT_SUCCESS) { /* autoconnect connection failed, that's ok */ /* autoconnect connection failed, that's ok */ if (status != GATT_ILLEGAL_PARAMETER && if (status != GATT_ILLEGAL_PARAMETER && (leAudioDevice->GetConnectionState() == (leAudioDevice->GetConnectionState() == Loading @@ -1885,6 +1883,8 @@ class LeAudioClientImpl : public LeAudioClient { if (leAudioDevice->group_id_ != bluetooth::groups::kGroupUnknown) { if (leAudioDevice->group_id_ != bluetooth::groups::kGroupUnknown) { auto group = GetGroupIfEnabled(leAudioDevice->group_id_); auto group = GetGroupIfEnabled(leAudioDevice->group_id_); if (group == nullptr) { if (group == nullptr) { BTA_GATTC_CancelOpen(gatt_if_, address, false); LOG_WARN( LOG_WARN( "LeAudio profile is disabled for group_id: %d. %s is not connected", "LeAudio profile is disabled for group_id: %d. %s is not connected", leAudioDevice->group_id_, ADDRESS_TO_LOGGABLE_CSTR(address)); leAudioDevice->group_id_, ADDRESS_TO_LOGGABLE_CSTR(address)); Loading Loading @@ -2209,6 +2209,11 @@ class LeAudioClientImpl : public LeAudioClient { return; 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_); BtaGattQueue::Clean(leAudioDevice->conn_id_); LeAudioDeviceGroup* group = aseGroups_.FindById(leAudioDevice->group_id_); LeAudioDeviceGroup* group = aseGroups_.FindById(leAudioDevice->group_id_); Loading system/bta/le_audio/le_audio_client_test.cc +12 −2 Original line number Original line Diff line number Diff line Loading @@ -4044,14 +4044,21 @@ TEST_F(UnicastTest, RemoveDeviceWhenGettingConnectionReady) { EXPECT_CALL(mock_audio_hal_client_callbacks_, EXPECT_CALL(mock_audio_hal_client_callbacks_, OnConnectionState(ConnectionState::CONNECTED, test_address0)) OnConnectionState(ConnectionState::CONNECTED, test_address0)) .Times(0); .Times(0); EXPECT_CALL(mock_gatt_interface_, CancelOpen(gatt_if, test_address0, false)) .Times(0); ConnectLeAudio(test_address0); ConnectLeAudio(test_address0); Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_); 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_queue_, Clean(conn_id)).Times(AtLeast(1)); EXPECT_CALL(mock_gatt_interface_, Close(conn_id)).Times(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)) 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 * StopStream will put calls on main_loop so to keep the correct order Loading Loading @@ -4167,14 +4174,17 @@ TEST_F(UnicastTest, DisconnectDeviceWhenGettingConnectionReady) { EXPECT_CALL(mock_audio_hal_client_callbacks_, EXPECT_CALL(mock_audio_hal_client_callbacks_, OnConnectionState(ConnectionState::CONNECTED, test_address0)) OnConnectionState(ConnectionState::CONNECTED, test_address0)) .Times(0); .Times(0); EXPECT_CALL(mock_gatt_interface_, CancelOpen(gatt_if, test_address0, false)) .Times(0); ConnectLeAudio(test_address0); ConnectLeAudio(test_address0); Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_); 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_queue_, Clean(conn_id)).Times(AtLeast(1)); EXPECT_CALL(mock_gatt_interface_, Close(conn_id)).Times(1); EXPECT_CALL(mock_gatt_interface_, Close(conn_id)).Times(1); EXPECT_CALL(mock_gatt_interface_, CancelOpen(gatt_if, test_address0, false)) EXPECT_CALL(mock_gatt_interface_, CancelOpen(gatt_if, test_address0, false)) .Times(0); .Times(1); LeAudioClient::Get()->Disconnect(test_address0); LeAudioClient::Get()->Disconnect(test_address0); SyncOnMainLoop(); SyncOnMainLoop(); Loading Loading
system/bta/le_audio/client.cc +10 −5 Original line number Original line Diff line number Diff line Loading @@ -1854,12 +1854,10 @@ class LeAudioClientImpl : public LeAudioClient { LOG_INFO("%s, status 0x%02x", ADDRESS_TO_LOGGABLE_CSTR(address), status); LOG_INFO("%s, status 0x%02x", ADDRESS_TO_LOGGABLE_CSTR(address), status); /* Remove device from the background connect (it might be either Allow list if (status != GATT_SUCCESS) { * or TA) and it will be added back on disconnection /* Clear current connection request and let it be set again if needed */ */ BTA_GATTC_CancelOpen(gatt_if_, address, false); BTA_GATTC_CancelOpen(gatt_if_, address, false); if (status != GATT_SUCCESS) { /* autoconnect connection failed, that's ok */ /* autoconnect connection failed, that's ok */ if (status != GATT_ILLEGAL_PARAMETER && if (status != GATT_ILLEGAL_PARAMETER && (leAudioDevice->GetConnectionState() == (leAudioDevice->GetConnectionState() == Loading @@ -1885,6 +1883,8 @@ class LeAudioClientImpl : public LeAudioClient { if (leAudioDevice->group_id_ != bluetooth::groups::kGroupUnknown) { if (leAudioDevice->group_id_ != bluetooth::groups::kGroupUnknown) { auto group = GetGroupIfEnabled(leAudioDevice->group_id_); auto group = GetGroupIfEnabled(leAudioDevice->group_id_); if (group == nullptr) { if (group == nullptr) { BTA_GATTC_CancelOpen(gatt_if_, address, false); LOG_WARN( LOG_WARN( "LeAudio profile is disabled for group_id: %d. %s is not connected", "LeAudio profile is disabled for group_id: %d. %s is not connected", leAudioDevice->group_id_, ADDRESS_TO_LOGGABLE_CSTR(address)); leAudioDevice->group_id_, ADDRESS_TO_LOGGABLE_CSTR(address)); Loading Loading @@ -2209,6 +2209,11 @@ class LeAudioClientImpl : public LeAudioClient { return; 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_); BtaGattQueue::Clean(leAudioDevice->conn_id_); LeAudioDeviceGroup* group = aseGroups_.FindById(leAudioDevice->group_id_); LeAudioDeviceGroup* group = aseGroups_.FindById(leAudioDevice->group_id_); Loading
system/bta/le_audio/le_audio_client_test.cc +12 −2 Original line number Original line Diff line number Diff line Loading @@ -4044,14 +4044,21 @@ TEST_F(UnicastTest, RemoveDeviceWhenGettingConnectionReady) { EXPECT_CALL(mock_audio_hal_client_callbacks_, EXPECT_CALL(mock_audio_hal_client_callbacks_, OnConnectionState(ConnectionState::CONNECTED, test_address0)) OnConnectionState(ConnectionState::CONNECTED, test_address0)) .Times(0); .Times(0); EXPECT_CALL(mock_gatt_interface_, CancelOpen(gatt_if, test_address0, false)) .Times(0); ConnectLeAudio(test_address0); ConnectLeAudio(test_address0); Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_); 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_queue_, Clean(conn_id)).Times(AtLeast(1)); EXPECT_CALL(mock_gatt_interface_, Close(conn_id)).Times(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)) 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 * StopStream will put calls on main_loop so to keep the correct order Loading Loading @@ -4167,14 +4174,17 @@ TEST_F(UnicastTest, DisconnectDeviceWhenGettingConnectionReady) { EXPECT_CALL(mock_audio_hal_client_callbacks_, EXPECT_CALL(mock_audio_hal_client_callbacks_, OnConnectionState(ConnectionState::CONNECTED, test_address0)) OnConnectionState(ConnectionState::CONNECTED, test_address0)) .Times(0); .Times(0); EXPECT_CALL(mock_gatt_interface_, CancelOpen(gatt_if, test_address0, false)) .Times(0); ConnectLeAudio(test_address0); ConnectLeAudio(test_address0); Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_); 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_queue_, Clean(conn_id)).Times(AtLeast(1)); EXPECT_CALL(mock_gatt_interface_, Close(conn_id)).Times(1); EXPECT_CALL(mock_gatt_interface_, Close(conn_id)).Times(1); EXPECT_CALL(mock_gatt_interface_, CancelOpen(gatt_if, test_address0, false)) EXPECT_CALL(mock_gatt_interface_, CancelOpen(gatt_if, test_address0, false)) .Times(0); .Times(1); LeAudioClient::Get()->Disconnect(test_address0); LeAudioClient::Get()->Disconnect(test_address0); SyncOnMainLoop(); SyncOnMainLoop(); Loading