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

Commit bf2260c4 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

bta_gattc_cache: Use GATT caching for devices with LMP version 5.1

This is a workaround for devices which are on the market and does not
like Androids Database hash read.

With this patch, Android requires LMP version 5.1 to read Database hash.

Bug: 241324007
Test: Manual testes with devices with different LMP version
Test: atest BluetoothInstrumentationTests
Tag: #feature
Change-Id: If48656d7eac5daeb1d7befce921270c1911b45e2
parent 9c3630f6
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -768,6 +768,26 @@ void bta_gattc_start_discover(tBTA_GATTC_CLCB* p_clcb,
      p_clcb->p_srcb->update_count = 0;
      p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC_ACT;

      /* This is workaround for the embedded devices being already on the market
       * and having a serious problem with handle Read By Type with
       * GATT_UUID_DATABASE_HASH. With this workaround, Android will assume that
       * embedded device having LMP version lower than 5.1 (0x0a), it does not
       * support GATT Caching.
       */
      uint8_t lmp_version = 0;
      if (!BTM_ReadRemoteVersion(p_clcb->bda, &lmp_version, nullptr, nullptr)) {
        LOG_WARN("Could not read remote version for %s",
                 p_clcb->bda.ToString().c_str());
      }

      if (lmp_version < 0x0a) {
        LOG_WARN(
            " Device LMP version 0x%02x < Bluetooth 5.1. Ignore database cache "
            "read.",
            lmp_version);
        p_clcb->p_srcb->srvc_hdl_db_hash = false;
      }

      /* read db hash if db hash characteristic exists */
      if (bta_gattc_is_robust_caching_enabled() &&
          p_clcb->p_srcb->srvc_hdl_db_hash &&