system/bt
Révision | d8cdc6c2b802fbc0c5a5b4f1599a9e6d911e74b9 (tree) |
---|---|
l'heure | 2019-06-12 16:29:52 |
Auteur | weichinweng <weichinweng@goog...> |
Commiter | weichinweng |
Load gatt_database if it is empty in bta_gattc_process_indicate
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
Merged-In: Id3f3f0f33d5e0469a6f2ac6612fa9f5ea0b24142
@@ -478,7 +478,7 @@ void bta_gattc_conn(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { | ||
478 | 478 | p_clcb->p_srcb->state != BTA_GATTC_SERV_IDLE) { |
479 | 479 | if (p_clcb->p_srcb->state == BTA_GATTC_SERV_IDLE) { |
480 | 480 | p_clcb->p_srcb->state = BTA_GATTC_SERV_LOAD; |
481 | - if (bta_gattc_cache_load(p_clcb)) { | |
481 | + if (bta_gattc_cache_load(p_clcb->p_srcb)) { | |
482 | 482 | p_clcb->p_srcb->state = BTA_GATTC_SERV_IDLE; |
483 | 483 | bta_gattc_reset_discover_st(p_clcb->p_srcb, GATT_SUCCESS); |
484 | 484 | } else { |
@@ -1127,6 +1127,10 @@ bool bta_gattc_process_srvc_chg_ind(uint16_t conn_id, tBTA_GATTC_RCB* p_clrcb, | ||
1127 | 1127 | Uuid gattp_uuid = Uuid::From16Bit(UUID_SERVCLASS_GATT_SERVER); |
1128 | 1128 | Uuid srvc_chg_uuid = Uuid::From16Bit(GATT_UUID_GATT_SRV_CHGD); |
1129 | 1129 | |
1130 | + if (p_srcb->gatt_database.IsEmpty() && p_srcb->state == BTA_GATTC_SERV_IDLE) { | |
1131 | + bta_gattc_cache_load(p_srcb); | |
1132 | + } | |
1133 | + | |
1130 | 1134 | const gatt::Characteristic* p_char = |
1131 | 1135 | bta_gattc_get_characteristic_srcb(p_srcb, p_notify->handle); |
1132 | 1136 | if (!p_char) return false; |
@@ -703,15 +703,14 @@ void bta_gattc_get_gatt_db(uint16_t conn_id, uint16_t start_handle, | ||
703 | 703 | * |
704 | 704 | * Description Load GATT cache from storage for server. |
705 | 705 | * |
706 | - * Parameter p_clcb: pointer to server clcb, that will | |
706 | + * Parameter p_srcb: pointer to server cache, that will | |
707 | 707 | * be filled from storage |
708 | 708 | * Returns true on success, false otherwise |
709 | 709 | * |
710 | 710 | ******************************************************************************/ |
711 | -bool bta_gattc_cache_load(tBTA_GATTC_CLCB* p_clcb) { | |
711 | +bool bta_gattc_cache_load(tBTA_GATTC_SERV* p_srcb) { | |
712 | 712 | char fname[255] = {0}; |
713 | - bta_gattc_generate_cache_file_name(fname, sizeof(fname), | |
714 | - p_clcb->p_srcb->server_bda); | |
713 | + bta_gattc_generate_cache_file_name(fname, sizeof(fname), p_srcb->server_bda); | |
715 | 714 | |
716 | 715 | FILE* fd = fopen(fname, "rb"); |
717 | 716 | if (!fd) { |
@@ -748,7 +747,7 @@ bool bta_gattc_cache_load(tBTA_GATTC_CLCB* p_clcb) { | ||
748 | 747 | goto done; |
749 | 748 | } |
750 | 749 | |
751 | - p_clcb->p_srcb->gatt_database = gatt::Database::Deserialize(attr, &success); | |
750 | + p_srcb->gatt_database = gatt::Database::Deserialize(attr, &success); | |
752 | 751 | } |
753 | 752 | |
754 | 753 | done: |
@@ -451,7 +451,7 @@ extern tBTA_GATTC_CONN* bta_gattc_conn_find(const RawAddress& remote_bda); | ||
451 | 451 | extern tBTA_GATTC_CONN* bta_gattc_conn_find_alloc(const RawAddress& remote_bda); |
452 | 452 | extern bool bta_gattc_conn_dealloc(const RawAddress& remote_bda); |
453 | 453 | |
454 | -extern bool bta_gattc_cache_load(tBTA_GATTC_CLCB* p_clcb); | |
454 | +extern bool bta_gattc_cache_load(tBTA_GATTC_SERV* p_srcb); | |
455 | 455 | extern void bta_gattc_cache_reset(const RawAddress& server_bda); |
456 | 456 | |
457 | 457 | #endif /* BTA_GATTC_INT_H */ |