Pause Bluetooth classic discovery

PiperOrigin-RevId: 647333108
This commit is contained in:
Guogang Li
2024-06-27 08:52:58 -07:00
committed by Copybara-Service
parent f63912cc28
commit 32cee3439b
13 changed files with 380 additions and 53 deletions
+1
View File
@@ -209,6 +209,7 @@ cc_library(
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/time",
"@com_google_absl//absl/types:optional",
],
@@ -160,6 +160,8 @@ Exception BleV2ServerSocket::DoClose() {
BleV2Medium::BleV2Medium(api::BluetoothAdapter& adapter)
: adapter_(static_cast<BluetoothAdapter*>(&adapter)) {
adapter_->SetBleV2Medium(this);
is_extended_advertisements_available_ =
MediumEnvironment::Instance().IsBleExtendedAdvertisementsAvailable();
MediumEnvironment::Instance().RegisterBleV2Medium(*this, &peripheral_);
}
@@ -326,7 +328,7 @@ std::unique_ptr<api::ble_v2::GattClient> BleV2Medium::ConnectToGattServer(
}
bool BleV2Medium::IsExtendedAdvertisementsAvailable() {
return MediumEnvironment::Instance().IsBleExtendedAdvertisementsAvailable();
return is_extended_advertisements_available_;
}
bool BleV2Medium::GetRemotePeripheral(const std::string& mac_address,
@@ -332,6 +332,7 @@ class BleV2Medium : public api::ble_v2::BleMedium {
ABSL_GUARDED_BY(mutex_);
absl::flat_hash_set<std::pair<Uuid, std::uint32_t>>
scanning_internal_session_ids_ ABSL_GUARDED_BY(mutex_);
bool is_extended_advertisements_available_ = false;
};
} // namespace g3
+4 -1
View File
@@ -24,9 +24,11 @@
#include "absl/container/flat_hash_set.h"
#include "absl/status/status.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "absl/types/optional.h"
#include "internal/platform/borrowable.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/count_down_latch.h"
#include "internal/platform/feature_flags.h"
@@ -35,6 +37,7 @@
#include "internal/platform/implementation/bluetooth_adapter.h"
#include "internal/platform/implementation/bluetooth_classic.h"
#include "internal/platform/implementation/wifi_direct.h"
#include "internal/platform/implementation/wifi_hotspot.h"
#include "internal/platform/implementation/wifi_lan.h"
#include "internal/platform/logging.h"
#include "internal/platform/mutex_lock.h"
@@ -1153,7 +1156,7 @@ std::optional<FakeClock*> MediumEnvironment::GetSimulatedClock() {
if (simulated_clock_) {
return std::optional<FakeClock*>(simulated_clock_.get());
}
return absl::nullopt;
return std::nullopt;
}
void MediumEnvironment::RegisterGattServer(