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

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

Remove unused main::shim::btm_api am: c2a5ed60 am: 599631e6

parents 81a7bd8e 599631e6
Loading
Loading
Loading
Loading
+0 −552
Original line number Diff line number Diff line
@@ -516,357 +516,6 @@ class ShimBondListener : public bluetooth::security::ISecurityManagerListener {
  const tBTM_APPL_INFO* bta_callbacks_;
};

tBTM_STATUS bluetooth::shim::BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb,
                                              tBTM_CMPL_CB* p_cmpl_cb) {
  CHECK(p_results_cb != nullptr);
  CHECK(p_cmpl_cb != nullptr);

  tBTM_INQ_PARMS inqparms = {};
  inqparms.mode = BTM_GENERAL_INQUIRY | BTM_BLE_GENERAL_INQUIRY;
  inqparms.duration = BTIF_DM_DEFAULT_INQ_MAX_DURATION;

  std::lock_guard<std::mutex> lock(btm_cb_mutex_);

  btm_cb.btm_inq_vars.inq_cmpl_info.num_resp = 0;

  Stack::GetInstance()->GetBtm()->StartActiveScanning();
  if (inqparms.duration != 0) {
    Stack::GetInstance()->GetBtm()->SetScanningTimer(
        inqparms.duration * 1000, common::BindOnce([]() {
          LOG_INFO("%s scanning timeout popped", __func__);
          std::lock_guard<std::mutex> lock(btm_cb_mutex_);
          Stack::GetInstance()->GetBtm()->StopActiveScanning();
        }));
  }

  Stack::GetInstance()->GetBtm()->StartActiveScanning();

  uint8_t classic_mode = inqparms.mode & 0x0f;
  if (!Stack::GetInstance()->GetBtm()->StartInquiry(
          classic_mode, inqparms.duration, 0,
          [](tBTM_STATUS status, uint8_t inquiry_mode) {
            LOG_INFO("%s Inquiry is complete status:%hd inquiry_mode:%hhd",
                     __func__, status, inquiry_mode);
            btm_cb.btm_inq_vars.inqparms.mode &= ~(inquiry_mode);

            btm_acl_update_inquiry_status(BTM_INQUIRY_COMPLETE);
            if (btm_cb.btm_inq_vars.inq_active) {
              btm_cb.btm_inq_vars.inq_cmpl_info.status = status;
              btm_clear_all_pending_le_entry();
              btm_cb.btm_inq_vars.state = BTM_INQ_INACTIVE_STATE;

              /* Increment so the start of a next inquiry has a new count */
              btm_cb.btm_inq_vars.inq_counter++;

              btm_clr_inq_result_flt();

              if ((status == BTM_SUCCESS) &&
                  controller_get_interface()
                      ->supports_rssi_with_inquiry_results()) {
                btm_sort_inq_result();
              }

              btm_cb.btm_inq_vars.inq_active = BTM_INQUIRY_INACTIVE;
              btm_cb.btm_inq_vars.p_inq_results_cb = nullptr;
              btm_cb.btm_inq_vars.p_inq_cmpl_cb = nullptr;

              if (btm_cb.btm_inq_vars.p_inq_cmpl_cb != nullptr) {
                LOG_INFO("%s Sending inquiry completion to upper layer",
                         __func__);
                (btm_cb.btm_inq_vars.p_inq_cmpl_cb)(
                    (tBTM_INQUIRY_CMPL*)&btm_cb.btm_inq_vars.inq_cmpl_info);
                btm_cb.btm_inq_vars.p_inq_cmpl_cb = nullptr;
              }
            }
          })) {
    LOG_WARN("%s Unable to start inquiry", __func__);
    return BTM_ERR_PROCESSING;
  }

  btm_cb.btm_inq_vars.state = BTM_INQ_ACTIVE_STATE;
  btm_cb.btm_inq_vars.p_inq_cmpl_cb = p_cmpl_cb;
  btm_cb.btm_inq_vars.p_inq_results_cb = p_results_cb;
  btm_cb.btm_inq_vars.inq_active = inqparms.mode;

  btm_acl_update_inquiry_status(BTM_INQUIRY_STARTED);

  return BTM_CMD_STARTED;
}

