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

Commit 0e0b1789 authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

legacy: Remove unused hci event handlers and support am: cc09855f am: 7ec8c69a am: f2820ac8

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2000497

Change-Id: If1a6b2f16eb6defb82050e71513b21b8a8a945bc
parents fc5d5f7f f2820ac8
Loading
Loading
Loading
Loading
+0 −64
Original line number Diff line number Diff line
@@ -99,70 +99,6 @@ bool maybe_resolve_address(RawAddress* bda, tBLE_ADDR_TYPE* bda_type) {
  return is_in_security_db;
}

/** LE connection complete. */
void btm_ble_conn_complete(uint8_t* p, UNUSED_ATTR uint16_t evt_len,
                           bool enhanced) {
  RawAddress local_rpa, peer_rpa;
  uint8_t raw_role, status;
  tBLE_ADDR_TYPE bda_type;
  uint16_t handle;
  RawAddress bda;
  uint16_t conn_interval, conn_latency, conn_timeout;

  STREAM_TO_UINT8(status, p);
  STREAM_TO_UINT16(handle, p);
  STREAM_TO_UINT8(raw_role, p);
  STREAM_TO_UINT8(bda_type, p);
  STREAM_TO_BDADDR(bda, p);
  if (enhanced) {
    STREAM_TO_BDADDR(local_rpa, p);
    STREAM_TO_BDADDR(peer_rpa, p);
  }
  STREAM_TO_UINT16(conn_interval, p);
  STREAM_TO_UINT16(conn_latency, p);
  STREAM_TO_UINT16(conn_timeout, p);
  handle = HCID_GET_HANDLE(handle);

  uint32_t hci_ble_event =
      enhanced ? android::bluetooth::hci::BLE_EVT_ENHANCED_CONN_COMPLETE_EVT
               : android::bluetooth::hci::BLE_EVT_CONN_COMPLETE_EVT;

  if (status == HCI_SUCCESS) {
    tBLE_ADDR_TYPE peer_addr_type = bda_type;
    bool is_in_security_db = maybe_resolve_address(&bda, &bda_type);

    // Log for the HCI success case after maybe resolving Bluetooth address
    log_link_layer_connection_event(
        &bda, handle, android::bluetooth::DIRECTION_UNKNOWN,
        android::bluetooth::LINK_TYPE_ACL, android::bluetooth::hci::CMD_UNKNOWN,
        android::bluetooth::hci::EVT_BLE_META, hci_ble_event, status,
        android::bluetooth::hci::STATUS_UNKNOWN);

    tBLE_BD_ADDR address_with_type{.bda = bda, .type = bda_type};
    tHCI_ROLE role = to_hci_role(raw_role);
    if (enhanced) {
      acl_ble_enhanced_connection_complete(
          address_with_type, handle, role, is_in_security_db, conn_interval,
          conn_latency, conn_timeout, local_rpa, peer_rpa, peer_addr_type);

    } else {
      acl_ble_connection_complete(address_with_type, handle, role,
                                  is_in_security_db, conn_interval,
                                  conn_latency, conn_timeout);
    }
  } else {
    log_link_layer_connection_event(
        &bda, handle, android::bluetooth::DIRECTION_UNKNOWN,
        android::bluetooth::LINK_TYPE_ACL, android::bluetooth::hci::CMD_UNKNOWN,
        android::bluetooth::hci::EVT_BLE_META, hci_ble_event, status,
        android::bluetooth::hci::STATUS_UNKNOWN);

    tBLE_BD_ADDR address_with_type{.bda = bda, .type = bda_type};
    acl_ble_connection_fail(address_with_type, handle, enhanced,
                            static_cast<tHCI_STATUS>(status));
  }
}

