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

Commit d31146f1 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

BTA_DM_DISC_BLE_RES_EVT -> BTA_DM_GATT_OVER_LE_RES_EVT and BTA_DM_GATT_OVER_SDP_RES_EVT

Differentiate between services disovered by SDP and LE GATT discovery.
Service avaliability differs between transports.

This patch is not making any functional changes, just making code
clearer.

Test: perform LE and Classic pairing to dual mode device
Bug: 248340112
Merged-In: I7be9d2c0549f8c33eff16b70d6f54dd1f08a71a0
Change-Id: I7be9d2c0549f8c33eff16b70d6f54dd1f08a71a0
parent 35e73bbb
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -1143,7 +1143,8 @@ void bta_dm_sdp_result(tBTA_DM_MSG* p_data) {
                  BD_NAME_LEN + 1);
                  BD_NAME_LEN + 1);


          result.disc_ble_res.services = &gatt_uuids;
          result.disc_ble_res.services = &gatt_uuids;
          bta_dm_search_cb.p_search_cback(BTA_DM_DISC_BLE_RES_EVT, &result);
          bta_dm_search_cb.p_search_cback(BTA_DM_GATT_OVER_SDP_RES_EVT,
                                          &result);
        }
        }
      } else {
      } else {
        /* SDP_DB_FULL means some records with the
        /* SDP_DB_FULL means some records with the
@@ -1336,7 +1337,7 @@ void bta_dm_search_cmpl() {


  LOG_INFO("GATT services discovered using LE Transport");
  LOG_INFO("GATT services discovered using LE Transport");
  // send all result back to app
  // send all result back to app
  bta_dm_search_cb.p_search_cback(BTA_DM_DISC_BLE_RES_EVT, &result);
  bta_dm_search_cb.p_search_cback(BTA_DM_GATT_OVER_LE_RES_EVT, &result);


  bta_dm_search_cb.p_search_cback(BTA_DM_DISC_CMPL_EVT, nullptr);
  bta_dm_search_cb.p_search_cback(BTA_DM_DISC_CMPL_EVT, nullptr);


+4 −2
Original line number Original line Diff line number Diff line
@@ -419,10 +419,12 @@ typedef void(tBTA_DM_SEC_CBACK)(tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data);
#define BTA_DM_INQ_RES_EVT 0  /* Inquiry result for a peer device. */
#define BTA_DM_INQ_RES_EVT 0  /* Inquiry result for a peer device. */
#define BTA_DM_INQ_CMPL_EVT 1 /* Inquiry complete. */
#define BTA_DM_INQ_CMPL_EVT 1 /* Inquiry complete. */
#define BTA_DM_DISC_RES_EVT 2 /* Discovery result for a peer device. */
#define BTA_DM_DISC_RES_EVT 2 /* Discovery result for a peer device. */
#define BTA_DM_DISC_BLE_RES_EVT \
#define BTA_DM_GATT_OVER_LE_RES_EVT \
  3 /* Discovery result for BLE GATT based servoce on a peer device. */
  3 /* GATT services over LE transport discovered */
#define BTA_DM_DISC_CMPL_EVT 4          /* Discovery complete. */
#define BTA_DM_DISC_CMPL_EVT 4          /* Discovery complete. */
#define BTA_DM_SEARCH_CANCEL_CMPL_EVT 6 /* Search cancelled */
#define BTA_DM_SEARCH_CANCEL_CMPL_EVT 6 /* Search cancelled */
#define BTA_DM_DID_RES_EVT 7            /* Vendor/Product ID search result */
#define BTA_DM_GATT_OVER_SDP_RES_EVT 8  /* GATT services over SDP discovered */


typedef uint8_t tBTA_DM_SEARCH_EVT;
typedef uint8_t tBTA_DM_SEARCH_EVT;


+9 −3
Original line number Original line Diff line number Diff line
@@ -1530,14 +1530,20 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event,
      /* no-op */
      /* no-op */
      break;
      break;


    case BTA_DM_DISC_BLE_RES_EVT: {
    case BTA_DM_GATT_OVER_SDP_RES_EVT:
    case BTA_DM_GATT_OVER_LE_RES_EVT: {
      int num_properties = 0;
      int num_properties = 0;
      bt_property_t prop[2];
      bt_property_t prop[2];
      std::vector<uint8_t> property_value;
      std::vector<uint8_t> property_value;
      std::set<Uuid> uuids;
      std::set<Uuid> uuids;
      RawAddress& bd_addr = p_data->disc_ble_res.bd_addr;
      RawAddress& bd_addr = p_data->disc_ble_res.bd_addr;


      LOG_INFO("New BLE UUIDs for %s:", bd_addr.ToString().c_str());
      if (event == BTA_DM_GATT_OVER_LE_RES_EVT) {
        LOG_INFO("New GATT over LE UUIDs for %s:", bd_addr.ToString().c_str());
      } else {
        LOG_INFO("New GATT over SDP UUIDs for %s:", bd_addr.ToString().c_str());
      }

      for (Uuid uuid : *p_data->disc_ble_res.services) {
      for (Uuid uuid : *p_data->disc_ble_res.services) {
        if (btif_is_interesting_le_service(uuid)) {
        if (btif_is_interesting_le_service(uuid)) {
          if (btif_should_ignore_uuid(uuid)) {
          if (btif_should_ignore_uuid(uuid)) {
@@ -1550,7 +1556,7 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event,
      }
      }


      if (uuids.empty()) {
      if (uuids.empty()) {
        LOG_INFO("No well known BLE services discovered");
        LOG_INFO("No well known GATT services discovered");
        return;
        return;
      }
      }


+2 −1
Original line number Original line Diff line number Diff line
@@ -112,9 +112,10 @@ const char* dump_dm_search_event(uint16_t event) {
    CASE_RETURN_STR(BTA_DM_INQ_RES_EVT)
    CASE_RETURN_STR(BTA_DM_INQ_RES_EVT)
    CASE_RETURN_STR(BTA_DM_INQ_CMPL_EVT)
    CASE_RETURN_STR(BTA_DM_INQ_CMPL_EVT)
    CASE_RETURN_STR(BTA_DM_DISC_RES_EVT)
    CASE_RETURN_STR(BTA_DM_DISC_RES_EVT)
    CASE_RETURN_STR(BTA_DM_DISC_BLE_RES_EVT)
    CASE_RETURN_STR(BTA_DM_GATT_OVER_LE_RES_EVT)
    CASE_RETURN_STR(BTA_DM_DISC_CMPL_EVT)
    CASE_RETURN_STR(BTA_DM_DISC_CMPL_EVT)
    CASE_RETURN_STR(BTA_DM_SEARCH_CANCEL_CMPL_EVT)
    CASE_RETURN_STR(BTA_DM_SEARCH_CANCEL_CMPL_EVT)
    CASE_RETURN_STR(BTA_DM_GATT_OVER_SDP_RES_EVT)


    default:
    default:
      return "UNKNOWN MSG ID";
      return "UNKNOWN MSG ID";
+4 −1
Original line number Original line Diff line number Diff line
@@ -225,10 +225,13 @@ TEST_F(BtifCoreTest, dump_dm_search_event) {
      std::make_pair(BTA_DM_INQ_RES_EVT, "BTA_DM_INQ_RES_EVT"),
      std::make_pair(BTA_DM_INQ_RES_EVT, "BTA_DM_INQ_RES_EVT"),
      std::make_pair(BTA_DM_INQ_CMPL_EVT, "BTA_DM_INQ_CMPL_EVT"),
      std::make_pair(BTA_DM_INQ_CMPL_EVT, "BTA_DM_INQ_CMPL_EVT"),
      std::make_pair(BTA_DM_DISC_RES_EVT, "BTA_DM_DISC_RES_EVT"),
      std::make_pair(BTA_DM_DISC_RES_EVT, "BTA_DM_DISC_RES_EVT"),
      std::make_pair(BTA_DM_DISC_BLE_RES_EVT, "BTA_DM_DISC_BLE_RES_EVT"),
      std::make_pair(BTA_DM_GATT_OVER_LE_RES_EVT,
                     "BTA_DM_GATT_OVER_LE_RES_EVT"),
      std::make_pair(BTA_DM_DISC_CMPL_EVT, "BTA_DM_DISC_CMPL_EVT"),
      std::make_pair(BTA_DM_DISC_CMPL_EVT, "BTA_DM_DISC_CMPL_EVT"),
      std::make_pair(BTA_DM_SEARCH_CANCEL_CMPL_EVT,
      std::make_pair(BTA_DM_SEARCH_CANCEL_CMPL_EVT,
                     "BTA_DM_SEARCH_CANCEL_CMPL_EVT"),
                     "BTA_DM_SEARCH_CANCEL_CMPL_EVT"),
      std::make_pair(BTA_DM_GATT_OVER_SDP_RES_EVT,
                     "BTA_DM_GATT_OVER_SDP_RES_EVT"),
  };
  };
  for (const auto& event : events) {
  for (const auto& event : events) {
    ASSERT_STREQ(event.second.c_str(), dump_dm_search_event(event.first));
    ASSERT_STREQ(event.second.c_str(), dump_dm_search_event(event.first));