tBTM_STATUS bluetooth::shim::BTM_SetDiscoverability(uint16_t discoverable_mode,
                                                    uint16_t window,
                                                    uint16_t interval) {
  uint16_t classic_discoverable_mode = discoverable_mode & 0xff;
  uint16_t le_discoverable_mode = discoverable_mode >> 8;

  if (window == 0) window = BTM_DEFAULT_DISC_WINDOW;
  if (interval == 0) interval = BTM_DEFAULT_DISC_INTERVAL;

  switch (le_discoverable_mode) {
    case kDiscoverableModeOff:
      Stack::GetInstance()->GetBtm()->StopAdvertising();
      break;
    case kLimitedDiscoverableMode:
    case kGeneralDiscoverableMode:
      Stack::GetInstance()->GetBtm()->StartAdvertising();
      break;
    default:
      LOG_WARN("%s Unexpected le discoverability mode:%d", __func__,
               le_discoverable_mode);
  }

  switch (classic_discoverable_mode) {
    case kDiscoverableModeOff:
      Stack::GetInstance()->GetBtm()->SetClassicDiscoverabilityOff();
      break;
    case kLimitedDiscoverableMode:
      Stack::GetInstance()->GetBtm()->SetClassicLimitedDiscoverability(
          window, interval);
      break;
    case kGeneralDiscoverableMode:
      Stack::GetInstance()->GetBtm()->SetClassicGeneralDiscoverability(
          window, interval);
      break;
    default:
      LOG_WARN("%s Unexpected classic discoverability mode:%d", __func__,
               classic_discoverable_mode);
  }
  return BTM_SUCCESS;
}

void bluetooth::shim::BTM_EnableInterlacedInquiryScan() {
  Stack::GetInstance()->GetBtm()->SetInterlacedInquiryScan();
}

tBTM_STATUS bluetooth::shim::BTM_BleObserve(bool start, uint8_t duration_sec,
                                            tBTM_INQ_RESULTS_CB* p_results_cb,
                                            tBTM_CMPL_CB* p_cmpl_cb) {
  if (start) {
    CHECK(p_results_cb != nullptr);
    CHECK(p_cmpl_cb != nullptr);

    std::lock_guard<std::mutex> lock(btm_cb_mutex_);

    if (btm_cb.ble_ctr_cb.is_ble_observe_active()) {
      if (duration_sec == 0) {
        Stack::GetInstance()->GetBtm()->CancelObservingTimer();
        return BTM_CMD_STARTED;
      }
      LOG_WARN("%s Observing already active", __func__);
      return BTM_WRONG_MODE;
    }

    btm_cb.ble_ctr_cb.p_obs_results_cb = p_results_cb;
    btm_cb.ble_ctr_cb.p_obs_cmpl_cb = p_cmpl_cb;
    Stack::GetInstance()->GetBtm()->StartObserving();
    btm_cb.ble_ctr_cb.set_ble_observe_active();

    if (duration_sec != 0) {
      Stack::GetInstance()->GetBtm()->SetObservingTimer(
          duration_sec * 1000, common::BindOnce([]() {
            LOG_INFO("%s observing timeout popped", __func__);

            Stack::GetInstance()->GetBtm()->CancelObservingTimer();
            Stack::GetInstance()->GetBtm()->StopObserving();

            std::lock_guard<std::mutex> lock(btm_cb_mutex_);
            btm_cb.ble_ctr_cb.reset_ble_observe();

            if (btm_cb.ble_ctr_cb.p_obs_cmpl_cb) {
              (btm_cb.ble_ctr_cb.p_obs_cmpl_cb)(
                  &btm_cb.btm_inq_vars.inq_cmpl_info);
            }
            btm_cb.ble_ctr_cb.p_obs_results_cb = nullptr;
            btm_cb.ble_ctr_cb.p_obs_cmpl_cb = nullptr;

            btm_cb.btm_inq_vars.inqparms.mode &= ~(BTM_BLE_INQUIRY_MASK);

            btm_acl_update_inquiry_status(BTM_INQUIRY_COMPLETE);

            btm_clear_all_pending_le_entry();
            btm_cb.btm_inq_vars.state = BTM_INQ_INACTIVE_STATE;

            btm_cb.btm_inq_vars.inq_counter++;
            btm_clr_inq_result_flt();
            btm_sort_inq_result();

            btm_cb.btm_inq_vars.inq_active = BTM_INQUIRY_INACTIVE;
            btm_cb.btm_inq_vars.p_inq_results_cb = NULL;
            btm_cb.btm_inq_vars.p_inq_cmpl_cb = NULL;

            if (btm_cb.btm_inq_vars.p_inq_cmpl_cb) {
              (btm_cb.btm_inq_vars.p_inq_cmpl_cb)(
                  (tBTM_INQUIRY_CMPL*)&btm_cb.btm_inq_vars.inq_cmpl_info);
              btm_cb.btm_inq_vars.p_inq_cmpl_cb = nullptr;
            }
          }));
    }
  } else {
    std::lock_guard<std::mutex> lock(btm_cb_mutex_);

    if (!btm_cb.ble_ctr_cb.is_ble_observe_active()) {
      LOG_WARN("%s Observing already inactive", __func__);
    }
    Stack::GetInstance()->GetBtm()->CancelObservingTimer();
    Stack::GetInstance()->GetBtm()->StopObserving();
    btm_cb.ble_ctr_cb.reset_ble_observe();
    Stack::GetInstance()->GetBtm()->StopObserving();
    if (btm_cb.ble_ctr_cb.p_obs_cmpl_cb) {
      (btm_cb.ble_ctr_cb.p_obs_cmpl_cb)(&btm_cb.btm_inq_vars.inq_cmpl_info);
    }
    btm_cb.ble_ctr_cb.p_obs_results_cb = nullptr;
    btm_cb.ble_ctr_cb.p_obs_cmpl_cb = nullptr;
  }
  return BTM_CMD_STARTED;
}

