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

Commit b8e2f681 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

CSIS: Don't use cached RSI value

Using cached RSI value can speed up the service discovery process, but
it causing some issues.
Assumption in this code was that scan is performed from Settings, and
each time scan is started, we clean the cache, tBTM_INQ_INFO.
However, if app starts LE only scan (i.e. FastPair), we don't know how
old the result is, and can attempt to connect to devices that are long
gone.
For now, disable the use of RSI cache.

Test: Pair with FP capable devices multiple times in a row in span of
couple minutes, ensure both devices are paired each time
Bug: 285191013

Change-Id: Ia61acb37e8920527acd6d1b07e9c6fd7e84a0683
parent cd5215df
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#include "csis_types.h"
#include "gap_api.h"
#include "gatt_api.h"
#include "gd/common/init_flags.h"
#include "main/shim/le_scanning_manager.h"
#include "main/shim/shim.h"
#include "osi/include/osi.h"
@@ -1369,7 +1370,9 @@ class CsisClientImpl : public CsisClient {
  }

  void CsisActiveDiscovery(std::shared_ptr<CsisGroup> csis_group) {
    if (bluetooth::common::InitFlags::UseRsiFromCachedInquiryResults()) {
      CheckForGroupInInqDb(csis_group);
    }

    if ((csis_group->GetDiscoveryState() !=
         CsisDiscoveryState::CSIS_DISCOVERY_IDLE)) {
+4 −0
Original line number Diff line number Diff line
@@ -68,6 +68,10 @@ class InitFlags final {
    return init_flags::leaudio_targeted_announcement_reconnection_mode_is_enabled();
  }

  inline static bool UseRsiFromCachedInquiryResults() {
    return init_flags::use_rsi_from_cached_inqiry_results_is_enabled();
  }

  inline static int GetAdapterIndex() {
    return init_flags::get_hci_adapter();
  }
+6 −0
Original line number Diff line number Diff line
@@ -104,3 +104,9 @@ TEST(InitFlagsTest, test_enable_bluetooth_quality_report_callback) {
  InitFlags::Load(input);
  ASSERT_TRUE(InitFlags::IsBluetoothQualityReportCallbackEnabled());
}

TEST(InitFlagsTest, test_enable_use_rsi_from_cached_inqiry_results) {
  const char* input[] = {"INIT_use_rsi_from_cached_inqiry_results=true", nullptr};
  InitFlags::Load(input);
  ASSERT_TRUE(InitFlags::UseRsiFromCachedInquiryResults());
}
+1 −0
Original line number Diff line number Diff line
@@ -403,6 +403,7 @@ init_flags!(
        trigger_advertising_callbacks_on_first_resume_after_pause = true,
        use_unified_connection_manager,
        sdp_return_classic_services_when_le_discovery_fails = true,
        use_rsi_from_cached_inqiry_results = false,
    }
    // dynamic flags can be updated at runtime and should be accessed directly
    // to check.
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ mod ffi {
        fn trigger_advertising_callbacks_on_first_resume_after_pause_is_enabled() -> bool;
        fn use_unified_connection_manager_is_enabled() -> bool;
        fn sdp_return_classic_services_when_le_discovery_fails_is_enabled() -> bool;
        fn use_rsi_from_cached_inqiry_results_is_enabled() -> bool;
    }
}