mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Optimize advertising on BLE device without extended support
PiperOrigin-RevId: 740159393
This commit is contained in:
committed by
Copybara-Service
parent
51ef2273ca
commit
cee47d9f98
@@ -83,6 +83,9 @@ constexpr auto kSafeToDisconnectVersion =
|
||||
// When true, use stable endpoint ID.
|
||||
constexpr auto kUseStableEndpointId =
|
||||
flags::Flag<bool>(kConfigPackage, "45639298", false);
|
||||
// When true, disable instant on lost on BLE without extended feature.
|
||||
constexpr auto kDisableInstantOnLostOnBleWithoutExtended =
|
||||
flags::Flag<bool>(kConfigPackage, "45687098", false);
|
||||
|
||||
} // namespace nearby_connections_feature
|
||||
} // namespace config_package_nearby
|
||||
|
||||
@@ -24,8 +24,10 @@
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/clock.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "connections/implementation/flags/nearby_connections_feature_flags.h"
|
||||
#include "connections/implementation/mediums/ble_v2/ble_utils.h"
|
||||
#include "connections/implementation/mediums/ble_v2/instant_on_lost_advertisement.h"
|
||||
#include "internal/flags/nearby_flags.h"
|
||||
#include "internal/platform/ble_v2.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
#include "internal/platform/cancelable_alarm.h"
|
||||
@@ -205,6 +207,16 @@ bool InstantOnLostManager::StartInstantOnLostAdvertisement() {
|
||||
|
||||
StopOnLostAdvertising();
|
||||
|
||||
if (NearbyFlags::GetInstance().GetBoolFlag(
|
||||
config_package_nearby::nearby_connections_feature::
|
||||
kDisableInstantOnLostOnBleWithoutExtended) &&
|
||||
!ble_medium_.IsExtendedAdvertisementsAvailable()) {
|
||||
LOG(WARNING)
|
||||
<< __func__
|
||||
<< ": Disabling instant on lost on BLE without extended advertising.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ble_medium_.StartAdvertising(advertisement_data, advertise_parameters)) {
|
||||
LOG(ERROR) << __func__
|
||||
<< ": Failed to start advertising for instant on lost.";
|
||||
|
||||
Reference in New Issue
Block a user