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

Commit a654522b authored by Ventsislav Zahariev's avatar Ventsislav Zahariev Committed by Gerrit Code Review
Browse files

Merge "Fix connect device with clock_offset=0 fail"

parents e1aabebe 70504ebf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2150,6 +2150,7 @@ static void bta_dm_inq_results_cb(tBTM_INQ_RESULTS* p_inq, const uint8_t* p_eir,
  result.inq_res.device_type = p_inq->device_type;
  result.inq_res.flag = p_inq->flag;
  result.inq_res.include_rsi = p_inq->include_rsi;
  result.inq_res.clock_offset = p_inq->clock_offset;

  /* application will parse EIR to find out remote device name */
  result.inq_res.p_eir = const_cast<uint8_t*>(p_eir);
+1 −0
Original line number Diff line number Diff line
@@ -512,6 +512,7 @@ typedef struct {
  bool include_rsi; /* true, if ADV contains RSI data */
  RawAddress original_bda; /* original address to pass up to
                              GattService#onScanResult */
  uint16_t clock_offset;
} tBTA_DM_INQ_RES;

/* Structure associated with BTA_DM_INQ_CMPL_EVT */
+2 −0
Original line number Diff line number Diff line
@@ -71,3 +71,5 @@ std::vector<RawAddress> btif_config_get_paired_devices();

bool btif_config_clear(void);
void btif_debug_config_dump(int fd);
bool btif_get_device_clockoffset(const RawAddress& bda, int* p_clock_offset);
bool btif_set_device_clockoffset(const RawAddress& bda, int clock_offset);
+25 −0
Original line number Diff line number Diff line
@@ -209,6 +209,31 @@ EXPORT_SYMBOL module_t btif_config_module = {.name = BTIF_CONFIG_MODULE,
                                             .shut_down = shut_down,
                                             .clean_up = clean_up};

bool btif_get_device_clockoffset(const RawAddress& bda, int* p_clock_offset) {
  if (p_clock_offset == NULL) return false;

  std::string addrstr = bda.ToString();
  const char* bd_addr_str = addrstr.c_str();

  if (!btif_config_get_int(bd_addr_str, "ClockOffset", p_clock_offset)) return false;

  LOG_DEBUG("%s: Device [%s] clock_offset %d", __func__, bd_addr_str,
            *p_clock_offset);
  return true;
}

bool btif_set_device_clockoffset(const RawAddress& bda, int clock_offset) {

  std::string addrstr = bda.ToString();
  const char* bd_addr_str = addrstr.c_str();

  if (!btif_config_set_int(bd_addr_str, "ClockOffset", clock_offset)) return false;

  LOG_DEBUG("%s: Device [%s] clock_offset %d", __func__, bd_addr_str,
            clock_offset);
  return true;
}

bool btif_config_exist(const std::string& section, const std::string& key) {
  CHECK(bluetooth::shim::is_gd_stack_started_up());
  return bluetooth::shim::BtifConfigInterface::HasProperty(section, key);
+6 −0
Original line number Diff line number Diff line
@@ -1468,6 +1468,12 @@ static void btif_dm_search_devices_evt(tBTA_DM_SEARCH_EVT event,
          num_properties++;
        }

        BTIF_TRACE_DEBUG("%s clock_offset is 0x%x", __func__,
            p_search_data->inq_res.clock_offset);
        if (p_search_data->inq_res.clock_offset & BTM_CLOCK_OFFSET_VALID) {
          btif_set_device_clockoffset(bdaddr, (int)p_search_data->inq_res.clock_offset);
        }

        /* DEV_TYPE */
        /* FixMe: Assumption is that bluetooth.h and BTE enums match */

Loading