void btm_ble_create_conn_cancel() {
  ASSERT_LOG(false,
             "When gd_acl enabled this code path should not be exercised");
+27 −113
Original line number Diff line number Diff line
@@ -60,8 +60,6 @@
using base::Location;
using bluetooth::hci::IsoManager;

bool l2c_link_hci_disc_comp(uint16_t handle,
                            tHCI_REASON reason);               // TODO remove
bool BTM_BLE_IS_RESOLVE_BDA(const RawAddress& x);              // TODO remove
void BTA_sys_signal_hw_error();                                // TODO remove
void smp_cancel_start_encryption_attempt();                    // TODO remove
@@ -73,7 +71,6 @@ void acl_disconnect_from_handle(uint16_t handle, tHCI_STATUS reason,
/******************************************************************************/
static void btu_hcif_inquiry_comp_evt(uint8_t* p);

static void btu_hcif_connection_comp_evt(const uint8_t* p, uint8_t evt_len);
static void btu_hcif_connection_request_evt(const uint8_t* p);
static void btu_hcif_disconnection_comp_evt(uint8_t* p);
static void btu_hcif_authentication_comp_evt(uint8_t* p);
@@ -152,56 +149,6 @@ void btu_hcif_log_event_metrics(uint8_t evt_code, const uint8_t* p_event) {
                                encryption_enabled);
      break;
    }
    case HCI_CONNECTION_COMP_EVT: {
      uint8_t link_type;
      STREAM_TO_UINT8(status, p_event);
      STREAM_TO_UINT16(handle, p_event);
      STREAM_TO_BDADDR(bda, p_event);
      STREAM_TO_UINT8(link_type, p_event);
      handle = HCID_GET_HANDLE(handle);
      log_link_layer_connection_event(
          &bda, handle, android::bluetooth::DIRECTION_UNKNOWN, link_type, cmd,
          evt_code, android::bluetooth::hci::BLE_EVT_UNKNOWN, status, reason);

      // Read SDP_DI manufacturer, model, HW version from config,
      // and log them
      int sdp_di_manufacturer_id = 0;
      int sdp_di_model_id = 0;
      int sdp_di_hw_version = 0;
      int sdp_di_vendor_id_source = 0;
      std::string bda_string = bda.ToString();
      btif_config_get_int(bda_string, BT_CONFIG_KEY_SDP_DI_MANUFACTURER,
                          &sdp_di_manufacturer_id);
      btif_config_get_int(bda_string, BT_CONFIG_KEY_SDP_DI_MODEL,
                          &sdp_di_model_id);
      btif_config_get_int(bda_string, BT_CONFIG_KEY_SDP_DI_HW_VERSION,
                          &sdp_di_hw_version);
      btif_config_get_int(bda_string, BT_CONFIG_KEY_SDP_DI_VENDOR_ID_SRC,
                          &sdp_di_vendor_id_source);

      std::stringstream ss;
      // [N - native]::SDP::[DIP - Device ID Profile]
      ss << "N:SDP::DIP::" << loghex(sdp_di_vendor_id_source);
      log_manufacturer_info(
          bda, android::bluetooth::DeviceInfoSrcEnum::DEVICE_INFO_INTERNAL,
          ss.str(), loghex(sdp_di_manufacturer_id), loghex(sdp_di_model_id),
          loghex(sdp_di_hw_version), "");

      // Read LMP version, subversion and  manufacturer from config,
      // and log them
      int lmp_version = -1;
      int lmp_subversion = -1;
      int lmp_manufacturer_id = -1;
      btif_config_get_int(bda_string, BT_CONFIG_KEY_REMOTE_VER_VER,
                          &lmp_version);
      btif_config_get_int(bda_string, BT_CONFIG_KEY_REMOTE_VER_SUBVER,
                          &lmp_subversion);
      btif_config_get_int(bda_string, BT_CONFIG_KEY_REMOTE_VER_MFCT,
                          &lmp_manufacturer_id);
      bluetooth::common::LogRemoteVersionInfo(
          handle, status, lmp_version, lmp_manufacturer_id, lmp_subversion);
      break;
    }
    case HCI_CONNECTION_REQUEST_EVT: {
      DEV_CLASS dc;
      uint8_t link_type;
@@ -247,6 +194,13 @@ void btu_hcif_log_event_metrics(uint8_t evt_code, const uint8_t* p_event) {
          android::bluetooth::hci::BLE_EVT_UNKNOWN, status, reason);
      break;
    }
    case HCI_CONNECTION_COMP_EVT:  // EventCode::CONNECTION_COMPLETE
    default:
      LOG_ERROR(
          "Unexpectedly received event_code:0x%02x that should not be "
          "handled here",
          evt_code);
      break;
  }
}

@@ -290,9 +244,6 @@ void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id,
    case HCI_EXTENDED_INQUIRY_RESULT_EVT:
      btm_process_inq_results(p, hci_evt_len, BTM_INQ_RESULT_EXTENDED);
      break;
    case HCI_CONNECTION_COMP_EVT:
      btu_hcif_connection_comp_evt(p, hci_evt_len);
      break;
    case HCI_CONNECTION_REQUEST_EVT:
      btu_hcif_connection_request_evt(p);
      break;
@@ -398,9 +349,6 @@ void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id,
        case HCI_BLE_ADV_PKT_RPT_EVT: /* result of inquiry */
          btm_ble_process_adv_pkt(ble_evt_len, p);
          break;
        case HCI_BLE_CONN_COMPLETE_EVT:
          btm_ble_conn_complete(p, hci_evt_len, false);
          break;
        case HCI_BLE_LL_CONN_PARAM_UPD_EVT:
          btu_ble_ll_conn_param_upd_evt(p, hci_evt_len);
          break;
