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

Commit 8b704a07 authored by Zach Johnson's avatar Zach Johnson
Browse files

Simplfy SetInquiryScanType & SetPageScanType

Only ever set to interlaced, so no need for the extra complexity

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I1ed2b45673d9029e4a96a2a1d4c23535f6feef69
parent a04c6294
Loading
Loading
Loading
Loading
+5 −32
Original line number Diff line number Diff line
@@ -406,20 +406,8 @@ tBTM_STATUS bluetooth::shim::BTM_SetDiscoverability(uint16_t discoverable_mode,
  return BTM_SUCCESS;
}

tBTM_STATUS bluetooth::shim::BTM_SetInquiryScanType(uint16_t scan_type) {
  switch (scan_type) {
    case kInterlacedScanType:
void bluetooth::shim::BTM_EnableInterlacedInquiryScan() {
  Stack::GetInstance()->GetBtm()->SetInterlacedInquiryScan();
      return BTM_SUCCESS;
      break;
    case kStandardScanType:
      Stack::GetInstance()->GetBtm()->SetStandardInquiryScan();
      return BTM_SUCCESS;
      break;
    default:
      return BTM_ILLEGAL_VALUE;
  }
  return BTM_WRONG_MODE;
}

tBTM_STATUS bluetooth::shim::BTM_BleObserve(bool start, uint8_t duration_sec,
@@ -501,23 +489,8 @@ tBTM_STATUS bluetooth::shim::BTM_BleObserve(bool start, uint8_t duration_sec,
  return BTM_CMD_STARTED;
}

tBTM_STATUS bluetooth::shim::BTM_SetPageScanType(uint16_t scan_type) {
  switch (scan_type) {
    case kInterlacedScanType:
      if (!Stack::GetInstance()->GetBtm()->IsInterlacedScanSupported()) {
        return BTM_MODE_UNSUPPORTED;
      }
void bluetooth::shim::BTM_EnableInterlacedPageScan() {
  Stack::GetInstance()->GetBtm()->SetInterlacedPageScan();
      return BTM_SUCCESS;
      break;
    case kStandardScanType:
      Stack::GetInstance()->GetBtm()->SetStandardPageScan();
      return BTM_SUCCESS;
      break;
    default:
      return BTM_ILLEGAL_VALUE;
  }
  return BTM_WRONG_MODE;
}

tBTM_STATUS bluetooth::shim::BTM_SetInquiryMode(uint8_t inquiry_mode) {
+3 −31
Original line number Diff line number Diff line
@@ -81,22 +81,6 @@ tBTM_STATUS BTM_StartInquiry(tBTM_INQ_PARMS* p_inqparms,
tBTM_STATUS BTM_SetDiscoverability(uint16_t inq_mode, uint16_t window,
                                   uint16_t interval);

/*******************************************************************************
 *
 * Function         BTM_SetInquiryScanType
 *
 * Description      This function is called to set the iquiry scan-type to
 *                  standard or interlaced.
 *
 * Input Params:    BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
 *
 * Returns          BTM_SUCCESS if successful
 *                  BTM_MODE_UNSUPPORTED if not a 1.2 device
 *                  BTM_WRONG_MODE if the device is not up.
 *
 ******************************************************************************/
tBTM_STATUS BTM_SetInquiryScanType(uint16_t scan_type);

/*******************************************************************************
 *
 * Function         BTM_BleObserve
@@ -113,21 +97,9 @@ tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration,
                           tBTM_INQ_RESULTS_CB* p_results_cb,
                           tBTM_CMPL_CB* p_cmpl_cb);

/*******************************************************************************
 *
 * Function         BTM_SetPageScanType
 *
 * Description      This function is called to set the page scan-type to
 *                  standard or interlaced.
 *
 * Input Params:    BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
 *
 * Returns          BTM_SUCCESS if successful
 *                  BTM_MODE_UNSUPPORTED if not a 1.2 device
 *                  BTM_WRONG_MODE if the device is not up.
 *
 ******************************************************************************/
tBTM_STATUS BTM_SetPageScanType(uint16_t scan_type);
void BTM_EnableInterlacedInquiryScan();

void BTM_EnableInterlacedPageScan();

/*******************************************************************************
 *
+2 −2
Original line number Diff line number Diff line
@@ -393,8 +393,8 @@ static void decode_controller_support() {
  else
    l2cu_set_non_flushable_pbf(false);
#endif
  BTM_SetPageScanType(BTM_SCAN_TYPE_INTERLACED);
  BTM_SetInquiryScanType(BTM_SCAN_TYPE_INTERLACED);
  BTM_EnableInterlacedPageScan();
  BTM_EnableInterlacedInquiryScan();
}

/*******************************************************************************
+19 −62
Original line number Diff line number Diff line
@@ -254,78 +254,35 @@ tBTM_STATUS BTM_SetDiscoverability(uint16_t inq_mode, uint16_t window,
  return (BTM_SUCCESS);
}

/*******************************************************************************
 *
 * Function         BTM_SetInquiryScanType
 *
 * Description      This function is called to set the iquiry scan-type to
 *                  standard or interlaced.
 *
 * Returns          BTM_SUCCESS if successful
 *                  BTM_MODE_UNSUPPORTED if not a 1.2 device
 *                  BTM_WRONG_MODE if the device is not up.
 *
 ******************************************************************************/
tBTM_STATUS BTM_SetInquiryScanType(uint16_t scan_type) {
void BTM_EnableInterlacedInquiryScan() {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::BTM_SetInquiryScanType(scan_type);
    bluetooth::shim::BTM_EnableInterlacedInquiryScan();
  }

  BTM_TRACE_API("BTM_SetInquiryScanType");
  if (scan_type != BTM_SCAN_TYPE_STANDARD &&
      scan_type != BTM_SCAN_TYPE_INTERLACED)
    return (BTM_ILLEGAL_VALUE);

  /* whatever app wants if device is not 1.2 scan type should be STANDARD */
  if (!controller_get_interface()->supports_interlaced_inquiry_scan())
    return (BTM_MODE_UNSUPPORTED);

  /* Check for scan type if configuration has been changed */
  if (scan_type != btm_cb.btm_inq_vars.inq_scan_type) {
    if (BTM_IsDeviceUp()) {
      btsnd_hcic_write_inqscan_type((uint8_t)scan_type);
      btm_cb.btm_inq_vars.inq_scan_type = scan_type;
    } else
      return (BTM_WRONG_MODE);
  BTM_TRACE_API("BTM_EnableInterlacedInquiryScan");
  if (!controller_get_interface()->supports_interlaced_inquiry_scan() ||
      btm_cb.btm_inq_vars.inq_scan_type == BTM_SCAN_TYPE_INTERLACED) {
    return;
  }
  return (BTM_SUCCESS);

  btsnd_hcic_write_inqscan_type(BTM_SCAN_TYPE_INTERLACED);
  btm_cb.btm_inq_vars.inq_scan_type = BTM_SCAN_TYPE_INTERLACED;
}

/*******************************************************************************
 *
 * Function         BTM_SetPageScanType
 *
 * Description      This function is called to set the page scan-type to
 *                  standard or interlaced.
 *
 * Returns          BTM_SUCCESS if successful
 *                  BTM_MODE_UNSUPPORTED if not a 1.2 device
 *                  BTM_WRONG_MODE if the device is not up.
 *
 ******************************************************************************/
tBTM_STATUS BTM_SetPageScanType(uint16_t scan_type) {
void BTM_EnableInterlacedPageScan() {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::BTM_SetPageScanType(scan_type);
    bluetooth::shim::BTM_EnableInterlacedPageScan();
    return;
  }

  BTM_TRACE_API("BTM_SetPageScanType");
  if (scan_type != BTM_SCAN_TYPE_STANDARD &&
      scan_type != BTM_SCAN_TYPE_INTERLACED)
    return (BTM_ILLEGAL_VALUE);

  /* whatever app wants if device is not 1.2 scan type should be STANDARD */
  if (!controller_get_interface()->supports_interlaced_inquiry_scan())
    return (BTM_MODE_UNSUPPORTED);

  /* Check for scan type if configuration has been changed */
  if (scan_type != btm_cb.btm_inq_vars.page_scan_type) {
    if (BTM_IsDeviceUp()) {
      btsnd_hcic_write_pagescan_type((uint8_t)scan_type);
      btm_cb.btm_inq_vars.page_scan_type = scan_type;
    } else
      return (BTM_WRONG_MODE);
  BTM_TRACE_API("BTM_EnableInterlacedPageScan");
  if (!controller_get_interface()->supports_interlaced_inquiry_scan() ||
      btm_cb.btm_inq_vars.page_scan_type == BTM_SCAN_TYPE_INTERLACED) {
    return;
  }
  return (BTM_SUCCESS);

  btsnd_hcic_write_pagescan_type(BTM_SCAN_TYPE_INTERLACED);
  btm_cb.btm_inq_vars.page_scan_type = BTM_SCAN_TYPE_INTERLACED;
}

/*******************************************************************************
+2 −31
Original line number Diff line number Diff line
@@ -427,38 +427,9 @@ extern uint16_t BTM_ReadConnectability(uint16_t* p_window,
 ******************************************************************************/
extern tBTM_STATUS BTM_SetInquiryMode(uint8_t mode);

/*******************************************************************************
 *
 * Function         BTM_SetInquiryScanType
 *
 * Description      This function is called to set the iquiry scan-type to
 *                  standard or interlaced.
 *
 * Input Params:    BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
 *
 * Returns          BTM_SUCCESS if successful
 *                  BTM_MODE_UNSUPPORTED if not a 1.2 device
 *                  BTM_WRONG_MODE if the device is not up.
 *
 ******************************************************************************/
extern tBTM_STATUS BTM_SetInquiryScanType(uint16_t scan_type);

/*******************************************************************************
 *
 * Function         BTM_SetPageScanType
 *
 * Description      This function is called to set the page scan-type to
 *                  standard or interlaced.
 *
 * Input Params:    BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
 *
 * Returns          BTM_SUCCESS if successful
 *                  BTM_MODE_UNSUPPORTED if not a 1.2 device
 *                  BTM_WRONG_MODE if the device is not up.
 *
 ******************************************************************************/
extern void BTM_EnableInterlacedInquiryScan();

extern tBTM_STATUS BTM_SetPageScanType(uint16_t scan_type);
extern void BTM_EnableInterlacedPageScan();

/*******************************************************************************
 *