void bluetooth::shim::BTM_BleOpportunisticObserve(
    bool enable, tBTM_INQ_RESULTS_CB* p_results_cb) {
  if (enable) {
    btm_cb.ble_ctr_cb.p_opportunistic_obs_results_cb = p_results_cb;
  } else {
    btm_cb.ble_ctr_cb.p_opportunistic_obs_results_cb = nullptr;
  }
}

void bluetooth::shim::BTM_BleTargetAnnouncementObserve(
    bool enable, tBTM_INQ_RESULTS_CB* p_results_cb) {
  if (enable) {
    btm_cb.ble_ctr_cb.p_target_announcement_obs_results_cb = p_results_cb;
  } else {
    btm_cb.ble_ctr_cb.p_target_announcement_obs_results_cb = nullptr;
  }
}

void bluetooth::shim::BTM_EnableInterlacedPageScan() {
  Stack::GetInstance()->GetBtm()->SetInterlacedPageScan();
}

tBTM_STATUS bluetooth::shim::BTM_SetInquiryMode(uint8_t inquiry_mode) {
  switch (inquiry_mode) {
    case kStandardInquiryResult:
      Stack::GetInstance()->GetBtm()->SetStandardInquiryResultMode();
      break;
    case kInquiryResultWithRssi:
      Stack::GetInstance()->GetBtm()->SetInquiryWithRssiResultMode();
      break;
    case kExtendedInquiryResult:
      Stack::GetInstance()->GetBtm()->SetExtendedInquiryResultMode();
      break;
    default:
      return BTM_ILLEGAL_VALUE;
  }
  return BTM_SUCCESS;
}

tBTM_STATUS bluetooth::shim::BTM_SetConnectability(uint16_t page_mode,
                                                   uint16_t window,
                                                   uint16_t interval) {
  uint16_t classic_connectible_mode = page_mode & 0xff;
  uint16_t le_connectible_mode = page_mode >> 8;

  if (!window) window = BTM_DEFAULT_CONN_WINDOW;
  if (!interval) {
    interval = (uint16_t)osi_property_get_int32(BTM_PAGE_SCAN_INTERVAL_PROPERTY,
                                                BTM_DEFAULT_CONN_INTERVAL);
  }
  LOG_INFO("shim::BTM_SetConnectability page scan interval = (%d * 0.625)ms",
           interval);

  switch (le_connectible_mode) {
    case kConnectibleModeOff:
      Stack::GetInstance()->GetBtm()->StopConnectability();
      break;
    case kConnectibleModeOn:
      Stack::GetInstance()->GetBtm()->StartConnectability();
      break;
    default:
      return BTM_ILLEGAL_VALUE;
      break;
  }

  switch (classic_connectible_mode) {
    case kConnectibleModeOff:
      Stack::GetInstance()->GetBtm()->SetClassicConnectibleOff();
      break;
    case kConnectibleModeOn:
      Stack::GetInstance()->GetBtm()->SetClassicConnectibleOn();
      break;
    default:
      return BTM_ILLEGAL_VALUE;
      break;
  }
  return BTM_SUCCESS;
}

