Resolve conflics from previous commit.

This commit is contained in:
hai007
2020-10-09 17:34:34 -07:00
parent 5dc9b74a07
commit 5fd30491bc
30 changed files with 0 additions and 831 deletions
-59
View File
@@ -335,21 +335,6 @@ Status BasePcpHandler::RequestConnection(ClientProxy* client,
OnEndpointFound(client, webrtc_endpoint);
}
<<<<<<< HEAD
auto discovered_endpoints = GetDiscoveredEndpoints(endpoint_id);
std::unique_ptr<EndpointChannel> channel;
ConnectImplResult connect_impl_result;
auto remote_bluetooth_mac_address =
BluetoothUtils::ToString(options.remote_bluetooth_mac_address);
if (!remote_bluetooth_mac_address.empty()) {
auto additional_endpoint = GetRemoteBluetoothMacAddressEndpoint(
endpoint_id, remote_bluetooth_mac_address, discovered_endpoints);
if (additional_endpoint != nullptr)
discovered_endpoints.push_back(additional_endpoint.get());
}
=======
auto remote_bluetooth_mac_address =
BluetoothUtils::ToString(options.remote_bluetooth_mac_address);
if (!remote_bluetooth_mac_address.empty()) {
@@ -363,7 +348,6 @@ Status BasePcpHandler::RequestConnection(ClientProxy* client,
std::unique_ptr<EndpointChannel> channel;
ConnectImplResult connect_impl_result;
>>>>>>> release
for (auto connect_endpoint : discovered_endpoints) {
connect_impl_result = ConnectImpl(client, connect_endpoint);
if (connect_impl_result.status.Ok()) {
@@ -667,9 +651,6 @@ void BasePcpHandler::OnIncomingFrame(OfflineFrame& frame,
const ConnectionResponseFrame& connection_response =
frame.v1().connection_response();
<<<<<<< HEAD
if (connection_response.status() == Status::kSuccess) {
=======
// For backward compatible, here still check both status and
// response parameters until the response feature is roll out in all
// supported devices.
@@ -681,7 +662,6 @@ void BasePcpHandler::OnIncomingFrame(OfflineFrame& frame,
accepted = connection_response.status() == Status::kSuccess;
}
if (accepted) {
>>>>>>> release
NEARBY_LOG(INFO, "OnConnectionResponse: remote accepted; id=%s",
endpoint_id.c_str());
client->RemoteEndpointAcceptedConnection(endpoint_id);
@@ -1022,21 +1002,6 @@ proto::connections::Medium BasePcpHandler::ChooseBestUpgradeMedium(
return proto::connections::Medium::UNKNOWN_MEDIUM;
}
<<<<<<< HEAD
std::unique_ptr<BasePcpHandler::DiscoveredEndpoint>
BasePcpHandler::GetRemoteBluetoothMacAddressEndpoint(
std::string endpoint_id, std::string remote_bluetooth_mac_address,
std::vector<DiscoveredEndpoint*> endpoints) {
if (!discovery_options_.allowed.bluetooth) {
return nullptr;
}
if (endpoints.empty()) {
NEARBY_LOGS(INFO)
<< "Cannot append remote Bluetooth MAC Address, because endpointId "
<< endpoint_id << " has not been discovered";
return nullptr;
=======
bool BasePcpHandler::AddRemoteBluetoothMacAddressEndpoint(
std::string endpoint_id, std::string remote_bluetooth_mac_address) {
if (!discovery_options_.allowed.bluetooth) {
@@ -1050,22 +1015,15 @@ bool BasePcpHandler::AddRemoteBluetoothMacAddressEndpoint(
<< endpoint_id << " has not been discovered "
<< "[" << remote_bluetooth_mac_address << "]";
return false;
>>>>>>> release
}
for (auto endpoint : endpoints) {
if (endpoint->medium == proto::connections::Medium::BLUETOOTH) {
NEARBY_LOGS(INFO)
<<<<<<< HEAD
<< "Cannot append remote Bluetooth MAC Address, because the "
"endpoint has already been found over Bluetooth.";
return nullptr;
=======
<< "Cannot append remote Bluetooth MAC Address endpoint, because the "
"endpoint has already been found over Bluetooth "
<< "[" << remote_bluetooth_mac_address << "]";
return false;
>>>>>>> release
}
}
@@ -1073,16 +1031,6 @@ bool BasePcpHandler::AddRemoteBluetoothMacAddressEndpoint(
mediums_->GetBluetoothClassic().GetRemoteDevice(
remote_bluetooth_mac_address);
if (!remote_bluetooth_device.IsValid()) {
<<<<<<< HEAD
NEARBY_LOGS(INFO)
<< "Cannot append remote Bluetooth MAC Address, because a valid "
"Bluetooth device could not be derived.";
return nullptr;
}
auto bluetooth_endpoint =
std::make_unique<BluetoothEndpoint>(BluetoothEndpoint{
=======
NEARBY_LOGS(INFO) << "Cannot append remote Bluetooth MAC Address endpoint, "
"because a valid "
"Bluetooth device could not be derived "
@@ -1092,7 +1040,6 @@ bool BasePcpHandler::AddRemoteBluetoothMacAddressEndpoint(
auto bluetooth_endpoint =
std::make_shared<BluetoothEndpoint>(BluetoothEndpoint{
>>>>>>> release
{
endpoint_id,
endpoints[0]->endpoint_info,
@@ -1101,15 +1048,9 @@ bool BasePcpHandler::AddRemoteBluetoothMacAddressEndpoint(
},
remote_bluetooth_device,
});
<<<<<<< HEAD
NEARBY_LOGS(INFO) << "Appended remote Bluetooth device "
<< remote_bluetooth_mac_address;
return bluetooth_endpoint;
=======
discovered_endpoints_.emplace(endpoint_id, std::move(bluetooth_endpoint));
return true;
>>>>>>> release
}
void BasePcpHandler::EvaluateConnectionResult(ClientProxy* client,
-10
View File
@@ -84,8 +84,6 @@ Swapper<T> MakeSwapper(T* value) {
return Swapper<T>(value);
}
<<<<<<< HEAD
=======
// Represents the WebRtc state that mediums are connectable or not.
enum class WebRtcState {
kUndefined = 0,
@@ -93,7 +91,6 @@ enum class WebRtcState {
kUnconnectable = 2,
};
>>>>>>> release
// A base implementation of the PcpHandler interface that takes care of all
// bookkeeping and handshake protocols that are common across all PcpHandler
// implementations -- thus, every concrete PcpHandler implementation must extend
@@ -422,18 +419,11 @@ class BasePcpHandler : public PcpHandler,
proto::connections::Medium ChooseBestUpgradeMedium(
const std::vector<proto::connections::Medium>& supported_mediums);
<<<<<<< HEAD
std::unique_ptr<BasePcpHandler::DiscoveredEndpoint>
GetRemoteBluetoothMacAddressEndpoint(
std::string endpoint_id, std::string remote_bluetooth_mac_address,
std::vector<DiscoveredEndpoint*> endpoints);
=======
// Returns true if the bluetooth endpoint based on remote bluetooth mac
// address is created and added into discovered_endpoints_ with key
// endpoint_id.
bool AddRemoteBluetoothMacAddressEndpoint(
std::string endpoint_id, std::string remote_bluetooth_mac_address);
>>>>>>> release
void ProcessPreConnectionInitiationFailure(const std::string& endpoint_id,
EndpointChannel* channel,
-56
View File
@@ -16,10 +16,7 @@
#include <inttypes.h>
<<<<<<< HEAD
=======
#include "core_v2/internal/base_pcp_handler.h"
>>>>>>> release
#include "platform_v2/base/base_input_stream.h"
#include "platform_v2/public/logging.h"
#include "absl/strings/escaping.h"
@@ -32,45 +29,29 @@ BleAdvertisement::BleAdvertisement(Version version, Pcp pcp,
const ByteArray& service_id_hash,
const std::string& endpoint_id,
const ByteArray& endpoint_info,
<<<<<<< HEAD
const std::string& bluetooth_mac_address) {
DoInitialize(/*fast_advertisement=*/false, version, pcp, service_id_hash,
endpoint_id, endpoint_info, bluetooth_mac_address);
=======
const std::string& bluetooth_mac_address,
const ByteArray& uwb_address,
WebRtcState web_rtc_state) {
DoInitialize(/*fast_advertisement=*/false, version, pcp, service_id_hash,
endpoint_id, endpoint_info, bluetooth_mac_address, uwb_address,
web_rtc_state);
>>>>>>> release
}
BleAdvertisement::BleAdvertisement(Version version, Pcp pcp,
const std::string& endpoint_id,
<<<<<<< HEAD
const ByteArray& endpoint_info) {
DoInitialize(/*fast_advertisement=*/true, version, pcp, {}, endpoint_id,
endpoint_info, {});
=======
const ByteArray& endpoint_info,
const ByteArray& uwb_address) {
DoInitialize(/*fast_advertisement=*/true, version, pcp, {}, endpoint_id,
endpoint_info, {}, uwb_address, WebRtcState::kUndefined);
>>>>>>> release
}
void BleAdvertisement::DoInitialize(bool fast_advertisement, Version version,
Pcp pcp, const ByteArray& service_id_hash,
const std::string& endpoint_id,
const ByteArray& endpoint_info,
<<<<<<< HEAD
const std::string& bluetooth_mac_address) {
=======
const std::string& bluetooth_mac_address,
const ByteArray& uwb_address,
WebRtcState web_rtc_state) {
>>>>>>> release
fast_advertisement_ = fast_advertisement;
if (!fast_advertisement_) {
if (service_id_hash.size() != kServiceIdHashLength) return;
@@ -97,19 +78,13 @@ void BleAdvertisement::DoInitialize(bool fast_advertisement, Version version,
service_id_hash_ = service_id_hash;
endpoint_id_ = endpoint_id;
endpoint_info_ = endpoint_info;
<<<<<<< HEAD
=======
uwb_address_ = uwb_address;
>>>>>>> release
if (!fast_advertisement_) {
if (!BluetoothUtils::FromString(bluetooth_mac_address).Empty()) {
bluetooth_mac_address_ = bluetooth_mac_address;
}
<<<<<<< HEAD
=======
web_rtc_state_ = web_rtc_state;
>>>>>>> release
}
}
@@ -169,11 +144,7 @@ BleAdvertisement::BleAdvertisement(bool fast_advertisement,
// The next 4 bytes are supposed to be the endpoint_id.
endpoint_id_ = std::string{base_input_stream.ReadBytes(kEndpointIdLength)};
<<<<<<< HEAD
// The next 1 byte are supposed to be the length of the endpoint_info.
=======
// The next 1 byte is supposed to be the length of the endpoint_info.
>>>>>>> release
std::uint32_t expected_endpoint_info_length = base_input_stream.ReadUint8();
// The next x bytes are the endpoint info. (Max length is 131 bytes or 17
@@ -190,11 +161,7 @@ BleAdvertisement::BleAdvertisement(bool fast_advertisement,
fast_advertisement_, expected_endpoint_info_length,
endpoint_info_.size());
<<<<<<< HEAD
// Clear enpoint_id for validadity.
=======
// Clear enpoint_id for validity.
>>>>>>> release
endpoint_id_.clear();
return;
}
@@ -207,8 +174,6 @@ BleAdvertisement::BleAdvertisement(bool fast_advertisement,
BluetoothUtils::ToString(bluetooth_mac_address_bytes);
}
<<<<<<< HEAD
=======
// The next 1 byte is supposed to be the length of the uwb_address.
std::uint32_t expected_uwb_address_length = base_input_stream.ReadUint8();
// If the length of uwb_address is not zero, then retrieve it.
@@ -238,7 +203,6 @@ BleAdvertisement::BleAdvertisement(bool fast_advertisement,
}
}
>>>>>>> release
base_input_stream.Close();
}
@@ -257,29 +221,13 @@ BleAdvertisement::operator ByteArray() const {
if (fast_advertisement_) {
// clang-format off
out = absl::StrCat(std::string(1, version_and_pcp_byte),
<<<<<<< HEAD
endpoint_id_,
std::string(1, endpoint_info_.size()),
std::string(endpoint_info_));
=======
endpoint_id_,
std::string(1, endpoint_info_.size()),
std::string(endpoint_info_));
>>>>>>> release
// clang-format on
} else {
// clang-format off
out = absl::StrCat(std::string(1, version_and_pcp_byte),
<<<<<<< HEAD
std::string(service_id_hash_),
endpoint_id_,
std::string(1, endpoint_info_.size()),
std::string(endpoint_info_));
// clang-format on
// The next 6 bytes are the bluetooth mac address. If bluetooth_mac_address
// is invalid or empty, we get back a null byte array.
=======
std::string(service_id_hash_),
endpoint_id_,
std::string(1, endpoint_info_.size()),
@@ -288,7 +236,6 @@ BleAdvertisement::operator ByteArray() const {
// The next 6 bytes are the bluetooth mac address. If bluetooth_mac_address
// is invalid or empty, we get back a empty byte array.
>>>>>>> release
auto bluetooth_mac_address_bytes{
BluetoothUtils::FromString(bluetooth_mac_address_)};
if (!bluetooth_mac_address_bytes.Empty()) {
@@ -296,8 +243,6 @@ BleAdvertisement::operator ByteArray() const {
}
}
<<<<<<< HEAD
=======
// The next bytes are UWB address field.
if (!uwb_address_.Empty()) {
absl::StrAppend(&out, std::string(1, uwb_address_.size()));
@@ -317,7 +262,6 @@ BleAdvertisement::operator ByteArray() const {
absl::StrAppend(&out, std::string(1, extra_field_byte));
}
>>>>>>> release
return ByteArray(std::move(out));
}
-42
View File
@@ -15,10 +15,7 @@
#ifndef CORE_V2_INTERNAL_BLE_ADVERTISEMENT_H_
#define CORE_V2_INTERNAL_BLE_ADVERTISEMENT_H_
<<<<<<< HEAD
=======
#include "core_v2/internal/base_pcp_handler.h"
>>>>>>> release
#include "core_v2/internal/pcp.h"
#include "platform_v2/base/bluetooth_utils.h"
#include "platform_v2/base/byte_array.h"
@@ -31,11 +28,7 @@ namespace connections {
// Advertising + Discovery.
//
// <p>[VERSION][PCP][SERVICE_ID_HASH][ENDPOINT_ID][ENDPOINT_INFO_SIZE]
<<<<<<< HEAD
// [ENDPOINT_INFO][BLUETOOTH_MAC]
=======
// [ENDPOINT_INFO][BLUETOOTH_MAC][UWB_ADDRESS_SIZE][UWB_ADDRESS][EXTRA_FIELD]
>>>>>>> release
//
// <p>The fast version of this advertisement simply omits SERVICE_ID_HASH and
// the Bluetooth MAC address.
@@ -57,12 +50,6 @@ class BleAdvertisement {
static constexpr int kServiceIdHashLength = 3;
static constexpr int kEndpointIdLength = 4;
static constexpr int kEndpointInfoSizeLength = 1;
<<<<<<< HEAD
static constexpr int kEndpointInfoLengthBitmask = 0x0FF;
static constexpr int kMinAdvertisementLength =
kVersionAndPcpLength + kServiceIdHashLength + kEndpointIdLength +
kEndpointInfoSizeLength + BluetoothUtils::kBluetoothMacAddressLength;
=======
static constexpr int kBluetoothMacAddressLength =
BluetoothUtils::kBluetoothMacAddressLength;
static constexpr int kUwbAddressSizeLength = 1;
@@ -72,32 +59,18 @@ class BleAdvertisement {
static constexpr int kMinAdvertisementLength =
kVersionAndPcpLength + kServiceIdHashLength + kEndpointIdLength +
kEndpointInfoSizeLength + kBluetoothMacAddressLength;
>>>>>>> release
// The difference between normal and fast advertisements is that the fast one
// omits the SERVICE_ID_HASH and Bluetooth MAC address. This is done to save
// space.
<<<<<<< HEAD
static constexpr int kMinFastAdvertisementLength =
kMinAdvertisementLength - kServiceIdHashLength -
BluetoothUtils::kBluetoothMacAddressLength;
=======
static constexpr int kMinFastAdvertisementLength = kMinAdvertisementLength -
kServiceIdHashLength -
kBluetoothMacAddressLength;
>>>>>>> release
static constexpr int kMaxEndpointInfoLength = 131;
static constexpr int kMaxFastEndpointInfoLength = 17;
BleAdvertisement() = default;
BleAdvertisement(Version version, Pcp pcp, const std::string& endpoint_id,
<<<<<<< HEAD
const ByteArray& endpoint_info);
BleAdvertisement(Version version, Pcp pcp, const ByteArray& service_id_hash,
const std::string& endpoint_id,
const ByteArray& endpoint_info,
const std::string& bluetooth_mac_address);
=======
const ByteArray& endpoint_info,
const ByteArray& uwb_address);
BleAdvertisement(Version version, Pcp pcp, const ByteArray& service_id_hash,
@@ -106,7 +79,6 @@ class BleAdvertisement {
const std::string& bluetooth_mac_address,
const ByteArray& uwb_address,
WebRtcState web_rtc_state);
>>>>>>> release
BleAdvertisement(bool fast_advertisement,
const ByteArray& ble_advertisement_bytes);
BleAdvertisement(const BleAdvertisement&) = default;
@@ -125,41 +97,27 @@ class BleAdvertisement {
std::string GetEndpointId() const { return endpoint_id_; }
ByteArray GetEndpointInfo() const { return endpoint_info_; }
std::string GetBluetoothMacAddress() const { return bluetooth_mac_address_; }
<<<<<<< HEAD
=======
ByteArray GetUwbAddress() const { return uwb_address_; }
WebRtcState GetWebRtcState() const { return web_rtc_state_; }
>>>>>>> release
private:
void DoInitialize(bool fast_advertisement, Version version, Pcp pcp,
const ByteArray& service_id_hash,
const std::string& endpoint_id,
const ByteArray& endpoint_info,
<<<<<<< HEAD
const std::string& bluetooth_mac_address);
bool fast_advertisement_ = false;
Version version_ = Version::kUndefined;
Pcp pcp_ = Pcp::kUnknown;
=======
const std::string& bluetooth_mac_address,
const ByteArray& uwb_address, WebRtcState web_rtc_state);
bool fast_advertisement_ = false;
Version version_{Version::kUndefined};
Pcp pcp_{Pcp::kUnknown};
>>>>>>> release
ByteArray service_id_hash_;
std::string endpoint_id_;
ByteArray endpoint_info_;
std::string bluetooth_mac_address_;
<<<<<<< HEAD
=======
// TODO(b/169550050): Define UWB address field.
ByteArray uwb_address_;
WebRtcState web_rtc_state_{WebRtcState::kUndefined};
>>>>>>> release
};
} // namespace connections
@@ -14,10 +14,7 @@
#include "core_v2/internal/ble_advertisement.h"
<<<<<<< HEAD
=======
#include "core_v2/internal/base_pcp_handler.h"
>>>>>>> release
#include "gtest/gtest.h"
namespace location {
@@ -33,16 +30,6 @@ constexpr absl::string_view kEndpointName{
"How much wood can a woodchuck chuck if a wood chuck would chuck wood?"};
constexpr absl::string_view kFastAdvertisementEndpointName{"Fast Advertise"};
constexpr absl::string_view kBluetoothMacAddress{"00:00:E6:88:64:13"};
<<<<<<< HEAD
TEST(BleAdvertisementTest, ConstructionWorks) {
ByteArray service_id_hash{std::string(kServiceIdHashBytes)};
ByteArray endpoint_info{std::string(kEndpointName)};
BleAdvertisement ble_advertisement{
kVersion, kPcp,
service_id_hash, std::string(kEndpointId),
endpoint_info, std::string(kBluetoothMacAddress)};
=======
constexpr WebRtcState kWebRtcState = WebRtcState::kConnectable;
// TODO(b/169550050): Implement UWBAddress.
@@ -57,7 +44,6 @@ TEST(BleAdvertisementTest, ConstructionWorks) {
std::string(kBluetoothMacAddress),
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_TRUE(ble_advertisement.IsValid());
EXPECT_FALSE(ble_advertisement.IsFastAdvertisement());
@@ -67,24 +53,16 @@ TEST(BleAdvertisementTest, ConstructionWorks) {
EXPECT_EQ(kEndpointId, ble_advertisement.GetEndpointId());
EXPECT_EQ(endpoint_info, ble_advertisement.GetEndpointInfo());
EXPECT_EQ(kBluetoothMacAddress, ble_advertisement.GetBluetoothMacAddress());
<<<<<<< HEAD
=======
EXPECT_EQ(kWebRtcState, ble_advertisement.GetWebRtcState());
>>>>>>> release
}
TEST(BleAdvertisementTest, ConstructionWorksForFastAdvertisement) {
ByteArray fast_endpoint_info{std::string(kFastAdvertisementEndpointName)};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{kVersion, kPcp, std::string(kEndpointId),
fast_endpoint_info};
=======
BleAdvertisement ble_advertisement{kVersion,
kPcp,
std::string(kEndpointId),
fast_endpoint_info,
ByteArray{}};
>>>>>>> release
EXPECT_TRUE(ble_advertisement.IsValid());
EXPECT_TRUE(ble_advertisement.IsFastAdvertisement());
@@ -92,10 +70,7 @@ TEST(BleAdvertisementTest, ConstructionWorksForFastAdvertisement) {
EXPECT_EQ(kPcp, ble_advertisement.GetPcp());
EXPECT_EQ(kEndpointId, ble_advertisement.GetEndpointId());
EXPECT_EQ(fast_endpoint_info, ble_advertisement.GetEndpointInfo());
<<<<<<< HEAD
=======
EXPECT_EQ(WebRtcState::kUndefined, ble_advertisement.GetWebRtcState());
>>>>>>> release
}
TEST(BleAdvertisementTest, ConstructionWorksWithEmptyEndpointInfo) {
@@ -107,13 +82,9 @@ TEST(BleAdvertisementTest, ConstructionWorksWithEmptyEndpointInfo) {
service_id_hash,
std::string(kEndpointId),
empty_endpoint_info,
<<<<<<< HEAD
std::string(kBluetoothMacAddress)};
=======
std::string(kBluetoothMacAddress),
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_TRUE(ble_advertisement.IsValid());
EXPECT_FALSE(ble_advertisement.IsFastAdvertisement());
@@ -123,26 +94,18 @@ TEST(BleAdvertisementTest, ConstructionWorksWithEmptyEndpointInfo) {
EXPECT_EQ(kEndpointId, ble_advertisement.GetEndpointId());
EXPECT_EQ(empty_endpoint_info, ble_advertisement.GetEndpointInfo());
EXPECT_EQ(kBluetoothMacAddress, ble_advertisement.GetBluetoothMacAddress());
<<<<<<< HEAD
=======
EXPECT_EQ(kWebRtcState, ble_advertisement.GetWebRtcState());
>>>>>>> release
}
TEST(BleAdvertisementTest,
ConstructionWorksWithEmptyEndpointInfoForFastAdvertisement) {
ByteArray empty_endpoint_info;
<<<<<<< HEAD
BleAdvertisement ble_advertisement{kVersion, kPcp, std::string(kEndpointId),
empty_endpoint_info};
=======
BleAdvertisement ble_advertisement{kVersion,
kPcp,
std::string(kEndpointId),
empty_endpoint_info,
ByteArray{}};
>>>>>>> release
EXPECT_TRUE(ble_advertisement.IsValid());
EXPECT_TRUE(ble_advertisement.IsFastAdvertisement());
@@ -150,10 +113,7 @@ TEST(BleAdvertisementTest,
EXPECT_EQ(kPcp, ble_advertisement.GetPcp());
EXPECT_EQ(kEndpointId, ble_advertisement.GetEndpointId());
EXPECT_EQ(empty_endpoint_info, ble_advertisement.GetEndpointInfo());
<<<<<<< HEAD
=======
EXPECT_EQ(WebRtcState::kUndefined, ble_advertisement.GetWebRtcState());
>>>>>>> release
}
TEST(BleAdvertisementTest, ConstructionWorksWithEmojiEndpointInfo) {
@@ -165,13 +125,9 @@ TEST(BleAdvertisementTest, ConstructionWorksWithEmojiEndpointInfo) {
service_id_hash,
std::string(kEndpointId),
emoji_endpoint_info,
<<<<<<< HEAD
std::string(kBluetoothMacAddress)};
=======
std::string(kBluetoothMacAddress),
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_TRUE(ble_advertisement.IsValid());
EXPECT_FALSE(ble_advertisement.IsFastAdvertisement());
@@ -181,26 +137,18 @@ TEST(BleAdvertisementTest, ConstructionWorksWithEmojiEndpointInfo) {
EXPECT_EQ(kEndpointId, ble_advertisement.GetEndpointId());
EXPECT_EQ(emoji_endpoint_info, ble_advertisement.GetEndpointInfo());
EXPECT_EQ(kBluetoothMacAddress, ble_advertisement.GetBluetoothMacAddress());
<<<<<<< HEAD
=======
EXPECT_EQ(kWebRtcState, ble_advertisement.GetWebRtcState());
>>>>>>> release
}
TEST(BleAdvertisementTest,
ConstructionWorksWithEmojiEndpointInfoForFastAdvertisement) {
ByteArray emoji_endpoint_info{std::string("\u0001F450 \u0001F450")};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{kVersion, kPcp, std::string(kEndpointId),
emoji_endpoint_info};
=======
BleAdvertisement ble_advertisement{kVersion,
kPcp,
std::string(kEndpointId),
emoji_endpoint_info,
ByteArray{}};
>>>>>>> release
EXPECT_TRUE(ble_advertisement.IsValid());
EXPECT_TRUE(ble_advertisement.IsFastAdvertisement());
@@ -208,10 +156,7 @@ TEST(BleAdvertisementTest,
EXPECT_EQ(kPcp, ble_advertisement.GetPcp());
EXPECT_EQ(kEndpointId, ble_advertisement.GetEndpointId());
EXPECT_EQ(emoji_endpoint_info, ble_advertisement.GetEndpointInfo());
<<<<<<< HEAD
=======
EXPECT_EQ(WebRtcState::kUndefined, ble_advertisement.GetWebRtcState());
>>>>>>> release
}
TEST(BleAdvertisementTest, ConstructionFailsWithLongEndpointInfo) {
@@ -220,12 +165,6 @@ TEST(BleAdvertisementTest, ConstructionFailsWithLongEndpointInfo) {
ByteArray long_endpoint_info{long_endpoint_name};
ByteArray service_id_hash{std::string(kServiceIdHashBytes)};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{
kVersion, kPcp,
service_id_hash, std::string(kEndpointId),
long_endpoint_info, std::string(kBluetoothMacAddress)};
=======
BleAdvertisement ble_advertisement{kVersion,
kPcp,
service_id_hash,
@@ -234,7 +173,6 @@ TEST(BleAdvertisementTest, ConstructionFailsWithLongEndpointInfo) {
std::string(kBluetoothMacAddress),
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(ble_advertisement.IsValid());
}
@@ -245,16 +183,11 @@ TEST(BleAdvertisementTest,
BleAdvertisement::kMaxFastEndpointInfoLength + 1, 'x');
ByteArray long_endpoint_info{long_endpoint_name};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{kVersion, kPcp, std::string(kEndpointId),
long_endpoint_info};
=======
BleAdvertisement ble_advertisement{kVersion,
kPcp,
std::string(kEndpointId),
long_endpoint_info,
ByteArray{}};
>>>>>>> release
EXPECT_FALSE(ble_advertisement.IsValid());
}
@@ -264,12 +197,6 @@ TEST(BleAdvertisementTest, ConstructionFailsWithBadVersion) {
ByteArray service_id_hash{std::string(kServiceIdHashBytes)};
ByteArray endpoint_info{std::string(kEndpointName)};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{
bad_version, kPcp,
service_id_hash, std::string(kEndpointId),
endpoint_info, std::string(kBluetoothMacAddress)};
=======
BleAdvertisement ble_advertisement{bad_version,
kPcp,
service_id_hash,
@@ -278,7 +205,6 @@ TEST(BleAdvertisementTest, ConstructionFailsWithBadVersion) {
std::string(kBluetoothMacAddress),
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(ble_advertisement.IsValid());
}
@@ -288,16 +214,11 @@ TEST(BleAdvertisementTest,
auto bad_version = static_cast<BleAdvertisement::Version>(666);
ByteArray fast_endpoint_info{std::string(kFastAdvertisementEndpointName)};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{
bad_version, kPcp, std::string(kEndpointId), fast_endpoint_info};
=======
BleAdvertisement ble_advertisement{bad_version,
kPcp,
std::string(kEndpointId),
fast_endpoint_info,
ByteArray{}};
>>>>>>> release
EXPECT_FALSE(ble_advertisement.IsValid());
}
@@ -307,12 +228,6 @@ TEST(BleAdvertisementTest, ConstructionFailsWithBadPCP) {
ByteArray service_id_hash{std::string(kServiceIdHashBytes)};
ByteArray endpoint_info{std::string(kEndpointName)};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{
kVersion, bad_pcp,
service_id_hash, std::string(kEndpointId),
endpoint_info, std::string(kBluetoothMacAddress)};
=======
BleAdvertisement ble_advertisement{kVersion,
bad_pcp,
service_id_hash,
@@ -321,7 +236,6 @@ TEST(BleAdvertisementTest, ConstructionFailsWithBadPCP) {
std::string(kBluetoothMacAddress),
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(ble_advertisement.IsValid());
}
@@ -330,16 +244,11 @@ TEST(BleAdvertisementTest, ConstructionFailsWithBadPCPForFastAdvertisement) {
auto bad_pcp = static_cast<Pcp>(666);
ByteArray fast_endpoint_info{std::string(kFastAdvertisementEndpointName)};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{
kVersion, bad_pcp, std::string(kEndpointId), fast_endpoint_info};
=======
BleAdvertisement ble_advertisement{kVersion,
bad_pcp,
std::string(kEndpointId),
fast_endpoint_info,
ByteArray{}};
>>>>>>> release
EXPECT_FALSE(ble_advertisement.IsValid());
}
@@ -349,12 +258,6 @@ TEST(BleAdvertisementTest, ConstructionSucceedsWithEmptyBluetoothMacAddress) {
ByteArray service_id_hash{std::string(kServiceIdHashBytes)};
ByteArray endpoint_info{std::string(kEndpointName)};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{
kVersion, kPcp,
service_id_hash, std::string(kEndpointId),
endpoint_info, empty_bluetooth_mac_address};
=======
BleAdvertisement ble_advertisement{kVersion,
kPcp,
service_id_hash,
@@ -363,7 +266,6 @@ TEST(BleAdvertisementTest, ConstructionSucceedsWithEmptyBluetoothMacAddress) {
empty_bluetooth_mac_address,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_TRUE(ble_advertisement.IsValid());
}
@@ -373,12 +275,6 @@ TEST(BleAdvertisementTest, ConstructionSucceedsWithInvalidBluetoothMacAddress) {
ByteArray service_id_hash{std::string(kServiceIdHashBytes)};
ByteArray endpoint_info{std::string(kEndpointName)};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{
kVersion, kPcp,
service_id_hash, std::string(kEndpointId),
endpoint_info, bad_bluetooth_mac_address};
=======
BleAdvertisement ble_advertisement{kVersion,
kPcp,
service_id_hash,
@@ -387,7 +283,6 @@ TEST(BleAdvertisementTest, ConstructionSucceedsWithInvalidBluetoothMacAddress) {
bad_bluetooth_mac_address,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_TRUE(ble_advertisement.IsValid());
EXPECT_EQ(kVersion, ble_advertisement.GetVersion());
@@ -396,22 +291,13 @@ TEST(BleAdvertisementTest, ConstructionSucceedsWithInvalidBluetoothMacAddress) {
EXPECT_EQ(kEndpointId, ble_advertisement.GetEndpointId());
EXPECT_EQ(endpoint_info, ble_advertisement.GetEndpointInfo());
EXPECT_TRUE(ble_advertisement.GetBluetoothMacAddress().empty());
<<<<<<< HEAD
=======
EXPECT_EQ(kWebRtcState, ble_advertisement.GetWebRtcState());
>>>>>>> release
}
TEST(BleAdvertisementTest, ConstructionFromBytesWorks) {
// Serialize good data into a good Ble Advertisement.
ByteArray service_id_hash{std::string(kServiceIdHashBytes)};
ByteArray endpoint_info{std::string(kEndpointName)};
<<<<<<< HEAD
BleAdvertisement org_ble_advertisement{
kVersion, kPcp,
service_id_hash, std::string(kEndpointId),
endpoint_info, std::string(kBluetoothMacAddress)};
=======
BleAdvertisement org_ble_advertisement{kVersion,
kPcp,
service_id_hash,
@@ -420,7 +306,6 @@ TEST(BleAdvertisementTest, ConstructionFromBytesWorks) {
std::string(kBluetoothMacAddress),
ByteArray{},
kWebRtcState};
>>>>>>> release
ByteArray ble_advertisement_bytes(org_ble_advertisement);
BleAdvertisement ble_advertisement{false, ble_advertisement_bytes};
@@ -433,25 +318,17 @@ TEST(BleAdvertisementTest, ConstructionFromBytesWorks) {
EXPECT_EQ(kEndpointId, ble_advertisement.GetEndpointId());
EXPECT_EQ(endpoint_info, ble_advertisement.GetEndpointInfo());
EXPECT_EQ(kBluetoothMacAddress, ble_advertisement.GetBluetoothMacAddress());
<<<<<<< HEAD
=======
EXPECT_EQ(kWebRtcState, ble_advertisement.GetWebRtcState());
>>>>>>> release
}
TEST(BleAdvertisementTest, ConstructionFromBytesWorksForFastAdvertisement) {
// Serialize good data into a good Ble Advertisement.
ByteArray fast_endpoint_info{std::string(kFastAdvertisementEndpointName)};
<<<<<<< HEAD
BleAdvertisement org_ble_advertisement{
kVersion, kPcp, std::string(kEndpointId), fast_endpoint_info};
=======
BleAdvertisement org_ble_advertisement{kVersion,
kPcp,
std::string(kEndpointId),
fast_endpoint_info,
ByteArray{}};
>>>>>>> release
ByteArray ble_advertisement_bytes(org_ble_advertisement);
BleAdvertisement ble_advertisement{true, ble_advertisement_bytes};
@@ -462,10 +339,7 @@ TEST(BleAdvertisementTest, ConstructionFromBytesWorksForFastAdvertisement) {
EXPECT_EQ(kPcp, ble_advertisement.GetPcp());
EXPECT_EQ(kEndpointId, ble_advertisement.GetEndpointId());
EXPECT_EQ(fast_endpoint_info, ble_advertisement.GetEndpointInfo());
<<<<<<< HEAD
=======
EXPECT_EQ(WebRtcState::kUndefined, ble_advertisement.GetWebRtcState());
>>>>>>> release
}
// Bytes at the end should be ignored so that they can be used as reserve bytes
@@ -474,12 +348,6 @@ TEST(BleAdvertisementTest, ConstructionFromLongLengthBytesWorks) {
// Serialize good data into a good Ble Advertisement.
ByteArray service_id_hash{std::string(kServiceIdHashBytes)};
ByteArray endpoint_info{std::string(kEndpointName)};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{
kVersion, kPcp,
service_id_hash, std::string(kEndpointId),
endpoint_info, std::string(kBluetoothMacAddress)};
=======
BleAdvertisement ble_advertisement{kVersion,
kPcp,
service_id_hash,
@@ -488,7 +356,6 @@ TEST(BleAdvertisementTest, ConstructionFromLongLengthBytesWorks) {
std::string(kBluetoothMacAddress),
ByteArray{},
kWebRtcState};
>>>>>>> release
ByteArray ble_advertisement_bytes(ble_advertisement);
// Add bytes to the end of the valid Ble advertisement.
@@ -509,10 +376,7 @@ TEST(BleAdvertisementTest, ConstructionFromLongLengthBytesWorks) {
EXPECT_EQ(endpoint_info, long_ble_advertisement.GetEndpointInfo());
EXPECT_EQ(kBluetoothMacAddress,
long_ble_advertisement.GetBluetoothMacAddress());
<<<<<<< HEAD
=======
EXPECT_EQ(kWebRtcState, ble_advertisement.GetWebRtcState());
>>>>>>> release
}
TEST(BleAdvertisementTest, ConstructionFromNullBytesFails) {
@@ -531,12 +395,6 @@ TEST(BleAdvertisementTest, ConstructionFromShortLengthBytesFails) {
// Serialize good data into a good Ble Advertisement.
ByteArray service_id_hash{std::string(kServiceIdHashBytes)};
ByteArray endpoint_info{std::string(kEndpointName)};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{
kVersion, kPcp,
service_id_hash, std::string(kEndpointId),
endpoint_info, std::string(kBluetoothMacAddress)};
=======
BleAdvertisement ble_advertisement{kVersion,
kPcp,
service_id_hash,
@@ -545,7 +403,6 @@ TEST(BleAdvertisementTest, ConstructionFromShortLengthBytesFails) {
std::string(kBluetoothMacAddress),
ByteArray{},
kWebRtcState};
>>>>>>> release
ByteArray ble_advertisement_bytes(ble_advertisement);
// Shorten the valid Ble Advertisement.
@@ -558,24 +415,16 @@ TEST(BleAdvertisementTest, ConstructionFromShortLengthBytesFails) {
EXPECT_FALSE(short_ble_advertisement.IsValid());
}
<<<<<<< HEAD
=======
>>>>>>> release
TEST(BleAdvertisementTest,
ConstructionFromShortLengthBytesFailsForFastAdvertisement) {
// Serialize good data into a good Ble Advertisement.
ByteArray fast_endpoint_info{std::string(kFastAdvertisementEndpointName)};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{kVersion, kPcp, std::string(kEndpointId),
fast_endpoint_info};
=======
BleAdvertisement ble_advertisement{kVersion,
kPcp,
std::string(kEndpointId),
fast_endpoint_info,
ByteArray{}};
>>>>>>> release
ByteArray ble_advertisement_bytes(ble_advertisement);
// Shorten the valid Ble Advertisement.
@@ -593,12 +442,6 @@ TEST(BleAdvertisementTest,
// Serialize good data into a good Ble Advertisement.
ByteArray service_id_hash{std::string(kServiceIdHashBytes)};
ByteArray endpoint_info{std::string(kEndpointName)};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{
kVersion, kPcp,
service_id_hash, std::string(kEndpointId),
endpoint_info, std::string(kBluetoothMacAddress)};
=======
BleAdvertisement ble_advertisement{kVersion,
kPcp,
service_id_hash,
@@ -607,7 +450,6 @@ TEST(BleAdvertisementTest,
std::string(kBluetoothMacAddress),
ByteArray{},
kWebRtcState};
>>>>>>> release
ByteArray ble_advertisement_bytes(ble_advertisement);
// Corrupt the EndpointNameLength bits.
@@ -625,16 +467,11 @@ TEST(BleAdvertisementTest,
ConstructionFromByesWithWrongEndpointInfoLengthFailsForFastAdvertisement) {
// Serialize good data into a good Ble Advertisement.
ByteArray fast_endpoint_info{std::string(kFastAdvertisementEndpointName)};
<<<<<<< HEAD
BleAdvertisement ble_advertisement{kVersion, kPcp, std::string(kEndpointId),
fast_endpoint_info};
=======
BleAdvertisement ble_advertisement{kVersion,
kPcp,
std::string(kEndpointId),
fast_endpoint_info,
ByteArray{}};
>>>>>>> release
ByteArray ble_advertisement_bytes = ByteArray(ble_advertisement);
// Corrupt the EndpointInfoLength bits.
@@ -32,13 +32,9 @@ namespace connections {
BluetoothDeviceName::BluetoothDeviceName(Version version, Pcp pcp,
absl::string_view endpoint_id,
const ByteArray& service_id_hash,
<<<<<<< HEAD
const ByteArray& endpoint_info) {
=======
const ByteArray& endpoint_info,
const ByteArray& uwb_address,
WebRtcState web_rtc_state) {
>>>>>>> release
if (version != Version::kV1 || endpoint_id.empty() ||
endpoint_id.length() != kEndpointIdLength ||
service_id_hash.size() != kServiceIdHashLength) {
@@ -58,11 +54,8 @@ BluetoothDeviceName::BluetoothDeviceName(Version version, Pcp pcp,
endpoint_id_ = std::string(endpoint_id);
service_id_hash_ = service_id_hash;
endpoint_info_ = endpoint_info;
<<<<<<< HEAD
=======
uwb_address_ = uwb_address;
web_rtc_state_ = web_rtc_state;
>>>>>>> release
}
BluetoothDeviceName::BluetoothDeviceName(
@@ -78,18 +71,6 @@ BluetoothDeviceName::BluetoothDeviceName(
return;
}
<<<<<<< HEAD
if (bluetooth_device_name_bytes.size() > kMaxBluetoothDeviceNameLength) {
NEARBY_LOG(INFO,
"Cannot deserialize BluetoothDeviceName: expecting max %d raw "
"bytes, got %" PRIu64,
kMaxBluetoothDeviceNameLength,
bluetooth_device_name_bytes.size());
return;
}
=======
>>>>>>> release
if (bluetooth_device_name_bytes.size() < kMinBluetoothDeviceNameLength) {
NEARBY_LOG(INFO,
"Cannot deserialize BluetoothDeviceName: expecting min %d raw "
@@ -131,13 +112,6 @@ BluetoothDeviceName::BluetoothDeviceName(
// The next 3 bytes are supposed to be the service_id_hash.
service_id_hash_ = base_input_stream.ReadBytes(kServiceIdHashLength);
<<<<<<< HEAD
// The next 7 bytes are supposed to be reserved, and can be left
// untouched.
base_input_stream.ReadBytes(kReservedLength);
// The next 1 byte are supposed to be the length of the endpoint_info.
=======
// The next 1 byte is field containning WebRtc state.
auto field_byte = static_cast<char>(base_input_stream.ReadUint8());
@@ -150,7 +124,6 @@ BluetoothDeviceName::BluetoothDeviceName(
base_input_stream.ReadBytes(kReservedLength);
// The next 1 byte is supposed to be the length of the endpoint_info.
>>>>>>> release
std::uint32_t expected_endpoint_info_length = base_input_stream.ReadUint8();
// The rest bytes are supposed to be the endpoint_info
@@ -166,8 +139,6 @@ BluetoothDeviceName::BluetoothDeviceName(
endpoint_id_.clear();
return;
}
<<<<<<< HEAD
=======
// If the input stream has extra bytes, it's for UWB address. The first byte
// is the address length. It can be 2-byte short address or 8-byte extended
@@ -191,7 +162,6 @@ BluetoothDeviceName::BluetoothDeviceName(
}
}
}
>>>>>>> release
}
BluetoothDeviceName::operator std::string() const {
@@ -206,15 +176,12 @@ BluetoothDeviceName::operator std::string() const {
version_and_pcp_byte |=
static_cast<char>(static_cast<uint32_t>(pcp_) & kPcpBitmask);
<<<<<<< HEAD
=======
// A byte contains WebRtcState state.
int web_rtc_connectable_flag =
(web_rtc_state_ == WebRtcState::kConnectable) ? 1 : 0;
char field_byte = static_cast<char>(web_rtc_connectable_flag) &
kWebRtcConnectableFlagBitmask;
>>>>>>> release
ByteArray reserved_bytes{kReservedLength};
ByteArray usable_endpoint_info(endpoint_info_);
@@ -231,24 +198,18 @@ BluetoothDeviceName::operator std::string() const {
std::string out = absl::StrCat(std::string(1, version_and_pcp_byte),
endpoint_id_,
std::string(service_id_hash_),
<<<<<<< HEAD
=======
std::string(1, field_byte),
>>>>>>> release
std::string(reserved_bytes),
std::string(1, usable_endpoint_info.size()),
std::string(usable_endpoint_info));
// clang-format on
<<<<<<< HEAD
=======
// If UWB address is available, attach it at the end.
if (!uwb_address_.Empty()) {
absl::StrAppend(&out, std::string(1, uwb_address_.size()));
absl::StrAppend(&out, std::string(uwb_address_));
}
>>>>>>> release
return Base64Utils::Encode(ByteArray{std::move(out)});
}
@@ -17,10 +17,7 @@
#include <cstdint>
<<<<<<< HEAD
=======
#include "core_v2/internal/base_pcp_handler.h"
>>>>>>> release
#include "core_v2/internal/pcp.h"
#include "platform_v2/base/byte_array.h"
#include "absl/strings/string_view.h"
@@ -48,13 +45,9 @@ class BluetoothDeviceName {
BluetoothDeviceName() = default;
BluetoothDeviceName(Version version, Pcp pcp, absl::string_view endpoint_id,
const ByteArray& service_id_hash,
<<<<<<< HEAD
const ByteArray& endpoint_info);
=======
const ByteArray& endpoint_info,
const ByteArray& uwb_address,
WebRtcState web_rtc_state);
>>>>>>> release
explicit BluetoothDeviceName(absl::string_view bluetooth_device_name_string);
BluetoothDeviceName(const BluetoothDeviceName&) = default;
BluetoothDeviceName& operator=(const BluetoothDeviceName&) = default;
@@ -70,16 +63,6 @@ class BluetoothDeviceName {
std::string GetEndpointId() const { return endpoint_id_; }
ByteArray GetServiceIdHash() const { return service_id_hash_; }
ByteArray GetEndpointInfo() const { return endpoint_info_; }
<<<<<<< HEAD
private:
static constexpr int kMaxBluetoothDeviceNameLength = 147;
static constexpr int kEndpointIdLength = 4;
static constexpr int kReservedLength = 7;
static constexpr int kMaxEndpointInfoLength = 131;
static constexpr int kMinBluetoothDeviceNameLength =
kMaxBluetoothDeviceNameLength - kMaxEndpointInfoLength;
=======
ByteArray GetUwbAddress() const { return uwb_address_; }
WebRtcState GetWebRtcState() const { return web_rtc_state_; }
@@ -88,27 +71,20 @@ class BluetoothDeviceName {
static constexpr int kReservedLength = 6;
static constexpr int kMaxEndpointInfoLength = 131;
static constexpr int kMinBluetoothDeviceNameLength = 16;
>>>>>>> release
static constexpr int kVersionBitmask = 0x0E0;
static constexpr int kPcpBitmask = 0x01F;
static constexpr int kEndpointNameLengthBitmask = 0x0FF;
<<<<<<< HEAD
=======
static constexpr int kWebRtcConnectableFlagBitmask = 0x01;
>>>>>>> release
Version version_{Version::kUndefined};
Pcp pcp_{Pcp::kUnknown};
std::string endpoint_id_;
ByteArray service_id_hash_;
ByteArray endpoint_info_;
<<<<<<< HEAD
=======
// TODO(b/169550050): Define UWB address field.
ByteArray uwb_address_;
WebRtcState web_rtc_state_{WebRtcState::kUndefined};
>>>>>>> release
};
} // namespace connections
@@ -31,14 +31,6 @@ constexpr Pcp kPcp = Pcp::kP2pCluster;
constexpr absl::string_view kEndPointID{"AB12"};
constexpr absl::string_view kServiceIDHashBytes{"\x0a\x0b\x0c"};
constexpr absl::string_view kEndPointName{"RAWK + ROWL!"};
<<<<<<< HEAD
TEST(BluetoothDeviceNameTest, ConstructionWorks) {
ByteArray service_id_hash{std::string(kServiceIDHashBytes)};
ByteArray endpoint_info{std::string(kEndPointName)};
BluetoothDeviceName bluetooth_device_name{kVersion, kPcp, kEndPointID,
service_id_hash, endpoint_info};
=======
constexpr WebRtcState kWebRtcState = WebRtcState::kConnectable;
// TODO(b/169550050): Implement UWBAddress.
@@ -52,7 +44,6 @@ TEST(BluetoothDeviceNameTest, ConstructionWorks) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_TRUE(bluetooth_device_name.IsValid());
EXPECT_EQ(kVersion, bluetooth_device_name.GetVersion());
@@ -60,20 +51,13 @@ TEST(BluetoothDeviceNameTest, ConstructionWorks) {
EXPECT_EQ(kEndPointID, bluetooth_device_name.GetEndpointId());
EXPECT_EQ(service_id_hash, bluetooth_device_name.GetServiceIdHash());
EXPECT_EQ(endpoint_info, bluetooth_device_name.GetEndpointInfo());
<<<<<<< HEAD
=======
EXPECT_EQ(kWebRtcState, bluetooth_device_name.GetWebRtcState());
>>>>>>> release
}
TEST(BluetoothDeviceNameTest, ConstructionWorksWithEmptyEndpointName) {
ByteArray empty_endpoint_info;
ByteArray service_id_hash{std::string(kServiceIDHashBytes)};
<<<<<<< HEAD
BluetoothDeviceName bluetooth_device_name{
kVersion, kPcp, kEndPointID, service_id_hash, empty_endpoint_info};
=======
BluetoothDeviceName bluetooth_device_name{kVersion,
kPcp,
kEndPointID,
@@ -81,7 +65,6 @@ TEST(BluetoothDeviceNameTest, ConstructionWorksWithEmptyEndpointName) {
empty_endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_TRUE(bluetooth_device_name.IsValid());
EXPECT_EQ(kVersion, bluetooth_device_name.GetVersion());
@@ -89,10 +72,7 @@ TEST(BluetoothDeviceNameTest, ConstructionWorksWithEmptyEndpointName) {
EXPECT_EQ(kEndPointID, bluetooth_device_name.GetEndpointId());
EXPECT_EQ(service_id_hash, bluetooth_device_name.GetServiceIdHash());
EXPECT_EQ(empty_endpoint_info, bluetooth_device_name.GetEndpointInfo());
<<<<<<< HEAD
=======
EXPECT_EQ(kWebRtcState, bluetooth_device_name.GetWebRtcState());
>>>>>>> release
}
TEST(BluetoothDeviceNameTest, ConstructionFailsWithBadVersion) {
@@ -100,10 +80,6 @@ TEST(BluetoothDeviceNameTest, ConstructionFailsWithBadVersion) {
ByteArray service_id_hash{std::string(kServiceIDHashBytes)};
ByteArray endpoint_info{std::string(kEndPointName)};
<<<<<<< HEAD
BluetoothDeviceName bluetooth_device_name{bad_version, kPcp, kEndPointID,
service_id_hash, endpoint_info};
=======
BluetoothDeviceName bluetooth_device_name{bad_version,
kPcp,
kEndPointID,
@@ -111,7 +87,6 @@ TEST(BluetoothDeviceNameTest, ConstructionFailsWithBadVersion) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(bluetooth_device_name.IsValid());
}
@@ -121,10 +96,6 @@ TEST(BluetoothDeviceNameTest, ConstructionFailsWithBadPcp) {
ByteArray service_id_hash{std::string(kServiceIDHashBytes)};
ByteArray endpoint_info{std::string(kEndPointName)};
<<<<<<< HEAD
BluetoothDeviceName bluetooth_device_name{kVersion, bad_pcp, kEndPointID,
service_id_hash, endpoint_info};
=======
BluetoothDeviceName bluetooth_device_name{kVersion,
bad_pcp,
kEndPointID,
@@ -132,7 +103,6 @@ TEST(BluetoothDeviceNameTest, ConstructionFailsWithBadPcp) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(bluetooth_device_name.IsValid());
}
@@ -142,10 +112,6 @@ TEST(BluetoothDeviceNameTest, ConstructionFailsWithShortEndpointId) {
ByteArray service_id_hash{std::string(kServiceIDHashBytes)};
ByteArray endpoint_info{std::string(kEndPointName)};
<<<<<<< HEAD
BluetoothDeviceName bluetooth_device_name{kVersion, kPcp, short_endpoint_id,
service_id_hash, endpoint_info};
=======
BluetoothDeviceName bluetooth_device_name{kVersion,
kPcp,
short_endpoint_id,
@@ -153,7 +119,6 @@ TEST(BluetoothDeviceNameTest, ConstructionFailsWithShortEndpointId) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(bluetooth_device_name.IsValid());
}
@@ -163,10 +128,6 @@ TEST(BluetoothDeviceNameTest, ConstructionFailsWithLongEndpointId) {
ByteArray service_id_hash{std::string(kServiceIDHashBytes)};
ByteArray endpoint_info{std::string(kEndPointName)};
<<<<<<< HEAD
BluetoothDeviceName bluetooth_device_name{kVersion, kPcp, long_endpoint_id,
service_id_hash, endpoint_info};
=======
BluetoothDeviceName bluetooth_device_name{kVersion,
kPcp,
long_endpoint_id,
@@ -174,7 +135,6 @@ TEST(BluetoothDeviceNameTest, ConstructionFailsWithLongEndpointId) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(bluetooth_device_name.IsValid());
}
@@ -184,10 +144,6 @@ TEST(BluetoothDeviceNameTest, ConstructionFailsWithShortServiceIdHash) {
ByteArray short_service_id_hash{short_service_id_hash_bytes};
ByteArray endpoint_info{std::string(kEndPointName)};
<<<<<<< HEAD
BluetoothDeviceName bluetooth_device_name{
kVersion, kPcp, kEndPointID, short_service_id_hash, endpoint_info};
=======
BluetoothDeviceName bluetooth_device_name{kVersion,
kPcp,
kEndPointID,
@@ -195,7 +151,6 @@ TEST(BluetoothDeviceNameTest, ConstructionFailsWithShortServiceIdHash) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(bluetooth_device_name.IsValid());
}
@@ -205,10 +160,6 @@ TEST(BluetoothDeviceNameTest, ConstructionFailsWithLongServiceIdHash) {
ByteArray long_service_id_hash{long_service_id_hash_bytes};
ByteArray endpoint_info{std::string(kEndPointName)};
<<<<<<< HEAD
BluetoothDeviceName bluetooth_device_name{
kVersion, kPcp, kEndPointID, long_service_id_hash, endpoint_info};
=======
BluetoothDeviceName bluetooth_device_name{kVersion,
kPcp,
kEndPointID,
@@ -216,7 +167,6 @@ TEST(BluetoothDeviceNameTest, ConstructionFailsWithLongServiceIdHash) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(bluetooth_device_name.IsValid());
}
@@ -235,10 +185,6 @@ TEST(BluetoothDeviceNameTest, ConstructionFailsWithWrongEndpointNameLength) {
// Serialize good data into a good Bluetooth Device Name.
ByteArray service_id_hash{std::string(kServiceIDHashBytes)};
ByteArray endpoint_info{std::string(kEndPointName)};
<<<<<<< HEAD
BluetoothDeviceName bluetooth_device_name{kVersion, kPcp, kEndPointID,
service_id_hash, endpoint_info};
=======
BluetoothDeviceName bluetooth_device_name{kVersion,
kPcp,
kEndPointID,
@@ -246,7 +192,6 @@ TEST(BluetoothDeviceNameTest, ConstructionFailsWithWrongEndpointNameLength) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
auto bluetooth_device_name_string = std::string(bluetooth_device_name);
// Base64-decode the good Bluetooth Device Name.
@@ -273,10 +218,6 @@ TEST(BluetoothDeviceNameTest, CanParseGeneratedName) {
ByteArray service_id_hash{std::string(kServiceIDHashBytes)};
ByteArray endpoint_info{std::string(kEndPointName)};
// Build name1 from scratch.
<<<<<<< HEAD
BluetoothDeviceName name1{kVersion, kPcp, kEndPointID, service_id_hash,
endpoint_info};
=======
BluetoothDeviceName name1{kVersion,
kPcp,
kEndPointID,
@@ -284,7 +225,6 @@ TEST(BluetoothDeviceNameTest, CanParseGeneratedName) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
// Build name2 from string composed from name1.
BluetoothDeviceName name2{std::string(name1)};
EXPECT_TRUE(name1.IsValid());
@@ -294,10 +234,7 @@ TEST(BluetoothDeviceNameTest, CanParseGeneratedName) {
EXPECT_EQ(name1.GetEndpointId(), name2.GetEndpointId());
EXPECT_EQ(name1.GetServiceIdHash(), name2.GetServiceIdHash());
EXPECT_EQ(name1.GetEndpointInfo(), name2.GetEndpointInfo());
<<<<<<< HEAD
=======
EXPECT_EQ(name1.GetWebRtcState(), name2.GetWebRtcState());
>>>>>>> release
}
} // namespace
-15
View File
@@ -15,10 +15,7 @@
#include "core_v2/internal/bwu_manager.h"
#include <algorithm>
<<<<<<< HEAD
=======
#include <memory>
>>>>>>> release
#include "core_v2/internal/bwu_handler.h"
#include "core_v2/internal/offline_frames.h"
@@ -210,11 +207,7 @@ void BwuManager::OnEndpointDisconnect(ClientProxy* client,
handler_->OnEndpointDisconnect(client, endpoint_id);
}
<<<<<<< HEAD
auto item = old_channels_.extract(endpoint_id);
=======
auto item = previous_endpoint_channels_.extract(endpoint_id);
>>>>>>> release
if (!item.empty()) {
auto old_channel = item.mapped();
@@ -282,14 +275,10 @@ void BwuManager::OnBwuNegotiationFrame(ClientProxy* client,
}
void BwuManager::OnIncomingConnection(
<<<<<<< HEAD
ClientProxy* client, BwuHandler::IncomingSocketConnection* connection) {
=======
ClientProxy* client,
BwuHandler::IncomingSocketConnection* mutable_connection) {
auto connection = std::make_shared<BwuHandler::IncomingSocketConnection>(
std::move(*mutable_connection));
>>>>>>> release
RunOnBwuManagerThread([this, client, connection]() {
EndpointChannel* channel = connection->channel.get();
if (channel == nullptr) {
@@ -358,11 +347,7 @@ void BwuManager::RunUpgradeProtocol(
// continue when we receive a corresponding
// BANDWIDTH_UPGRADE_NEGOTIATION.LAST_WRITE_TO_PRIOR_CHANNEL OfflineFrame from
// the remote device, so for now, just store that previous EndpointChannel.
<<<<<<< HEAD
old_channels_.emplace(endpoint_id, old_channel);
=======
previous_endpoint_channels_.emplace(endpoint_id, old_channel);
>>>>>>> release
// If we already read LAST_WRITE on the old endpoint channel, then we can
// safely close it now.
-7
View File
@@ -170,15 +170,8 @@ class BwuManager : public EndpointManager::FrameProcessor {
// Stores each upgraded endpoint's previous EndpointChannel (that was
// displaced in favor of a new EndpointChannel) temporarily, until it can
// safely be shut down for good in processLastWriteToPriorChannelEvent().
<<<<<<< HEAD
absl::flat_hash_map<std::string, std::unique_ptr<EndpointChannel>>
previous_endpoint_channels_;
absl::flat_hash_map<std::string, std::shared_ptr<EndpointChannel>>
old_channels_;
=======
absl::flat_hash_map<std::string, std::shared_ptr<EndpointChannel>>
previous_endpoint_channels_;
>>>>>>> release
absl::flat_hash_set<std::string> successfully_upgraded_endpoints_;
// Maps endpointId -> ClientProxy for which
// initiateBwuForEndpoint() has been called but which have not
-7
View File
@@ -39,13 +39,9 @@ cc_library(
"//core_v2/internal:__subpackages__",
],
deps = [
<<<<<<< HEAD
"//core_v2:core_types",
=======
":utils",
"//core_v2:core_types",
"//core_v2/internal/mediums/ble_v2",
>>>>>>> release
"//core_v2/internal/mediums/webrtc",
"//platform_v2/base",
"//platform_v2/public:comm",
@@ -69,10 +65,7 @@ cc_library(
hdrs = ["utils.h"],
visibility = [
"//core_v2/internal:__pkg__",
<<<<<<< HEAD
=======
"//core_v2/internal/mediums:__pkg__",
>>>>>>> release
"//core_v2/internal/mediums/ble_v2:__pkg__",
"//core_v2/internal/mediums/webrtc:__pkg__",
],
-21
View File
@@ -18,12 +18,9 @@
#include <string>
#include <utility>
<<<<<<< HEAD
=======
#include "core_v2/internal/mediums/ble_v2/ble_advertisement.h"
#include "core_v2/internal/mediums/utils.h"
#include "platform_v2/base/prng.h"
>>>>>>> release
#include "platform_v2/public/logging.h"
#include "platform_v2/public/mutex_lock.h"
@@ -31,8 +28,6 @@ namespace location {
namespace nearby {
namespace connections {
<<<<<<< HEAD
=======
ByteArray Ble::GenerateHash(const std::string& source, size_t size) {
return Utils::Sha256Hash(source, size);
}
@@ -42,7 +37,6 @@ ByteArray Ble::GenerateDeviceToken() {
mediums::BleAdvertisement::kDeviceTokenLength);
}
>>>>>>> release
Ble::Ble(BluetoothRadio& radio) : radio_(radio) {}
bool Ble::IsAvailable() const {
@@ -95,9 +89,6 @@ bool Ble::StartAdvertising(const std::string& service_id,
<< ", service id=" << service_id
<< ", fast advertisement service uuid="
<< fast_advertisement_service_uuid;
<<<<<<< HEAD
if (!medium_.StartAdvertising(service_id, advertisement_bytes,
=======
// Wrap the connections advertisement to the medium advertisement.
const bool fast_advertisement = !fast_advertisement_service_uuid.empty();
@@ -115,7 +106,6 @@ bool Ble::StartAdvertising(const std::string& service_id,
}
if (!medium_.StartAdvertising(service_id, medium_advertisement_bytes,
>>>>>>> release
fast_advertisement_service_uuid)) {
NEARBY_LOGS(INFO)
<< "Failed to turn on BLE advertising with advertisement bytes="
@@ -162,11 +152,8 @@ bool Ble::StartScanning(const std::string& service_id,
DiscoveredPeripheralCallback callback) {
MutexLock lock(&mutex_);
<<<<<<< HEAD
=======
discovered_peripheral_callback_ = std::move(callback);
>>>>>>> release
if (service_id.empty()) {
NEARBY_LOGS(INFO)
<< "Refusing to start BLE scanning with empty service id.";
@@ -191,10 +178,6 @@ bool Ble::StartScanning(const std::string& service_id,
return false;
}
<<<<<<< HEAD
if (!medium_.StartScanning(service_id, fast_advertisement_service_uuid,
callback)) {
=======
if (!medium_.StartScanning(
service_id, fast_advertisement_service_uuid,
{
@@ -218,7 +201,6 @@ bool Ble::StartScanning(const std::string& service_id,
peripheral, service_id);
},
})) {
>>>>>>> release
NEARBY_LOGS(INFO) << "Failed to start scan of BLE services.";
return false;
}
@@ -355,8 +337,6 @@ BleSocket Ble::Connect(BlePeripheral& peripheral,
return socket;
}
<<<<<<< HEAD
=======
ByteArray Ble::UnwrapAdvertisementBytes(
const ByteArray& medium_advertisement_data) {
mediums::BleAdvertisement medium_ble_advertisement{medium_advertisement_data};
@@ -367,7 +347,6 @@ ByteArray Ble::UnwrapAdvertisementBytes(
return medium_ble_advertisement.GetData();
}
>>>>>>> release
} // namespace connections
} // namespace nearby
} // namespace location
-14
View File
@@ -102,11 +102,6 @@ class Ble {
ABSL_LOCKS_EXCLUDED(mutex_);
private:
<<<<<<< HEAD
static constexpr int kMaxAdvertisementLength = 512;
=======
>>>>>>> release
struct AdvertisingInfo {
bool Empty() const { return service_ids.empty(); }
void Clear() { service_ids.clear(); }
@@ -149,14 +144,11 @@ class Ble {
absl::flat_hash_set<std::string> service_ids;
};
<<<<<<< HEAD
=======
static constexpr int kMaxAdvertisementLength = 512;
static ByteArray GenerateHash(const std::string& source, size_t size);
static ByteArray GenerateDeviceToken();
>>>>>>> release
// Same as IsAvailable(), but must be called with mutex_ held.
bool IsAvailableLocked() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
@@ -172,13 +164,10 @@ class Ble {
bool IsAcceptingConnectionsLocked(const std::string& service_id)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
<<<<<<< HEAD
=======
// Extract connection advertisement from medium advertisement.
ByteArray UnwrapAdvertisementBytes(
const ByteArray& medium_advertisement_data);
>>>>>>> release
mutable Mutex mutex_;
BluetoothRadio& radio_ ABSL_GUARDED_BY(mutex_);
BluetoothAdapter& adapter_ ABSL_GUARDED_BY(mutex_){
@@ -186,10 +175,7 @@ class Ble {
BleMedium medium_ ABSL_GUARDED_BY(mutex_){adapter_};
AdvertisingInfo advertising_info_ ABSL_GUARDED_BY(mutex_);
ScanningInfo scanning_info_ ABSL_GUARDED_BY(mutex_);
<<<<<<< HEAD
=======
DiscoveredPeripheralCallback discovered_peripheral_callback_;
>>>>>>> release
AcceptingConnectionsInfo accepting_connections_info_ ABSL_GUARDED_BY(mutex_);
};
-24
View File
@@ -74,20 +74,12 @@ TEST_F(BleTest, CanStartAdvertising) {
CountDownLatch found_latch(1);
ble_b.StartScanning(
<<<<<<< HEAD
service_id,
fast_advertisement_service_uuid,
=======
service_id, fast_advertisement_service_uuid,
>>>>>>> release
DiscoveredPeripheralCallback{
.peripheral_discovered_cb =
[&found_latch](
BlePeripheral& peripheral, const std::string& service_id,
<<<<<<< HEAD
=======
const ByteArray& advertisement_bytes,
>>>>>>> release
bool fast_advertisement) { found_latch.CountDown(); },
});
@@ -117,20 +109,12 @@ TEST_F(BleTest, CanStartDiscovery) {
fast_advertisement_service_uuid);
EXPECT_TRUE(ble_a.StartScanning(
<<<<<<< HEAD
service_id,
fast_advertisement_service_uuid,
=======
service_id, fast_advertisement_service_uuid,
>>>>>>> release
DiscoveredPeripheralCallback{
.peripheral_discovered_cb =
[&accept_latch](
BlePeripheral& peripheral, const std::string& service_id,
<<<<<<< HEAD
=======
const ByteArray& advertisement_bytes,
>>>>>>> release
bool fast_advertisement) { accept_latch.CountDown(); },
.peripheral_lost_cb =
[&lost_latch](BlePeripheral& peripheral,
@@ -170,20 +154,12 @@ TEST_F(BleTest, CanStartAcceptingConnectionsAndConnect) {
});
BlePeripheral discovered_peripheral;
ble_b.StartScanning(
<<<<<<< HEAD
service_id,
fast_advertisement_service_uuid,
=======
service_id, fast_advertisement_service_uuid,
>>>>>>> release
{
.peripheral_discovered_cb =
[&found_latch, &discovered_peripheral](
BlePeripheral& peripheral, const std::string& service_id,
<<<<<<< HEAD
=======
const ByteArray& advertisement_bytes,
>>>>>>> release
bool fast_advertisement) {
discovered_peripheral = peripheral;
NEARBY_LOG(
@@ -30,21 +30,8 @@ BleAdvertisement::BleAdvertisement(Version version,
const ByteArray &service_id_hash,
const ByteArray &data,
const ByteArray &device_token) {
<<<<<<< HEAD
DoInitialize(/*fast_advertisement=*/false, version, socket_version,
service_id_hash, data, device_token);
}
BleAdvertisement::BleAdvertisement(Version version,
SocketVersion socket_version,
const ByteArray &data,
const ByteArray &device_token) {
DoInitialize(/*fast_advertisement=*/true, version, socket_version,
{}, data, device_token);
=======
DoInitialize(/*fast_advertisement=*/service_id_hash.Empty(), version,
socket_version, service_id_hash, data, device_token);
>>>>>>> release
}
void BleAdvertisement::DoInitialize(bool fast_advertisement, Version version,
@@ -61,11 +61,6 @@ class BleAdvertisement {
BleAdvertisement(Version version, SocketVersion socket_version,
const ByteArray &service_id_hash, const ByteArray &data,
const ByteArray &device_token);
<<<<<<< HEAD
BleAdvertisement(Version version, SocketVersion socket_version,
const ByteArray &data, const ByteArray &device_token);
=======
>>>>>>> release
explicit BleAdvertisement(const ByteArray &ble_advertisement_bytes);
BleAdvertisement(const BleAdvertisement &) = default;
BleAdvertisement &operator=(const BleAdvertisement &) = default;
@@ -67,10 +67,7 @@ TEST(BleAdvertisementTest, ConstructionWorksV1ForFastAdvertisement) {
BleAdvertisement ble_advertisement{BleAdvertisement::Version::kV1,
BleAdvertisement::SocketVersion::kV1,
<<<<<<< HEAD
=======
ByteArray{},
>>>>>>> release
fast_data,
device_token};
@@ -101,10 +98,7 @@ TEST(BleAdvertisementTest, ConstructionFailsWithBadVersion) {
BleAdvertisement fast_ble_advertisement{bad_version,
kSocketVersion,
<<<<<<< HEAD
=======
ByteArray{},
>>>>>>> release
data,
device_token};
EXPECT_FALSE(fast_ble_advertisement.IsValid());
@@ -127,10 +121,7 @@ TEST(BleAdvertisementTest, ConstructionFailsWithBadSocketVersion) {
BleAdvertisement fast_ble_advertisement{kVersion,
bad_socket_version,
<<<<<<< HEAD
=======
ByteArray{},
>>>>>>> release
data,
device_token};
EXPECT_FALSE(fast_ble_advertisement.IsValid());
@@ -186,10 +177,7 @@ TEST(BleAdvertisementTest, ConstructionFailsWithLongData) {
BleAdvertisement fast_ble_advertisement{kVersion,
kSocketVersion,
<<<<<<< HEAD
=======
ByteArray{},
>>>>>>> release
bad_data,
device_token};
EXPECT_FALSE(fast_ble_advertisement.IsValid());
@@ -221,10 +209,7 @@ TEST(BleAdvertisementTest,
BleAdvertisement ble_advertisement{kVersion,
kSocketVersion,
<<<<<<< HEAD
=======
ByteArray{},
>>>>>>> release
fast_data,
ByteArray{}};
@@ -262,20 +247,14 @@ TEST(BleAdvertisementTest, ConstructionFailsWithWrongSizeofDeviceToken) {
BleAdvertisement fast_ble_advertisement_1{kVersion,
kSocketVersion,
<<<<<<< HEAD
=======
ByteArray{},
>>>>>>> release
data,
bad_device_token_1};
EXPECT_FALSE(fast_ble_advertisement_1.IsValid());
BleAdvertisement fast_ble_advertisement_2{kVersion,
kSocketVersion,
<<<<<<< HEAD
=======
ByteArray{},
>>>>>>> release
data,
bad_device_token_2};
EXPECT_FALSE(fast_ble_advertisement_2.IsValid());
@@ -312,10 +291,7 @@ TEST(BleAdvertisementTest,
BleAdvertisement org_ble_advertisement{kVersion,
kSocketVersion,
<<<<<<< HEAD
=======
ByteArray{},
>>>>>>> release
fast_data,
device_token};
@@ -358,10 +334,7 @@ TEST(BleAdvertisementTest,
BleAdvertisement org_ble_advertisement{kVersion,
kSocketVersion,
<<<<<<< HEAD
=======
ByteArray{},
>>>>>>> release
ByteArray(),
device_token};
ByteArray ble_advertisement_bytes{org_ble_advertisement};
@@ -416,10 +389,7 @@ TEST(BleAdvertisementTest,
BleAdvertisement org_ble_advertisement{kVersion,
kSocketVersion,
<<<<<<< HEAD
=======
ByteArray{},
>>>>>>> release
fast_data,
device_token};
ByteArray org_ble_advertisement_bytes{org_ble_advertisement};
@@ -478,10 +448,7 @@ TEST(BleAdvertisementTest,
BleAdvertisement org_ble_advertisement{kVersion,
kSocketVersion,
<<<<<<< HEAD
=======
ByteArray{},
>>>>>>> release
fast_data,
device_token};
ByteArray org_ble_advertisement_bytes{org_ble_advertisement};
@@ -533,10 +500,7 @@ TEST(BleAdvertisementTest,
BleAdvertisement org_ble_advertisement{kVersion,
kSocketVersion,
<<<<<<< HEAD
=======
ByteArray{},
>>>>>>> release
fast_data,
device_token};
ByteArray org_ble_advertisement_bytes{org_ble_advertisement};
@@ -245,13 +245,10 @@ bool ConnectionFlow::Close() {
bool ConnectionFlow::InitPeerConnection(WebRtcMedium& webrtc_medium) {
Future<bool> success_future;
<<<<<<< HEAD
=======
// CreatePeerConnection callback may be invoked after ConnectionFlow lifetime
// has ended, in case of a timeout. Future is captured by value, and is safe
// to access, but it is not safe to access ConnectionFlow member variables
// unless the Future::Set() returns true.
>>>>>>> release
webrtc_medium.CreatePeerConnection(
&peer_connection_observer_,
[this, success_future](rtc::scoped_refptr<webrtc::PeerConnectionInterface>
@@ -261,14 +258,11 @@ bool ConnectionFlow::InitPeerConnection(WebRtcMedium& webrtc_medium) {
return;
}
<<<<<<< HEAD
=======
// If this fails, means we have already assigned something to
// success_future; it is either:
// 1) this is the 2nd call of this callback (and this is a bug), or
// 2) Get(timeout) has set the future value as exception already.
if (success_future.IsSet()) return;
>>>>>>> release
peer_connection_ = peer_connection;
success_future.Set(true);
});
-7
View File
@@ -18,10 +18,7 @@
#include <utility>
#include "core/internal/message_lite.h"
<<<<<<< HEAD
=======
#include "core_v2/status.h"
>>>>>>> release
#include "proto/connections/offline_wire_formats.pb.h"
#include "platform_v2/base/byte_array.h"
@@ -89,9 +86,6 @@ ByteArray ForConnectionResponse(std::int32_t status) {
auto* v1_frame = frame.mutable_v1();
v1_frame->set_type(V1Frame::CONNECTION_RESPONSE);
auto* sub_frame = v1_frame->mutable_connection_response();
<<<<<<< HEAD
sub_frame->set_status(status);
=======
// For backward compatiblility, here still sets both status and response
// parameters until the response feature is roll out in all supported
@@ -100,7 +94,6 @@ ByteArray ForConnectionResponse(std::int32_t status) {
sub_frame->set_response(status == Status::kSuccess
? ConnectionResponseFrame::ACCEPT
: ConnectionResponseFrame::REJECT);
>>>>>>> release
return ToBytes(std::move(frame));
}
@@ -107,14 +107,10 @@ TEST(OfflineFramesTest, CanGenerateConnectionResponse) {
version: V1
v1: <
type: CONNECTION_RESPONSE
<<<<<<< HEAD
connection_response: < status: 1 >
=======
connection_response: <
status: 1
response: REJECT
>
>>>>>>> release
>)pb";
ByteArray bytes = ForConnectionResponse(1);
auto response = FromBytes(bytes);
@@ -328,16 +328,10 @@ bool P2pClusterPcpHandler::IsRecognizedBleEndpoint(
void P2pClusterPcpHandler::BlePeripheralDiscoveredHandler(
ClientProxy* client, BlePeripheral& peripheral,
<<<<<<< HEAD
const std::string& service_id, bool fast_advertisement) {
RunOnPcpHandlerThread([this, client, &peripheral, service_id,
fast_advertisement]() {
=======
const std::string& service_id, const ByteArray& advertisement_bytes,
bool fast_advertisement) {
RunOnPcpHandlerThread([this, client, &peripheral, service_id,
advertisement_bytes, fast_advertisement]() {
>>>>>>> release
// Make sure we are still discovering before proceeding.
if (!client->IsDiscovering()) {
NEARBY_LOG(INFO,
@@ -348,12 +342,7 @@ void P2pClusterPcpHandler::BlePeripheralDiscoveredHandler(
}
// Parse the BLE advertisement bytes.
<<<<<<< HEAD
BleAdvertisement advertisement(
fast_advertisement, peripheral.GetAdvertisementBytes(service_id));
=======
BleAdvertisement advertisement(fast_advertisement, advertisement_bytes);
>>>>>>> release
// Make sure the BLE advertisement points to a valid
// endpoint we're discovering.
@@ -593,12 +582,9 @@ BasePcpHandler::StartOperationResult P2pClusterPcpHandler::StartDiscoveryImpl(
.device_discovered_cb = absl::bind_front(
&P2pClusterPcpHandler::BluetoothDeviceDiscoveredHandler, this,
client, service_id),
<<<<<<< HEAD
=======
.device_name_changed_cb = absl::bind_front(
&P2pClusterPcpHandler::BluetoothDeviceDiscoveredHandler, this,
client, service_id),
>>>>>>> release
.device_lost_cb = absl::bind_front(
&P2pClusterPcpHandler::BluetoothDeviceLostHandler, this, client,
service_id),
@@ -745,17 +731,11 @@ proto::connections::Medium P2pClusterPcpHandler::StartBluetoothAdvertising(
absl::BytesToHexString(service_id_hash.data()).c_str(),
absl::BytesToHexString(local_endpoint_info.data()).c_str());
// Generate a BluetoothDeviceName with which to become Bluetooth discoverable.
<<<<<<< HEAD
std::string device_name(BluetoothDeviceName(
kBluetoothDeviceNameVersion, GetPcp(), local_endpoint_id, service_id_hash,
local_endpoint_info));
=======
// TODO(b/169550050): Implement UWBAddress.
// TODO(b/169303359): Implement WebRtcState.
std::string device_name(BluetoothDeviceName(
kBluetoothDeviceNameVersion, GetPcp(), local_endpoint_id, service_id_hash,
local_endpoint_info, ByteArray{}, WebRtcState::kUnconnectable));
>>>>>>> release
if (device_name.empty()) {
NEARBY_LOG(INFO,
"P2pClusterPcpHandler::StartBluetoothAdvertising: generate "
@@ -926,18 +906,11 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleAdvertising(
// Generate a BleAdvertisement. If a fast advertisement service UUID was
// provided, create a fast BleAdvertisement.
ByteArray advertisement_bytes;
<<<<<<< HEAD
if (fast_advertisement) {
advertisement_bytes =
ByteArray(BleAdvertisement(kBleAdvertisementVersion, GetPcp(),
local_endpoint_id, local_endpoint_info));
=======
// TODO(b/169550050): Implement UWBAddress.
if (fast_advertisement) {
advertisement_bytes = ByteArray(
BleAdvertisement(kBleAdvertisementVersion, GetPcp(), local_endpoint_id,
local_endpoint_info, ByteArray{}));
>>>>>>> release
} else {
const ByteArray service_id_hash =
GenerateHash(service_id, BleAdvertisement::kServiceIdHashLength);
@@ -946,17 +919,11 @@ proto::connections::Medium P2pClusterPcpHandler::StartBleAdvertising(
ShouldAdvertiseBluetoothMacOverBle(power_level))
bluetooth_mac_address = bluetooth_medium_.GetMacAddress();
<<<<<<< HEAD
advertisement_bytes = ByteArray(BleAdvertisement(
kBleAdvertisementVersion, GetPcp(), service_id_hash, local_endpoint_id,
local_endpoint_info, bluetooth_mac_address));
=======
// TODO(b/169303359): Implement WebRtcState.
advertisement_bytes = ByteArray(BleAdvertisement(
kBleAdvertisementVersion, GetPcp(), service_id_hash, local_endpoint_id,
local_endpoint_info, bluetooth_mac_address, ByteArray{},
WebRtcState::kUnconnectable));
>>>>>>> release
}
if (advertisement_bytes.Empty()) {
NEARBY_LOG(INFO,
@@ -1077,17 +1044,11 @@ proto::connections::Medium P2pClusterPcpHandler::StartWifiLanAdvertising(
absl::BytesToHexString(service_id_hash.data()).c_str(),
absl::BytesToHexString(local_endpoint_info.data()).c_str());
// Generate a WifiLanServiceInfo with which to become WifiLan discoverable.
<<<<<<< HEAD
std::string service_info_name(WifiLanServiceInfo(
kWifiLanServiceInfoVersion, GetPcp(), local_endpoint_id, service_id_hash,
local_endpoint_info));
=======
// TODO(b/169550050): Implement UWBAddress.
// TODO(b/169303359): Implement WebRtcState.
std::string service_info_name(WifiLanServiceInfo(
kWifiLanServiceInfoVersion, GetPcp(), local_endpoint_id, service_id_hash,
local_endpoint_info, ByteArray{}, WebRtcState::kUnconnectable));
>>>>>>> release
if (service_info_name.empty()) {
NEARBY_LOG(INFO,
"P2pClusterPcpHandler::StartWifiLanAdvertising: generate "
@@ -165,10 +165,7 @@ class P2pClusterPcpHandler : public BasePcpHandler {
void BlePeripheralDiscoveredHandler(ClientProxy* client,
BlePeripheral& peripheral,
const std::string& service_id,
<<<<<<< HEAD
=======
const ByteArray& advertisement_bytes,
>>>>>>> release
bool fast_advertisement);
void BlePeripheralLostHandler(ClientProxy* client, BlePeripheral& peripheral,
const std::string& service_id);
@@ -31,13 +31,9 @@ namespace connections {
WifiLanServiceInfo::WifiLanServiceInfo(Version version, Pcp pcp,
absl::string_view endpoint_id,
const ByteArray& service_id_hash,
<<<<<<< HEAD
const ByteArray& endpoint_info) {
=======
const ByteArray& endpoint_info,
const ByteArray& uwb_address,
WebRtcState web_rtc_state) {
>>>>>>> release
if (version != Version::kV1 || endpoint_id.empty() ||
endpoint_id.length() != kEndpointIdLength ||
service_id_hash.size() != kServiceIdHashLength) {
@@ -57,11 +53,8 @@ WifiLanServiceInfo::WifiLanServiceInfo(Version version, Pcp pcp,
service_id_hash_ = service_id_hash;
endpoint_id_ = std::string(endpoint_id);
endpoint_info_ = endpoint_info;
<<<<<<< HEAD
=======
uwb_address_ = uwb_address;
web_rtc_state_ = web_rtc_state;
>>>>>>> release
}
WifiLanServiceInfo::WifiLanServiceInfo(absl::string_view service_info_string) {
@@ -75,17 +68,6 @@ WifiLanServiceInfo::WifiLanServiceInfo(absl::string_view service_info_string) {
return;
}
<<<<<<< HEAD
if (service_info_bytes.size() > kMaxLanServiceNameLength) {
NEARBY_LOG(INFO,
"Cannot deserialize WifiLanServiceInfo: expecting max %d raw "
"bytes, got %" PRIu64,
kMaxLanServiceNameLength, service_info_bytes.size());
return;
}
=======
>>>>>>> release
if (service_info_bytes.size() < kMinLanServiceNameLength) {
NEARBY_LOG(INFO,
"Cannot deserialize WifiLanServiceInfo: expecting min %d raw "
@@ -133,8 +115,6 @@ WifiLanServiceInfo::WifiLanServiceInfo(absl::string_view service_info_string) {
// The next 3 bytes are supposed to be the service_id_hash.
service_id_hash_ = base_input_stream.ReadBytes(kServiceIdHashLength);
<<<<<<< HEAD
=======
// The next 1 byte are supposed to be the length of the UWB address.
std::uint32_t expected_uwb_address_length = base_input_stream.ReadUint8();
@@ -149,7 +129,6 @@ WifiLanServiceInfo::WifiLanServiceInfo(absl::string_view service_info_string) {
? WebRtcState::kConnectable
: WebRtcState::kUnconnectable;
>>>>>>> release
// The next 1 byte are supposed to be the length of the endpoint_info.
std::uint32_t expected_endpoint_info_length = base_input_stream.ReadUint8();
@@ -180,15 +159,12 @@ WifiLanServiceInfo::operator std::string() const {
version_and_pcp_byte |=
static_cast<char>(static_cast<uint32_t>(pcp_) & kPcpBitmask);
<<<<<<< HEAD
=======
// A byte contains WebRtcState state.
int web_rtc_connectable_flag =
(web_rtc_state_ == WebRtcState::kConnectable) ? 1 : 0;
char field_byte = static_cast<char>(web_rtc_connectable_flag) &
kWebRtcConnectableFlagBitmask;
>>>>>>> release
ByteArray usable_endpoint_info(endpoint_info_);
if (endpoint_info_.size() > kMaxEndpointInfoLength) {
NEARBY_LOG(
@@ -200,15 +176,6 @@ WifiLanServiceInfo::operator std::string() const {
usable_endpoint_info.SetData(endpoint_info_.data(), kMaxEndpointInfoLength);
}
<<<<<<< HEAD
// clang-format off
std::string out = absl::StrCat(std::string(1, version_and_pcp_byte),
endpoint_id_,
std::string(service_id_hash_),
std::string(1, usable_endpoint_info.size()),
std::string(usable_endpoint_info));
// clang-format on
=======
std::string out;
if (!uwb_address_.Empty()) {
// clang-format off
@@ -232,7 +199,6 @@ WifiLanServiceInfo::operator std::string() const {
std::string(usable_endpoint_info));
// clang-format on
}
>>>>>>> release
return Base64Utils::Encode(ByteArray{std::move(out)});
}
@@ -17,10 +17,7 @@
#include <cstdint>
<<<<<<< HEAD
=======
#include "core_v2/internal/base_pcp_handler.h"
>>>>>>> release
#include "core_v2/internal/pcp.h"
#include "platform_v2/base/byte_array.h"
#include "absl/strings/string_view.h"
@@ -46,13 +43,9 @@ class WifiLanServiceInfo {
WifiLanServiceInfo() = default;
WifiLanServiceInfo(Version version, Pcp pcp, absl::string_view endpoint_id,
const ByteArray& service_id_hash,
<<<<<<< HEAD
const ByteArray& endpoint_info);
=======
const ByteArray& endpoint_info,
const ByteArray& uwb_address,
WebRtcState web_rtc_state);
>>>>>>> release
explicit WifiLanServiceInfo(absl::string_view service_info_string);
WifiLanServiceInfo(const WifiLanServiceInfo&) = default;
WifiLanServiceInfo& operator=(const WifiLanServiceInfo&) = default;
@@ -68,18 +61,6 @@ class WifiLanServiceInfo {
std::string GetEndpointId() const { return endpoint_id_; }
ByteArray GetEndpointInfo() const { return endpoint_info_; }
ByteArray GetServiceIdHash() const { return service_id_hash_; }
<<<<<<< HEAD
private:
// The maximum length of encrypted WifiLanServiceInfo string.
static constexpr int kMaxLanServiceNameLength = 47;
// The minimum length of encrypted WifiLanServiceInfo string.
static constexpr int kMinLanServiceNameLength = 9;
// The length for endpoint id in encrypted WifiLanServiceInfo string.
static constexpr int kEndpointIdLength = 4;
// The maximum length for endpoint id in encrypted WifiLanServiceInfo string.
static constexpr int kMaxEndpointInfoLength = 131;
=======
ByteArray GetUwbAddress() const { return uwb_address_; }
WebRtcState GetWebRtcState() const { return web_rtc_state_; }
@@ -88,24 +69,10 @@ class WifiLanServiceInfo {
static constexpr int kEndpointIdLength = 4;
static constexpr int kMaxEndpointInfoLength = 131;
static constexpr int kUwbAddressLengthSize = 1;
>>>>>>> release
static constexpr int kVersionBitmask = 0x0E0;
static constexpr int kPcpBitmask = 0x01F;
static constexpr int kVersionShift = 5;
<<<<<<< HEAD
// WifiLanServiceInfo version.
Version version_ = Version::kUndefined;
// Pre-Connection Protocols version.
Pcp pcp_ = Pcp::kUnknown;
// Connected endpoint id.
std::string endpoint_id_;
// Connected hash service id.
ByteArray service_id_hash_;
// Connected endpoint info.
ByteArray endpoint_info_;
=======
static constexpr int kWebRtcConnectableFlagBitmask = 0x01;
Version version_{Version::kUndefined};
@@ -116,7 +83,6 @@ class WifiLanServiceInfo {
// TODO(b/169550050): Define UWB address field.
ByteArray uwb_address_;
WebRtcState web_rtc_state_{WebRtcState::kUndefined};
>>>>>>> release
};
} // namespace connections
@@ -31,14 +31,6 @@ constexpr Pcp kPcp = Pcp::kP2pCluster;
constexpr absl::string_view kEndPointID{"AB12"};
constexpr absl::string_view kServiceIDHashBytes{"\x0a\x0b\x0c"};
constexpr absl::string_view kEndPointName{"RAWK + ROWL!"};
<<<<<<< HEAD
TEST(WifiLanServiceInfoTest, ConstructionWorks) {
ByteArray service_id_hash{std::string(kServiceIDHashBytes)};
ByteArray endpoint_info{std::string(kEndPointName)};
WifiLanServiceInfo wifi_lan_service_info{
kVersion, kPcp, kEndPointID, service_id_hash, endpoint_info};
=======
constexpr WebRtcState kWebRtcState = WebRtcState::kConnectable;
// TODO(b/169550050): Implement UWBAddress.
@@ -52,7 +44,6 @@ TEST(WifiLanServiceInfoTest, ConstructionWorks) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_TRUE(wifi_lan_service_info.IsValid());
EXPECT_EQ(kPcp, wifi_lan_service_info.GetPcp());
@@ -65,10 +56,6 @@ TEST(WifiLanServiceInfoTest, ConstructionWorks) {
TEST(WifiLanServiceInfoTest, ConstructionFromSerializedStringWorks) {
ByteArray service_id_hash{std::string(kServiceIDHashBytes)};
ByteArray endpoint_info{std::string(kEndPointName)};
<<<<<<< HEAD
WifiLanServiceInfo org_wifi_lan_service_info{kVersion, kPcp, kEndPointID,
service_id_hash, endpoint_info};
=======
WifiLanServiceInfo org_wifi_lan_service_info{kVersion,
kPcp,
kEndPointID,
@@ -76,7 +63,6 @@ TEST(WifiLanServiceInfoTest, ConstructionFromSerializedStringWorks) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
std::string wifi_lan_service_info_string{org_wifi_lan_service_info};
WifiLanServiceInfo wifi_lan_service_info{wifi_lan_service_info_string};
@@ -87,10 +73,7 @@ TEST(WifiLanServiceInfoTest, ConstructionFromSerializedStringWorks) {
EXPECT_EQ(kEndPointID, wifi_lan_service_info.GetEndpointId());
EXPECT_EQ(service_id_hash, wifi_lan_service_info.GetServiceIdHash());
EXPECT_EQ(endpoint_info, wifi_lan_service_info.GetEndpointInfo());
<<<<<<< HEAD
=======
EXPECT_EQ(kWebRtcState, wifi_lan_service_info.GetWebRtcState());
>>>>>>> release
}
TEST(WifiLanServiceInfoTest, ConstructionFailsWithBadVersion) {
@@ -98,10 +81,6 @@ TEST(WifiLanServiceInfoTest, ConstructionFailsWithBadVersion) {
ByteArray service_id_hash{std::string(kServiceIDHashBytes)};
ByteArray endpoint_info{std::string(kEndPointName)};
<<<<<<< HEAD
WifiLanServiceInfo wifi_lan_service_info{bad_version, kPcp, kEndPointID,
service_id_hash, endpoint_info};
=======
WifiLanServiceInfo wifi_lan_service_info{bad_version,
kPcp,
kEndPointID,
@@ -109,7 +88,6 @@ TEST(WifiLanServiceInfoTest, ConstructionFailsWithBadVersion) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(wifi_lan_service_info.IsValid());
}
@@ -119,10 +97,6 @@ TEST(WifiLanServiceInfoTest, ConstructionFailsWithBadPCP) {
ByteArray service_id_hash{std::string(kServiceIDHashBytes)};
ByteArray endpoint_info{std::string(kEndPointName)};
<<<<<<< HEAD
WifiLanServiceInfo wifi_lan_service_info{kVersion, bad_pcp, kEndPointID,
service_id_hash, endpoint_info};
=======
WifiLanServiceInfo wifi_lan_service_info{kVersion,
bad_pcp,
kEndPointID,
@@ -130,7 +104,6 @@ TEST(WifiLanServiceInfoTest, ConstructionFailsWithBadPCP) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(wifi_lan_service_info.IsValid());
}
@@ -140,10 +113,6 @@ TEST(WifiLanServiceInfoTest, ConstructionFailsWithShortEndpointId) {
ByteArray service_id_hash{std::string(kServiceIDHashBytes)};
ByteArray endpoint_info{std::string(kEndPointName)};
<<<<<<< HEAD
WifiLanServiceInfo wifi_lan_service_info{kVersion, kPcp, short_endpoint_id,
service_id_hash, endpoint_info};
=======
WifiLanServiceInfo wifi_lan_service_info{kVersion,
kPcp,
short_endpoint_id,
@@ -151,7 +120,6 @@ TEST(WifiLanServiceInfoTest, ConstructionFailsWithShortEndpointId) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(wifi_lan_service_info.IsValid());
}
@@ -161,10 +129,6 @@ TEST(WifiLanServiceInfoTest, ConstructionFailsWithLongEndpointId) {
ByteArray service_id_hash{std::string(kServiceIDHashBytes)};
ByteArray endpoint_info{std::string(kEndPointName)};
<<<<<<< HEAD
WifiLanServiceInfo wifi_lan_service_info{kVersion, kPcp, long_endpoint_id,
service_id_hash, endpoint_info};
=======
WifiLanServiceInfo wifi_lan_service_info{kVersion,
kPcp,
long_endpoint_id,
@@ -172,7 +136,6 @@ TEST(WifiLanServiceInfoTest, ConstructionFailsWithLongEndpointId) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(wifi_lan_service_info.IsValid());
}
@@ -182,10 +145,6 @@ TEST(WifiLanServiceInfoTest, ConstructionFailsWithShortServiceIdHash) {
ByteArray short_service_id_hash{short_service_id_hash_bytes};
ByteArray endpoint_info{std::string(kEndPointName)};
<<<<<<< HEAD
WifiLanServiceInfo wifi_lan_service_info{
kVersion, kPcp, kEndPointID, short_service_id_hash, endpoint_info};
=======
WifiLanServiceInfo wifi_lan_service_info{kVersion,
kPcp,
kEndPointID,
@@ -193,7 +152,6 @@ TEST(WifiLanServiceInfoTest, ConstructionFailsWithShortServiceIdHash) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(wifi_lan_service_info.IsValid());
}
@@ -203,10 +161,6 @@ TEST(WifiLanServiceInfoTest, ConstructionFailsWithLongServiceIdHash) {
ByteArray long_service_id_hash{long_service_id_hash_bytes};
ByteArray endpoint_info{std::string(kEndPointName)};
<<<<<<< HEAD
WifiLanServiceInfo wifi_lan_service_info{kVersion, kPcp, kEndPointID,
long_service_id_hash, endpoint_info};
=======
WifiLanServiceInfo wifi_lan_service_info{kVersion,
kPcp,
kEndPointID,
@@ -214,7 +168,6 @@ TEST(WifiLanServiceInfoTest, ConstructionFailsWithLongServiceIdHash) {
endpoint_info,
ByteArray{},
kWebRtcState};
>>>>>>> release
EXPECT_FALSE(wifi_lan_service_info.IsValid());
}