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

Commit d5b3ec0c authored by Chris Manton's avatar Chris Manton
Browse files

legacy: Add and use additional disconnect param comment reason

Bug: 174215138
Tag: #refactor
Test: gd/cert/run

Change-Id: I87a336e4ada73fa5d69a81e2d11e6a3b5f18632c
parent 3213a372
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -788,7 +788,8 @@ class LeAudioClientImpl : public LeAudioClient {
      uint16_t acl_handle =
          BTM_GetHCIConnHandle(leAudioDevice->address_, BT_TRANSPORT_LE);
      if (acl_handle != HCI_INVALID_HANDLE) {
        acl_disconnect_from_handle(acl_handle, HCI_ERR_PEER_USER);
        acl_disconnect_from_handle(acl_handle, HCI_ERR_PEER_USER,
                                   "bta::le_audio::client disconnect");
        return;
      }
    }
+3 −2
Original line number Diff line number Diff line
@@ -89,7 +89,8 @@ uint16_t BTM_GetHCIConnHandle(RawAddress const& bd_addr,
  return btm_interface->GetHCIConnHandle(bd_addr, transport);
}

void acl_disconnect_from_handle(uint16_t handle, tHCI_STATUS reason) {
void acl_disconnect_from_handle(uint16_t handle, tHCI_STATUS reason,
                                std::string comment) {
  LOG_ASSERT(btm_interface) << "Mock btm interface not set!";
  return btm_interface->AclDisconnectFromHandle(handle, reason);
}
+17 −11
Original line number Diff line number Diff line
@@ -844,7 +844,8 @@ struct shim::legacy::Acl::impl {
    handle_to_classic_connection_map_[handle]->SetConnectionEncryption(enable);
  }

  void disconnect_classic(uint16_t handle, tHCI_STATUS reason) {
  void disconnect_classic(uint16_t handle, tHCI_STATUS reason,
                          std::string comment) {
    auto connection = handle_to_classic_connection_map_.find(handle);
    if (connection != handle_to_classic_connection_map_.end()) {
      auto remote_address = connection->second->GetRemoteAddress();
@@ -854,15 +855,16 @@ struct shim::legacy::Acl::impl {
                PRIVATE_ADDRESS(remote_address), handle);
      BTM_LogHistory(kBtmLogTag, ToRawAddress(remote_address),
                     "Disconnection initiated",
                     base::StringPrintf("classic reason:%s",
                                        hci_status_code_text(reason).c_str()));
                     base::StringPrintf("classic reason:%s comment:%s",
                                        hci_status_code_text(reason).c_str(),
                                        comment.c_str()));
    } else {
      LOG_WARN("Unable to disconnect unknown classic connection handle:0x%04x",
               handle);
    }
  }

  void disconnect_le(uint16_t handle, tHCI_STATUS reason) {
  void disconnect_le(uint16_t handle, tHCI_STATUS reason, std::string comment) {
    auto connection = handle_to_le_connection_map_.find(handle);
    if (connection != handle_to_le_connection_map_.end()) {
      auto remote_address_with_type =
@@ -874,8 +876,9 @@ struct shim::legacy::Acl::impl {
      BTM_LogHistory(kBtmLogTag,
                     ToLegacyAddressWithType(remote_address_with_type),
                     "Disconnection initiated",
                     base::StringPrintf("Le reason:%s",
                                        hci_status_code_text(reason).c_str()));
                     base::StringPrintf("Le reason:%s comment:%s",
                                        hci_status_code_text(reason).c_str(),
                                        comment.c_str()));
    } else {
      LOG_WARN("Unable to disconnect unknown le connection handle:0x%04x",
               handle);
@@ -1485,13 +1488,16 @@ void shim::legacy::Acl::OnLeConnectFail(hci::AddressWithType address_with_type,
      base::StringPrintf("le reason:%s", hci::ErrorCodeText(reason).c_str()));
}

void shim::legacy::Acl::DisconnectClassic(uint16_t handle, tHCI_STATUS reason) {
  handler_->CallOn(pimpl_.get(), &Acl::impl::disconnect_classic, handle,
                   reason);
void shim::legacy::Acl::DisconnectClassic(uint16_t handle, tHCI_STATUS reason,
                                          std::string comment) {
  handler_->CallOn(pimpl_.get(), &Acl::impl::disconnect_classic, handle, reason,
                   comment);
}

void shim::legacy::Acl::DisconnectLe(uint16_t handle, tHCI_STATUS reason) {
  handler_->CallOn(pimpl_.get(), &Acl::impl::disconnect_le, handle, reason);
void shim::legacy::Acl::DisconnectLe(uint16_t handle, tHCI_STATUS reason,
                                     std::string comment) {
  handler_->CallOn(pimpl_.get(), &Acl::impl::disconnect_le, handle, reason,
                   comment);
}

bool shim::legacy::Acl::HoldMode(uint16_t hci_handle, uint16_t max_interval,
+4 −2
Original line number Diff line number Diff line
@@ -72,8 +72,10 @@ class Acl : public hci::acl_manager::ConnectionCallbacks,
                              std::promise<bool> promise) override;
  void IgnoreLeConnectionFrom(
      const hci::AddressWithType& address_with_type) override;
  void DisconnectClassic(uint16_t handle, tHCI_REASON reason) override;
  void DisconnectLe(uint16_t handle, tHCI_REASON reason) override;
  void DisconnectClassic(uint16_t handle, tHCI_REASON reason,
                         std::string comment) override;
  void DisconnectLe(uint16_t handle, tHCI_REASON reason,
                    std::string comment) override;

  // Address Resolution List
  void AddToAddressResolution(const hci::AddressWithType& address_with_type,
+4 −3
Original line number Diff line number Diff line
@@ -85,10 +85,11 @@ void bluetooth::shim::ACL_ConfigureLePrivacy(bool is_le_privacy_enabled) {
}

void bluetooth::shim::ACL_Disconnect(uint16_t handle, bool is_classic,
                                     tHCI_STATUS reason) {
                                     tHCI_STATUS reason, std::string comment) {
  (is_classic)
      ? Stack::GetInstance()->GetAcl()->DisconnectClassic(handle, reason)
      : Stack::GetInstance()->GetAcl()->DisconnectLe(handle, reason);
      ? Stack::GetInstance()->GetAcl()->DisconnectClassic(handle, reason,
                                                          comment)
      : Stack::GetInstance()->GetAcl()->DisconnectLe(handle, reason, comment);
}

void bluetooth::shim::ACL_Shutdown() {
Loading