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

Commit 4ca22cd4 authored by Brian Delwiche's avatar Brian Delwiche
Browse files

Fix premature GATT DB lookup

As part of a change made to support Robust Caching, our code makes an
early query against the peer's GATT database hash characteristic,
skipping the check only when the peer is known not to support Robust
Caching. However, the check is still made even on initial connection,
when the peer's support for Robust Caching is unknown and no database
entry exists for it.

Skip the check if the peer's support is unknown.

Bug: 295365121
Bug: 317128464
Test: atest net_test_stack_gatt
Change-Id: I0d3e406b0ce70edd11cdab0bb355cc448e40fed7
parent 9bae1793
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ cc_library_static {
    ],
    static_libs: [
        "avrcp-target-service",
        "bluetooth_flags_c_lib",
        "lib-bt-packets",
        "libbluetooth_crypto_toolbox",
        "libbluetooth_gd",
@@ -336,8 +337,10 @@ cc_test {
    shared_libs: [
        "libcrypto",
        "liblog",
        "server_configurable_flags",
    ],
    static_libs: [
        "bluetooth_flags_c_lib",
        "libbluetooth-types",
        "libbluetooth_crypto_toolbox",
        "libbluetooth_gd",
@@ -383,6 +386,7 @@ cc_test {
        "server_configurable_flags",
    ],
    static_libs: [
        "bluetooth_flags_c_lib",
        "libbluetooth-types",
        "libbluetooth_crypto_toolbox",
        "libbluetooth_gd",
+6 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@

#define LOG_TAG "bt_bta_gattc"

#include <android_bluetooth_flags.h>
#include <base/functional/bind.h>
#include <base/logging.h>
#include <base/strings/stringprintf.h>
@@ -905,8 +906,11 @@ void bta_gattc_continue_discovery_if_needed(const RawAddress& bd_addr,
void bta_gattc_continue_with_version_and_cache_known(
    tBTA_GATTC_CLCB* p_clcb, RobustCachingSupport cache_support,
    bool is_svc_chg) {
  if (cache_support == RobustCachingSupport::UNSUPPORTED) {
    // Skip initial DB hash read if we have strong reason (due to interop,
  if (cache_support == RobustCachingSupport::UNSUPPORTED ||
      (IS_FLAG_ENABLED(skip_unknown_robust_caching) &&
       cache_support == RobustCachingSupport::UNKNOWN)) {
    // Skip initial DB hash read if no DB hash is known, or if
    // we have strong reason (due to interop,
    // or a prior discovery) to believe that it is unsupported.
    p_clcb->p_srcb->srvc_hdl_db_hash = false;
  }