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

Commit 30393d0c authored by Jason Huang's avatar Jason Huang
Browse files

csip: avoid create two group with same id

Summary:
- When first device connected for a new csis group, csip stack is
possible to create two group with same id.

Reason:
- In OnCsisSirkValueUpdate(), if the group not found
(means group_id is unknown), it will call DeviceGroups::AddDevice(),
and OnGroupAddedCb() be raised, a new csis group will be made in
AssignCsisGroup().
- But in OnCsisSirkValueUpdate(), it still creating a new csis group
without checking if the group is already created, this causes another
new group with same id will be added to csis_groups_.

Solution:
- We should remove it and ensure create new group only in
AssignCsisGroup().

Change-Id: Iaff4a54a0ea44d67f256052e7be9ffa47f11407d
parent 9295f0d2
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ class CsisClientImpl : public CsisClient {
    if (!csis_group) {
      if (create_group_if_non_existing) {
        /* Let's create a group */
        LOG(INFO) << __func__ << ": Create a new group";
        auto g = std::make_shared<CsisGroup>(group_id, uuid);
        csis_groups_.push_back(g);
        csis_group = FindCsisGroup(group_id);
@@ -1340,11 +1341,6 @@ class CsisClientImpl : public CsisClient {
        group_id =
            dev_groups_->AddDevice(device->addr, csis_instance->GetUuid());
        LOG_ASSERT(group_id != -1);

        /* Create new group */
        auto g =
            std::make_shared<CsisGroup>(group_id, csis_instance->GetUuid());
        csis_groups_.push_back(g);
      } else {
        dev_groups_->AddDevice(device->addr, csis_instance->GetUuid(),
                               group_id);