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

Commit f6d71e1a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Eatt: Improve colision handling" into tm-qpr-dev

parents fadc373a b371321c
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -93,6 +93,15 @@ struct eatt_impl {
    return (it == eatt_dev->eatt_channels.end()) ? nullptr : it->second.get();
  }

  bool is_channel_connection_pending(eatt_device* eatt_dev) {
    for (const std::pair<uint16_t, std::shared_ptr<EattChannel>>& el :
         eatt_dev->eatt_channels) {
      if (el.second->state_ == EattChannelState::EATT_CHANNEL_PENDING)
        return true;
    }
    return false;
  }

  EattChannel* find_channel_by_cid(const RawAddress& bdaddr, uint16_t lcid) {
    eatt_device* eatt_dev = find_device_by_address(bdaddr);
    if (!eatt_dev) return nullptr;
@@ -242,6 +251,11 @@ struct eatt_impl {
      LOG(ERROR) << __func__
                 << " Could not connect CoC result: " << loghex(result);
      remove_channel_by_cid(eatt_dev, lcid);

      /* If there is no channels connected, check if there was collision */
      if (!is_channel_connection_pending(eatt_dev)) {
        eatt_retry_after_collision_if_needed(eatt_dev);
      }
      return;
    }

@@ -252,8 +266,7 @@ struct eatt_impl {
    CHECK(eatt_dev->bda_ == channel->bda_);
    eatt_dev->eatt_tcb_->eatt++;

    LOG(INFO) << __func__ << " Channel connected CID " << loghex(lcid);
    eatt_retry_after_collision_if_needed(eatt_dev);
    LOG_INFO("Channel connected CID 0x%04x", lcid);
  }

  void eatt_l2cap_reconfig_completed(const RawAddress& bda, uint16_t lcid,
@@ -323,8 +336,10 @@ struct eatt_impl {
        break;
    }

    if (!is_channel_connection_pending(eatt_dev)) {
      eatt_retry_after_collision_if_needed(eatt_dev);
    }
  }

  void eatt_l2cap_disconnect_ind(uint16_t lcid, bool please_confirm) {
    LOG(INFO) << __func__ << " cid: " << loghex(lcid);
+7 −3
Original line number Diff line number Diff line
@@ -82,9 +82,13 @@ class EattTest : public testing::Test {
    eatt_instance_->Connect(test_address);

    if (collision) {
      /* Collision should be handled only if all channels has been rejected in
       * first place.*/
      if (num_of_accepted_connections == 0) {
        EXPECT_CALL(l2cap_interface_,
                    ConnectCreditBasedReq(BT_PSM_EATT, test_address, _))
            .Times(1);
      }

      l2cap_app_info_.pL2CA_CreditBasedCollisionInd_Cb(test_address);
    }