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

Commit 626accd4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes I54ab2506,I64ac8a87,I37b7d946,I6e152469 am: 778ed463

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1519365

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic543b96d0cb548c0a8b290dca2baa7e79ebdad77
parents 35ba87d7 778ed463
Loading
Loading
Loading
Loading
+32 −16
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@
#include "stack/include/sec_hci_link_interface.h"
#include "stack/l2cap/l2c_int.h"

extern tBTM_CB btm_cb;

bt_status_t do_in_main_thread(const base::Location& from_here,
                              base::OnceClosure task);

@@ -307,6 +309,9 @@ class ClassicShimAclConnection
                        ToLegacyHciErrorCode(hci::ErrorCode::SUCCESS),
                        ToRawAddress(connection_->GetAddress()),
                        ToLegacyRole(new_role));
    btm_cb.history_->Push("%-32s: %s classic new_role:%s", "Role change",
                          PRIVATE_ADDRESS(connection_->GetAddress()),
                          hci::RoleText(new_role).c_str());
  }

  void OnDisconnection(hci::ErrorCode reason) override {
@@ -449,7 +454,6 @@ void DumpsysL2cap(int fd) {

#undef DUMPSYS_TAG
#define DUMPSYS_TAG "shim::legacy::acl"
extern tBTM_CB btm_cb;
void DumpsysAcl(int fd) {
  const tACL_CB& acl_cb = btm_cb.acl_cb_;

@@ -488,6 +492,7 @@ void DumpsysAcl(int fd) {
    LOG_DUMPSYS(fd, "    pkt_types_mask:0x%04x", acl_conn.pkt_types_mask);
    LOG_DUMPSYS(fd, "    disconnect_reason:0x%02x", acl_conn.disconnect_reason);
    LOG_DUMPSYS(fd, "    chg_ind:%s", (btm_pm_mcb.chg_ind) ? "true" : "false");
    LOG_DUMPSYS(fd, "    role:%s", RoleText(acl_conn.link_role).c_str());
  }
}
#undef DUMPSYS_TAG
@@ -496,7 +501,6 @@ using Record = bluetooth::common::TimestampedEntry<std::string>;
const std::string kTimeFormat("%Y-%m-%d %H:%M:%S");

#define DUMPSYS_TAG "shim::legacy::btm"
extern tBTM_CB btm_cb;
void DumpsysBtm(int fd) {
  LOG_DUMPSYS_TITLE(fd, DUMPSYS_TAG);
  if (btm_cb.history_ != nullptr) {
@@ -563,9 +567,9 @@ void bluetooth::shim::legacy::Acl::WriteData(

void bluetooth::shim::legacy::Acl::CreateClassicConnection(
    const bluetooth::hci::Address& address) {
  LOG_DEBUG("Initiate the creation of a classic connection %s",
            address.ToString().c_str());
  GetAclManager()->CreateConnection(address);
  LOG_DEBUG("Connection initiated for classic to remote:%s",
            PRIVATE_ADDRESS(address));
  btm_cb.history_->Push("%-32s: %s classic", "Initiated connection",
                        PRIVATE_ADDRESS(address));
}
@@ -573,8 +577,8 @@ void bluetooth::shim::legacy::Acl::CreateClassicConnection(
void bluetooth::shim::legacy::Acl::CreateLeConnection(
    const bluetooth::hci::AddressWithType& address_with_type) {
  GetAclManager()->CreateLeConnection(address_with_type);
  LOG_DEBUG("Started Le device to connection %s",
            address_with_type.ToString().c_str());
  LOG_DEBUG("Connection initiated for le connection to remote:%s",
            PRIVATE_ADDRESS(address_with_type));
  btm_cb.history_->Push("%-32s: %s le", "Initiated connection",
                        PRIVATE_ADDRESS(address_with_type));
}
@@ -582,21 +586,23 @@ void bluetooth::shim::legacy::Acl::CreateLeConnection(
void bluetooth::shim::legacy::Acl::CancelLeConnection(
    const bluetooth::hci::AddressWithType& address_with_type) {
  GetAclManager()->CancelLeConnect(address_with_type);
  LOG_DEBUG("Canceled le connection %s", address_with_type.ToString().c_str());
  LOG_DEBUG("Cancelled le connection to remote:%s",
            PRIVATE_ADDRESS(address_with_type));
  btm_cb.history_->Push("%-32s: %s le", "Cancelled connection",
                        PRIVATE_ADDRESS(address_with_type));
}

void bluetooth::shim::legacy::Acl::OnClassicLinkDisconnected(
    HciHandle handle, hci::ErrorCode reason) {
  LOG_DEBUG("Classic link disconnected handle:%hu reason:%s", handle,
            ErrorCodeText(reason).c_str());
  bluetooth::hci::Address remote_address =
      pimpl_->handle_to_classic_connection_map_[handle]->GetRemoteAddress();
  pimpl_->handle_to_classic_connection_map_.erase(handle);
  TRY_POSTING_ON_MAIN(acl_interface_.connection.classic.on_disconnected,
                      ToLegacyHciErrorCode(hci::ErrorCode::SUCCESS), handle,
                      ToLegacyHciErrorCode(reason));
  LOG_DEBUG("Disconnected classic link remote:%s handle:%hu reason:%s",
            PRIVATE_ADDRESS(remote_address), handle,
            ErrorCodeText(reason).c_str());
  btm_cb.history_->Push("%-32s: %s classic reason:%s", "Disconnected",
                        PRIVATE_ADDRESS(remote_address),
                        ErrorCodeText(reason).c_str());
@@ -604,14 +610,15 @@ void bluetooth::shim::legacy::Acl::OnClassicLinkDisconnected(

void bluetooth::shim::legacy::Acl::OnLeLinkDisconnected(HciHandle handle,
                                                        hci::ErrorCode reason) {
  LOG_DEBUG("Le link disconnected handle:%hu reason:%s", handle,
            ErrorCodeText(reason).c_str());
  hci::AddressWithType remote_address_with_type =
      pimpl_->handle_to_le_connection_map_[handle]->GetRemoteAddressWithType();
  pimpl_->handle_to_le_connection_map_.erase(handle);
  TRY_POSTING_ON_MAIN(acl_interface_.connection.le.on_disconnected,
                      ToLegacyHciErrorCode(hci::ErrorCode::SUCCESS), handle,
                      ToLegacyHciErrorCode(reason));
  LOG_DEBUG("Disconnected le link remote:%s handle:%hu reason:%s",
            PRIVATE_ADDRESS(remote_address_with_type), handle,
            ErrorCodeText(reason).c_str());
  btm_cb.history_->Push("%-32s: %s le reason:%s", "Disconnected",
                        PRIVATE_ADDRESS(remote_address_with_type),
                        ErrorCodeText(reason).c_str());
@@ -622,7 +629,8 @@ void bluetooth::shim::legacy::Acl::OnConnectSuccess(
  ASSERT(connection != nullptr);
  auto handle = connection->GetHandle();
  bool locally_initiated = connection->locally_initiated_;
  const RawAddress bd_addr = ToRawAddress(connection->GetAddress());
  const hci::Address remote_address = connection->GetAddress();
  const RawAddress bd_addr = ToRawAddress(remote_address);

  pimpl_->handle_to_classic_connection_map_.emplace(
      handle,
@@ -637,8 +645,12 @@ void bluetooth::shim::legacy::Acl::OnConnectSuccess(

  TRY_POSTING_ON_MAIN(acl_interface_.connection.classic.on_connected, bd_addr,
                      handle, HCI_SUCCESS, false);
  LOG_DEBUG("Connection successful classic remote:%s handle:%hu initiator:%s",
            PRIVATE_ADDRESS(remote_address), handle,
            (locally_initiated) ? "local" : "remote");
  btm_cb.history_->Push(
      "%-32s: %s %s classic", "Connection successful", PRIVATE_ADDRESS(bd_addr),
      "%-32s: %s %s classic", "Connection successful",
      PRIVATE_ADDRESS(remote_address),
      (locally_initiated) ? "Local initiated" : "Remote initiated");
}

@@ -647,8 +659,8 @@ void bluetooth::shim::legacy::Acl::OnConnectFail(hci::Address address,
  const RawAddress bd_addr = ToRawAddress(address);
  TRY_POSTING_ON_MAIN(acl_interface_.connection.classic.on_failed, bd_addr,
                      kInvalidHciHandle, HCI_SUCCESS, false);
  LOG_WARN("Classic ACL connection failed peer:%s reason:%s",
           address.ToString().c_str(), hci::ErrorCodeText(reason).c_str());
  LOG_WARN("Connection failed classic remote:%s reason:%s",
           PRIVATE_ADDRESS(address), hci::ErrorCodeText(reason).c_str());
  btm_cb.history_->Push("%-32s: %s classic reason:%s", "Connection failed",
                        PRIVATE_ADDRESS(address),
                        hci::ErrorCodeText(reason).c_str());
@@ -690,6 +702,9 @@ void bluetooth::shim::legacy::Acl::OnLeConnectSuccess(
      handle, static_cast<uint8_t>(connection_role), conn_interval,
      conn_latency, conn_timeout, local_rpa, peer_rpa, peer_addr_type);

  LOG_DEBUG("Connection successful le remote:%s handle:%hu initiator:%s",
            PRIVATE_ADDRESS(address_with_type), handle,
            (locally_initiated) ? "local" : "remote");
  btm_cb.history_->Push(
      "%-32s: %s %s le", "Connection successful",
      PRIVATE_ADDRESS(address_with_type),
@@ -707,7 +722,8 @@ void bluetooth::shim::legacy::Acl::OnLeConnectFail(

  TRY_POSTING_ON_MAIN(acl_interface_.connection.le.on_failed,
                      legacy_address_with_type, handle, enhanced, status);
  LOG_WARN("Le ACL failed peer:%s", address_with_type.ToString().c_str());
  LOG_WARN("Connection failed le remote:%s",
           PRIVATE_ADDRESS(address_with_type));
  btm_cb.history_->Push("%-32s: %s le reason:%s", "Connection failed",
                        PRIVATE_ADDRESS(address_with_type),
                        hci::ErrorCodeText(reason).c_str());
+3 −3
Original line number Diff line number Diff line
@@ -3559,6 +3559,7 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
  }

  p_dev_rec->hci_handle = handle;
  btm_acl_created(bda, handle, HCI_ROLE_PERIPHERAL, BT_TRANSPORT_BR_EDR);

  /* role may not be correct here, it will be updated by l2cap, but we need to
   */
@@ -3572,8 +3573,6 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
  btm_set_packet_types_from_address(bda, BT_TRANSPORT_BR_EDR,
                                    acl_get_supported_packet_types());

  btm_acl_created(bda, handle, HCI_ROLE_PERIPHERAL, BT_TRANSPORT_BR_EDR);

  /* Initialize security flags.  We need to do that because some            */
  /* authorization complete could have come after the connection is dropped */
  /* and that would set wrong flag that link has been authorized already    */
@@ -3594,7 +3593,8 @@ void btm_sec_connected(const RawAddress& bda, uint16_t handle, uint8_t status,
  /* After connection is established we perform security if we do not know */
  /* the name, or if we are originator because some procedure can have */
  /* been scheduled while connection was down */
  BTM_TRACE_DEBUG("is_originator:%d ", p_dev_rec->is_originator);
  LOG_DEBUG("Is connection locally initiated:%s",
            logbool(p_dev_rec->is_originator).c_str());
  if (!(p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) ||
      p_dev_rec->is_originator) {
    res = btm_sec_execute_procedure(p_dev_rec);