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

Commit 4dca0310 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

csis: Start set member search when first device is connected

With this patch we start active search when first set member is fully
connected and all the characteristic are read.

Bug: 281119807
Test: atest bluetooth_csis_test
Test: atest BluetoothInstrumentationTests
Tag: #feature
Change-Id: I419714d51e844f78e2bbd401bd7b2cdc4f1934f8
parent 90756340
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -814,6 +814,7 @@ class CsisClientImpl : public CsisClient {
     * CSIS group.
     */
    bool notify_connected = false;
    int group_id_to_discover = bluetooth::groups::kGroupUnknown;
    for (const auto& csis_group : csis_groups_) {
      if (!csis_group->IsDeviceInTheGroup(device)) continue;

@@ -837,10 +838,26 @@ class CsisClientImpl : public CsisClient {
          device->addr, group_id, csis_group->GetDesiredSize(),
          csis_instance->GetRank(), csis_instance->GetUuid());
      notify_connected = true;

      if (group_id_to_discover == bluetooth::groups::kGroupUnknown) {
        group_id_to_discover = group_id;
      }
    }
    if (notify_connected)

    if (notify_connected) {
      callbacks_->OnConnectionState(device->addr, ConnectionState::CONNECTED);

      if (group_id_to_discover != bluetooth::groups::kGroupUnknown) {
        /* Start active search for the other device
         * b/281120322
         */
        auto g = FindCsisGroup(group_id_to_discover);
        if (g->GetDesiredSize() > g->GetCurrentSize()) {
          CsisActiveDiscovery(g);
        }
      }
    }

    if (device->first_connection) {
      device->first_connection = false;
      btif_storage_set_csis_autoconnect(device->addr, true);
@@ -1016,9 +1033,6 @@ class CsisClientImpl : public CsisClient {

    auto new_size = value[0];
    csis_group->SetDesiredSize(new_size);
    if (new_size > csis_group->GetCurrentSize()) {
      CsisActiveDiscovery(csis_group);
    }

    if (notify_valid_services) NotifyCsisDeviceValidAndStoreIfNeeded(device);
  }
@@ -1505,10 +1519,6 @@ class CsisClientImpl : public CsisClient {
               << loghex(csis_group->GetDesiredSize())
               << ", actual group Size: "
               << loghex(csis_group->GetCurrentSize());

    /* Start active search for the other device */
    if (csis_group->GetDesiredSize() > csis_group->GetCurrentSize())
      CsisActiveDiscovery(csis_group);
  }

  void DeregisterNotifications(std::shared_ptr<CsisDevice> device) {