uint16_t bluetooth::shim::BTM_IsInquiryActive(void) {
  if (Stack::GetInstance()->GetBtm()->IsGeneralInquiryActive()) {
    return BTM_GENERAL_INQUIRY_ACTIVE;
  }
  return BTM_INQUIRY_INACTIVE;
}

void bluetooth::shim::BTM_CancelInquiry(void) {
  LOG_INFO("%s Cancel inquiry", __func__);
  Stack::GetInstance()->GetBtm()->CancelInquiry();

  btm_cb.btm_inq_vars.state = BTM_INQ_INACTIVE_STATE;
  btm_clr_inq_result_flt();

  Stack::GetInstance()->GetBtm()->CancelScanningTimer();
  Stack::GetInstance()->GetBtm()->StopActiveScanning();

  btm_cb.ble_ctr_cb.reset_ble_inquiry();

  btm_cb.btm_inq_vars.inqparms.mode &=
      ~(btm_cb.btm_inq_vars.inqparms.mode & BTM_BLE_INQUIRY_MASK);

  btm_acl_update_inquiry_status(BTM_INQUIRY_COMPLETE);
  /* Ignore any stray or late complete messages if the inquiry is not active */
  if (btm_cb.btm_inq_vars.inq_active) {
    btm_cb.btm_inq_vars.inq_cmpl_info.status = BTM_SUCCESS;
    btm_clear_all_pending_le_entry();

    if (controller_get_interface()->supports_rssi_with_inquiry_results()) {
      btm_sort_inq_result();
    }

    btm_cb.btm_inq_vars.inq_active = BTM_INQUIRY_INACTIVE;
    btm_cb.btm_inq_vars.p_inq_results_cb = nullptr;
    btm_cb.btm_inq_vars.p_inq_cmpl_cb = nullptr;
    btm_cb.btm_inq_vars.inq_counter++;

    if (btm_cb.btm_inq_vars.p_inq_cmpl_cb != nullptr) {
      LOG_INFO("%s Sending cancel inquiry completion to upper layer", __func__);
      (btm_cb.btm_inq_vars.p_inq_cmpl_cb)(
          (tBTM_INQUIRY_CMPL*)&btm_cb.btm_inq_vars.inq_cmpl_info);
      btm_cb.btm_inq_vars.p_inq_cmpl_cb = nullptr;
    }
  }
}

tBTM_STATUS bluetooth::shim::BTM_ReadRemoteDeviceName(
    const RawAddress& raw_address, tBTM_NAME_CMPL_CB* callback,
    tBT_TRANSPORT transport) {
  CHECK(callback != nullptr);
  tBTM_STATUS status = BTM_NO_RESOURCES;

  switch (transport) {
    case BT_TRANSPORT_LE:
      status = Stack::GetInstance()->GetBtm()->ReadLeRemoteDeviceName(
          raw_address, callback);
      break;
    case BT_TRANSPORT_BR_EDR:
      status = Stack::GetInstance()->GetBtm()->ReadClassicRemoteDeviceName(
          raw_address, callback);
      break;
    default:
      LOG_WARN("%s Unspecified transport:%d", __func__, transport);
      break;
  }
  return status;
}

tBTM_STATUS bluetooth::shim::BTM_CancelRemoteDeviceName(void) {
  return Stack::GetInstance()->GetBtm()->CancelAllReadRemoteDeviceName();
}
@@ -916,45 +565,6 @@ void bluetooth::shim::BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16) {
  CHECK(p_eir_uuid != nullptr);
}

void bluetooth::shim::BTM_SecAddBleDevice(const RawAddress& bd_addr,
                                          tBT_DEVICE_TYPE dev_type,
                                          tBLE_ADDR_TYPE addr_type) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
}

void bluetooth::shim::BTM_SecAddBleKey(const RawAddress& bd_addr,
                                       tBTM_LE_KEY_VALUE* p_le_key,
                                       tBTM_LE_KEY_TYPE key_type) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
  CHECK(p_le_key != nullptr);
}

