Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dfd3e73c authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

LeAudio: Improve detecting disconnected devices.

When the device disconnection cleanup is ongoing, make
sure the group does not count devices which did not reached the
DISCONNECTED state yet. Those devices can be detected by their
connection ID being invalid.

Bug: 275154325
Test: atest --host bluetooth_le_audio_client_test bluetooth_le_audio_test --no-bazel-mode
Change-Id: I8417394a75646ea13c416587782eb6163acef239
parent f4ffb1d6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ int LeAudioDeviceGroup::NumOfConnected(types::LeAudioContextType context_type) {
      leAudioDevices_.begin(), leAudioDevices_.end(),
      [type_set, check_context_type](auto& iter) {
        if (iter.expired()) return false;
        if (iter.lock()->conn_id_ == GATT_INVALID_CONN_ID) return false;
        if (iter.lock()->GetConnectionState() != DeviceConnectState::CONNECTED)
          return false;

+15 −0
Original line number Diff line number Diff line
@@ -1366,6 +1366,21 @@ TEST_F(LeAudioAseConfigurationTest, test_reactivation_conversational) {
  /* Only two ASEs can be bonded to one bi-directional CIS */
  ASSERT_EQ(bi_dir_ases_count, 2);
}

TEST_F(LeAudioAseConfigurationTest, test_num_of_connected) {
  auto device1 = AddTestDevice(2, 1);
  auto device2 = AddTestDevice(2, 1);
  ASSERT_EQ(2, group_->NumOfConnected());

  // Drop the ACL connection
  device1->conn_id_ = GATT_INVALID_CONN_ID;
  ASSERT_EQ(1, group_->NumOfConnected());

  // Fully disconnect the other device
  device2->SetConnectionState(DeviceConnectState::DISCONNECTING);
  ASSERT_EQ(0, group_->NumOfConnected());
}

}  // namespace
}  // namespace internal
}  // namespace le_audio