OSDN Git Service

DO NOT MERGE ANYWHERE: Disable the use of GATT cache by default.
authorJacky Cheung <jackyc@google.com>
Tue, 7 Nov 2017 19:17:38 +0000 (11:17 -0800)
committerZheng Zhang <zhzh@google.com>
Thu, 30 Nov 2017 20:31:41 +0000 (20:31 +0000)
When a set of GATT services of a bonded device is cached locally,
an application needs to call BluetoothGatt.refresh() to clear it out
and to trigger a new service discovery.  By disabling local caching,
a service discovery is performed on every connection and that prevents
an application from getting staled GATT services.

bug: 68954828
Change-Id: I2c07404c3d56a5c8a0ffc86bc65d36480f3c46f2

bta/gatt/bta_gattc_cache.c
include/bt_target.h

index d283b38..62b4d81 100644 (file)
@@ -1517,6 +1517,12 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
 *******************************************************************************/
 bool bta_gattc_cache_load(tBTA_GATTC_CLCB *p_clcb)
 {
+
+#if (defined WEAR_DISABLE_GATT_CACHE && WEAR_DISABLE_GATT_CACHE == TRUE)
+    LOG_WARN(LOG_TAG, "%s GATT cache not used.", __func__);
+    return false;
+#endif
+
     char fname[255] = {0};
     bta_gattc_generate_cache_file_name(fname, p_clcb->p_srcb->server_bda);
 
index be427f5..c339d9f 100644 (file)
@@ -1592,4 +1592,12 @@ The maximum number of payload octets that the local device can receive in a sing
 #define WEAR_AUTO_CONN_IDLE_INTERVAL_1_25_MS  72
 #endif
 
+/*
+ * Disable the use of local GATT cache.  This forces service discovery on connection
+ * establishment.
+ */
+#ifndef WEAR_DISABLE_GATT_CACHE
+#define WEAR_DISABLE_GATT_CACHE               TRUE
+#endif
+
 #endif /* BT_TARGET_H */