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

Commit e46c054a authored by Myles Watson's avatar Myles Watson
Browse files

Use GD for controller pairing support

Bug: 301661850
Bug: 321273521
Test: mma -j32
Flag: EXEMPT, no logical change
Change-Id: Ida970f6d4709c2301a6442d392d656bd1f25afcd
parent fb92adb2
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -36,8 +36,6 @@ typedef struct controller_t {

  const uint8_t* (*get_ble_supported_states)(void);

  bool (*SupportsSimplePairing)(void);
  bool (*SupportsSecureConnections)(void);
  bool (*SupportsSimultaneousLeBrEdr)(void);
  bool (*supports_reading_remote_extended_features)(void);
  bool (*SupportsInterlacedInquiryScan)(void);
+0 −4
Original line number Diff line number Diff line
@@ -117,8 +117,6 @@ static const uint8_t* get_ble_supported_states(void) {
#define MAP_TO_GD(legacy, gd) \
  static bool legacy(void) { return GetController()->gd(); }

MAP_TO_GD(supports_simple_pairing, SupportsSimplePairing)
MAP_TO_GD(supports_secure_connections, SupportsSecureConnections)
MAP_TO_GD(supports_simultaneous_le_bredr, SupportsSimultaneousLeBrEdr)
MAP_TO_GD(supports_interlaced_inquiry_scan, SupportsInterlacedInquiryScan)
MAP_TO_GD(supports_rssi_with_inquiry_results, SupportsRssiWithInquiryResults)
@@ -327,8 +325,6 @@ static const controller_t interface = {

    .get_ble_supported_states = get_ble_supported_states,

    .SupportsSimplePairing = supports_simple_pairing,
    .SupportsSecureConnections = supports_secure_connections,
    .SupportsSimultaneousLeBrEdr = supports_simultaneous_le_bredr,
    .supports_reading_remote_extended_features =
        supports_reading_remote_extended_features,
+2 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include "device/include/controller.h"
#include "device/include/device_iot_config.h"
#include "hci/class_of_device.h"
#include "hci/controller_interface.h"
#include "hci/hci_layer.h"
#include "hci/hci_packets.h"
#include "hci/include/hci_layer.h"
@@ -554,7 +555,7 @@ static tBTM_STATUS btm_send_connect_request(uint16_t acl_handle,
      ** If so, we cannot use SCO-only packet types (HFP 1.7)
      */
      const bool local_supports_sc =
          controller_get_interface()->SupportsSecureConnections();
          bluetooth::shim::GetController()->SupportsSecureConnections();
      const bool remote_supports_sc =
          BTM_PeerSupportsSecureConnections(bd_addr);

+9 −7
Original line number Diff line number Diff line
@@ -40,8 +40,10 @@
#include "device/include/controller.h"
#include "device/include/device_iot_config.h"
#include "device/include/interop.h"
#include "hci/controller_interface.h"
#include "internal_include/bt_target.h"
#include "l2c_api.h"
#include "main/shim/entry.h"
#include "osi/include/allocator.h"
#include "osi/include/properties.h"
#include "stack/btm/btm_ble_int.h"
@@ -668,7 +670,7 @@ tBTM_STATUS btm_sec_bond_by_transport(const RawAddress& bd_addr,
        BTM_SEC_ROLE_SWITCHED | BTM_SEC_LINK_KEY_AUTHED);

  LOG_VERBOSE("after update sec_flags=0x%x", p_dev_rec->sec_rec.sec_flags);
  if (!controller_get_interface()->SupportsSimplePairing()) {
  if (!bluetooth::shim::GetController()->SupportsSimplePairing()) {
    /* The special case when we authenticate keyboard.  Set pin type to fixed */
    /* It would be probably better to do it from the application, but it is */
    /* complicated */
@@ -700,7 +702,7 @@ tBTM_STATUS btm_sec_bond_by_transport(const RawAddress& bd_addr,
  }

  LOG_VERBOSE("sec mode: %d sm4:x%x", btm_sec_cb.security_mode, p_dev_rec->sm4);
  if (!controller_get_interface()->SupportsSimplePairing() ||
  if (!bluetooth::shim::GetController()->SupportsSimplePairing() ||
      (p_dev_rec->sm4 == BTM_SM4_KNOWN)) {
    if (btm_sec_check_prefetch_pin(p_dev_rec)) return (BTM_CMD_STARTED);
  }
@@ -1302,7 +1304,7 @@ void BTM_RemoteOobDataReply(tBTM_STATUS res, const RawAddress& bd_addr,
 *
 ******************************************************************************/
bool BTM_BothEndsSupportSecureConnections(const RawAddress& bd_addr) {
  return ((controller_get_interface()->SupportsSecureConnections()) &&
  return ((bluetooth::shim::GetController()->SupportsSecureConnections()) &&
          (BTM_PeerSupportsSecureConnections(bd_addr)));
}

@@ -1475,7 +1477,7 @@ tBTM_STATUS btm_sec_l2cap_access_req_by_requirement(

  if ((!is_originator) && (security_required & BTM_SEC_MODE4_LEVEL4)) {
    bool local_supports_sc =
        controller_get_interface()->SupportsSecureConnections();
        bluetooth::shim::GetController()->SupportsSecureConnections();
    /* acceptor receives L2CAP Channel Connect Request for Secure Connections
     * Only service */
    if (!local_supports_sc || !p_dev_rec->SupportsSecureConnections()) {
@@ -1821,7 +1823,7 @@ tBTM_STATUS btm_sec_mx_access_request(const RawAddress& bd_addr,
  if ((!is_originator) && ((security_required & BTM_SEC_MODE4_LEVEL4) ||
                           (btm_sec_cb.security_mode == BTM_SEC_MODE_SC))) {
    bool local_supports_sc =
        controller_get_interface()->SupportsSecureConnections();
        bluetooth::shim::GetController()->SupportsSecureConnections();
    /* acceptor receives service connection establishment Request for */
    /* Secure Connections Only service */
    if (!(local_supports_sc) || !(p_dev_rec->SupportsSecureConnections())) {
@@ -2054,7 +2056,7 @@ void btm_sec_check_pending_reqs(void) {
 *
 ******************************************************************************/
void btm_sec_dev_reset(void) {
  ASSERT_LOG(controller_get_interface()->SupportsSimplePairing(),
  ASSERT_LOG(bluetooth::shim::GetController()->SupportsSimplePairing(),
             "only controllers with SSP is supported");

  /* set the default IO capabilities */
@@ -2511,7 +2513,7 @@ void btm_io_capabilities_req(RawAddress p) {
    err_code = HCI_ERR_PAIRING_NOT_ALLOWED;
  } else if (btm_sec_cb.security_mode == BTM_SEC_MODE_SC) {
    bool local_supports_sc =
        controller_get_interface()->SupportsSecureConnections();
        bluetooth::shim::GetController()->SupportsSecureConnections();
    /* device in Secure Connections Only mode */
    if (!(local_supports_sc) || !(p_dev_rec->SupportsSecureConnections())) {
      LOG_DEBUG(
+3 −2
Original line number Diff line number Diff line
@@ -30,7 +30,8 @@
#include <cstring>

#include "crypto_toolbox/crypto_toolbox.h"
#include "device/include/controller.h"
#include "hci/controller_interface.h"
#include "main/shim/entry.h"
#include "os/log.h"
#include "osi/include/osi.h"
#include "p_256_ecc_pp.h"
@@ -985,7 +986,7 @@ bool smp_calculate_link_key_from_long_term_key(tSMP_CB* p_cb) {
  if (p_cb->init_security_mode == BTM_SEC_MODE_SC) {
    /* Secure Connections Only Mode */
    link_key_type = BTM_LKEY_TYPE_AUTH_COMB_P_256;
  } else if (controller_get_interface()->SupportsSecureConnections()) {
  } else if (bluetooth::shim::GetController()->SupportsSecureConnections()) {
    /* both transports are SC capable */
    if (p_cb->sec_level == SMP_SEC_AUTHENTICATED)
      link_key_type = BTM_LKEY_TYPE_AUTH_COMB_P_256;
Loading