mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Added logic to stabilize endpoint IDs
PiperOrigin-RevId: 644407047
This commit is contained in:
committed by
Copybara-Service
parent
23031698dd
commit
4f386b95db
@@ -227,20 +227,34 @@ Status BasePcpHandler::StartAdvertising(
|
||||
"start-advertising",
|
||||
[this, client, &service_id, &info, &compatible_advertising_options,
|
||||
&response]() RUN_ON_PCP_HANDLER_THREAD() {
|
||||
// The endpoint id inside of the advertisement is different to high
|
||||
// visibility and low visibility mode. In order to decide if client
|
||||
// should grab the high visibility or low visibility id, it needs to
|
||||
// tell client which one right now, before
|
||||
// client#StartedAdvertising.
|
||||
if (ShouldEnterHighVisibilityMode(compatible_advertising_options)) {
|
||||
client->EnterHighVisibilityMode();
|
||||
if (NearbyFlags::GetInstance().GetBoolFlag(
|
||||
connections::config_package_nearby::nearby_connections_feature::
|
||||
kUseStableEndpointId)) {
|
||||
if (ShouldEnterStableEndpointIdMode(compatible_advertising_options)) {
|
||||
client->EnterStableEndpointIdMode();
|
||||
}
|
||||
} else {
|
||||
// The endpoint id inside of the advertisement is different to high
|
||||
// visibility and low visibility mode. In order to decide if client
|
||||
// should grab the high visibility or low visibility id, it needs to
|
||||
// tell client which one right now, before
|
||||
// client#StartedAdvertising.
|
||||
if (ShouldEnterHighVisibilityMode(compatible_advertising_options)) {
|
||||
client->EnterHighVisibilityMode();
|
||||
}
|
||||
}
|
||||
|
||||
auto result = StartAdvertisingImpl(
|
||||
client, service_id, client->GetLocalEndpointId(),
|
||||
info.endpoint_info, compatible_advertising_options);
|
||||
if (!result.status.Ok()) {
|
||||
client->ExitHighVisibilityMode();
|
||||
if (NearbyFlags::GetInstance().GetBoolFlag(
|
||||
connections::config_package_nearby::
|
||||
nearby_connections_feature::kUseStableEndpointId)) {
|
||||
client->ExitStableEndpointIdMode();
|
||||
} else {
|
||||
client->ExitHighVisibilityMode();
|
||||
}
|
||||
response.Set(result.status);
|
||||
return;
|
||||
}
|
||||
@@ -333,6 +347,17 @@ bool BasePcpHandler::ShouldEnterHighVisibilityMode(
|
||||
advertising_options.allowed.bluetooth;
|
||||
}
|
||||
|
||||
bool BasePcpHandler::ShouldEnterStableEndpointIdMode(
|
||||
const AdvertisingOptions& advertising_options) {
|
||||
if (advertising_options.use_stable_endpoint_id) {
|
||||
return true;
|
||||
} else if (advertising_options.low_power) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
BooleanMediumSelector BasePcpHandler::ComputeIntersectionOfSupportedMediums(
|
||||
const PendingConnectionInfo& connection_info) {
|
||||
absl::flat_hash_set<Medium> intersection;
|
||||
|
||||
Reference in New Issue
Block a user