Loading system/bta/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -606,6 +606,7 @@ cc_test { "le_audio/le_audio_types_test.cc", "le_audio/metrics_collector_linux.cc", "le_audio/mock_iso_manager.cc", "test/common/btif_storage_mock.cc", "test/common/mock_controller.cc", "test/common/mock_csis_client.cc", "le_audio/state_machine.cc", Loading system/bta/le_audio/client.cc +30 −9 Original line number Diff line number Diff line Loading @@ -1217,12 +1217,12 @@ class LeAudioClientImpl : public LeAudioClient { LOG_WARN("Could not load ases"); } if (autoconnect) { leAudioDevice->SetConnectionState( DeviceConnectState::CONNECTING_AUTOCONNECT); leAudioDevice->autoconnect_flag_ = true; BTA_GATTC_Open(gatt_if_, address, reconnection_mode_, false); } leAudioDevice->autoconnect_flag_ = autoconnect; /* When adding from storage, make sure that autoconnect is used * by all the devices in the group. */ leAudioDevices_.SetInitialGroupAutoconnectState( group_id, gatt_if_, reconnection_mode_, autoconnect); } bool GetHandlesForStorage(const RawAddress& addr, std::vector<uint8_t>& out) { Loading Loading @@ -1291,12 +1291,33 @@ class LeAudioClientImpl : public LeAudioClient { BTA_GATTC_CancelOpen(0, address, false); if (leAudioDevice->conn_id_ != GATT_INVALID_CONN_ID) { /* User is disconnecting the device, we shall remove the autoconnect flag /* User is disconnecting the device, we shall remove the autoconnect * flag for this device and all others */ LOG_INFO("Removing autoconnect flag for group_id %d", leAudioDevice->group_id_); auto group = aseGroups_.FindById(leAudioDevice->group_id_); if (leAudioDevice->autoconnect_flag_) { btif_storage_set_leaudio_autoconnect(address, false); leAudioDevice->autoconnect_flag_ = false; } if (group) { /* Remove devices from auto connect mode */ for (auto dev = group->GetFirstDevice(); dev; dev = group->GetNextDevice(dev)) { if (dev->GetConnectionState() == DeviceConnectState::CONNECTING_AUTOCONNECT) { btif_storage_set_leaudio_autoconnect(address, false); dev->autoconnect_flag_ = false; BTA_GATTC_CancelOpen(gatt_if_, address, false); dev->SetConnectionState(DeviceConnectState::DISCONNECTED); } } } auto group = aseGroups_.FindById(leAudioDevice->group_id_); if (group && group->GetState() == le_audio::types::AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) { Loading system/bta/le_audio/devices.cc +37 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "bta_gatt_queue.h" #include "bta_groups.h" #include "bta_le_audio_api.h" #include "btif_storage.h" #include "btm_iso_api.h" #include "btm_iso_api_types.h" #include "device/include/controller.h" Loading Loading @@ -2727,6 +2728,42 @@ LeAudioDevice* LeAudioDevices::FindByCisConnHdl(uint8_t cig_id, return iter->get(); } void LeAudioDevices::SetInitialGroupAutoconnectState( int group_id, int gatt_if, tBTM_BLE_CONN_TYPE reconnection_mode, bool current_dev_autoconnect_flag) { if (!current_dev_autoconnect_flag) { /* If current device autoconnect flag is false, check if there is other * device in the group which is in autoconnect mode. * If yes, assume whole group is in autoconnect. */ auto iter = std::find_if(leAudioDevices_.begin(), leAudioDevices_.end(), [&group_id](auto& d) { LeAudioDevice* dev; dev = d.get(); if (dev->group_id_ != group_id) { return false; } return dev->autoconnect_flag_; }); current_dev_autoconnect_flag = !(iter == leAudioDevices_.end()); } if (!current_dev_autoconnect_flag) { return; } for (auto dev : leAudioDevices_) { if ((dev->group_id_ == group_id) && (dev->GetConnectionState() == DeviceConnectState::DISCONNECTED)) { dev->SetConnectionState(DeviceConnectState::CONNECTING_AUTOCONNECT); dev->autoconnect_flag_ = true; btif_storage_set_leaudio_autoconnect(dev->address_, true); BTA_GATTC_Open(gatt_if, dev->address_, reconnection_mode, false); } } } size_t LeAudioDevices::Size() { return (leAudioDevices_.size()); } void LeAudioDevices::Dump(int fd, int group_id) { Loading system/bta/le_audio/devices.h +3 −0 Original line number Diff line number Diff line Loading @@ -204,6 +204,9 @@ class LeAudioDevices { std::shared_ptr<LeAudioDevice> GetByAddress(const RawAddress& address); LeAudioDevice* FindByConnId(uint16_t conn_id); LeAudioDevice* FindByCisConnHdl(uint8_t cig_id, uint16_t conn_hdl); void SetInitialGroupAutoconnectState(int group_id, int gatt_if, tBTM_BLE_CONN_TYPE reconnection_mode, bool current_dev_autoconnect_flag); size_t Size(void); void Dump(int fd, int group_id); void Cleanup(tGATT_IF client_if); Loading Loading
system/bta/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -606,6 +606,7 @@ cc_test { "le_audio/le_audio_types_test.cc", "le_audio/metrics_collector_linux.cc", "le_audio/mock_iso_manager.cc", "test/common/btif_storage_mock.cc", "test/common/mock_controller.cc", "test/common/mock_csis_client.cc", "le_audio/state_machine.cc", Loading
system/bta/le_audio/client.cc +30 −9 Original line number Diff line number Diff line Loading @@ -1217,12 +1217,12 @@ class LeAudioClientImpl : public LeAudioClient { LOG_WARN("Could not load ases"); } if (autoconnect) { leAudioDevice->SetConnectionState( DeviceConnectState::CONNECTING_AUTOCONNECT); leAudioDevice->autoconnect_flag_ = true; BTA_GATTC_Open(gatt_if_, address, reconnection_mode_, false); } leAudioDevice->autoconnect_flag_ = autoconnect; /* When adding from storage, make sure that autoconnect is used * by all the devices in the group. */ leAudioDevices_.SetInitialGroupAutoconnectState( group_id, gatt_if_, reconnection_mode_, autoconnect); } bool GetHandlesForStorage(const RawAddress& addr, std::vector<uint8_t>& out) { Loading Loading @@ -1291,12 +1291,33 @@ class LeAudioClientImpl : public LeAudioClient { BTA_GATTC_CancelOpen(0, address, false); if (leAudioDevice->conn_id_ != GATT_INVALID_CONN_ID) { /* User is disconnecting the device, we shall remove the autoconnect flag /* User is disconnecting the device, we shall remove the autoconnect * flag for this device and all others */ LOG_INFO("Removing autoconnect flag for group_id %d", leAudioDevice->group_id_); auto group = aseGroups_.FindById(leAudioDevice->group_id_); if (leAudioDevice->autoconnect_flag_) { btif_storage_set_leaudio_autoconnect(address, false); leAudioDevice->autoconnect_flag_ = false; } if (group) { /* Remove devices from auto connect mode */ for (auto dev = group->GetFirstDevice(); dev; dev = group->GetNextDevice(dev)) { if (dev->GetConnectionState() == DeviceConnectState::CONNECTING_AUTOCONNECT) { btif_storage_set_leaudio_autoconnect(address, false); dev->autoconnect_flag_ = false; BTA_GATTC_CancelOpen(gatt_if_, address, false); dev->SetConnectionState(DeviceConnectState::DISCONNECTED); } } } auto group = aseGroups_.FindById(leAudioDevice->group_id_); if (group && group->GetState() == le_audio::types::AseState::BTA_LE_AUDIO_ASE_STATE_STREAMING) { Loading
system/bta/le_audio/devices.cc +37 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "bta_gatt_queue.h" #include "bta_groups.h" #include "bta_le_audio_api.h" #include "btif_storage.h" #include "btm_iso_api.h" #include "btm_iso_api_types.h" #include "device/include/controller.h" Loading Loading @@ -2727,6 +2728,42 @@ LeAudioDevice* LeAudioDevices::FindByCisConnHdl(uint8_t cig_id, return iter->get(); } void LeAudioDevices::SetInitialGroupAutoconnectState( int group_id, int gatt_if, tBTM_BLE_CONN_TYPE reconnection_mode, bool current_dev_autoconnect_flag) { if (!current_dev_autoconnect_flag) { /* If current device autoconnect flag is false, check if there is other * device in the group which is in autoconnect mode. * If yes, assume whole group is in autoconnect. */ auto iter = std::find_if(leAudioDevices_.begin(), leAudioDevices_.end(), [&group_id](auto& d) { LeAudioDevice* dev; dev = d.get(); if (dev->group_id_ != group_id) { return false; } return dev->autoconnect_flag_; }); current_dev_autoconnect_flag = !(iter == leAudioDevices_.end()); } if (!current_dev_autoconnect_flag) { return; } for (auto dev : leAudioDevices_) { if ((dev->group_id_ == group_id) && (dev->GetConnectionState() == DeviceConnectState::DISCONNECTED)) { dev->SetConnectionState(DeviceConnectState::CONNECTING_AUTOCONNECT); dev->autoconnect_flag_ = true; btif_storage_set_leaudio_autoconnect(dev->address_, true); BTA_GATTC_Open(gatt_if, dev->address_, reconnection_mode, false); } } } size_t LeAudioDevices::Size() { return (leAudioDevices_.size()); } void LeAudioDevices::Dump(int fd, int group_id) { Loading
system/bta/le_audio/devices.h +3 −0 Original line number Diff line number Diff line Loading @@ -204,6 +204,9 @@ class LeAudioDevices { std::shared_ptr<LeAudioDevice> GetByAddress(const RawAddress& address); LeAudioDevice* FindByConnId(uint16_t conn_id); LeAudioDevice* FindByCisConnHdl(uint8_t cig_id, uint16_t conn_hdl); void SetInitialGroupAutoconnectState(int group_id, int gatt_if, tBTM_BLE_CONN_TYPE reconnection_mode, bool current_dev_autoconnect_flag); size_t Size(void); void Dump(int fd, int group_id); void Cleanup(tGATT_IF client_if); Loading