From 974d4b357ca799babd3497b7eddcb975a97fcf21 Mon Sep 17 00:00:00 2001 From: Janusz Sobczak Date: Wed, 26 Jul 2023 18:14:47 -0700 Subject: [PATCH] Skip SDP check for FP rfcomm connection on Windows The SDP checks fails but rfcomm connection works. Skipping the SDP check does not seem to have any ill side effects. PiperOrigin-RevId: 551370531 --- fastpair/fast_pair_service.cc | 1 + internal/platform/feature_flags.h | 4 ++++ .../implementation/windows/bluetooth_classic_medium.cc | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/fastpair/fast_pair_service.cc b/fastpair/fast_pair_service.cc index 791821b3..e511ce2a 100644 --- a/fastpair/fast_pair_service.cc +++ b/fastpair/fast_pair_service.cc @@ -43,6 +43,7 @@ namespace { constexpr char kFastPairPreferencesFilePath[] = "Google/Nearby/FastPair"; constexpr FeatureFlags::Flags fast_pair_feature_flags = FeatureFlags::Flags{ .enable_scan_for_fast_pair_advertisement = true, + .skip_service_discovery_before_connecting_to_rfcomm = true, }; constexpr absl::Duration kTimeout = absl::Seconds(3); } // namespace diff --git a/internal/platform/feature_flags.h b/internal/platform/feature_flags.h index 92d0e532..58f8835d 100644 --- a/internal/platform/feature_flags.h +++ b/internal/platform/feature_flags.h @@ -56,6 +56,10 @@ class FeatureFlags { // Controls enable or disable BLE scan advertisement for fast pair // service uuid 0x2cfe bool enable_scan_for_fast_pair_advertisement = false; + // Skip Service Discovery Protocol check if the remote party supports the + // requested service id before attempting to connect over rfcomm. SDP fails + // on Windows when connecting to FP service id but the rfcomm is successful. + bool skip_service_discovery_before_connecting_to_rfcomm = false; }; static const FeatureFlags& GetInstance() { diff --git a/internal/platform/implementation/windows/bluetooth_classic_medium.cc b/internal/platform/implementation/windows/bluetooth_classic_medium.cc index 431400ba..9daaa8d7 100644 --- a/internal/platform/implementation/windows/bluetooth_classic_medium.cc +++ b/internal/platform/implementation/windows/bluetooth_classic_medium.cc @@ -311,7 +311,10 @@ std::unique_ptr BluetoothClassicMedium::ConnectToService( RfcommDeviceService requested_service( GetRequestedService(current_device, service)); - if (!CheckSdp(requested_service)) { + if (!FeatureFlags::GetInstance() + .GetFlags() + .skip_service_discovery_before_connecting_to_rfcomm && + !CheckSdp(requested_service)) { NEARBY_LOGS(ERROR) << __func__ << ": Invalid SDP."; return nullptr; }