Internal change

PiperOrigin-RevId: 360321561
This commit is contained in:
hai007
2021-03-01 18:10:48 -08:00
committed by Copybara-Service
parent d5976e6857
commit 0c70dc054a
5 changed files with 274 additions and 18 deletions
+16 -3
View File
@@ -84,10 +84,19 @@ Status BasePcpHandler::StartAdvertising(ClientProxy* client,
ConnectionOptions advertising_options = options.CompatibleOptions();
RunOnPcpHandlerThread([this, client, &service_id, &info, &advertising_options,
&response]() {
// 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(advertising_options)) {
client->EnterHighVisibilityMode();
}
auto result =
StartAdvertisingImpl(client, service_id, client->GetLocalEndpointId(),
info.endpoint_info, advertising_options);
if (!result.status.Ok()) {
client->ExitHighVisibilityMode();
response.Set(result.status);
return;
}
@@ -103,9 +112,8 @@ Status BasePcpHandler::StartAdvertising(ClientProxy* client,
advertising_options);
response.Set({Status::kSuccess});
});
return WaitForResult(
absl::StrCat("StartAdvertising(", service_id, ")"),
client->GetClientId(), &response);
return WaitForResult(absl::StrCat("StartAdvertising(", service_id, ")"),
client->GetClientId(), &response);
}
void BasePcpHandler::StopAdvertising(ClientProxy* client) {
@@ -130,6 +138,11 @@ std::string BasePcpHandler::GetStringValueOfSupportedMediums(
return result.str();
}
bool BasePcpHandler::ShouldEnterHighVisibilityMode(
const ConnectionOptions& options) {
return !options.low_power && options.allowed.bluetooth;
}
Status BasePcpHandler::StartDiscovery(ClientProxy* client,
const std::string& service_id,
const ConnectionOptions& options,