Loading system/bta/le_audio/client.cc +4 −27 Original line number Diff line number Diff line Loading @@ -1433,30 +1433,12 @@ class LeAudioClientImpl : public LeAudioClient { } void BackgroundConnectIfNeeded(LeAudioDevice* leAudioDevice) { auto group = GetGroupIfEnabled(leAudioDevice->group_id_); if (group == nullptr) { LOG_INFO(" Device %s is not yet part of the group %d. ", ADDRESS_TO_LOGGABLE_CSTR(leAudioDevice->address_), leAudioDevice->group_id_); return; } if (!leAudioDevice->autoconnect_flag_ && !group->IsAnyDeviceConnected()) { if (!leAudioDevice->autoconnect_flag_) { LOG_DEBUG("Device %s not in the background connect", ADDRESS_TO_LOGGABLE_CSTR(leAudioDevice->address_)); return; } LOG_INFO( "Add %s added to background connect. autoconnect flag: %d " "group_connected: %d", ADDRESS_TO_LOGGABLE_CSTR(leAudioDevice->address_), leAudioDevice->group_id_, group->IsAnyDeviceConnected()); leAudioDevice->SetConnectionState( DeviceConnectState::CONNECTING_AUTOCONNECT); BTA_GATTC_Open(gatt_if_, leAudioDevice->address_, reconnection_mode_, false); AddToBackgroundConnectCheckGroupConnected(leAudioDevice); } void Disconnect(const RawAddress& address) override { Loading Loading @@ -2259,6 +2241,8 @@ class LeAudioClientImpl : public LeAudioClient { return; } leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED); /* Attempt background re-connect if disconnect was not initiated locally * or if autoconnect is set and device got disconnected because of some * issues Loading @@ -2266,7 +2250,6 @@ class LeAudioClientImpl : public LeAudioClient { if (group == nullptr || !group->IsEnabled()) { LOG_ERROR("Group id %d (%p) disabled or null", leAudioDevice->group_id_, group); leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED); return; } Loading @@ -2274,9 +2257,6 @@ class LeAudioClientImpl : public LeAudioClient { if (leAudioDevice->autoconnect_flag_) { /* In this case ACL might not yet been disconnected */ scheduleAutoConnect(address); } else { /* Just acknowledge disconnected state*/ leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED); } return; } Loading Loading @@ -2305,9 +2285,6 @@ class LeAudioClientImpl : public LeAudioClient { */ scheduleGroupConnectedCheck(leAudioDevice->group_id_); } } else { /* Just acknowledge disconnected state*/ leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED); } } Loading system/bta/le_audio/devices.cc +2 −1 Original line number Diff line number Diff line Loading @@ -3114,7 +3114,8 @@ void LeAudioDevices::Dump(int fd, int group_id) { void LeAudioDevices::Cleanup(tGATT_IF client_if) { for (auto const& device : leAudioDevices_) { auto connection_state = device->GetConnectionState(); if (connection_state == DeviceConnectState::DISCONNECTED) { if (connection_state == DeviceConnectState::DISCONNECTED || connection_state == DeviceConnectState::DISCONNECTING) { continue; } Loading system/bta/le_audio/le_audio_client_test.cc +10 −9 Original line number Diff line number Diff line Loading @@ -4204,21 +4204,22 @@ TEST_F(UnicastTest, TwoEarbudsStreamingProfileDisconnect) { EXPECT_CALL(mock_gatt_interface_, Open(_, _, BTM_BLE_BKG_CONNECT_TARGETED_ANNOUNCEMENTS, _)) .Times(1); .Times(2); EXPECT_CALL(mock_state_machine_, StopStream(_)).Times(1); DisconnectLeAudio(test_address0, 1); SyncOnMainLoop(); Mock::VerifyAndClearExpectations(&mock_gatt_interface_); Mock::VerifyAndClearExpectations(&mock_state_machine_); EXPECT_CALL(mock_gatt_interface_, Open(_, _, BTM_BLE_BKG_CONNECT_TARGETED_ANNOUNCEMENTS, _)) .Times(1); /* Do not inject OPEN_EVENT by default */ ON_CALL(mock_gatt_interface_, Open(_, _, _, _)) .WillByDefault(DoAll(Return())); ON_CALL(mock_gatt_interface_, Close(_)).WillByDefault(DoAll(Return())); DisconnectLeAudio(test_address0, 1); DisconnectLeAudio(test_address1, 2); InjectDisconnectedEvent(1); InjectDisconnectedEvent(2); SyncOnMainLoop(); Mock::VerifyAndClearExpectations(&mock_state_machine_); Mock::VerifyAndClearExpectations(&mock_gatt_interface_); } Loading Loading
system/bta/le_audio/client.cc +4 −27 Original line number Diff line number Diff line Loading @@ -1433,30 +1433,12 @@ class LeAudioClientImpl : public LeAudioClient { } void BackgroundConnectIfNeeded(LeAudioDevice* leAudioDevice) { auto group = GetGroupIfEnabled(leAudioDevice->group_id_); if (group == nullptr) { LOG_INFO(" Device %s is not yet part of the group %d. ", ADDRESS_TO_LOGGABLE_CSTR(leAudioDevice->address_), leAudioDevice->group_id_); return; } if (!leAudioDevice->autoconnect_flag_ && !group->IsAnyDeviceConnected()) { if (!leAudioDevice->autoconnect_flag_) { LOG_DEBUG("Device %s not in the background connect", ADDRESS_TO_LOGGABLE_CSTR(leAudioDevice->address_)); return; } LOG_INFO( "Add %s added to background connect. autoconnect flag: %d " "group_connected: %d", ADDRESS_TO_LOGGABLE_CSTR(leAudioDevice->address_), leAudioDevice->group_id_, group->IsAnyDeviceConnected()); leAudioDevice->SetConnectionState( DeviceConnectState::CONNECTING_AUTOCONNECT); BTA_GATTC_Open(gatt_if_, leAudioDevice->address_, reconnection_mode_, false); AddToBackgroundConnectCheckGroupConnected(leAudioDevice); } void Disconnect(const RawAddress& address) override { Loading Loading @@ -2259,6 +2241,8 @@ class LeAudioClientImpl : public LeAudioClient { return; } leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED); /* Attempt background re-connect if disconnect was not initiated locally * or if autoconnect is set and device got disconnected because of some * issues Loading @@ -2266,7 +2250,6 @@ class LeAudioClientImpl : public LeAudioClient { if (group == nullptr || !group->IsEnabled()) { LOG_ERROR("Group id %d (%p) disabled or null", leAudioDevice->group_id_, group); leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED); return; } Loading @@ -2274,9 +2257,6 @@ class LeAudioClientImpl : public LeAudioClient { if (leAudioDevice->autoconnect_flag_) { /* In this case ACL might not yet been disconnected */ scheduleAutoConnect(address); } else { /* Just acknowledge disconnected state*/ leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED); } return; } Loading Loading @@ -2305,9 +2285,6 @@ class LeAudioClientImpl : public LeAudioClient { */ scheduleGroupConnectedCheck(leAudioDevice->group_id_); } } else { /* Just acknowledge disconnected state*/ leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED); } } Loading
system/bta/le_audio/devices.cc +2 −1 Original line number Diff line number Diff line Loading @@ -3114,7 +3114,8 @@ void LeAudioDevices::Dump(int fd, int group_id) { void LeAudioDevices::Cleanup(tGATT_IF client_if) { for (auto const& device : leAudioDevices_) { auto connection_state = device->GetConnectionState(); if (connection_state == DeviceConnectState::DISCONNECTED) { if (connection_state == DeviceConnectState::DISCONNECTED || connection_state == DeviceConnectState::DISCONNECTING) { continue; } Loading
system/bta/le_audio/le_audio_client_test.cc +10 −9 Original line number Diff line number Diff line Loading @@ -4204,21 +4204,22 @@ TEST_F(UnicastTest, TwoEarbudsStreamingProfileDisconnect) { EXPECT_CALL(mock_gatt_interface_, Open(_, _, BTM_BLE_BKG_CONNECT_TARGETED_ANNOUNCEMENTS, _)) .Times(1); .Times(2); EXPECT_CALL(mock_state_machine_, StopStream(_)).Times(1); DisconnectLeAudio(test_address0, 1); SyncOnMainLoop(); Mock::VerifyAndClearExpectations(&mock_gatt_interface_); Mock::VerifyAndClearExpectations(&mock_state_machine_); EXPECT_CALL(mock_gatt_interface_, Open(_, _, BTM_BLE_BKG_CONNECT_TARGETED_ANNOUNCEMENTS, _)) .Times(1); /* Do not inject OPEN_EVENT by default */ ON_CALL(mock_gatt_interface_, Open(_, _, _, _)) .WillByDefault(DoAll(Return())); ON_CALL(mock_gatt_interface_, Close(_)).WillByDefault(DoAll(Return())); DisconnectLeAudio(test_address0, 1); DisconnectLeAudio(test_address1, 2); InjectDisconnectedEvent(1); InjectDisconnectedEvent(2); SyncOnMainLoop(); Mock::VerifyAndClearExpectations(&mock_state_machine_); Mock::VerifyAndClearExpectations(&mock_gatt_interface_); } Loading