void bluetooth::shim::BTM_BleLoadLocalKeys(uint8_t key_type,
                                           tBTM_BLE_LOCAL_KEYS* p_key) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
  CHECK(p_key != nullptr);
}

static Octet16 bogus_root;

/** Returns local device encryption root (ER) */
const Octet16& bluetooth::shim::BTM_GetDeviceEncRoot() {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
  return bogus_root;
}

/** Returns local device identity root (IR). */
const Octet16& bluetooth::shim::BTM_GetDeviceIDRoot() {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
  return bogus_root;
}

/** Return local device DHK. */
const Octet16& bluetooth::shim::BTM_GetDeviceDHK() {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
  return bogus_root;
}

void bluetooth::shim::BTM_ReadConnectionAddr(const RawAddress& remote_bda,
                                             RawAddress& local_conn_addr,
                                             tBLE_ADDR_TYPE* p_addr_type) {
@@ -970,38 +580,11 @@ bool bluetooth::shim::BTM_ReadRemoteConnectionAddr(
  return false;
}

void bluetooth::shim::BTM_SecurityGrant(const RawAddress& bd_addr,
                                        uint8_t res) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
}

void bluetooth::shim::BTM_BleOobDataReply(const RawAddress& bd_addr,
                                          uint8_t res, uint8_t len,
                                          uint8_t* p_data) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
  CHECK(p_data != nullptr);
}

void bluetooth::shim::BTM_BleSecureConnectionOobDataReply(
    const RawAddress& bd_addr, uint8_t* p_c, uint8_t* p_r) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
  CHECK(p_c != nullptr);
  CHECK(p_r != nullptr);
}

void bluetooth::shim::BTM_BleSetConnScanParams(uint32_t scan_interval,
                                               uint32_t scan_window) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
}

void bluetooth::shim::BTM_BleSetPrefConnParams(const RawAddress& bd_addr,
                                               uint16_t min_conn_int,
                                               uint16_t max_conn_int,
                                               uint16_t peripheral_latency,
                                               uint16_t supervision_tout) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
}

void bluetooth::shim::BTM_ReadDevInfo(const RawAddress& remote_bda,
                                      tBT_DEVICE_TYPE* p_dev_type,
                                      tBLE_ADDR_TYPE* p_addr_type) {
@@ -1017,39 +600,6 @@ bool bluetooth::shim::BTM_ReadConnectedTransportAddress(
  return false;
}

bool bluetooth::shim::BTM_UseLeLink(const RawAddress& raw_address) {
  return Stack::GetInstance()->GetBtm()->UseLeLink(raw_address);
}

void bluetooth::shim::BTM_BleReadPhy(
    const RawAddress& bd_addr,
    base::Callback<void(uint8_t tx_phy, uint8_t rx_phy, uint8_t status)> cb) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
}

void bluetooth::shim::BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys,
                                    uint8_t rx_phys, uint16_t phy_options) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
}

bool bluetooth::shim::BTM_BleDataSignature(const RawAddress& bd_addr,
                                           uint8_t* p_text, uint16_t len,
                                           BLE_SIGNATURE signature) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
  CHECK(p_text != nullptr);
  return false;
}

bool bluetooth::shim::BTM_BleVerifySignature(const RawAddress& bd_addr,
                                             uint8_t* p_orig, uint16_t len,
                                             uint32_t counter,
                                             uint8_t* p_comp) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
  CHECK(p_orig != nullptr);
  CHECK(p_comp != nullptr);
  return false;
}

