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

Commit 43e38a9e authored by weichinweng's avatar weichinweng Committed by android-build-merger
Browse files

Load gatt_database if it is empty in bta_gattc_process_indicate

am: 67d83bab

Change-Id: Ic21850a535194b85aa558fe97b8118e0e089581e
parents a37b6595 67d83bab
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -478,7 +478,7 @@ void bta_gattc_conn(tBTA_GATTC_CLCB* p_clcb, 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;
      if (bta_gattc_cache_load(p_clcb)) {
      if (bta_gattc_cache_load(p_clcb->p_srcb)) {
        p_clcb->p_srcb->state = BTA_GATTC_SERV_IDLE;
        bta_gattc_reset_discover_st(p_clcb->p_srcb, GATT_SUCCESS);
      } else {
@@ -1127,6 +1127,10 @@ bool bta_gattc_process_srvc_chg_ind(uint16_t conn_id, tBTA_GATTC_RCB* p_clrcb,
  Uuid gattp_uuid = Uuid::From16Bit(UUID_SERVCLASS_GATT_SERVER);
  Uuid srvc_chg_uuid = Uuid::From16Bit(GATT_UUID_GATT_SRV_CHGD);

  if (p_srcb->gatt_database.IsEmpty() && p_srcb->state == BTA_GATTC_SERV_IDLE) {
    bta_gattc_cache_load(p_srcb);
  }

  const gatt::Characteristic* p_char =
      bta_gattc_get_characteristic_srcb(p_srcb, p_notify->handle);
  if (!p_char) return false;
+4 −5
Original line number Diff line number Diff line
@@ -703,15 +703,14 @@ void bta_gattc_get_gatt_db(uint16_t conn_id, uint16_t start_handle,
 *
 * Description      Load GATT cache from storage for server.
 *
 * Parameter        p_clcb: pointer to server clcb, that will
 * Parameter        p_srcb: pointer to server cache, that will
 *                          be filled from storage
 * Returns          true on success, false otherwise
 *
 ******************************************************************************/
bool bta_gattc_cache_load(tBTA_GATTC_CLCB* p_clcb) {
bool bta_gattc_cache_load(tBTA_GATTC_SERV* p_srcb) {
  char fname[255] = {0};
  bta_gattc_generate_cache_file_name(fname, sizeof(fname),
                                     p_clcb->p_srcb->server_bda);
  bta_gattc_generate_cache_file_name(fname, sizeof(fname), p_srcb->server_bda);

  FILE* fd = fopen(fname, "rb");
  if (!fd) {
@@ -748,7 +747,7 @@ bool bta_gattc_cache_load(tBTA_GATTC_CLCB* p_clcb) {
      goto done;
    }

    p_clcb->p_srcb->gatt_database = gatt::Database::Deserialize(attr, &success);
    p_srcb->gatt_database = gatt::Database::Deserialize(attr, &success);
  }

done:
+1 −1
Original line number Diff line number Diff line
@@ -451,7 +451,7 @@ extern tBTA_GATTC_CONN* bta_gattc_conn_find(const RawAddress& remote_bda);
extern tBTA_GATTC_CONN* bta_gattc_conn_find_alloc(const RawAddress& remote_bda);
extern bool bta_gattc_conn_dealloc(const RawAddress& remote_bda);

extern bool bta_gattc_cache_load(tBTA_GATTC_CLCB* p_clcb);
extern bool bta_gattc_cache_load(tBTA_GATTC_SERV* p_srcb);
extern void bta_gattc_cache_reset(const RawAddress& server_bda);

#endif /* BTA_GATTC_INT_H */