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

Commit d619c11b authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

leaudio: Fix handling invalid peer device

With this patch we make sure that le audio device is recognize as a part
of CSIS member if CSIS service is primary and is included by CAS on the
peer device.

Bug: 150670922
Tag: #feature
Sponsor: jpawlowski@
Test: atest --host bluetooth_le_audio_test bluetooth_le_audio_client_test

Change-Id: Ic454d8e586b4e42bc6af887479e5b824ac2afcc4
parent 82f0417e
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -1252,6 +1252,9 @@ class LeAudioClientImpl : public LeAudioClient {
    const gatt::Service* pac_svc = nullptr;
    const gatt::Service* ase_svc = nullptr;

    std::vector<uint16_t> csis_primary_handles;
    uint16_t cas_csis_included_handle = 0;

    for (const gatt::Service& tmp : *services) {
      if (tmp.uuid == le_audio::uuid::kPublishedAudioCapabilityServiceUuid) {
        LOG(INFO) << "Found Audio Capability service, handle: "
@@ -1261,6 +1264,10 @@ class LeAudioClientImpl : public LeAudioClient {
        LOG(INFO) << "Found Audio Stream Endpoint service, handle: "
                  << loghex(tmp.handle);
        ase_svc = &tmp;
      } else if (tmp.uuid == bluetooth::csis::kCsisServiceUuid) {
        LOG(INFO) << "Found CSIS service, handle: " << loghex(tmp.handle)
                  << " is primary? " << tmp.is_primary;
        if (tmp.is_primary) csis_primary_handles.push_back(tmp.handle);
      } else if (tmp.uuid == le_audio::uuid::kCapServiceUuid) {
        LOG(INFO) << "Found CAP Service, handle: " << loghex(tmp.handle);

@@ -1269,7 +1276,7 @@ class LeAudioClientImpl : public LeAudioClient {
          if (included_srvc.uuid == bluetooth::csis::kCsisServiceUuid) {
            LOG(INFO) << __func__ << " CSIS included into CAS";
            if (bluetooth::csis::CsisClient::IsCsisClientRunning())
              leAudioDevice->csis_member_ = true;
              cas_csis_included_handle = included_srvc.start_handle;

            break;
          }
@@ -1277,6 +1284,15 @@ class LeAudioClientImpl : public LeAudioClient {
      }
    }

    /* Check if CAS includes primary CSIS service */
    if (!csis_primary_handles.empty() && cas_csis_included_handle) {
      auto iter =
          std::find(csis_primary_handles.begin(), csis_primary_handles.end(),
                    cas_csis_included_handle);
      if (iter != csis_primary_handles.end())
        leAudioDevice->csis_member_ = true;
    }

    if (!pac_svc || !ase_svc) {
      LOG(ERROR) << "No mandatory le audio services found";