mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Add use_stable_endpoint_id to AdvertisingOptions
PiperOrigin-RevId: 638501216
This commit is contained in:
committed by
Copybara-Service
parent
b2efc04bb2
commit
9b8d708a7f
@@ -33,6 +33,8 @@ struct AdvertisingOptions : public OptionsBase {
|
||||
bool low_power;
|
||||
bool enable_bluetooth_listening;
|
||||
bool enable_webrtc_listening;
|
||||
// Indicates whether the endpoint id should be stable.
|
||||
bool use_stable_endpoint_id = false;
|
||||
|
||||
// Whether this is intended to be used in conjunction with InjectEndpoint().
|
||||
bool is_out_of_band_connection = false;
|
||||
|
||||
+31
-21
@@ -270,21 +270,26 @@ void Core::StartAdvertisingV3(absl::string_view service_id,
|
||||
|
||||
CheckServiceId(service_id);
|
||||
CHECK(advertising_options.strategy.IsValid());
|
||||
AdvertisingOptions old_advertising_options = {
|
||||
{
|
||||
advertising_options.strategy,
|
||||
advertising_options.advertising_mediums,
|
||||
},
|
||||
advertising_options.auto_upgrade_bandwidth,
|
||||
advertising_options.enforce_topology_constraints,
|
||||
advertising_options.power_level == PowerLevel::kLowPower, // low_power
|
||||
advertising_options.enable_bluetooth_listening,
|
||||
advertising_options.advertising_mediums.web_rtc,
|
||||
false, // is_out_of_band_connection
|
||||
advertising_options.fast_advertisement_service_uuid,
|
||||
"" // device_info
|
||||
};
|
||||
// TODO(b/291295755): Refactor deeper to use v3 options throughout.
|
||||
AdvertisingOptions old_advertising_options = {
|
||||
/*OptionsBase=*/
|
||||
{
|
||||
/*strategy=*/advertising_options.strategy,
|
||||
/*allowed=*/advertising_options.advertising_mediums,
|
||||
},
|
||||
/*auto_upgrade_bandwidth=*/advertising_options.auto_upgrade_bandwidth,
|
||||
/*enforce_topology_constraints=*/
|
||||
advertising_options.enforce_topology_constraints,
|
||||
/*low_power=*/advertising_options.power_level == PowerLevel::kLowPower,
|
||||
/*enable_bluetooth_listening=*/
|
||||
advertising_options.enable_bluetooth_listening,
|
||||
/*enable_webrtc_listening=*/
|
||||
advertising_options.advertising_mediums.web_rtc,
|
||||
/*use_stable_endpoint_id=*/advertising_options.use_stable_endpoint_id,
|
||||
/*is_out_of_band_connection=*/false,
|
||||
/*fast_advertisement_service_uuid=*/
|
||||
advertising_options.fast_advertisement_service_uuid,
|
||||
/*device_info=*/""};
|
||||
router_->StartAdvertising(&client_, service_id, old_advertising_options,
|
||||
old_info, std::move(callback));
|
||||
}
|
||||
@@ -505,19 +510,24 @@ void Core::UpdateAdvertisingOptionsV3(
|
||||
ResultCallback result_cb) {
|
||||
// TODO(b/291295755): Deeper refactor to use new advertising options.
|
||||
AdvertisingOptions old_advertising_options = {
|
||||
/*OptionsBase=*/
|
||||
{
|
||||
advertising_options.strategy,
|
||||
advertising_options.advertising_mediums,
|
||||
/*strategy=*/advertising_options.strategy,
|
||||
/*allowed=*/advertising_options.advertising_mediums,
|
||||
},
|
||||
advertising_options.auto_upgrade_bandwidth,
|
||||
/*auto_upgrade_bandwidth=*/advertising_options.auto_upgrade_bandwidth,
|
||||
/*enforce_topology_constraints=*/
|
||||
advertising_options.enforce_topology_constraints,
|
||||
advertising_options.power_level == PowerLevel::kLowPower, // low_power
|
||||
/*low_power=*/advertising_options.power_level == PowerLevel::kLowPower,
|
||||
/*enable_bluetooth_listening=*/
|
||||
advertising_options.enable_bluetooth_listening,
|
||||
/*enable_webrtc_listening=*/
|
||||
advertising_options.advertising_mediums.web_rtc,
|
||||
false, // is_out_of_band_connection
|
||||
/*use_stable_endpoint_id=*/advertising_options.use_stable_endpoint_id,
|
||||
/*is_out_of_band_connection=*/false,
|
||||
/*fast_advertisement_service_uuid=*/
|
||||
advertising_options.fast_advertisement_service_uuid,
|
||||
"" // device_info
|
||||
};
|
||||
/*device_info=*/""};
|
||||
router_->UpdateAdvertisingOptionsV3(
|
||||
&client_, service_id, old_advertising_options, std::move(result_cb));
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ struct AdvertisingOptions {
|
||||
// If Nearby Connections should auto-upgrade bandwidth.
|
||||
bool auto_upgrade_bandwidth = true;
|
||||
bool enforce_topology_constraints = true;
|
||||
// Indicates whether the endpoint id should be stable.
|
||||
bool use_stable_endpoint_id = false;
|
||||
std::string fast_advertisement_service_uuid;
|
||||
BooleanMediumSelector advertising_mediums;
|
||||
BooleanMediumSelector upgrade_mediums;
|
||||
|
||||
@@ -277,6 +277,7 @@ void NearbyConnectionsManagerImpl::StartAdvertising(
|
||||
/*enable_bluetooth_listening=*/use_ble,
|
||||
/*enable_webrtc_listening=*/
|
||||
ShouldEnableWebRtc(connectivity_manager_, data_usage, power_level),
|
||||
/*use_stable_endpoint_id=*/false,
|
||||
/*fast_advertisement_service_uuid=*/
|
||||
fast_advertisement_service_uuid),
|
||||
std::move(connection_listener), std::move(callback));
|
||||
|
||||
@@ -75,6 +75,7 @@ void NearbyConnectionsServiceImpl::StartAdvertising(
|
||||
options.enable_bluetooth_listening =
|
||||
advertising_options.enable_bluetooth_listening;
|
||||
options.enable_webrtc_listening = advertising_options.enable_webrtc_listening;
|
||||
options.use_stable_endpoint_id = advertising_options.use_stable_endpoint_id;
|
||||
options.fast_advertisement_service_uuid =
|
||||
advertising_options.fast_advertisement_service_uuid.uuid;
|
||||
|
||||
|
||||
@@ -205,6 +205,7 @@ struct AdvertisingOptions {
|
||||
bool enforce_topology_constraints,
|
||||
bool enable_bluetooth_listening,
|
||||
bool enable_webrtc_listening,
|
||||
bool use_stable_endpoint_id,
|
||||
Uuid fast_advertisement_service_uuid) {
|
||||
this->strategy = strategy;
|
||||
this->allowed_mediums = allowed_mediums;
|
||||
@@ -212,6 +213,7 @@ struct AdvertisingOptions {
|
||||
this->enforce_topology_constraints = enforce_topology_constraints;
|
||||
this->enable_bluetooth_listening = enable_bluetooth_listening;
|
||||
this->enable_webrtc_listening = enable_webrtc_listening;
|
||||
this->use_stable_endpoint_id = use_stable_endpoint_id;
|
||||
this->fast_advertisement_service_uuid = fast_advertisement_service_uuid;
|
||||
}
|
||||
|
||||
@@ -238,6 +240,9 @@ struct AdvertisingOptions {
|
||||
// By default, this option is false. If true, this allows listening on
|
||||
// incoming WebRTC connections while advertising.
|
||||
bool enable_webrtc_listening = false;
|
||||
// Indicates whether the endpoint id should be stable. When visibility is
|
||||
// everyone mode, we should set this to true to avoid duplicated endpoint ids.
|
||||
bool use_stable_endpoint_id = false;
|
||||
// Optional. If set, BLE advertisements will be in their "fast advertisement"
|
||||
// form, use this UUID, and non-connectable; if empty, BLE advertisements
|
||||
// will otherwise be normal and connectable.
|
||||
|
||||
Reference in New Issue
Block a user