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

Commit 224fc3bb authored by Chris Manton's avatar Chris Manton
Browse files

stack::rnr::btm_initiate_rem_name [1/5] Extract get_clock_offset_from_storage

Bug: 354452689
Test: m .
Flag: EXEMPT, Mechanical Refactor

Change-Id: I6aa074d05e495919f18e3f74ac0c3850e1266d6d
parent b19f6eba
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -1843,6 +1843,13 @@ static void btm_process_cancel_complete(tHCI_STATUS status, uint8_t mode) {
 *                  BTM_WRONG_MODE if the device is not up.
 *
 ******************************************************************************/
static uint16_t get_clock_offset_from_storage(const RawAddress& remote_bda) {
  int clock_offset_in_cfg = 0;
  return btif_get_device_clockoffset(remote_bda, &clock_offset_in_cfg)
                 ? static_cast<uint16_t>(clock_offset_in_cfg)
                 : 0;
}

tBTM_STATUS btm_initiate_rem_name(const RawAddress& remote_bda, uint64_t timeout_ms,
                                  tBTM_NAME_CMPL_CB* p_cb) {
  /*** Make sure the device is ready ***/
@@ -1858,11 +1865,8 @@ tBTM_STATUS btm_initiate_rem_name(const RawAddress& remote_bda, uint64_t timeout
  if (p_i && (p_i->inq_info.results.inq_result_type & BT_DEVICE_TYPE_BREDR)) {
    tBTM_INQ_INFO* p_cur = &p_i->inq_info;
    uint16_t clock_offset = p_cur->results.clock_offset | BTM_CLOCK_OFFSET_VALID;
    int clock_offset_in_cfg = 0;
    if (0 == (p_cur->results.clock_offset & BTM_CLOCK_OFFSET_VALID)) {
      if (btif_get_device_clockoffset(remote_bda, &clock_offset_in_cfg)) {
        clock_offset = clock_offset_in_cfg;
      }
      clock_offset = get_clock_offset_from_storage(remote_bda);
    }
    uint8_t page_scan_rep_mode = p_cur->results.page_scan_rep_mode;
    if (com::android::bluetooth::flags::rnr_validate_page_scan_repetition_mode() &&
@@ -1876,11 +1880,7 @@ tBTM_STATUS btm_initiate_rem_name(const RawAddress& remote_bda, uint64_t timeout
    bluetooth::shim::ACL_RemoteNameRequest(remote_bda, page_scan_rep_mode,
                                           p_cur->results.page_scan_mode, clock_offset);
  } else {
    uint16_t clock_offset = 0;
    int clock_offset_in_cfg = 0;
    if (btif_get_device_clockoffset(remote_bda, &clock_offset_in_cfg)) {
      clock_offset = clock_offset_in_cfg;
    }
    uint16_t clock_offset = get_clock_offset_from_storage(remote_bda);
    bluetooth::shim::ACL_RemoteNameRequest(remote_bda, HCI_PAGE_SCAN_REP_MODE_R1,
                                           HCI_MANDATARY_PAGE_SCAN_MODE, clock_offset);
  }