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

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

Remove is_gd_security_enabled am: f628def4

parents b9cc5a03 f628def4
Loading
Loading
Loading
Loading
+24 −116
Original line number Diff line number Diff line
@@ -391,11 +391,7 @@ void BTA_dm_on_hw_on() {
  LOG_INFO("%s: Read default class of device {0x%x, 0x%x, 0x%x}", __func__,
      dev_class[0], dev_class[1], dev_class[2]);

  if (bluetooth::shim::is_gd_security_enabled()) {
    bluetooth::shim::BTM_SetDeviceClass(dev_class);
  } else {
  BTM_SetDeviceClass(dev_class);
  }

  /* load BLE local information: ID keys, ER if available */
  Octet16 er;
@@ -411,11 +407,7 @@ void BTA_dm_on_hw_on() {
  }
  bta_dm_search_cb.conn_id = GATT_INVALID_CONN_ID;

  if (bluetooth::shim::is_gd_security_enabled()) {
    bluetooth::shim::BTM_SecRegister(&bta_security);
  } else {
  get_btm_client_interface().security.BTM_SecRegister(&bta_security);
  }

  BTM_WritePageTimeout(osi_property_get_int32(PROPERTY_PAGE_TIMEOUT,
                                              p_bta_dm_cfg->page_timeout));
@@ -602,11 +594,7 @@ static void bta_dm_process_remove_device_no_callback(
  /* need to remove all pending background connection before unpair */
  BTA_GATTC_CancelOpen(0, bd_addr, false);

  if (bluetooth::shim::is_gd_security_enabled()) {
    bluetooth::shim::BTM_SecDeleteDevice(bd_addr);
  } else {
  BTM_SecDeleteDevice(bd_addr);
  }

  /* remove all cached GATT information */
  BTA_GATTC_Refresh(bd_addr);
@@ -729,10 +717,6 @@ void bta_dm_add_device(std::unique_ptr<tBTA_DM_API_ADD_DEVICE> msg) {

  if (msg->link_key_known) p_lc = &msg->link_key;

  if (bluetooth::shim::is_gd_security_enabled()) {
    bluetooth::shim::BTM_SecAddDevice(msg->bd_addr, p_dc, msg->bd_name, nullptr,
                                      p_lc, msg->key_type, msg->pin_length);
  } else {
    auto add_result =
        BTM_SecAddDevice(msg->bd_addr, p_dc, msg->bd_name, nullptr, p_lc,
                         msg->key_type, msg->pin_length);
@@ -741,7 +725,6 @@ void bta_dm_add_device(std::unique_ptr<tBTA_DM_API_ADD_DEVICE> msg) {
                 << ADDRESS_TO_LOGGABLE_STR(msg->bd_addr);
    }
}
}

/** This function forces to close the connection to a remote device and
 * optionaly remove the device from security database if required. */
@@ -788,17 +771,12 @@ void bta_dm_bond(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
  char* p_name;

  tBTM_STATUS status =
      (bluetooth::shim::is_gd_security_enabled())
          ? bluetooth::shim::BTM_SecBond(bd_addr, addr_type, transport,
                                         device_type)
          : BTM_SecBond(bd_addr, addr_type, transport, device_type, 0, NULL);
      BTM_SecBond(bd_addr, addr_type, transport, device_type, 0, NULL);

  if (bta_dm_cb.p_sec_cback && (status != BTM_CMD_STARTED)) {
    memset(&sec_event, 0, sizeof(tBTA_DM_SEC));
    sec_event.auth_cmpl.bd_addr = bd_addr;
    p_name = (bluetooth::shim::is_gd_security_enabled())
                 ? bluetooth::shim::BTM_SecReadDevName(bd_addr)
                 : BTM_SecReadDevName(bd_addr);
    p_name = BTM_SecReadDevName(bd_addr);
    if (p_name != NULL) {
      memcpy(sec_event.auth_cmpl.bd_name, p_name, BD_NAME_LEN);
      sec_event.auth_cmpl.bd_name[BD_NAME_LEN] = 0;
@@ -826,9 +804,7 @@ void bta_dm_bond_cancel(const RawAddress& bd_addr) {

  APPL_TRACE_EVENT(" bta_dm_bond_cancel ");

  status = (bluetooth::shim::is_gd_security_enabled())
               ? bluetooth::shim::BTM_SecBondCancel(bd_addr)
               : BTM_SecBondCancel(bd_addr);
  status = BTM_SecBondCancel(bd_addr);

  if (bta_dm_cb.p_sec_cback &&
      (status != BTM_CMD_STARTED && status != BTM_SUCCESS)) {
@@ -841,43 +817,22 @@ void bta_dm_bond_cancel(const RawAddress& bd_addr) {
/** Send the pin_reply to a request from BTM */
void bta_dm_pin_reply(std::unique_ptr<tBTA_DM_API_PIN_REPLY> msg) {
  if (msg->accept) {
    if (bluetooth::shim::is_gd_security_enabled()) {
      bluetooth::shim::BTM_PINCodeReply(msg->bd_addr, BTM_SUCCESS, msg->pin_len,
                                        msg->p_pin);
    } else {
    BTM_PINCodeReply(msg->bd_addr, BTM_SUCCESS, msg->pin_len, msg->p_pin);
    }
  } else {
    if (bluetooth::shim::is_gd_security_enabled()) {
      bluetooth::shim::BTM_PINCodeReply(msg->bd_addr, BTM_NOT_AUTHORIZED, 0,
                                        NULL);
  } else {
    BTM_PINCodeReply(msg->bd_addr, BTM_NOT_AUTHORIZED, 0, NULL);
  }
}
}

/** Send the user confirm request reply in response to a request from BTM */
void bta_dm_confirm(const RawAddress& bd_addr, bool accept) {
  if (bluetooth::shim::is_gd_security_enabled()) {
    bluetooth::shim::BTM_ConfirmReqReply(
        accept ? BTM_SUCCESS : BTM_NOT_AUTHORIZED, bd_addr);
  } else {
  BTM_ConfirmReqReply(accept ? BTM_SUCCESS : BTM_NOT_AUTHORIZED, bd_addr);
}
}

/** respond to the OOB data request for the remote device from BTM */
void bta_dm_ci_rmt_oob_act(std::unique_ptr<tBTA_DM_CI_RMT_OOB> msg) {
  if (bluetooth::shim::is_gd_security_enabled()) {
    bluetooth::shim::BTM_RemoteOobDataReply(
        msg->accept ? BTM_SUCCESS : BTM_NOT_AUTHORIZED, msg->bd_addr, msg->c,
        msg->r);
  } else {
  BTM_RemoteOobDataReply(msg->accept ? BTM_SUCCESS : BTM_NOT_AUTHORIZED,
                         msg->bd_addr, msg->c, msg->r);
}
}

/*******************************************************************************
 *
@@ -1015,11 +970,7 @@ static bool bta_dm_read_remote_device_name(const RawAddress& bd_addr,
  bta_dm_search_cb.peer_bdaddr = bd_addr;
  bta_dm_search_cb.peer_name[0] = 0;

  btm_status =
      (bluetooth::shim::is_gd_security_enabled())
          ? bluetooth::shim::BTM_ReadRemoteDeviceName(
                bta_dm_search_cb.peer_bdaddr, bta_dm_remname_cback, transport)
          : BTM_ReadRemoteDeviceName(bta_dm_search_cb.peer_bdaddr,
  btm_status = BTM_ReadRemoteDeviceName(bta_dm_search_cb.peer_bdaddr,
                                        bta_dm_remname_cback, transport);

  if (btm_status == BTM_CMD_STARTED) {
@@ -1033,12 +984,7 @@ static bool bta_dm_read_remote_device_name(const RawAddress& bd_addr,
     * "bta_dm_remname_cback" */
    /* adding callback to get notified that current reading remote name done */

    if (bluetooth::shim::is_gd_security_enabled()) {
      bluetooth::shim::BTM_SecAddRmtNameNotifyCallback(
          &bta_dm_service_search_remname_cback);
    } else {
    BTM_SecAddRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
    }

    return (true);
  } else {
@@ -1360,13 +1306,7 @@ void bta_dm_sdp_result(tBTA_DM_MSG* p_data) {
      /* callbacks */
      /* start next bd_addr if necessary */

      if (bluetooth::shim::is_gd_security_enabled()) {
        bluetooth::shim::BTM_SecDeleteRmtNameNotifyCallback(
            &bta_dm_service_search_remname_cback);
      } else {
        BTM_SecDeleteRmtNameNotifyCallback(
            &bta_dm_service_search_remname_cback);
      }
      BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);

      BTM_LogHistory(
          kBtmLogTag, bta_dm_search_cb.peer_bdaddr, "Discovery completed",
@@ -1436,12 +1376,7 @@ void bta_dm_sdp_result(tBTA_DM_MSG* p_data) {
    if (bta_dm_search_cb.p_sdp_db)
      osi_free_and_reset((void**)&bta_dm_search_cb.p_sdp_db);

    if (bluetooth::shim::is_gd_security_enabled()) {
      bluetooth::shim::BTM_SecDeleteRmtNameNotifyCallback(
          &bta_dm_service_search_remname_cback);
    } else {
    BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
    }

    p_msg = (tBTA_DM_MSG*)osi_calloc(sizeof(tBTA_DM_MSG));
    p_msg->hdr.event = BTA_DM_DISCOVERY_RESULT_EVT;
@@ -2213,24 +2148,13 @@ static void bta_dm_remname_cback(const tBTM_REMOTE_DEV_NAME* p) {
      p_remote_name->remote_bd_name[0], p_remote_name->length);

  if (bta_dm_search_cb.peer_bdaddr == p_remote_name->bd_addr) {
    if (bluetooth::shim::is_gd_security_enabled()) {
      bluetooth::shim::BTM_SecDeleteRmtNameNotifyCallback(
          &bta_dm_service_search_remname_cback);
    } else {
    BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
    }
  } else {
    // if we got a different response, maybe ignore it
    // we will have made a request directly from BTM_ReadRemoteDeviceName so we
    // expect a dedicated response for us
    if (p_remote_name->hci_status == HCI_ERR_CONNECTION_EXISTS) {
      if (bluetooth::shim::is_gd_security_enabled()) {
        bluetooth::shim::BTM_SecDeleteRmtNameNotifyCallback(
            &bta_dm_service_search_remname_cback);
      } else {
        BTM_SecDeleteRmtNameNotifyCallback(
            &bta_dm_service_search_remname_cback);
      }
      BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
      LOG_INFO(
          "Assume command failed due to disconnection hci_status:%s peer:%s",
          hci_error_code_text(p_remote_name->hci_status).c_str(),
@@ -2791,10 +2715,7 @@ static void bta_dm_acl_down(const RawAddress& bd_addr,
      continue;

    if (device->conn_state == BTA_DM_UNPAIRING) {
      issue_unpair_cb =
          (bluetooth::shim::is_gd_security_enabled())
              ? bluetooth::shim::BTM_SecDeleteDevice(device->peer_bdaddr)
              : BTM_SecDeleteDevice(device->peer_bdaddr);
      issue_unpair_cb = BTM_SecDeleteDevice(device->peer_bdaddr);

      /* remove all cached GATT information */
      BTA_GATTC_Refresh(bd_addr);
@@ -3038,11 +2959,7 @@ static void bta_dm_remove_sec_dev_entry(const RawAddress& remote_bd_addr) {
    APPL_TRACE_DEBUG(
        "%s ACL is not down. Schedule for  Dev Removal when ACL closes",
        __func__);
    if (bluetooth::shim::is_gd_security_enabled()) {
      bluetooth::shim::BTM_SecClearSecurityFlags(remote_bd_addr);
    } else {
    BTM_SecClearSecurityFlags(remote_bd_addr);
    }
    for (int i = 0; i < bta_dm_cb.device_list.count; i++) {
      if (bta_dm_cb.device_list.peer_device[i].peer_bdaddr == remote_bd_addr) {
        bta_dm_cb.device_list.peer_device[i].remove_dev_pending = TRUE;
@@ -3118,10 +3035,7 @@ static char* bta_dm_get_remname(void) {

  /* If the name isn't already stored, try retrieving from BTM */
  if (*p_name == '\0') {
    p_temp =
        (bluetooth::shim::is_gd_security_enabled())
            ? bluetooth::shim::BTM_SecReadDevName(bta_dm_search_cb.peer_bdaddr)
            : BTM_SecReadDevName(bta_dm_search_cb.peer_bdaddr);
    p_temp = BTM_SecReadDevName(bta_dm_search_cb.peer_bdaddr);
    if (p_temp != NULL) p_name = p_temp;
  }

@@ -3866,9 +3780,7 @@ static uint8_t bta_dm_ble_smp_cback(tBTM_LE_EVT event, const RawAddress& bda,

    case BTM_LE_SEC_REQUEST_EVT:
      sec_event.ble_req.bd_addr = bda;
      p_name = (bluetooth::shim::is_gd_security_enabled())
                   ? bluetooth::shim::BTM_SecReadDevName(bda)
                   : BTM_SecReadDevName(bda);
      p_name = BTM_SecReadDevName(bda);
      if (p_name != NULL)
        strlcpy((char*)sec_event.ble_req.bd_name, p_name, BD_NAME_LEN + 1);
      else
@@ -3878,9 +3790,7 @@ static uint8_t bta_dm_ble_smp_cback(tBTM_LE_EVT event, const RawAddress& bda,

    case BTM_LE_KEY_NOTIF_EVT:
      sec_event.key_notif.bd_addr = bda;
      p_name = (bluetooth::shim::is_gd_security_enabled())
                   ? bluetooth::shim::BTM_SecReadDevName(bda)
                   : BTM_SecReadDevName(bda);
      p_name = BTM_SecReadDevName(bda);
      if (p_name != NULL)
        strlcpy((char*)sec_event.key_notif.bd_name, p_name, BD_NAME_LEN + 1);
      else
@@ -3931,9 +3841,7 @@ static uint8_t bta_dm_ble_smp_cback(tBTM_LE_EVT event, const RawAddress& bda,
      sec_event.auth_cmpl.bd_addr = bda;
      BTM_ReadDevInfo(bda, &sec_event.auth_cmpl.dev_type,
                      &sec_event.auth_cmpl.addr_type);
      p_name = (bluetooth::shim::is_gd_security_enabled())
                   ? bluetooth::shim::BTM_SecReadDevName(bda)
                   : BTM_SecReadDevName(bda);
      p_name = BTM_SecReadDevName(bda);
      if (p_name != NULL)
        strlcpy((char*)sec_event.auth_cmpl.bd_name, p_name, (BD_NAME_LEN + 1));
      else
+40 −50
Original line number Diff line number Diff line
@@ -659,12 +659,10 @@ static void btif_update_remote_properties(const RawAddress& bdaddr,
  if (strlen((const char*)bd_name)) {
    BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties], BT_PROPERTY_BDNAME,
                               strlen((char*)bd_name), bd_name);
    if (!bluetooth::shim::is_gd_security_enabled()) {
    status = btif_storage_set_remote_device_property(
        &bdaddr, &properties[num_properties]);
    ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote device name",
            status);
    }
    num_properties++;
  }

@@ -689,12 +687,10 @@ static void btif_update_remote_properties(const RawAddress& bdaddr,
  BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties],
                             BT_PROPERTY_CLASS_OF_DEVICE, sizeof(cod), &cod);

  if (!bluetooth::shim::is_gd_security_enabled()) {
    status = btif_storage_set_remote_device_property(
        &bdaddr, &properties[num_properties]);
  status = btif_storage_set_remote_device_property(&bdaddr,
                                                   &properties[num_properties]);
  ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote device class",
          status);
  }
  num_properties++;

  /* device type */
@@ -712,12 +708,10 @@ static void btif_update_remote_properties(const RawAddress& bdaddr,
  BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties],
                             BT_PROPERTY_TYPE_OF_DEVICE, sizeof(dev_type),
                             &dev_type);
  if (!bluetooth::shim::is_gd_security_enabled()) {
    status = btif_storage_set_remote_device_property(
        &bdaddr, &properties[num_properties]);
  status = btif_storage_set_remote_device_property(&bdaddr,
                                                   &properties[num_properties]);
  ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote device type",
          status);
  }
  num_properties++;

  GetInterfaceToProfiles()->events->invoke_remote_device_properties_cb(
@@ -1106,7 +1100,6 @@ static void btif_dm_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {

  RawAddress bd_addr = p_auth_cmpl->bd_addr;
  tBLE_ADDR_TYPE addr_type = p_auth_cmpl->addr_type;
  if (!bluetooth::shim::is_gd_security_enabled()) {
  if ((p_auth_cmpl->success) && (p_auth_cmpl->key_present)) {
    if ((p_auth_cmpl->key_type < HCI_LKEY_TYPE_DEBUG_COMB) ||
        (p_auth_cmpl->key_type == HCI_LKEY_TYPE_AUTH_COMB) ||
@@ -1138,7 +1131,6 @@ static void btif_dm_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
      }
    }
  }
  }

  if (p_auth_cmpl->success) {
    // save remote info to iot conf file
@@ -1159,9 +1151,7 @@ static void btif_dm_auth_cmpl_evt(tBTA_DM_AUTH_CMPL* p_auth_cmpl) {
      return;
    }

    if (!bluetooth::shim::is_gd_security_enabled()) {
    btif_storage_set_remote_addr_type(&bd_addr, p_auth_cmpl->addr_type);
    }

    int dev_type;
    if (BTM_GetPeerDeviceTypeFromFeatures(bd_addr) == BT_DEVICE_TYPE_DUMO) {
+6 −7
Original line number Diff line number Diff line
@@ -120,13 +120,12 @@ struct Controller::impl {
    }

    // SSP is managed by security layer once enabled
    if (!common::init_flags::gd_security_is_enabled()) {
    write_simple_pairing_mode(Enable::ENABLED);
    if (module_.SupportsSecureConnections()) {
      hci_->EnqueueCommand(
          WriteSecureConnectionsHostSupportBuilder::Create(Enable::ENABLED),
            handler->BindOnceOn(this, &Controller::impl::write_secure_connections_host_support_complete_handler));
      }
          handler->BindOnceOn(
              this, &Controller::impl::write_secure_connections_host_support_complete_handler));
    }
    if (is_supported(OpCode::LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH) && module_.SupportsBleDataPacketLengthExtension()) {
      hci_->EnqueueCommand(
+1 −3
Original line number Diff line number Diff line
@@ -379,7 +379,6 @@ init_flags!(
        gd_link_policy,
        gd_remote_name_request,
        gd_rust,
        gd_security,
        hci_adapter: i32,
        hfp_dynamic_version = true,
        irk_rotation,
@@ -419,8 +418,7 @@ init_flags!(
    }
    dependencies: {
        always_use_private_gatt_for_debugging => private_gatt,
        private_gatt => rust_event_loop,
        gd_core => gd_security
        private_gatt => rust_event_loop
    }
);

+0 −1
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ mod ffi {
        fn gd_link_policy_is_enabled() -> bool;
        fn gd_remote_name_request_is_enabled() -> bool;
        fn gd_rust_is_enabled() -> bool;
        fn gd_security_is_enabled() -> bool;
        fn get_default_log_level() -> i32;
        fn get_hci_adapter() -> i32;
        fn get_log_level_for_tag(tag: &str) -> i32;
Loading