Loading system/bta/le_audio/client.cc +6 −0 Original line number Diff line number Diff line Loading @@ -1396,6 +1396,12 @@ class LeAudioClientImpl : public LeAudioClient { LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); if (!leAudioDevice) { if (!BTM_IsLinkKeyKnown(address, BT_TRANSPORT_LE)) { log::error("Connecting {} when not bonded", ADDRESS_TO_LOGGABLE_CSTR(address)); callbacks_->OnConnectionState(ConnectionState::DISCONNECTED, address); return; } leAudioDevices_.Add(address, DeviceConnectState::CONNECTING_BY_USER); } else { auto current_connect_state = leAudioDevice->GetConnectionState(); Loading system/bta/le_audio/le_audio_client_test.cc +42 −0 Original line number Diff line number Diff line Loading @@ -1539,6 +1539,9 @@ class UnicastTestNoInit : public Test { ON_CALL(*mock_iso_manager_, RegisterCigCallbacks(_)) .WillByDefault(SaveArg<0>(&cig_callbacks_)); ON_CALL(mock_btm_interface_, IsLinkKeyKnown(_, _)) .WillByDefault(DoAll(Return(true))); // Required since we call OnAudioDataReady() const auto codec_location = ::bluetooth::le_audio::types::CodecLocation::HOST; Loading Loading @@ -5040,6 +5043,45 @@ TEST_F(UnicastTest, RemoveTwoEarbudsCsisGrouped) { Mock::VerifyAndClearExpectations(&mock_btm_interface_); } TEST_F(UnicastTest, ConnectAfterRemove) { const RawAddress test_address0 = GetTestAddress(0); int group_id = bluetooth::groups::kGroupUnknown; uint16_t conn_id = 1; SetSampleDatabaseEarbudsValid( conn_id, test_address0, codec_spec_conf::kLeAudioLocationStereo, codec_spec_conf::kLeAudioLocationStereo, default_channel_cnt, default_channel_cnt, 0x0004, /* source sample freq 16khz */ false /*add_csis*/, true /*add_cas*/, true /*add_pacs*/, default_ase_cnt /*add_ascs_cnt*/, 1 /*set_size*/, 0 /*rank*/); EXPECT_CALL(mock_audio_hal_client_callbacks_, OnConnectionState(ConnectionState::DISCONNECTED, test_address0)) .Times(1); /* RemoveDevice */ do_in_main_thread(FROM_HERE, base::BindOnce( [](LeAudioClient* client, const RawAddress& test_address0) { client->RemoveDevice(test_address0); }, LeAudioClient::Get(), test_address0)); SyncOnMainLoop(); ON_CALL(mock_btm_interface_, IsLinkKeyKnown(_, _)) .WillByDefault(DoAll(Return(false))); do_in_main_thread( FROM_HERE, base::BindOnce(&LeAudioClient::Connect, base::Unretained(LeAudioClient::Get()), test_address0)); SyncOnMainLoop(); Mock::VerifyAndClearExpectations(&mock_btif_storage_); Mock::VerifyAndClearExpectations(&mock_gatt_queue_); Mock::VerifyAndClearExpectations(&mock_gatt_interface_); } TEST_F(UnicastTest, RemoveDeviceWhenConnected) { const RawAddress test_address0 = GetTestAddress(0); int group_id = bluetooth::groups::kGroupUnknown; Loading Loading
system/bta/le_audio/client.cc +6 −0 Original line number Diff line number Diff line Loading @@ -1396,6 +1396,12 @@ class LeAudioClientImpl : public LeAudioClient { LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); if (!leAudioDevice) { if (!BTM_IsLinkKeyKnown(address, BT_TRANSPORT_LE)) { log::error("Connecting {} when not bonded", ADDRESS_TO_LOGGABLE_CSTR(address)); callbacks_->OnConnectionState(ConnectionState::DISCONNECTED, address); return; } leAudioDevices_.Add(address, DeviceConnectState::CONNECTING_BY_USER); } else { auto current_connect_state = leAudioDevice->GetConnectionState(); Loading
system/bta/le_audio/le_audio_client_test.cc +42 −0 Original line number Diff line number Diff line Loading @@ -1539,6 +1539,9 @@ class UnicastTestNoInit : public Test { ON_CALL(*mock_iso_manager_, RegisterCigCallbacks(_)) .WillByDefault(SaveArg<0>(&cig_callbacks_)); ON_CALL(mock_btm_interface_, IsLinkKeyKnown(_, _)) .WillByDefault(DoAll(Return(true))); // Required since we call OnAudioDataReady() const auto codec_location = ::bluetooth::le_audio::types::CodecLocation::HOST; Loading Loading @@ -5040,6 +5043,45 @@ TEST_F(UnicastTest, RemoveTwoEarbudsCsisGrouped) { Mock::VerifyAndClearExpectations(&mock_btm_interface_); } TEST_F(UnicastTest, ConnectAfterRemove) { const RawAddress test_address0 = GetTestAddress(0); int group_id = bluetooth::groups::kGroupUnknown; uint16_t conn_id = 1; SetSampleDatabaseEarbudsValid( conn_id, test_address0, codec_spec_conf::kLeAudioLocationStereo, codec_spec_conf::kLeAudioLocationStereo, default_channel_cnt, default_channel_cnt, 0x0004, /* source sample freq 16khz */ false /*add_csis*/, true /*add_cas*/, true /*add_pacs*/, default_ase_cnt /*add_ascs_cnt*/, 1 /*set_size*/, 0 /*rank*/); EXPECT_CALL(mock_audio_hal_client_callbacks_, OnConnectionState(ConnectionState::DISCONNECTED, test_address0)) .Times(1); /* RemoveDevice */ do_in_main_thread(FROM_HERE, base::BindOnce( [](LeAudioClient* client, const RawAddress& test_address0) { client->RemoveDevice(test_address0); }, LeAudioClient::Get(), test_address0)); SyncOnMainLoop(); ON_CALL(mock_btm_interface_, IsLinkKeyKnown(_, _)) .WillByDefault(DoAll(Return(false))); do_in_main_thread( FROM_HERE, base::BindOnce(&LeAudioClient::Connect, base::Unretained(LeAudioClient::Get()), test_address0)); SyncOnMainLoop(); Mock::VerifyAndClearExpectations(&mock_btif_storage_); Mock::VerifyAndClearExpectations(&mock_gatt_queue_); Mock::VerifyAndClearExpectations(&mock_gatt_interface_); } TEST_F(UnicastTest, RemoveDeviceWhenConnected) { const RawAddress test_address0 = GetTestAddress(0); int group_id = bluetooth::groups::kGroupUnknown; Loading