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

Commit 6089760e authored by Rahul Arya's avatar Rahul Arya Committed by Gerrit Code Review
Browse files

Merge "Always send BTA_DM_GATT_OVER_LE_RES_EVT"

parents d5177caf 3380f3dd
Loading
Loading
Loading
Loading
+42 −31
Original line number Diff line number Diff line
@@ -1474,26 +1474,33 @@ void bta_dm_search_cmpl() {

  uint16_t conn_id = bta_dm_search_cb.conn_id;

  tBTA_DM_SEARCH result;
  std::vector<Uuid> gatt_services;
  result.disc_ble_res.services = &gatt_services;
  result.disc_ble_res.bd_addr = bta_dm_search_cb.peer_bdaddr;
  strlcpy((char*)result.disc_ble_res.bd_name, bta_dm_get_remname(),
          BD_NAME_LEN + 1);

  bool send_gatt_results =
      bluetooth::common::init_flags::
              always_send_services_if_gatt_disc_done_is_enabled()
          ? bta_dm_search_cb.gatt_disc_active
          : false;

  /* no BLE connection, i.e. Classic service discovery end */
  if (conn_id == GATT_INVALID_CONN_ID) {
    bta_dm_search_cb.p_search_cback(BTA_DM_DISC_CMPL_EVT, nullptr);
    bta_dm_execute_queued_request();
    return;
    if (bta_dm_search_cb.gatt_disc_active) {
      LOG_WARN(
          "GATT active but no BLE connection, likely disconnected midway "
          "through");
    } else {
      LOG_INFO("No BLE connection, processing classic results");
    }

  } else {
    btgatt_db_element_t* db = NULL;
    int count = 0;
    BTA_GATTC_GetGattDb(conn_id, 0x0000, 0xFFFF, &db, &count);

  if (count == 0) {
    LOG_INFO("Empty GATT database - no BLE services discovered");
    bta_dm_search_cb.p_search_cback(BTA_DM_DISC_CMPL_EVT, nullptr);
    bta_dm_execute_queued_request();
    return;
  }

  std::vector<Uuid> gatt_services;

    if (count != 0) {
      for (int i = 0; i < count; i++) {
        // we process service entries only
        if (db[i].type == BTGATT_DB_PRIMARY_SERVICE) {
@@ -1501,18 +1508,23 @@ void bta_dm_search_cmpl() {
        }
      }
      osi_free(db);
      LOG_INFO(
          "GATT services discovered using LE Transport, will always send to "
          "upper layer");
      send_gatt_results = true;
    } else {
      LOG_WARN("Empty GATT database - no BLE services discovered");
    }
  }

  tBTA_DM_SEARCH result;
  result.disc_ble_res.services = &gatt_services;
  result.disc_ble_res.bd_addr = bta_dm_search_cb.peer_bdaddr;
  strlcpy((char*)result.disc_ble_res.bd_name, bta_dm_get_remname(),
          BD_NAME_LEN + 1);

  LOG_INFO("GATT services discovered using LE Transport");
  // send all result back to app
  if (send_gatt_results) {
    LOG_INFO("Sending GATT results to upper layer");
    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.gatt_disc_active = false;

#if TARGET_FLOSS
  if (DIS_ReadDISInfo(bta_dm_search_cb.peer_bdaddr, bta_dm_read_dis_cmpl,
@@ -4249,7 +4261,6 @@ static void bta_dm_gatt_disc_complete(uint16_t conn_id, tGATT_STATUS status) {
      bta_dm_search_cb.conn_id = GATT_INVALID_CONN_ID;
    }
  }
  bta_dm_search_cb.gatt_disc_active = false;
}

/*******************************************************************************
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ table InitFlagsData {
    gd_hci_enabled:bool (privacy:"Any");
    gd_controller_enabled:bool (privacy:"Any");

    always_send_services_if_gatt_disc_done_is_enabled:bool (private:"Any");
    always_use_private_gatt_for_debugging_is_enabled:bool (private:"Any");
    asynchronously_start_l2cap_coc_is_enabled:bool (privacy:"Any");
    btaa_hci_is_enabled:bool (privacy:"Any");
+2 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ flatbuffers::Offset<bluetooth::common::InitFlagsData> bluetooth::dumpsys::InitFl
  builder.add_gd_hci_enabled(true);
  builder.add_gd_controller_enabled(true);

  builder.add_always_send_services_if_gatt_disc_done_is_enabled(
      initFlags::always_send_services_if_gatt_disc_done_is_enabled());
  builder.add_always_use_private_gatt_for_debugging_is_enabled(
      initFlags::always_use_private_gatt_for_debugging_is_enabled());
  builder.add_asynchronously_start_l2cap_coc_is_enabled(initFlags::asynchronously_start_l2cap_coc_is_enabled());
+1 −0
Original line number Diff line number Diff line
@@ -251,6 +251,7 @@ fn parse_hci_adapter(flags: &mut InitFlags, values: Vec<&str>) {
init_flags!(
    // LINT.IfChange
    flags: {
        always_send_services_if_gatt_disc_done = true,
        always_use_private_gatt_for_debugging,
        asynchronously_start_l2cap_coc = true,
        btaa_hci = true,
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ mod ffi {
        fn load(flags: Vec<String>);
        fn set_all_for_testing();

        fn always_send_services_if_gatt_disc_done_is_enabled() -> bool;
        fn always_use_private_gatt_for_debugging_is_enabled() -> bool;
        fn asynchronously_start_l2cap_coc_is_enabled() -> bool;
        fn btaa_hci_is_enabled() -> bool;