@@ -410,9 +358,6 @@ void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id,
        case HCI_BLE_LTK_REQ_EVT: /* received only at peripheral device */
          btu_ble_proc_ltk_req(p);
          break;
        case HCI_BLE_ENHANCED_CONN_COMPLETE_EVT:
          btm_ble_conn_complete(p, hci_evt_len, true);
          break;
        case HCI_BLE_RC_PARAM_REQ_EVT:
          btu_ble_rc_param_req_evt(p);
          break;
@@ -467,13 +412,31 @@ void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id,
        case HCI_LE_BIGINFO_ADVERTISING_REPORT_EVT:
          btm_ble_biginfo_adv_report_rcvd(p, hci_evt_len);
          break;
      }

          // Events are now captured by gd/hci/le_acl_connection_interface.h
        case HCI_BLE_CONN_COMPLETE_EVT:  // SubeventCode::CONNECTION_COMPLETE
        case HCI_BLE_ENHANCED_CONN_COMPLETE_EVT:  // SubeventCode::ENHANCED_CONNECTION_COMPLETE
        default:
          LOG_ERROR(
              "Unexpectedly received LE sub_event_code:0x%02x that should not "
              "be handled here",
              ble_sub_code);
          break;
      }
    } break;

    case HCI_VENDOR_SPECIFIC_EVT:
      btm_vendor_specific_evt(const_cast<const uint8_t*>(p), hci_evt_len);
      break;

      // Events now captured by gd::hci_layer module
    case HCI_CONNECTION_COMP_EVT:  // EventCode::CONNECTION_COMPLETE
    default:
      LOG_ERROR(
          "Unexpectedly received event_code:0x%02x that should not be "
          "handled here",
          hci_evt_code);
      break;
  }
}

@@ -955,55 +918,6 @@ static void btu_hcif_inquiry_comp_evt(uint8_t* p) {
  btm_process_inq_complete(to_hci_status_code(status), BTM_BR_INQUIRY_MASK);
}

/*******************************************************************************
 *
 * Function         btu_hcif_connection_comp_evt
 *
 * Description      Process event HCI_CONNECTION_COMP_EVT
 *
 * Returns          void
 *
 ******************************************************************************/
static void btu_hcif_connection_comp_evt(const uint8_t* p, uint8_t evt_len) {
  uint8_t status;
  uint16_t handle;
  RawAddress bda;
  uint8_t link_type;
  uint8_t enc_mode;
  tBTM_ESCO_DATA esco_data;

  if (evt_len < 11) {
    android_errorWriteLog(0x534e4554, "141619686");
    HCI_TRACE_WARNING("%s: malformed event of size %hhd", __func__, evt_len);
    return;
  }

  STREAM_TO_UINT8(status, p);
  STREAM_TO_UINT16(handle, p);
  STREAM_TO_BDADDR(bda, p);
  STREAM_TO_UINT8(link_type, p);
  STREAM_TO_UINT8(enc_mode, p);

  handle = HCID_GET_HANDLE(handle);

  if (status != HCI_SUCCESS) {
    HCI_TRACE_DEBUG(
        "%s: Connection failed: status=%d, handle=%d, link_type=%d, "
        "enc_mode=%d",
        __func__, status, handle, link_type, enc_mode);
  }

  if (link_type == HCI_LINK_TYPE_ACL) {
    btm_acl_connected(bda, handle, static_cast<tHCI_STATUS>(status), enc_mode);
  } else {
    memset(&esco_data, 0, sizeof(tBTM_ESCO_DATA));
    /* esco_data.link_type = HCI_LINK_TYPE_SCO; already zero */
    esco_data.bd_addr = bda;
    btm_sco_connected(static_cast<tHCI_STATUS>(status), bda, handle,
                      &esco_data);
  }
}

/*******************************************************************************
 *
 * Function         btu_hcif_connection_request_evt
+0 −2
Original line number Diff line number Diff line
@@ -23,8 +23,6 @@
#include "types/raw_address.h"

// This header contains functions for HCI-ble to invoke
void btm_ble_conn_complete(uint8_t* p, UNUSED_ATTR uint16_t evt_len,
                           bool enhanced);
void btm_ble_process_adv_pkt(uint8_t len, const uint8_t* p);
void btm_ble_process_ext_adv_pkt(uint8_t len, const uint8_t* p);
void btm_ble_process_phy_update_pkt(uint8_t len, uint8_t* p);