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

Commit 5c01e711 authored by David Duarte's avatar David Duarte
Browse files

Remove gatt_robust_caching_client flag

Bug: 290844234
Fix: 290844234
Test: m com.android.btservices
Change-Id: Ia16d360e669ab63eb0776cf7dc331416e5d22ae2
parent 30bd4820
Loading
Loading
Loading
Loading
+6 −16
Original line number Diff line number Diff line
@@ -569,9 +569,7 @@ void bta_gattc_conn(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) {
        p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC;

        /* set true to read database hash before service discovery */
        if (bta_gattc_is_robust_caching_enabled()) {
        p_clcb->p_srcb->srvc_hdl_db_hash = true;
        }

        /* cache load failure, start discovery */
        bta_gattc_start_discover(p_clcb, NULL);
@@ -589,9 +587,7 @@ void bta_gattc_conn(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) {
      p_clcb->p_srcb->srvc_hdl_chg = false;

      /* set true to read database hash before service discovery */
      if (bta_gattc_is_robust_caching_enabled()) {
      p_clcb->p_srcb->srvc_hdl_db_hash = true;
      }

      /* start discovery */
      bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
@@ -919,8 +915,7 @@ void bta_gattc_continue_with_version_and_cache_known(
  }

  /* read db hash if db hash characteristic exists */
  if (bta_gattc_is_robust_caching_enabled() &&
      p_clcb->p_srcb->srvc_hdl_db_hash &&
  if (p_clcb->p_srcb->srvc_hdl_db_hash &&
      bta_gattc_read_db_hash(p_clcb, is_svc_chg)) {
    log::info("pending service discovery, read db hash first conn_id:{}",
              loghex(p_clcb->bta_conn_id));
@@ -1309,8 +1304,7 @@ void bta_gattc_op_cmpl(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) {

  // If receive DATABASE_OUT_OF_SYNC error code, bta_gattc should start service
  // discovery immediately
  if (bta_gattc_is_robust_caching_enabled() &&
      p_data->op_cmpl.status == GATT_DATABASE_OUT_OF_SYNC) {
  if (p_data->op_cmpl.status == GATT_DATABASE_OUT_OF_SYNC) {
    log::info("DATABASE_OUT_OF_SYNC, re-discover service");
    p_clcb->auto_update = BTA_GATTC_REQ_WAITING;
    /* request read db hash first */
@@ -1323,9 +1317,7 @@ void bta_gattc_op_cmpl(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) {
    p_clcb->auto_update = BTA_GATTC_REQ_WAITING;

    /* request read db hash first */
    if (bta_gattc_is_robust_caching_enabled()) {
    p_clcb->p_srcb->srvc_hdl_db_hash = true;
    }

    bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
    return;
@@ -1523,9 +1515,7 @@ static bool bta_gattc_process_srvc_chg_ind(uint16_t conn_id,
    /* if connection available, refresh cache by doing discovery now */
    if (p_clcb) {
      /* request read db hash first */
      if (bta_gattc_is_robust_caching_enabled()) {
      p_srcb->srvc_hdl_db_hash = true;
      }
      bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
    }
  }
+19 −39
Original line number Diff line number Diff line
@@ -137,12 +137,6 @@ RobustCachingSupport GetRobustCachingSupport(const tBTA_GATTC_CLCB* p_clcb,
  log::debug("GetRobustCachingSupport {}",
             p_clcb->bda.ToRedactedStringForLogging());

  // If the feature is disabled, then we never support it
  if (!bta_gattc_is_robust_caching_enabled()) {
    log::debug("robust caching is disabled, so UNSUPPORTED");
    return RobustCachingSupport::UNSUPPORTED;
  }

  // An empty database means that discovery hasn't taken place yet, so
  // we can't infer anything from that
  if (!db.IsEmpty()) {
@@ -305,13 +299,6 @@ static void bta_gattc_explore_srvc_finished(uint16_t conn_id,
  /* save cache to NV */
  p_clcb->p_srcb->state = BTA_GATTC_SERV_SAVE;

  // If robust caching is not enabled, use original design
  if (!bta_gattc_is_robust_caching_enabled()) {
    if (btm_sec_is_a_bonded_dev(p_srvc_cb->server_bda)) {
      bta_gattc_cache_write(p_clcb->p_srcb->server_bda,
                            p_clcb->p_srcb->gatt_database);
    }
  } else {
  // If robust caching is enabled, do something optimized
  Octet16 hash = p_clcb->p_srcb->gatt_database.Hash();
  bool success = bta_gattc_hash_write(hash, p_clcb->p_srcb->gatt_database);
@@ -324,11 +311,9 @@ static void bta_gattc_explore_srvc_finished(uint16_t conn_id,
  }

  // After success, reset the count.
    log::debug(
        "service discovery succeed, reset count to zero, conn_id=0x{:04x}",
  log::debug("service discovery succeed, reset count to zero, conn_id=0x{:04x}",
             conn_id);
  p_srvc_cb->srvc_disc_count = 0;
  }

  bta_gattc_reset_discover_st(p_clcb->p_srcb, GATT_SUCCESS);
}
@@ -472,16 +457,12 @@ void bta_gattc_op_cmpl_during_discovery(tBTA_GATTC_CLCB* p_clcb,
      bta_gattc_read_ext_prop_desc_cmpl(p_clcb, &p_data->op_cmpl);
      break;
    case BTA_GATTC_DISCOVER_REQ_READ_DB_HASH:
    case BTA_GATTC_DISCOVER_REQ_READ_DB_HASH_FOR_SVC_CHG:
      if (bta_gattc_is_robust_caching_enabled()) {
    case BTA_GATTC_DISCOVER_REQ_READ_DB_HASH_FOR_SVC_CHG: {
      bool is_svc_chg = (p_clcb->request_during_discovery ==
                         BTA_GATTC_DISCOVER_REQ_READ_DB_HASH_FOR_SVC_CHG);
      bta_gattc_read_db_hash_cmpl(p_clcb, &p_data->op_cmpl, is_svc_chg);
      } else {
        // it is not possible here if flag is off, but just in case
        p_clcb->request_during_discovery = BTA_GATTC_DISCOVER_REQ_NONE;
      }
      break;
    }
    case BTA_GATTC_DISCOVER_REQ_NONE:
    default:
      break;
@@ -538,8 +519,7 @@ void bta_gattc_disc_cmpl_cback(uint16_t conn_id, tGATT_DISC_TYPE disc_type,
    if (status == GATT_SUCCESS) p_clcb->status = status;

    // if db out of sync is received, try to start service discovery if possible
    if (bta_gattc_is_robust_caching_enabled() &&
        status == GATT_DATABASE_OUT_OF_SYNC) {
    if (status == GATT_DATABASE_OUT_OF_SYNC) {
      if (p_srvc_cb &&
          p_srvc_cb->srvc_disc_count < BTA_GATTC_DISCOVER_RETRY_COUNT) {
        p_srvc_cb->srvc_disc_count++;
+0 −1
Original line number Diff line number Diff line
@@ -471,7 +471,6 @@ void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV* p_srcb,
                                        uint16_t conn_id, uint16_t start_handle,
                                        uint16_t end_handle);
tBTA_GATTC_SERV* bta_gattc_find_srvr_cache(const RawAddress& bda);
bool bta_gattc_is_robust_caching_enabled();

/* discovery functions */
void bta_gattc_disc_res_cback(uint16_t conn_id, tGATT_DISC_TYPE disc_type,
+1 −14
Original line number Diff line number Diff line
@@ -798,19 +798,6 @@ tBTA_GATTC_CLCB* bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA* p_msg) {
  return p_clcb;
}

/*******************************************************************************
 *
 * Function         bta_gattc_is_robust_caching_enabled
 *
 * Description      check if robust caching is enabled
 *
 * Returns          true if enabled; otherwise false
 *
 ******************************************************************************/
bool bta_gattc_is_robust_caching_enabled() {
  return bluetooth::common::init_flags::gatt_robust_caching_client_is_enabled();
}

void bta_gatt_client_dump(int fd) {
  std::stringstream stream;
  int entry_count = 0;
+0 −1
Original line number Diff line number Diff line
@@ -232,7 +232,6 @@ init_flags!(
        classic_discovery_only,
        device_iot_config_logging,
        dynamic_avrcp_version_enhancement = true,
        gatt_robust_caching_client = true,
        gatt_robust_caching_server,
        hci_adapter: i32,
        hfp_dynamic_version = true,
Loading