bool bluetooth::shim::BTM_GetLeSecurityState(const RawAddress& bd_addr,
                                             uint8_t* p_le_dev_sec_flags,
                                             uint8_t* p_le_key_size) {
@@ -1144,14 +694,6 @@ void bluetooth::shim::BTM_BleEnableDisableFilterFeature(
  LOG_INFO("UNIMPLEMENTED %s", __func__);
}

uint8_t bluetooth::shim::BTM_BleMaxMultiAdvInstanceCount() {
  return Stack::GetInstance()->GetBtm()->GetNumberOfAdvertisingInstances();
}

bool bluetooth::shim::BTM_BleLocalPrivacyEnabled(void) {
  return controller_get_interface()->supports_ble_privacy();
}

tBTM_STATUS bluetooth::shim::BTM_SecBond(const RawAddress& bd_addr,
                                         tBLE_ADDR_TYPE addr_type,
                                         tBT_TRANSPORT transport,
@@ -1160,59 +702,6 @@ tBTM_STATUS bluetooth::shim::BTM_SecBond(const RawAddress& bd_addr,
                                                    transport, device_type);
}

bool bluetooth::shim::BTM_SecRegister(const tBTM_APPL_INFO* bta_callbacks) {
  CHECK(bta_callbacks != nullptr);
  LOG_INFO("%s Registering security application", __func__);

  if (bta_callbacks->p_pin_callback == nullptr) {
    LOG_INFO("UNIMPLEMENTED %s pin_callback", __func__);
  }

  if (bta_callbacks->p_link_key_callback == nullptr) {
    LOG_INFO("UNIMPLEMENTED %s link_key_callback", __func__);
  }

  if (bta_callbacks->p_auth_complete_callback == nullptr) {
    LOG_INFO("UNIMPLEMENTED %s auth_complete_callback", __func__);
  }

  if (bta_callbacks->p_bond_cancel_cmpl_callback == nullptr) {
    LOG_INFO("UNIMPLEMENTED %s bond_cancel_complete_callback", __func__);
  }

  if (bta_callbacks->p_le_callback == nullptr) {
    LOG_INFO("UNIMPLEMENTED %s le_callback", __func__);
  }

  if (bta_callbacks->p_le_key_callback == nullptr) {
    LOG_INFO("UNIMPLEMENTED %s le_key_callback", __func__);
  }

  ShimBondListener::GetInstance()->SetBtaCallbacks(bta_callbacks);

  bluetooth::shim::GetSecurityModule()
      ->GetSecurityManager()
      ->RegisterCallbackListener(ShimBondListener::GetInstance(),
                                 bluetooth::shim::GetGdShimHandler());

  ShimUi::GetInstance()->SetBtaCallbacks(bta_callbacks);

  bluetooth::shim::GetSecurityModule()
      ->GetSecurityManager()
      ->SetUserInterfaceHandler(ShimUi::GetInstance(),
                                bluetooth::shim::GetGdShimHandler());

  return true;
}

tBTM_STATUS bluetooth::shim::BTM_SecBondCancel(const RawAddress& bd_addr) {
  if (Stack::GetInstance()->GetBtm()->CancelBond(bd_addr)) {
    return BTM_SUCCESS;
  } else {
    return BTM_UNKNOWN_ADDR;
  }
}

bool bluetooth::shim::BTM_SecAddDevice(const RawAddress& bd_addr,
                                       DEV_CLASS dev_class,
                                       const BD_NAME& bd_name,
@@ -1222,10 +711,6 @@ bool bluetooth::shim::BTM_SecAddDevice(const RawAddress& bd_addr,
  return BTM_SUCCESS;
}

bool bluetooth::shim::BTM_SecDeleteDevice(const RawAddress& bd_addr) {
  return Stack::GetInstance()->GetBtm()->RemoveBond(bd_addr);
}

void bluetooth::shim::BTM_ConfirmReqReply(tBTM_STATUS res,
                                          const RawAddress& bd_addr) {
  // Send for both Classic and LE until we can determine the type
@@ -1251,43 +736,6 @@ uint16_t bluetooth::shim::BTM_GetHCIConnHandle(const RawAddress& remote_bda,
  return Stack::GetInstance()->GetBtm()->GetAclHandle(remote_bda, transport);
}

static void remote_name_request_complete_noop(
    UNUSED_ATTR const tBTM_REMOTE_DEV_NAME* p_name){
    // Should notify BTM_Sec, but we should use GD SMP.
};

void bluetooth::shim::SendRemoteNameRequest(const RawAddress& raw_address) {
  Stack::GetInstance()->GetBtm()->ReadClassicRemoteDeviceName(
      raw_address, remote_name_request_complete_noop);
}

tBTM_STATUS bluetooth::shim::btm_sec_mx_access_request(
    const RawAddress& bd_addr, bool is_originator,
    uint16_t security_requirement, tBTM_SEC_CALLBACK* p_callback,
    void* p_ref_data) {
  // Security has already been fulfilled by the l2cap connection, so reply back
  // that everything is totally fine and legit and definitely not two kids in a
  // trenchcoat

  if (p_callback) {
    (*p_callback)(&bd_addr, false, p_ref_data, BTM_SUCCESS);
  }
  return BTM_SUCCESS;
}

tBTM_STATUS bluetooth::shim::BTM_SetEncryption(const RawAddress& bd_addr,
                                               tBT_TRANSPORT transport,
                                               tBTM_SEC_CALLBACK* p_callback,
                                               void* p_ref_data,
                                               tBTM_BLE_SEC_ACT sec_act) {
  // When we just bond a device, encryption is already done
  (*p_callback)(&bd_addr, transport, p_ref_data, BTM_SUCCESS);

  // TODO(hsz): Re-encrypt the link after first bonded

  return BTM_SUCCESS;
}

void bluetooth::shim::BTM_SecClearSecurityFlags(const RawAddress& bd_addr) {
  // TODO(optedoblivion): Call RemoveBond on device address
}
+2 −72

File changed.

Preview size limit exceeded, changes collapsed.

+0 −23
Original line number Diff line number Diff line
@@ -465,12 +465,6 @@ inline bool BTM_LE_STATES_SUPPORTED(const uint8_t* x, uint8_t bit_num) {

void BTM_BleOpportunisticObserve(bool enable,
                                 tBTM_INQ_RESULTS_CB* p_results_cb) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    bluetooth::shim::BTM_BleOpportunisticObserve(enable, p_results_cb);
    // NOTE: passthrough, no return here. GD would send the results back to BTM,
    // and it needs the callbacks set properly.
  }

  if (enable) {
    btm_cb.ble_ctr_cb.p_opportunistic_obs_results_cb = p_results_cb;
  } else {
@@ -480,12 +474,6 @@ void BTM_BleOpportunisticObserve(bool enable,

void BTM_BleTargetAnnouncementObserve(bool enable,
                                      tBTM_INQ_RESULTS_CB* p_results_cb) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    bluetooth::shim::BTM_BleTargetAnnouncementObserve(enable, p_results_cb);
    // NOTE: passthrough, no return here. GD would send the results back to BTM,
    // and it needs the callbacks set properly.
  }

  if (enable) {
    btm_cb.ble_ctr_cb.p_target_announcement_obs_results_cb = p_results_cb;
  } else {
@@ -511,11 +499,6 @@ void BTM_BleTargetAnnouncementObserve(bool enable,
tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration,
                           tBTM_INQ_RESULTS_CB* p_results_cb,
                           tBTM_CMPL_CB* p_cmpl_cb) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::BTM_BleObserve(start, duration, p_results_cb,
                                           p_cmpl_cb);
  }

  tBTM_BLE_INQ_CB* p_inq = &btm_cb.ble_ctr_cb.inq_var;
  tBTM_STATUS status = BTM_WRONG_MODE;

@@ -878,9 +861,6 @@ bool BTM_BleConfigPrivacy(bool privacy_mode) {
 *
 ******************************************************************************/
uint8_t BTM_BleMaxMultiAdvInstanceCount(void) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::BTM_BleMaxMultiAdvInstanceCount();
  }
  return btm_cb.cmn_ble_vsc_cb.adv_inst_max < BTM_BLE_MULTI_ADV_MAX
             ? btm_cb.cmn_ble_vsc_cb.adv_inst_max
             : BTM_BLE_MULTI_ADV_MAX;
@@ -896,9 +876,6 @@ uint8_t BTM_BleMaxMultiAdvInstanceCount(void) {
 *
 ******************************************************************************/
bool BTM_BleLocalPrivacyEnabled(void) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::BTM_BleLocalPrivacyEnabled();
  }
  return (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE);
}

+0 −4
Original line number Diff line number Diff line
@@ -159,10 +159,6 @@ void BTM_AcceptlistRemove(const RawAddress& address);
 * Returns true if removed OK, false if not found or ACL link is active.
 */
bool BTM_SecDeleteDevice(const RawAddress& bd_addr) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::BTM_SecDeleteDevice(bd_addr);
  }

  if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE) ||
      BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_BR_EDR)) {
    LOG_WARN("%s FAILED: Cannot Delete when connection to %s is active",
+2 −45

File changed.

Preview size limit exceeded, changes collapsed.

Loading