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

Commit 54d535b7 authored by Qasim Javed's avatar Qasim Javed Committed by Automerger Merge Worker
Browse files

Merge "Use SDP when SDP succeeds and EIR when SDP fails" into tm-dev am: ffc7b2bb

parents 23cdffd0 ffc7b2bb
Loading
Loading
Loading
Loading
+26 −20
Original line number Original line Diff line number Diff line
@@ -164,6 +164,8 @@ typedef struct {
  bool is_le_nc; /* LE Numeric comparison */
  bool is_le_nc; /* LE Numeric comparison */
  btif_dm_ble_cb_t ble;
  btif_dm_ble_cb_t ble;
  uint8_t fail_reason;
  uint8_t fail_reason;
  Uuid::UUID128Bit eir_uuids[32];
  uint8_t num_eir_uuids;
} btif_dm_pairing_cb_t;
} btif_dm_pairing_cb_t;


// TODO(jpawlowski): unify ?
// TODO(jpawlowski): unify ?
@@ -1296,19 +1298,17 @@ static void btif_dm_search_devices_evt(tBTA_DM_SEARCH_EVT event,
                                   &(p_search_data->inq_res.include_rsi));
                                   &(p_search_data->inq_res.include_rsi));
        num_properties++;
        num_properties++;


        /* EIR queried services */
        /* Cache EIR queried services */
        std::vector<Uuid> uuid128_list;
        if (num_uuids > 0) {
        if (num_uuids > 0) {
          uint16_t* p_uuid16 = (uint16_t*)uuid_list;
          uint16_t* p_uuid16 = (uint16_t*)uuid_list;
          pairing_cb.num_eir_uuids = 0;
          LOG_INFO("EIR UUIDS:");
          for (int i = 0; i < num_uuids; ++i) {
          for (int i = 0; i < num_uuids; ++i) {
            Uuid uuid = Uuid::From16Bit(p_uuid16[i]);
            Uuid uuid = Uuid::From16Bit(p_uuid16[i]);
            uuid128_list.push_back(uuid);
            LOG_INFO("        %s", uuid.ToString().c_str());
            pairing_cb.eir_uuids[i] = uuid.To128BitBE();
            pairing_cb.num_eir_uuids++;
          }
          }

          BTIF_STORAGE_FILL_PROPERTY(
              &properties[num_properties], BT_PROPERTY_UUIDS,
              num_uuids * Uuid::kNumBytes128, uuid128_list.data());
          num_properties++;
        }
        }


        status =
        status =
@@ -1408,28 +1408,34 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event,
        LOG_INFO("SDP search done for %s", bd_addr.ToString().c_str());
        LOG_INFO("SDP search done for %s", bd_addr.ToString().c_str());
        pairing_cb.sdp_attempts = 0;
        pairing_cb.sdp_attempts = 0;


        // Both SDP and bonding are done, clear pairing control block in case
        // Send UUIDs discovered through EIR to Java to unblock pairing intent
        // it is not already cleared
        // when SDP failed or no UUID is discovered
        pairing_cb = {};

        // Send one empty UUID to Java to unblock pairing intent when SDP failed
        // or no UUID is discovered
        if (p_data->disc_res.result != BTA_SUCCESS ||
        if (p_data->disc_res.result != BTA_SUCCESS ||
            p_data->disc_res.num_uuids == 0) {
            p_data->disc_res.num_uuids == 0) {
          LOG_INFO("SDP failed, send empty UUID to unblock bonding %s",
          LOG_INFO("SDP failed, send %d EIR UUIDs to unblock bonding %s",
                   bd_addr.ToString().c_str());
                   pairing_cb.num_eir_uuids, bd_addr.ToString().c_str());
          bt_property_t prop_uuids;
          bt_property_t prop_uuids;
          Uuid uuid = {};
          Uuid uuid = {};

          prop_uuids.type = BT_PROPERTY_UUIDS;
          prop_uuids.type = BT_PROPERTY_UUIDS;
          if (pairing_cb.num_eir_uuids > 0) {
            prop_uuids.val = pairing_cb.eir_uuids;
            prop_uuids.len = pairing_cb.num_eir_uuids * Uuid::kNumBytes128;
          } else {
            prop_uuids.val = &uuid;
            prop_uuids.val = &uuid;
            prop_uuids.len = Uuid::kNumBytes128;
            prop_uuids.len = Uuid::kNumBytes128;
          }


          /* Send the event to the BTIF */
          /* Send the event to the BTIF
           * prop_uuids will be deep copied by this call
           */
          invoke_remote_device_properties_cb(BT_STATUS_SUCCESS, bd_addr, 1,
          invoke_remote_device_properties_cb(BT_STATUS_SUCCESS, bd_addr, 1,
                                             &prop_uuids);
                                             &prop_uuids);
          pairing_cb = {};
          break;
          break;
        }
        }
        // Both SDP and bonding are done, clear pairing control block in case
        // it is not already cleared
        pairing_cb = {};
      }
      }


      if (p_data->disc_res.num_uuids != 0) {
      if (p_data->disc_res.num_uuids != 0) {