• Home
  • Raw
  • Download

Lines Matching refs:leAudioDevice

644   void AseInitialStateReadRequest(LeAudioDevice* leAudioDevice) {  in AseInitialStateReadRequest()  argument
645 int ases_num = leAudioDevice->ases_.size(); in AseInitialStateReadRequest()
646 bool is_eatt_supported = gatt_profile_get_eatt_support_by_conn_id(leAudioDevice->conn_id_); in AseInitialStateReadRequest()
657 if (leAudioDevice->notify_connected_after_read_ && (i == (ases_num - 1))) { in AseInitialStateReadRequest()
658 notify_flag_ptr = INT_TO_PTR(leAudioDevice->notify_connected_after_read_); in AseInitialStateReadRequest()
662 BtaGattQueue::ReadCharacteristic(leAudioDevice->conn_id_, in AseInitialStateReadRequest()
663 leAudioDevice->ases_[i].hdls.val_hdl, OnGattReadRspStatic, in AseInitialStateReadRequest()
670 BtaGattQueue::ReadMultiCharacteristic(leAudioDevice->conn_id_, multi_read, in AseInitialStateReadRequest()
674 multi_read.handles[i % GATT_MAX_READ_MULTI_HANDLES] = leAudioDevice->ases_[i].hdls.val_hdl; in AseInitialStateReadRequest()
680 BtaGattQueue::ReadMultiCharacteristic(leAudioDevice->conn_id_, multi_read, in AseInitialStateReadRequest()
693 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in OnGroupAddedCb() local
694 if (!leAudioDevice) { in OnGroupAddedCb()
697 if (leAudioDevice->group_id_ != bluetooth::groups::kGroupUnknown) { in OnGroupAddedCb()
698 log::info("group already set: {}", leAudioDevice->group_id_); in OnGroupAddedCb()
709 void SetDeviceAsRemovePendingAndStopGroup(LeAudioDevice* leAudioDevice) { in SetDeviceAsRemovePendingAndStopGroup() argument
710 log::info("device {}", leAudioDevice->address_); in SetDeviceAsRemovePendingAndStopGroup()
711 leAudioDevice->SetConnectionState(DeviceConnectState::REMOVING); in SetDeviceAsRemovePendingAndStopGroup()
712 leAudioDevice->closing_stream_for_disconnection_ = true; in SetDeviceAsRemovePendingAndStopGroup()
713 GroupStop(leAudioDevice->group_id_); in SetDeviceAsRemovePendingAndStopGroup()
725 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in OnGroupMemberAddedCb() local
726 if (!leAudioDevice) { in OnGroupMemberAddedCb()
729 if (leAudioDevice->group_id_ != bluetooth::groups::kGroupUnknown) { in OnGroupMemberAddedCb()
730 log::info("group already set: {}", leAudioDevice->group_id_); in OnGroupMemberAddedCb()
735 leAudioHealthStatus_->AddStatisticForDevice(leAudioDevice, in OnGroupMemberAddedCb()
745 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in OnGroupMemberRemovedCb() local
746 if (!leAudioDevice) { in OnGroupMemberRemovedCb()
749 if (leAudioDevice->group_id_ != group_id) { in OnGroupMemberRemovedCb()
750 log::warn("Device: {} not assigned to the group.", leAudioDevice->address_); in OnGroupMemberRemovedCb()
756 log::info("device not in the group: {}, {}", leAudioDevice->address_, group_id); in OnGroupMemberRemovedCb()
764 if (leAudioDevice->HaveActiveAse()) { in OnGroupMemberRemovedCb()
765 SetDeviceAsRemovePendingAndStopGroup(leAudioDevice); in OnGroupMemberRemovedCb()
804 LeAudioDevice* leAudioDevice = group->GetFirstActiveDevice(); in OnLeAudioDeviceSetStateTimeout() local
805 if (leAudioDevice == nullptr) { in OnLeAudioDeviceSetStateTimeout()
807 leAudioDevice = group->GetFirstDevice(); in OnLeAudioDeviceSetStateTimeout()
808 if (leAudioDevice == nullptr) { in OnLeAudioDeviceSetStateTimeout()
819 for (auto tmpDevice = leAudioDevice; tmpDevice != nullptr; in OnLeAudioDeviceSetStateTimeout()
829 DisconnectDevice(leAudioDevice, true, recovery); in OnLeAudioDeviceSetStateTimeout()
830 leAudioDevice = group->GetNextActiveDevice(leAudioDevice); in OnLeAudioDeviceSetStateTimeout()
831 } while (leAudioDevice); in OnLeAudioDeviceSetStateTimeout()
927 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in group_add_node() local
931 if (!leAudioDevice) { in group_add_node()
943 leAudioDevice = leAudioDevices_.FindByAddress(address); in group_add_node()
945 if (leAudioDevice->group_id_ != bluetooth::groups::kGroupUnknown) { in group_add_node()
946 old_group = aseGroups_.FindById(leAudioDevice->group_id_); in group_add_node()
970 if (new_group->IsDeviceInTheGroup(leAudioDevice)) { in group_add_node()
990 if (leAudioDevice->conn_id_ != GATT_INVALID_CONN_ID) { in group_add_node()
991 AseInitialStateReadRequest(leAudioDevice); in group_add_node()
994 if (leAudioDevice->GetConnectionState() == DeviceConnectState::CONNECTED) { in group_add_node()
1051 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in GroupRemoveNode() local
1056 if (!leAudioDevice) { in GroupRemoveNode()
1061 if (leAudioDevice->group_id_ != group_id) { in GroupRemoveNode()
1063 leAudioDevice->group_id_); in GroupRemoveNode()
1072 if (leAudioDevice->HaveActiveAse()) { in GroupRemoveNode()
1073 SetDeviceAsRemovePendingAndStopGroup(leAudioDevice); in GroupRemoveNode()
1795 auto leAudioDevice = leAudioDevices_.FindByAddress(address); in SetEnableState() local
1796 if (leAudioDevice == nullptr) { in SetEnableState()
1801 auto group_id = leAudioDevice->group_id_; in SetEnableState()
1817 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in RemoveDevice() local
1818 if (!leAudioDevice) { in RemoveDevice()
1827 bluetooth::common::ToString(leAudioDevice->GetConnectionState())); in RemoveDevice()
1828 auto connection_state = leAudioDevice->GetConnectionState(); in RemoveDevice()
1842 leAudioDevice->SetConnectionState(DeviceConnectState::REMOVING); in RemoveDevice()
1850 leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED); in RemoveDevice()
1861 if (leAudioDevice->group_id_ != bluetooth::groups::kGroupUnknown) { in RemoveDevice()
1862 auto group = aseGroups_.FindById(leAudioDevice->group_id_); in RemoveDevice()
1872 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in Connect() local
1873 if (!leAudioDevice) { in Connect()
1881 auto current_connect_state = leAudioDevice->GetConnectionState(); in Connect()
1884 log::error("Device {} is in invalid state: {}", leAudioDevice->address_, in Connect()
1890 if (leAudioDevice->group_id_ != bluetooth::groups::kGroupUnknown) { in Connect()
1891 auto group = GetGroupIfEnabled(leAudioDevice->group_id_); in Connect()
1894 leAudioDevice->group_id_); in Connect()
1900 leAudioDevice->SetConnectionState(DeviceConnectState::CONNECTING_BY_USER); in Connect()
1903 leAudioDevice->group_id_, address, ConnectionState::CONNECTING, in Connect()
1915 LeAudioDevice* leAudioDevice = group->GetFirstDevice(); in GetGroupDevices() local
1916 while (leAudioDevice) { in GetGroupDevices()
1917 all_group_device_addrs.push_back(leAudioDevice->address_); in GetGroupDevices()
1918 leAudioDevice = group->GetNextDevice(leAudioDevice); in GetGroupDevices()
1933 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in AddFromStorage() local
1935 if (leAudioDevice) { in AddFromStorage()
1950 leAudioDevice = leAudioDevices_.FindByAddress(address); in AddFromStorage()
1963 leAudioDevice->SetSupportedContexts(supported_contexts); in AddFromStorage()
1966 leAudioDevice->SetAvailableContexts(supported_contexts); in AddFromStorage()
1968 if (!DeserializeHandles(leAudioDevice, handles)) { in AddFromStorage()
1973 leAudioDevice->audio_locations_.sink->value = sink_audio_location.value(); in AddFromStorage()
1977 leAudioDevice->audio_locations_.source->value = source_audio_location.value(); in AddFromStorage()
1981 if (leAudioDevice->audio_locations_.source) { in AddFromStorage()
1982 leAudioDevice->audio_directions_ |= bluetooth::le_audio::types::kLeAudioDirectionSource; in AddFromStorage()
1984 if (leAudioDevice->audio_locations_.sink) { in AddFromStorage()
1985 leAudioDevice->audio_directions_ |= bluetooth::le_audio::types::kLeAudioDirectionSink; in AddFromStorage()
1986 callbacks_->OnSinkAudioLocationAvailable(leAudioDevice->address_, in AddFromStorage()
1987 leAudioDevice->audio_locations_.sink->value); in AddFromStorage()
1990 if (!DeserializeSinkPacs(leAudioDevice, sink_pacs)) { in AddFromStorage()
1992 leAudioDevice->known_service_handles_ = false; in AddFromStorage()
1996 if (!DeserializeSourcePacs(leAudioDevice, source_pacs)) { in AddFromStorage()
1998 leAudioDevice->known_service_handles_ = false; in AddFromStorage()
2002 if (!DeserializeAses(leAudioDevice, ases)) { in AddFromStorage()
2004 leAudioDevice->known_service_handles_ = false; in AddFromStorage()
2009 leAudioDevice->gmap_client_ = std::make_unique<GmapClient>(leAudioDevice->address_); in AddFromStorage()
2010 if (!le_audio::DeserializeGmap(leAudioDevice->gmap_client_.get(), gmap)) { in AddFromStorage()
2011 leAudioDevice->gmap_client_.reset(); in AddFromStorage()
2012 log::warn("Invalid GMAP storage for {}", leAudioDevice->address_); in AddFromStorage()
2016 leAudioDevice->autoconnect_flag_ = autoconnect; in AddFromStorage()
2025 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(addr); in GetHandlesForStorage() local
2026 return SerializeHandles(leAudioDevice, out); in GetHandlesForStorage()
2030 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(addr); in GetGmapForStorage() local
2031 return SerializeGmap(leAudioDevice->gmap_client_.get(), out); in GetGmapForStorage()
2035 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(addr); in GetSinkPacsForStorage() local
2036 return SerializeSinkPacs(leAudioDevice, out); in GetSinkPacsForStorage()
2040 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(addr); in GetSourcePacsForStorage() local
2041 return SerializeSourcePacs(leAudioDevice, out); in GetSourcePacsForStorage()
2045 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(addr); in GetAsesForStorage() local
2047 return SerializeAses(leAudioDevice, out); in GetAsesForStorage()
2050 void BackgroundConnectIfNeeded(LeAudioDevice* leAudioDevice) { in BackgroundConnectIfNeeded() argument
2051 if (!leAudioDevice->autoconnect_flag_) { in BackgroundConnectIfNeeded()
2052 log::debug("Device {} not in the background connect", leAudioDevice->address_); in BackgroundConnectIfNeeded()
2055 AddToBackgroundConnectCheckGroupConnected(leAudioDevice); in BackgroundConnectIfNeeded()
2060 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in Disconnect() local
2062 if (!leAudioDevice) { in Disconnect()
2068 auto connection_state = leAudioDevice->GetConnectionState(); in Disconnect()
2080 BackgroundConnectIfNeeded(leAudioDevice); in Disconnect()
2091 if (leAudioDevice->autoconnect_flag_ && remove_from_autoconnect) { in Disconnect()
2092 log::info("Removing autoconnect flag for group_id {}", leAudioDevice->group_id_); in Disconnect()
2097 leAudioDevice->autoconnect_flag_ = false; in Disconnect()
2103 bool force_acl_disconnect = leAudioDevice->autoconnect_flag_; in Disconnect()
2105 auto group = aseGroups_.FindById(leAudioDevice->group_id_); in Disconnect()
2123 group->group_id_, leAudioDevice->address_); in Disconnect()
2124 leAudioDevice->closing_stream_for_disconnection_ = true; in Disconnect()
2131 group->group_id_, leAudioDevice->address_); in Disconnect()
2133 leAudioDevice->closing_stream_for_disconnection_ = true; in Disconnect()
2140 DisconnectDevice(leAudioDevice, force_acl_disconnect); in Disconnect()
2146 DisconnectDevice(leAudioDevice); in Disconnect()
2153 DisconnectDevice(leAudioDevice); in Disconnect()
2165 void DisconnectDevice(LeAudioDevice* leAudioDevice, bool acl_force_disconnect = false, in DisconnectDevice() argument
2167 if (leAudioDevice->conn_id_ == GATT_INVALID_CONN_ID) { in DisconnectDevice()
2171 if (leAudioDevice->GetConnectionState() != DeviceConnectState::REMOVING) { in DisconnectDevice()
2172 leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTING); in DisconnectDevice()
2175 BtaGattQueue::Clean(leAudioDevice->conn_id_); in DisconnectDevice()
2179 leAudioDevice->DisconnectAcl(); in DisconnectDevice()
2181 leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTING_AND_RECOVER); in DisconnectDevice()
2184 BTA_GATTC_Close(leAudioDevice->conn_id_); in DisconnectDevice()
2188 void DeregisterNotifications(LeAudioDevice* leAudioDevice) { in DeregisterNotifications() argument
2190 for (auto pac_tuple : leAudioDevice->snk_pacs_) { in DeregisterNotifications()
2191 BTA_GATTC_DeregisterForNotifications(gatt_if_, leAudioDevice->address_, in DeregisterNotifications()
2194 for (auto pac_tuple : leAudioDevice->src_pacs_) { in DeregisterNotifications()
2195 BTA_GATTC_DeregisterForNotifications(gatt_if_, leAudioDevice->address_, in DeregisterNotifications()
2199 if (leAudioDevice->audio_locations_.sink) { in DeregisterNotifications()
2200 BTA_GATTC_DeregisterForNotifications(gatt_if_, leAudioDevice->address_, in DeregisterNotifications()
2201 leAudioDevice->audio_locations_.sink->handles.val_hdl); in DeregisterNotifications()
2203 if (leAudioDevice->audio_locations_.source) { in DeregisterNotifications()
2204 BTA_GATTC_DeregisterForNotifications(gatt_if_, leAudioDevice->address_, in DeregisterNotifications()
2205 leAudioDevice->audio_locations_.source->handles.val_hdl); in DeregisterNotifications()
2207 if (leAudioDevice->audio_avail_hdls_.val_hdl != 0) { in DeregisterNotifications()
2208 BTA_GATTC_DeregisterForNotifications(gatt_if_, leAudioDevice->address_, in DeregisterNotifications()
2209 leAudioDevice->audio_avail_hdls_.val_hdl); in DeregisterNotifications()
2211 if (leAudioDevice->audio_supp_cont_hdls_.val_hdl != 0) { in DeregisterNotifications()
2212 BTA_GATTC_DeregisterForNotifications(gatt_if_, leAudioDevice->address_, in DeregisterNotifications()
2213 leAudioDevice->audio_supp_cont_hdls_.val_hdl); in DeregisterNotifications()
2215 if (leAudioDevice->ctp_hdls_.val_hdl != 0) { in DeregisterNotifications()
2216 BTA_GATTC_DeregisterForNotifications(gatt_if_, leAudioDevice->address_, in DeregisterNotifications()
2217 leAudioDevice->ctp_hdls_.val_hdl); in DeregisterNotifications()
2220 for (struct ase& ase : leAudioDevice->ases_) { in DeregisterNotifications()
2221 BTA_GATTC_DeregisterForNotifications(gatt_if_, leAudioDevice->address_, ase.hdls.val_hdl); in DeregisterNotifications()
2225 void handleInitialCtpCccRead(LeAudioDevice* leAudioDevice, uint16_t len, uint8_t* value) { in handleInitialCtpCccRead() argument
2227 log::error("Could not read CCC for {}, disconnecting", leAudioDevice->address_); in handleInitialCtpCccRead()
2228 instance->Disconnect(leAudioDevice->address_); in handleInitialCtpCccRead()
2234 log::warn("{} forgot CCC values. Re-subscribing", leAudioDevice->address_); in handleInitialCtpCccRead()
2235 RegisterKnownNotifications(leAudioDevice, false, true); in handleInitialCtpCccRead()
2239 log::verbose("{}, ASCS ctp ccc: {:#x}", leAudioDevice->address_, val); in handleInitialCtpCccRead()
2240 connectionReady(leAudioDevice); in handleInitialCtpCccRead()
2248 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByConnId(conn_id); in LeAudioCharValueHandle() local
2251 if (!leAudioDevice) { in LeAudioCharValueHandle()
2256 ase = leAudioDevice->GetAseByValHandle(hdl); in LeAudioCharValueHandle()
2257 LeAudioDeviceGroup* group = aseGroups_.FindById(leAudioDevice->group_id_); in LeAudioCharValueHandle()
2259 groupStateMachine_->ProcessGattNotifEvent(value, len, ase, leAudioDevice, group); in LeAudioCharValueHandle()
2264 if (hdl == leAudioDevice->ctp_hdls_.ccc_hdl) { in LeAudioCharValueHandle()
2265 handleInitialCtpCccRead(leAudioDevice, len, value); in LeAudioCharValueHandle()
2270 std::find_if(leAudioDevice->snk_pacs_.begin(), leAudioDevice->snk_pacs_.end(), in LeAudioCharValueHandle()
2272 if (snk_pac_ent != leAudioDevice->snk_pacs_.end()) { in LeAudioCharValueHandle()
2282 leAudioDevice->RegisterPACs(&std::get<1>(*snk_pac_ent), &pac_recs); in LeAudioCharValueHandle()
2293 btif_storage_leaudio_update_pacs_bin(leAudioDevice->address_); in LeAudioCharValueHandle()
2299 std::find_if(leAudioDevice->src_pacs_.begin(), leAudioDevice->src_pacs_.end(), in LeAudioCharValueHandle()
2301 if (src_pac_ent != leAudioDevice->src_pacs_.end()) { in LeAudioCharValueHandle()
2311 leAudioDevice->RegisterPACs(&std::get<1>(*src_pac_ent), &pac_recs); in LeAudioCharValueHandle()
2322 btif_storage_leaudio_update_pacs_bin(leAudioDevice->address_); in LeAudioCharValueHandle()
2327 if (leAudioDevice->audio_locations_.sink && in LeAudioCharValueHandle()
2328 hdl == leAudioDevice->audio_locations_.sink->handles.val_hdl) { in LeAudioCharValueHandle()
2334 if (!leAudioDevice->audio_locations_.sink || in LeAudioCharValueHandle()
2335 (leAudioDevice->audio_locations_.sink->value ^ snk_audio_locations).none()) { in LeAudioCharValueHandle()
2342 leAudioDevice->audio_directions_ |= bluetooth::le_audio::types::kLeAudioDirectionSink; in LeAudioCharValueHandle()
2343 leAudioDevice->audio_locations_.sink->value = snk_audio_locations; in LeAudioCharValueHandle()
2345 callbacks_->OnSinkAudioLocationAvailable(leAudioDevice->address_, snk_audio_locations); in LeAudioCharValueHandle()
2349 leAudioDevice->address_, leAudioDevice->audio_locations_.sink->value.to_ulong()); in LeAudioCharValueHandle()
2354 } else if (leAudioDevice->audio_locations_.source && in LeAudioCharValueHandle()
2355 hdl == leAudioDevice->audio_locations_.source->handles.val_hdl) { in LeAudioCharValueHandle()
2361 if (!leAudioDevice->audio_locations_.source || in LeAudioCharValueHandle()
2362 (leAudioDevice->audio_locations_.source->value ^ src_audio_locations).none()) { in LeAudioCharValueHandle()
2369 leAudioDevice->audio_directions_ |= bluetooth::le_audio::types::kLeAudioDirectionSource; in LeAudioCharValueHandle()
2370 leAudioDevice->audio_locations_.source->value = src_audio_locations; in LeAudioCharValueHandle()
2374 leAudioDevice->address_, leAudioDevice->audio_locations_.source->value.to_ulong()); in LeAudioCharValueHandle()
2379 } else if (hdl == leAudioDevice->audio_avail_hdls_.val_hdl) { in LeAudioCharValueHandle()
2392 leAudioDevice->SetAvailableContexts(contexts); in LeAudioCharValueHandle()
2405 AttachToStreamingGroupIfNeeded(leAudioDevice); in LeAudioCharValueHandle()
2420 AttachToStreamingGroupIfNeeded(leAudioDevice); in LeAudioCharValueHandle()
2422 } else if (hdl == leAudioDevice->audio_supp_cont_hdls_.val_hdl) { in LeAudioCharValueHandle()
2427 leAudioDevice->SetSupportedContexts(supp_audio_contexts); in LeAudioCharValueHandle()
2429 btif_storage_set_leaudio_supported_context_types(leAudioDevice->address_, in LeAudioCharValueHandle()
2433 } else if (hdl == leAudioDevice->ctp_hdls_.val_hdl) { in LeAudioCharValueHandle()
2434 groupStateMachine_->ProcessGattCtpNotification(group, leAudioDevice, value, len); in LeAudioCharValueHandle()
2435 } else if (hdl == leAudioDevice->tmap_role_hdl_) { in LeAudioCharValueHandle()
2436 bluetooth::le_audio::client_parser::tmap::ParseTmapRole(leAudioDevice->tmap_role_, len, in LeAudioCharValueHandle()
2438 } else if (leAudioDevice->gmap_client_ != nullptr && GmapClient::IsGmapClientEnabled() && in LeAudioCharValueHandle()
2439 hdl == leAudioDevice->gmap_client_->getRoleHandle()) { in LeAudioCharValueHandle()
2440 leAudioDevice->gmap_client_->parseAndSaveGmapRole(len, value); in LeAudioCharValueHandle()
2441 btif_storage_leaudio_update_gmap_bin(leAudioDevice->address_); in LeAudioCharValueHandle()
2442 } else if (leAudioDevice->gmap_client_ != nullptr && GmapClient::IsGmapClientEnabled() && in LeAudioCharValueHandle()
2443 hdl == leAudioDevice->gmap_client_->getUGTFeatureHandle()) { in LeAudioCharValueHandle()
2444 leAudioDevice->gmap_client_->parseAndSaveUGTFeature(len, value); in LeAudioCharValueHandle()
2445 btif_storage_leaudio_update_gmap_bin(leAudioDevice->address_); in LeAudioCharValueHandle()
2469 void AddToBackgroundConnectCheckGroupConnected(LeAudioDevice* leAudioDevice) { in AddToBackgroundConnectCheckGroupConnected() argument
2471 auto address = leAudioDevice->address_; in AddToBackgroundConnectCheckGroupConnected()
2472 auto group = GetGroupIfEnabled(leAudioDevice->group_id_); in AddToBackgroundConnectCheckGroupConnected()
2474 log::info("Group {} is invalid or disabled", leAudioDevice->group_id_); in AddToBackgroundConnectCheckGroupConnected()
2478 leAudioDevice->SetConnectionState(DeviceConnectState::CONNECTING_AUTOCONNECT); in AddToBackgroundConnectCheckGroupConnected()
2483 log::info("Group {} in connected state. Adding {} to allow list", leAudioDevice->group_id_, in AddToBackgroundConnectCheckGroupConnected()
2495 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in OnGattConnected() local
2506 if (!leAudioDevice) { in OnGattConnected()
2510 if (leAudioDevice->conn_id_ != GATT_INVALID_CONN_ID) { in OnGattConnected()
2511 log::debug("Already connected {}, conn_id=0x{:04x}", address, leAudioDevice->conn_id_); in OnGattConnected()
2521 (leAudioDevice->GetConnectionState() == DeviceConnectState::CONNECTING_AUTOCONNECT || in OnGattConnected()
2522 leAudioDevice->autoconnect_flag_)) { in OnGattConnected()
2524 leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED); in OnGattConnected()
2525 AddToBackgroundConnectCheckGroupConnected(leAudioDevice); in OnGattConnected()
2529 leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED); in OnGattConnected()
2534 leAudioDevice->group_id_, address, ConnectionState::CONNECTED, in OnGattConnected()
2539 if (leAudioDevice->group_id_ != bluetooth::groups::kGroupUnknown) { in OnGattConnected()
2540 auto group = GetGroupIfEnabled(leAudioDevice->group_id_); in OnGattConnected()
2545 leAudioDevice->group_id_, address); in OnGattConnected()
2550 leAudioDevice->conn_id_ = conn_id; in OnGattConnected()
2551 leAudioDevice->mtu_ = mtu; in OnGattConnected()
2569 get_btm_client_interface().peer.BTM_RequestPeerSCA(leAudioDevice->address_, transport); in OnGattConnected()
2571 if (leAudioDevice->GetConnectionState() == DeviceConnectState::CONNECTING_AUTOCONNECT) { in OnGattConnected()
2572 leAudioDevice->SetConnectionState(DeviceConnectState::CONNECTED_AUTOCONNECT_GETTING_READY); in OnGattConnected()
2574 leAudioDevice->SetConnectionState(DeviceConnectState::CONNECTED_BY_USER_GETTING_READY); in OnGattConnected()
2578 leAudioDevice->UpdateDeviceAllowlistFlag(); in OnGattConnected()
2600 leAudioDevice->group_id_, address, ConnectionState::CONNECTED, in OnGattConnected()
2608 void RegisterKnownNotifications(LeAudioDevice* leAudioDevice, bool gatt_register, in RegisterKnownNotifications() argument
2610 log::info("device: {}", leAudioDevice->address_); in RegisterKnownNotifications()
2612 if (leAudioDevice->ctp_hdls_.val_hdl == 0) { in RegisterKnownNotifications()
2614 leAudioDevice->address_); in RegisterKnownNotifications()
2615 DisconnectDevice(leAudioDevice); in RegisterKnownNotifications()
2620 for (auto pac_tuple : leAudioDevice->snk_pacs_) { in RegisterKnownNotifications()
2621 subscribe_for_notification(leAudioDevice->conn_id_, leAudioDevice->address_, in RegisterKnownNotifications()
2624 for (auto pac_tuple : leAudioDevice->src_pacs_) { in RegisterKnownNotifications()
2625 subscribe_for_notification(leAudioDevice->conn_id_, leAudioDevice->address_, in RegisterKnownNotifications()
2629 if (leAudioDevice->audio_locations_.sink) { in RegisterKnownNotifications()
2630 subscribe_for_notification(leAudioDevice->conn_id_, leAudioDevice->address_, in RegisterKnownNotifications()
2631 leAudioDevice->audio_locations_.sink->handles, gatt_register, in RegisterKnownNotifications()
2634 if (leAudioDevice->audio_locations_.source) { in RegisterKnownNotifications()
2635 subscribe_for_notification(leAudioDevice->conn_id_, leAudioDevice->address_, in RegisterKnownNotifications()
2636 leAudioDevice->audio_locations_.source->handles, gatt_register, in RegisterKnownNotifications()
2640 if (leAudioDevice->audio_avail_hdls_.val_hdl != 0) { in RegisterKnownNotifications()
2641 subscribe_for_notification(leAudioDevice->conn_id_, leAudioDevice->address_, in RegisterKnownNotifications()
2642 leAudioDevice->audio_avail_hdls_, gatt_register, write_ccc); in RegisterKnownNotifications()
2645 if (leAudioDevice->audio_supp_cont_hdls_.val_hdl != 0) { in RegisterKnownNotifications()
2646 subscribe_for_notification(leAudioDevice->conn_id_, leAudioDevice->address_, in RegisterKnownNotifications()
2647 leAudioDevice->audio_supp_cont_hdls_, gatt_register, write_ccc); in RegisterKnownNotifications()
2650 for (struct ase& ase : leAudioDevice->ases_) { in RegisterKnownNotifications()
2651 subscribe_for_notification(leAudioDevice->conn_id_, leAudioDevice->address_, ase.hdls, in RegisterKnownNotifications()
2655 subscribe_for_notification(leAudioDevice->conn_id_, leAudioDevice->address_, in RegisterKnownNotifications()
2656 leAudioDevice->ctp_hdls_, gatt_register, write_ccc); in RegisterKnownNotifications()
2659 void changeMtuIfPossible(LeAudioDevice* leAudioDevice) { in changeMtuIfPossible() argument
2660 if (leAudioDevice->mtu_ == GATT_DEF_BLE_MTU_SIZE) { in changeMtuIfPossible()
2666 BtaGattQueue::ConfigureMtu(leAudioDevice->conn_id_, kBapMinimumAttMtu); in changeMtuIfPossible()
2670 void ReadMustHaveAttributesOnReconnect(LeAudioDevice* leAudioDevice) { in ReadMustHaveAttributesOnReconnect() argument
2671 bool is_eatt_supported = gatt_profile_get_eatt_support_by_conn_id(leAudioDevice->conn_id_); in ReadMustHaveAttributesOnReconnect()
2673 log::verbose("{}, eatt supported {}", leAudioDevice->address_, is_eatt_supported); in ReadMustHaveAttributesOnReconnect()
2683 BtaGattQueue::ReadCharacteristic(leAudioDevice->conn_id_, in ReadMustHaveAttributesOnReconnect()
2684 leAudioDevice->audio_avail_hdls_.val_hdl, in ReadMustHaveAttributesOnReconnect()
2686 BtaGattQueue::ReadCharacteristic(leAudioDevice->conn_id_, leAudioDevice->ctp_hdls_.ccc_hdl, in ReadMustHaveAttributesOnReconnect()
2690 .handles = {leAudioDevice->audio_avail_hdls_.val_hdl, in ReadMustHaveAttributesOnReconnect()
2691 leAudioDevice->ctp_hdls_.ccc_hdl}}; in ReadMustHaveAttributesOnReconnect()
2693 BtaGattQueue::ReadMultiCharacteristic(leAudioDevice->conn_id_, multi_read, in ReadMustHaveAttributesOnReconnect()
2700 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in OnEncryptionComplete() local
2701 if (leAudioDevice == NULL || (leAudioDevice->conn_id_ == GATT_INVALID_CONN_ID)) { in OnEncryptionComplete()
2703 leAudioDevice ? " not connected by service." : " null"); in OnEncryptionComplete()
2709 if (leAudioDevice->GetConnectionState() == in OnEncryptionComplete()
2713 leAudioDevice->group_id_, address, ConnectionState::CONNECTED, in OnEncryptionComplete()
2717 leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTING); in OnEncryptionComplete()
2719 BTA_GATTC_Close(leAudioDevice->conn_id_); in OnEncryptionComplete()
2723 if (leAudioDevice->encrypted_) { in OnEncryptionComplete()
2732 if (!leAudioDevice->acl_phy_update_done_ && in OnEncryptionComplete()
2734 log::info("{} set preferred PHY to 2M", leAudioDevice->address_); in OnEncryptionComplete()
2738 changeMtuIfPossible(leAudioDevice); in OnEncryptionComplete()
2740 leAudioDevice->encrypted_ = true; in OnEncryptionComplete()
2743 if (leAudioDevice->known_service_handles_) { in OnEncryptionComplete()
2747 RegisterKnownNotifications(leAudioDevice, true, false); in OnEncryptionComplete()
2748 ReadMustHaveAttributesOnReconnect(leAudioDevice); in OnEncryptionComplete()
2753 if (leAudioDevice->known_service_handles_ && !leAudioDevice->notify_connected_after_read_) { in OnEncryptionComplete()
2758 BTA_GATTC_ServiceSearchRequest(leAudioDevice->conn_id_, in OnEncryptionComplete()
2802 auto leAudioDevice = leAudioDevices_.FindByAddress(address); in autoConnect() local
2803 if (leAudioDevice == nullptr) { in autoConnect()
2808 BackgroundConnectIfNeeded(leAudioDevice); in autoConnect()
2820 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in recoveryReconnect() local
2822 if (leAudioDevice == nullptr || in recoveryReconnect()
2823 leAudioDevice->GetConnectionState() != DeviceConnectState::DISCONNECTING_AND_RECOVER) { in recoveryReconnect()
2828 auto group = GetGroupIfEnabled(leAudioDevice->group_id_); in recoveryReconnect()
2831 leAudioDevice->SetConnectionState(DeviceConnectState::CONNECTING_AUTOCONNECT); in recoveryReconnect()
2834 leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED); in recoveryReconnect()
2847 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in checkIfGroupMember() local
2849 if (leAudioDevice == nullptr) { in checkIfGroupMember()
2854 if (leAudioDevice->group_id_ == bluetooth::groups::kGroupUnknown) { in checkIfGroupMember()
2855 disconnectInvalidDevice(leAudioDevice, ", device not a valid group member", in checkIfGroupMember()
2877 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByConnId(conn_id); in OnGattDisconnected() local
2879 if (!leAudioDevice) { in OnGattDisconnected()
2884 leAudioDevice->acl_asymmetric_ = false; in OnGattDisconnected()
2885 BtaGattQueue::Clean(leAudioDevice->conn_id_); in OnGattDisconnected()
2886 LeAudioDeviceGroup* group = aseGroups_.FindById(leAudioDevice->group_id_); in OnGattDisconnected()
2888 DeregisterNotifications(leAudioDevice); in OnGattDisconnected()
2891 leAudioDevice->conn_id_ = GATT_INVALID_CONN_ID; in OnGattDisconnected()
2892 leAudioDevice->mtu_ = 0; in OnGattDisconnected()
2893 leAudioDevice->closing_stream_for_disconnection_ = false; in OnGattDisconnected()
2894 leAudioDevice->encrypted_ = false; in OnGattDisconnected()
2895 leAudioDevice->acl_phy_update_done_ = false; in OnGattDisconnected()
2897 auto connection_state = leAudioDevice->GetConnectionState(); in OnGattDisconnected()
2899 leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTED); in OnGattDisconnected()
2901 groupStateMachine_->ProcessHciNotifAclDisconnected(group, leAudioDevice); in OnGattDisconnected()
2904 leAudioDevice->group_id_, address, ConnectionState::DISCONNECTED, in OnGattDisconnected()
2908 if (leAudioDevice->group_id_ != bluetooth::groups::kGroupUnknown) { in OnGattDisconnected()
2909 auto group = aseGroups_.FindById(leAudioDevice->group_id_); in OnGattDisconnected()
2916 log::info("{}, autoconnect {}, reason 0x{:02x}, connection state {}", leAudioDevice->address_, in OnGattDisconnected()
2917 leAudioDevice->autoconnect_flag_, reason, in OnGattDisconnected()
2929 leAudioDevice->SetConnectionState(DeviceConnectState::DISCONNECTING_AND_RECOVER); in OnGattDisconnected()
2939 log::error("Group id {} ({}) disabled or null", leAudioDevice->group_id_, in OnGattDisconnected()
2945 if (leAudioDevice->autoconnect_flag_) { in OnGattDisconnected()
2955 leAudioDevice->SetConnectionState(DeviceConnectState::CONNECTING_AUTOCONNECT); in OnGattDisconnected()
2963 if (leAudioDevice->autoconnect_flag_) { in OnGattDisconnected()
2969 scheduleGroupConnectedCheck(leAudioDevice->group_id_); in OnGattDisconnected()
3023 void ClearDeviceInformationAndStartSearch(LeAudioDevice* leAudioDevice) { in ClearDeviceInformationAndStartSearch() argument
3024 if (!leAudioDevice) { in ClearDeviceInformationAndStartSearch()
3029 log::info("{}", leAudioDevice->address_); in ClearDeviceInformationAndStartSearch()
3031 if (leAudioDevice->known_service_handles_ == false) { in ClearDeviceInformationAndStartSearch()
3036 leAudioDevice->known_service_handles_ = false; in ClearDeviceInformationAndStartSearch()
3037 leAudioDevice->csis_member_ = false; in ClearDeviceInformationAndStartSearch()
3038 BtaGattQueue::Clean(leAudioDevice->conn_id_); in ClearDeviceInformationAndStartSearch()
3039 DeregisterNotifications(leAudioDevice); in ClearDeviceInformationAndStartSearch()
3041 if (leAudioDevice->GetConnectionState() == DeviceConnectState::CONNECTED) { in ClearDeviceInformationAndStartSearch()
3042 leAudioDevice->SetConnectionState(DeviceConnectState::CONNECTED_BY_USER_GETTING_READY); in ClearDeviceInformationAndStartSearch()
3045 btif_storage_leaudio_clear_service_data(leAudioDevice->address_); in ClearDeviceInformationAndStartSearch()
3047 BTA_GATTC_ServiceSearchRequest(leAudioDevice->conn_id_, in ClearDeviceInformationAndStartSearch()
3052 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in OnServiceChangeEvent() local
3053 if (!leAudioDevice) { in OnServiceChangeEvent()
3054 log::warn("Skipping unknown leAudioDevice {} ({})", address, std::format_ptr(leAudioDevice)); in OnServiceChangeEvent()
3058 if (leAudioDevice->conn_id_ != GATT_INVALID_CONN_ID) { in OnServiceChangeEvent()
3059 ClearDeviceInformationAndStartSearch(leAudioDevice); in OnServiceChangeEvent()
3065 leAudioDevice->known_service_handles_ = false; in OnServiceChangeEvent()
3070 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByConnId(conn_id); in OnMtuChanged() local
3071 if (!leAudioDevice) { in OnMtuChanged()
3086 leAudioDevice->address_, mtu); in OnMtuChanged()
3087 Disconnect(leAudioDevice->address_); in OnMtuChanged()
3091 leAudioDevice->mtu_ = mtu; in OnMtuChanged()
3095 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByConnId(conn_id); in OnPhyUpdate() local
3096 if (leAudioDevice == nullptr) { in OnPhyUpdate()
3101 log::info("{}, tx_phy: {:#x}, rx_phy: {:#x} , status: {:#x}", leAudioDevice->address_, tx_phy, in OnPhyUpdate()
3105 leAudioDevice->acl_phy_update_done_ = true; in OnPhyUpdate()
3110 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(address); in OnGattServiceDiscoveryDone() local
3111 if (!leAudioDevice || (leAudioDevice->conn_id_ == GATT_INVALID_CONN_ID)) { in OnGattServiceDiscoveryDone()
3113 std::format_ptr(leAudioDevice)); in OnGattServiceDiscoveryDone()
3117 if (!leAudioDevice->encrypted_) { in OnGattServiceDiscoveryDone()
3122 if (!leAudioDevice->known_service_handles_) { in OnGattServiceDiscoveryDone()
3124 leAudioDevice->conn_id_, in OnGattServiceDiscoveryDone()
3129 void disconnectInvalidDevice(LeAudioDevice* leAudioDevice, std::string error_string, in disconnectInvalidDevice() argument
3131 log::error("{}, {}", leAudioDevice->address_, error_string); in disconnectInvalidDevice()
3133 leAudioHealthStatus_->AddStatisticForDevice(leAudioDevice, stat); in disconnectInvalidDevice()
3135 DisconnectDevice(leAudioDevice); in disconnectInvalidDevice()
3143 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByConnId(conn_id); in OnServiceSearchComplete() local
3145 if (!leAudioDevice) { in OnServiceSearchComplete()
3150 log::info("test csis_member {}", leAudioDevice->csis_member_); in OnServiceSearchComplete()
3156 DisconnectDevice(leAudioDevice); in OnServiceSearchComplete()
3160 if (!leAudioDevice->encrypted_) { in OnServiceSearchComplete()
3178 leAudioDevice->address_); in OnServiceSearchComplete()
3182 leAudioDevice->address_); in OnServiceSearchComplete()
3186 tmp.is_primary, leAudioDevice->address_); in OnServiceSearchComplete()
3192 leAudioDevice->address_); in OnServiceSearchComplete()
3207 tmp.handle, leAudioDevice->address_); in OnServiceSearchComplete()
3211 leAudioDevice->address_); in OnServiceSearchComplete()
3221 leAudioDevice->csis_member_ = true; in OnServiceSearchComplete()
3226 disconnectInvalidDevice(leAudioDevice, "No mandatory le audio services found (pacs or ascs)", in OnServiceSearchComplete()
3232 leAudioDevice->ClearPACs(); in OnServiceSearchComplete()
3246 !subscribe_for_notification(conn_id, leAudioDevice->address_, hdl_pair)) { in OnServiceSearchComplete()
3247 disconnectInvalidDevice(leAudioDevice, ", could not subscribe for snk pac char", in OnServiceSearchComplete()
3255 leAudioDevice->snk_pacs_.push_back(std::make_tuple( in OnServiceSearchComplete()
3259 charac.value_handle, hdl_pair.ccc_hdl, leAudioDevice->address_); in OnServiceSearchComplete()
3271 !subscribe_for_notification(conn_id, leAudioDevice->address_, hdl_pair)) { in OnServiceSearchComplete()
3272 disconnectInvalidDevice(leAudioDevice, ", could not subscribe for src pac char", in OnServiceSearchComplete()
3280 leAudioDevice->src_pacs_.push_back(std::make_tuple( in OnServiceSearchComplete()
3285 charac.value_handle, hdl_pair.ccc_hdl, leAudioDevice->address_); in OnServiceSearchComplete()
3288 leAudioDevice->audio_locations_.sink.emplace(hdl_pair(charac.value_handle, ccc_hdl), in OnServiceSearchComplete()
3293 } else if (!subscribe_for_notification(conn_id, leAudioDevice->address_, in OnServiceSearchComplete()
3294 leAudioDevice->audio_locations_.sink->handles)) { in OnServiceSearchComplete()
3295 disconnectInvalidDevice(leAudioDevice, ", could not subscribe for snk locations char", in OnServiceSearchComplete()
3302 leAudioDevice->audio_locations_.sink->handles.val_hdl, in OnServiceSearchComplete()
3308 charac.value_handle, ccc_hdl, leAudioDevice->address_); in OnServiceSearchComplete()
3311 leAudioDevice->audio_locations_.source.emplace(hdl_pair(charac.value_handle, ccc_hdl), in OnServiceSearchComplete()
3316 } else if (!subscribe_for_notification(conn_id, leAudioDevice->address_, in OnServiceSearchComplete()
3317 leAudioDevice->audio_locations_.source->handles)) { in OnServiceSearchComplete()
3318 disconnectInvalidDevice(leAudioDevice, ", could not subscribe for src locations char", in OnServiceSearchComplete()
3325 leAudioDevice->audio_locations_.source->handles.val_hdl, in OnServiceSearchComplete()
3331 charac.value_handle, ccc_hdl, leAudioDevice->address_); in OnServiceSearchComplete()
3334 leAudioDevice->audio_avail_hdls_.val_hdl = charac.value_handle; in OnServiceSearchComplete()
3335 leAudioDevice->audio_avail_hdls_.ccc_hdl = find_ccc_handle(charac); in OnServiceSearchComplete()
3337 if (leAudioDevice->audio_avail_hdls_.ccc_hdl == 0) { in OnServiceSearchComplete()
3338 disconnectInvalidDevice(leAudioDevice, ", audio avails char doesn't have ccc", in OnServiceSearchComplete()
3343 if (!subscribe_for_notification(conn_id, leAudioDevice->address_, in OnServiceSearchComplete()
3344 leAudioDevice->audio_avail_hdls_)) { in OnServiceSearchComplete()
3345 disconnectInvalidDevice(leAudioDevice, ", could not subscribe for audio avails char", in OnServiceSearchComplete()
3351 BtaGattQueue::ReadCharacteristic(conn_id, leAudioDevice->audio_avail_hdls_.val_hdl, in OnServiceSearchComplete()
3357 charac.value_handle, leAudioDevice->audio_avail_hdls_.ccc_hdl, in OnServiceSearchComplete()
3358 leAudioDevice->address_); in OnServiceSearchComplete()
3361 leAudioDevice->audio_supp_cont_hdls_.val_hdl = charac.value_handle; in OnServiceSearchComplete()
3362 leAudioDevice->audio_supp_cont_hdls_.ccc_hdl = find_ccc_handle(charac); in OnServiceSearchComplete()
3364 if (leAudioDevice->audio_supp_cont_hdls_.ccc_hdl == 0) { in OnServiceSearchComplete()
3368 if (leAudioDevice->audio_supp_cont_hdls_.ccc_hdl != 0 && in OnServiceSearchComplete()
3369 !subscribe_for_notification(conn_id, leAudioDevice->address_, in OnServiceSearchComplete()
3370 leAudioDevice->audio_supp_cont_hdls_)) { in OnServiceSearchComplete()
3371 disconnectInvalidDevice(leAudioDevice, in OnServiceSearchComplete()
3378 BtaGattQueue::ReadCharacteristic(conn_id, leAudioDevice->audio_supp_cont_hdls_.val_hdl, in OnServiceSearchComplete()
3384 charac.value_handle, leAudioDevice->audio_supp_cont_hdls_.ccc_hdl, in OnServiceSearchComplete()
3385 leAudioDevice->address_); in OnServiceSearchComplete()
3390 leAudioDevice->ases_.clear(); in OnServiceSearchComplete()
3398 disconnectInvalidDevice(leAudioDevice, ", ASE char doesn't have ccc", in OnServiceSearchComplete()
3403 if (!subscribe_for_notification(conn_id, leAudioDevice->address_, hdls)) { in OnServiceSearchComplete()
3404 disconnectInvalidDevice(leAudioDevice, ", could not subscribe ASE char", in OnServiceSearchComplete()
3413 leAudioDevice->ases_.emplace_back(charac.value_handle, ccc_handle, direction); in OnServiceSearchComplete()
3418 charac.value_handle, ccc_handle, direction, leAudioDevice->address_); in OnServiceSearchComplete()
3421 leAudioDevice->ctp_hdls_.val_hdl = charac.value_handle; in OnServiceSearchComplete()
3422 leAudioDevice->ctp_hdls_.ccc_hdl = find_ccc_handle(charac); in OnServiceSearchComplete()
3424 if (leAudioDevice->ctp_hdls_.ccc_hdl == 0) { in OnServiceSearchComplete()
3425 disconnectInvalidDevice(leAudioDevice, ", ASE ctp doesn't have ccc", in OnServiceSearchComplete()
3430 if (!subscribe_for_notification(conn_id, leAudioDevice->address_, in OnServiceSearchComplete()
3431 leAudioDevice->ctp_hdls_)) { in OnServiceSearchComplete()
3432 disconnectInvalidDevice(leAudioDevice, ", could not subscribe ASE char", in OnServiceSearchComplete()
3440 charac.value_handle, leAudioDevice->ctp_hdls_.ccc_hdl, leAudioDevice->address_); in OnServiceSearchComplete()
3448 leAudioDevice->tmap_role_hdl_ = charac.value_handle; in OnServiceSearchComplete()
3451 BtaGattQueue::ReadCharacteristic(conn_id, leAudioDevice->tmap_role_hdl_, in OnServiceSearchComplete()
3456 leAudioDevice->tmap_role_hdl_, leAudioDevice->address_); in OnServiceSearchComplete()
3462 leAudioDevice->gmap_client_ = std::make_unique<GmapClient>(leAudioDevice->address_); in OnServiceSearchComplete()
3466 leAudioDevice->gmap_client_->setRoleHandle(handle); in OnServiceSearchComplete()
3469 leAudioDevice->gmap_client_->getRoleHandle(), leAudioDevice->address_); in OnServiceSearchComplete()
3473 leAudioDevice->gmap_client_->setUGTFeatureHandle(handle); in OnServiceSearchComplete()
3476 leAudioDevice->gmap_client_->getUGTFeatureHandle(), leAudioDevice->address_); in OnServiceSearchComplete()
3481 leAudioDevice->known_service_handles_ = true; in OnServiceSearchComplete()
3482 leAudioDevice->notify_connected_after_read_ = true; in OnServiceSearchComplete()
3484 leAudioHealthStatus_->AddStatisticForDevice(leAudioDevice, in OnServiceSearchComplete()
3489 if (leAudioDevice->group_id_ != bluetooth::groups::kGroupUnknown) { in OnServiceSearchComplete()
3490 AseInitialStateReadRequest(leAudioDevice); in OnServiceSearchComplete()
3498 int group_id = DeviceGroups::Get()->GetGroupId(leAudioDevice->address_, in OnServiceSearchComplete()
3501 instance->group_add_node(group_id, leAudioDevice->address_); in OnServiceSearchComplete()
3506 if (leAudioDevice->csis_member_) { in OnServiceSearchComplete()
3507 log::info("{}, waiting for CSIS to create group for device", leAudioDevice->address_); in OnServiceSearchComplete()
3508 scheduleGuardForCsisAdd(leAudioDevice->address_); in OnServiceSearchComplete()
3512 log::info("{} Not a CSIS member. Create group by our own", leAudioDevice->address_); in OnServiceSearchComplete()
3515 DeviceGroups::Get()->AddDevice(leAudioDevice->address_, in OnServiceSearchComplete()
3520 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByConnId(conn_id); in OnGattWriteCcc() local
3523 if (!leAudioDevice) { in OnGattWriteCcc()
3529 log::info("Database out of sync for {}, conn_id: 0x{:04x}", leAudioDevice->address_, conn_id); in OnGattWriteCcc()
3530 ClearDeviceInformationAndStartSearch(leAudioDevice); in OnGattWriteCcc()
3536 leAudioDevice->address_); in OnGattWriteCcc()
3538 if (leAudioDevice->ctp_hdls_.ccc_hdl == hdl && leAudioDevice->known_service_handles_ && in OnGattWriteCcc()
3539 !leAudioDevice->notify_connected_after_read_) { in OnGattWriteCcc()
3542 connectionReady(leAudioDevice); in OnGattWriteCcc()
3549 leAudioDevice->address_, status); in OnGattWriteCcc()
3552 std::find_if(leAudioDevice->ases_.begin(), leAudioDevice->ases_.end(), in OnGattWriteCcc()
3555 if (ase_it == leAudioDevice->ases_.end()) { in OnGattWriteCcc()
3556 log::error("Unknown ccc handle: 0x{:04x}, device: {}", hdl, leAudioDevice->address_); in OnGattWriteCcc()
3560 BTA_GATTC_DeregisterForNotifications(gatt_if_, leAudioDevice->address_, ase_it->hdls.val_hdl); in OnGattWriteCcc()
3563 void AttachToStreamingGroupIfNeeded(LeAudioDevice* leAudioDevice) { in AttachToStreamingGroupIfNeeded() argument
3564 if (leAudioDevice->group_id_ != active_group_id_) { in AttachToStreamingGroupIfNeeded()
3565 log::info("group {} is not streaming. Nothing to do", leAudioDevice->group_id_); in AttachToStreamingGroupIfNeeded()
3569 if (leAudioDevice->GetConnectionState() != DeviceConnectState::CONNECTED) { in AttachToStreamingGroupIfNeeded()
3571 log::debug("{} is not yet connected", leAudioDevice->address_); in AttachToStreamingGroupIfNeeded()
3575 if (leAudioDevice->HaveActiveAse()) { in AttachToStreamingGroupIfNeeded()
3576 log::debug("{} is already configured, nothing to do", leAudioDevice->address_); in AttachToStreamingGroupIfNeeded()
3583 auto device_available_contexts = leAudioDevice->GetAvailableContexts(); in AttachToStreamingGroupIfNeeded()
3587 leAudioDevice->address_, common::ToString(group_metadata_contexts), in AttachToStreamingGroupIfNeeded()
3605 log::info("Attaching {} to group: {}", leAudioDevice->address_, leAudioDevice->group_id_); in AttachToStreamingGroupIfNeeded()
3612 ? leAudioDevice->snk_pacs_ in AttachToStreamingGroupIfNeeded()
3613 : leAudioDevice->src_pacs_; in AttachToStreamingGroupIfNeeded()
3616 log::info("Configuration is not supported by device {}", leAudioDevice->address_); in AttachToStreamingGroupIfNeeded()
3636 if (!groupStateMachine_->AttachToStream(group, leAudioDevice, std::move(ccids))) { in AttachToStreamingGroupIfNeeded()
3637 log::warn("Could not add device {} to the group {} streaming.", leAudioDevice->address_, in AttachToStreamingGroupIfNeeded()
3639 scheduleAttachDeviceToTheStream(leAudioDevice->address_); in AttachToStreamingGroupIfNeeded()
3646 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByAddress(addr); in restartAttachToTheStream() local
3647 if (leAudioDevice == nullptr || leAudioDevice->conn_id_ == GATT_INVALID_CONN_ID) { in restartAttachToTheStream()
3651 AttachToStreamingGroupIfNeeded(leAudioDevice); in restartAttachToTheStream()
3662 auto leAudioDevice = group->GetFirstDevice(); in SendAudioGroupSelectableCodecConfigChanged() local
3666 leAudioDevice->src_pacs_), in SendAudioGroupSelectableCodecConfigChanged()
3668 leAudioDevice->snk_pacs_)); in SendAudioGroupSelectableCodecConfigChanged()
3692 void connectionReady(LeAudioDevice* leAudioDevice) { in connectionReady() argument
3693 log::debug("{}, {}", leAudioDevice->address_, in connectionReady()
3694 bluetooth::common::ToString(leAudioDevice->GetConnectionState())); in connectionReady()
3697 leAudioDevice->address_, false); in connectionReady()
3699 if (leAudioDevice->GetConnectionState() == in connectionReady()
3701 (leAudioDevice->autoconnect_flag_ == false)) { in connectionReady()
3702 btif_storage_set_leaudio_autoconnect(leAudioDevice->address_, true); in connectionReady()
3703 leAudioDevice->autoconnect_flag_ = true; in connectionReady()
3706 leAudioDevice->SetConnectionState(DeviceConnectState::CONNECTED); in connectionReady()
3708 leAudioDevice->group_id_, leAudioDevice->address_, ConnectionState::CONNECTED, in connectionReady()
3711 if (leAudioDevice->group_id_ == bluetooth::groups::kGroupUnknown) { in connectionReady()
3712 log::warn("LeAudio device {} connected with no group", leAudioDevice->address_); in connectionReady()
3713 callbacks_->OnConnectionState(ConnectionState::CONNECTED, leAudioDevice->address_); in connectionReady()
3717 LeAudioDeviceGroup* group = aseGroups_.FindById(leAudioDevice->group_id_); in connectionReady()
3723 callbacks_->OnConnectionState(ConnectionState::CONNECTED, leAudioDevice->address_); in connectionReady()
3725 AttachToStreamingGroupIfNeeded(leAudioDevice); in connectionReady()
5741 LeAudioDevice* leAudioDevice = instance->leAudioDevices_.FindByConnId(conn_id); in OnGattReadRspStatic() local
5746 instance->ClearDeviceInformationAndStartSearch(leAudioDevice); in OnGattReadRspStatic()
5756 leAudioDevice->notify_connected_after_read_ = false; in OnGattReadRspStatic()
5759 btif_storage_leaudio_update_handles_bin(leAudioDevice->address_); in OnGattReadRspStatic()
5760 btif_storage_leaudio_update_pacs_bin(leAudioDevice->address_); in OnGattReadRspStatic()
5761 btif_storage_leaudio_update_ase_bin(leAudioDevice->address_); in OnGattReadRspStatic()
5763 if (leAudioDevice->audio_locations_.sink) { in OnGattReadRspStatic()
5765 leAudioDevice->address_, leAudioDevice->audio_locations_.sink->value.to_ulong()); in OnGattReadRspStatic()
5767 if (leAudioDevice->audio_locations_.source) { in OnGattReadRspStatic()
5769 leAudioDevice->address_, leAudioDevice->audio_locations_.source->value.to_ulong()); in OnGattReadRspStatic()
5772 instance->connectionReady(leAudioDevice); in OnGattReadRspStatic()
5784 LeAudioDevice* leAudioDevice = instance->leAudioDevices_.FindByConnId(conn_id); in OnGattReadMultiRspStatic() local
5785 instance->ClearDeviceInformationAndStartSearch(leAudioDevice); in OnGattReadMultiRspStatic()
5876 LeAudioDevice* leAudioDevice = in IsoCisEventsCb() local
5878 if (!leAudioDevice) { in IsoCisEventsCb()
5882 LeAudioDeviceGroup* group = aseGroups_.FindById(leAudioDevice->group_id_); in IsoCisEventsCb()
5898 groupStateMachine_->ProcessHciNotifCisEstablished(group, leAudioDevice, event); in IsoCisEventsCb()
5903 LeAudioDevice* leAudioDevice = in IsoCisEventsCb() local
5905 if (!leAudioDevice) { in IsoCisEventsCb()
5909 LeAudioDeviceGroup* group = aseGroups_.FindById(leAudioDevice->group_id_); in IsoCisEventsCb()
5911 groupStateMachine_->ProcessHciNotifCisDisconnected(group, leAudioDevice, event); in IsoCisEventsCb()
5920 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByCisConnHdl(cig_id, conn_handle); in IsoSetupIsoDataPathCb() local
5922 if (!leAudioDevice) { in IsoSetupIsoDataPathCb()
5927 LeAudioDeviceGroup* group = aseGroups_.FindById(leAudioDevice->group_id_); in IsoSetupIsoDataPathCb()
5929 instance->groupStateMachine_->ProcessHciNotifSetupIsoDataPath(group, leAudioDevice, status, in IsoSetupIsoDataPathCb()
5934 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByCisConnHdl(cig_id, conn_handle); in IsoRemoveIsoDataPathCb() local
5940 if (!leAudioDevice) { in IsoRemoveIsoDataPathCb()
5946 LeAudioDeviceGroup* group = aseGroups_.FindById(leAudioDevice->group_id_); in IsoRemoveIsoDataPathCb()
5948 instance->groupStateMachine_->ProcessHciNotifRemoveIsoDataPath(group, leAudioDevice, status, in IsoRemoveIsoDataPathCb()
5956 LeAudioDevice* leAudioDevice = leAudioDevices_.FindByCisConnHdl(cig_id, conn_handle); in IsoLinkQualityReadCb() local
5957 if (!leAudioDevice) { in IsoLinkQualityReadCb()
5962 LeAudioDeviceGroup* group = aseGroups_.FindById(leAudioDevice->group_id_); in IsoLinkQualityReadCb()
5965 group, leAudioDevice, conn_handle, txUnackedPackets, txFlushedPackets, in IsoLinkQualityReadCb()
5988 auto leAudioDevice = group->GetFirstDevice(); in HandlePendingDeviceDisconnection() local
5989 while (leAudioDevice) { in HandlePendingDeviceDisconnection()
5990 if (leAudioDevice->closing_stream_for_disconnection_) { in HandlePendingDeviceDisconnection()
5991 leAudioDevice->closing_stream_for_disconnection_ = false; in HandlePendingDeviceDisconnection()
5993 leAudioDevice->address_); in HandlePendingDeviceDisconnection()
5994 bool force_acl_disconnect = leAudioDevice->autoconnect_flag_ && group->IsEnabled(); in HandlePendingDeviceDisconnection()
5995 DisconnectDevice(leAudioDevice, force_acl_disconnect); in HandlePendingDeviceDisconnection()
5997 leAudioDevice = group->GetNextDevice(leAudioDevice); in HandlePendingDeviceDisconnection()
6565 LeAudioDevice* leAudioDevice = group->GetFirstDevice(); in DsaDataConsume() local
6566 while (leAudioDevice != nullptr) { in DsaDataConsume()
6567 if (leAudioDevice->GetDsaCisHandle() == cis_conn_hdl && in DsaDataConsume()
6568 leAudioDevice->GetDsaDataPathState() == DataPathState::CONFIGURED) { in DsaDataConsume()
6571 leAudioDevice = group->GetNextDevice(leAudioDevice); in DsaDataConsume()
6573 if (leAudioDevice == nullptr) { in DsaDataConsume()
6578 bool consumed = iso_data_callback(leAudioDevice->address_, cis_conn_hdl, data, size, timestamp); in DsaDataConsume()
6588 LeAudioDevice* leAudioDevice = group->GetFirstDevice(); in SetAsymmetricBlePhy() local
6589 if (leAudioDevice == nullptr) { in SetAsymmetricBlePhy()
6594 for (auto tmpDevice = leAudioDevice; tmpDevice != nullptr; in SetAsymmetricBlePhy()