If Service Changed indication is received but gatt_database is empty,
will try to load database from storage.
Bug:
131814072
Bug:
134994428
Test: 1.CTS Bluetooth LE Secure Test. 2.Unit test.
3. Pair BLE device via APP. 4. Pair device via Bluetooth Setting
Change-Id: Id3f3f0f33d5e0469a6f2ac6612fa9f5ea0b24142
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 {
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;
*
* 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) {
goto done;
}
- p_clcb->p_srcb->gatt_database = gatt::Database::Deserialize(attr, &success);
+ p_srcb->gatt_database = gatt::Database::Deserialize(attr, &success);
}
done:
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 */