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

Commit a2dce06e authored by Jack He's avatar Jack He Committed by Android (Google) Code Review
Browse files

Merge changes I09303d9b,I2910ab5f,Iae2cd514 into tm-qpr-dev

* changes:
  Enable robust caching for client side by default
  Change flag for client bit mask
  Read local cache directly if bonded
parents 4ad67445 36b0b88a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5089,7 +5089,7 @@ public class AdapterService extends Service {
            initFlags.add(String.format("%s=%s", GD_LINK_POLICY_FLAG, "true"));
        }
        if (DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_BLUETOOTH,
                GATT_ROBUST_CACHING_CLIENT_FLAG, false)) {
                GATT_ROBUST_CACHING_CLIENT_FLAG, true)) {
            initFlags.add(String.format("%s=%s", GATT_ROBUST_CACHING_CLIENT_FLAG, "true"));
        }
        if (DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_BLUETOOTH,
+2 −5
Original line number Diff line number Diff line
@@ -536,12 +536,9 @@ void bta_gattc_conn(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) {
      p_clcb->p_srcb->state != BTA_GATTC_SERV_IDLE) {
    if (p_clcb->p_srcb->state == BTA_GATTC_SERV_IDLE) {
      p_clcb->p_srcb->state = BTA_GATTC_SERV_LOAD;
      // Consider the case that if GATT Server is changed, but no service
      // changed indication is received, the database might be out of date. So
      // if robust caching is enabled, any time when connection is established,
      // always check the db hash first, not just load the stored database.
      // For bonded devices, read cache directly, and back to connected state.
      gatt::Database db = bta_gattc_cache_load(p_clcb->p_srcb->server_bda);
      if (!bta_gattc_is_robust_caching_enabled() && !db.IsEmpty()) {
      if (!db.IsEmpty() && btm_sec_is_a_bonded_dev(p_clcb->p_srcb->server_bda)) {
        p_clcb->p_srcb->gatt_database = db;
        p_clcb->p_srcb->state = BTA_GATTC_SERV_IDLE;
        bta_gattc_reset_discover_st(p_clcb->p_srcb, GATT_SUCCESS);
+16 −1
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ static void gatt_cl_op_cmpl_cback(uint16_t conn_id, tGATTC_OPTYPE op,

static void gatt_cl_start_config_ccc(tGATT_PROFILE_CLCB* p_clcb);

static bool gatt_cl_is_robust_caching_enabled();

static bool gatt_sr_is_robust_caching_enabled();

static bool read_sr_supported_feat_req(
@@ -430,7 +432,7 @@ void gatt_profile_db_init(void) {
  gatt_cb.gatt_svr_supported_feat_mask |= BLE_GATT_SVR_SUP_FEAT_EATT_BITMASK;
  gatt_cb.gatt_cl_supported_feat_mask |= BLE_GATT_CL_ANDROID_SUP_FEAT;

  if (gatt_sr_is_robust_caching_enabled())
  if (gatt_cl_is_robust_caching_enabled())
    gatt_cb.gatt_cl_supported_feat_mask |= BLE_GATT_CL_SUP_FEAT_CACHING_BITMASK;

  VLOG(1) << __func__ << ": gatt_if=" << gatt_cb.gatt_if << " EATT supported";
@@ -846,6 +848,19 @@ bool gatt_profile_get_eatt_support(const RawAddress& remote_bda) {
  return tcb.sr_supp_feat & BLE_GATT_SVR_SUP_FEAT_EATT_BITMASK;
}

/*******************************************************************************
 *
 * Function         gatt_cl_is_robust_caching_enabled
 *
 * Description      Check if Robust Caching is enabled on client side.
 *
 * Returns          true if enabled in gd flag, otherwise false
 *
 ******************************************************************************/
static bool gatt_cl_is_robust_caching_enabled() {
  return bluetooth::common::init_flags::gatt_robust_caching_client_is_enabled();
}

/*******************************************************************************
 *
 * Function         gatt_sr_is_robust_caching_enabled