Commit 4bf6d398 authored by Alex Chau's avatar Alex Chau Committed by Commit Bot

Upprev NearbyConnections to abc1cbf2673a38678eb7033291049590762526d7

- All code changes are caused by API changes in NearbyConnections library
- Added TODOs for unimplemented APIs

Bug: 1076008
Change-Id: I7a1cfa0d435386222f2ba00bfc503fcd706aa526
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2379713
Commit-Queue: Alex Chau <alexchau@chromium.org>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Auto-Submit: Alex Chau <alexchau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802598}
parent 1dfd75f2
......@@ -346,7 +346,7 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling nearby
# and whatever else without interference from each other.
'nearby_revision': 'ae277748ce068ef1730d5104002d4324fc4ed89e',
'nearby_revision': 'abc1cbf2673a38678eb7033291049590762526d7',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling securemessage
# and whatever else without interference from each other.
......
......@@ -24,7 +24,7 @@ ConnectionRequestInfo CreateConnectionRequestInfo(
mojo::SharedRemote<mojom::ConnectionLifecycleListener> remote(
std::move(listener));
return ConnectionRequestInfo{
.name = std::string(endpoint_info.begin(), endpoint_info.end()),
.endpoint_info = ByteArrayFromMojom(endpoint_info),
.listener = {
.initiated_cb =
[remote](const std::string& endpoint_id,
......@@ -37,7 +37,7 @@ ConnectionRequestInfo CreateConnectionRequestInfo(
mojom::ConnectionInfo::New(
info.authentication_token,
ByteArrayToMojom(info.raw_authentication_token),
ByteArrayToMojom(info.endpoint_info),
ByteArrayToMojom(info.remote_endpoint_info),
info.is_incoming_connection));
},
.accepted_cb =
......@@ -230,7 +230,7 @@ void NearbyConnections::StartDiscovery(
DiscoveryListener discovery_listener{
.endpoint_found_cb =
[remote](const std::string& endpoint_id,
const std::string& endpoint_name,
const ByteArray& endpoint_info,
const std::string& service_id) {
if (!remote) {
return;
......@@ -238,9 +238,7 @@ void NearbyConnections::StartDiscovery(
remote->OnEndpointFound(
endpoint_id, mojom::DiscoveredEndpointInfo::New(
std::vector<uint8_t>(endpoint_name.begin(),
endpoint_name.end()),
service_id));
ByteArrayToMojom(endpoint_info), service_id));
},
.endpoint_lost_cb =
[remote](const std::string& endpoint_id) {
......@@ -269,7 +267,8 @@ void NearbyConnections::RequestConnection(
core_->RequestConnection(
endpoint_id,
CreateConnectionRequestInfo(endpoint_info, std::move(listener)),
ResultCallbackFromMojom(std::move(callback)));
// TODO(alexchau): Add ConnectionsOptions to mojo.
/*options=*/{}, ResultCallbackFromMojom(std::move(callback)));
}
void NearbyConnections::DisconnectFromEndpoint(
......
......@@ -52,6 +52,9 @@ mojom::Status StatusToMojom(Status::Value status) {
return mojom::Status::kNotConnectedToEndpoint;
case Status::Value::kBluetoothError:
return mojom::Status::kBluetoothError;
// TODO(alexchau): Add kBleError to mojo.
case Status::Value::kBleError:
return mojom::Status::kError;
case Status::Value::kWifiLanError:
return mojom::Status::kWifiLanError;
case Status::Value::kPayloadUnknown:
......
......@@ -12,36 +12,36 @@ BleMedium::BleMedium() = default;
BleMedium::~BleMedium() = default;
bool BleMedium::StartAdvertising(absl::string_view service_id,
bool BleMedium::StartAdvertising(const std::string& service_id,
const ByteArray& advertisement) {
// TODO(b/154845685): Implement this method.
NOTIMPLEMENTED();
return false;
}
void BleMedium::StopAdvertising(absl::string_view service_id) {
bool BleMedium::StopAdvertising(const std::string& service_id) {
// TODO(b/154845685): Implement this method.
NOTIMPLEMENTED();
return false;
}
bool BleMedium::StartScanning(
absl::string_view service_id,
const api::BleMedium::DiscoveredPeripheralCallback&
discovered_peripheral_callback) {
bool BleMedium::StartScanning(const std::string& service_id,
api::BleMedium::DiscoveredPeripheralCallback
discovered_peripheral_callback) {
// TODO(b/154848193): Implement this method.
NOTIMPLEMENTED();
return true;
}
void BleMedium::StopScanning(absl::string_view service_id) {
bool BleMedium::StopScanning(const std::string& service_id) {
// TODO(b/154848193): Implement this method.
NOTIMPLEMENTED();
return false;
}
bool BleMedium::StartAcceptingConnections(
absl::string_view service_id,
const api::BleMedium::AcceptedConnectionCallback&
accepted_connection_callback) {
const std::string& service_id,
api::BleMedium::AcceptedConnectionCallback accepted_connection_callback) {
// Do not actually start a GATT server, because BLE connections are not yet
// supported in Chrome Nearby. However, return true in order to allow
// BLE advertising to continue.
......@@ -50,13 +50,14 @@ bool BleMedium::StartAcceptingConnections(
return true;
}
void BleMedium::StopAcceptingConnections(const std::string& service_id) {
bool BleMedium::StopAcceptingConnections(const std::string& service_id) {
// Do nothing. BLE connections are not yet supported in Chrome Nearby.
return false;
}
std::unique_ptr<api::BleSocket> BleMedium::Connect(
api::BlePeripheral* ble_peripheral,
absl::string_view service_id) {
api::BlePeripheral& ble_peripheral,
const std::string& service_id) {
// Do nothing. BLE connections are not yet supported in Chrome Nearby.
return nullptr;
}
......
......@@ -24,20 +24,20 @@ class BleMedium : public api::BleMedium {
BleMedium& operator=(const BleMedium&) = delete;
// api::BleMedium:
bool StartAdvertising(absl::string_view service_id,
bool StartAdvertising(const std::string& service_id,
const ByteArray& advertisement) override;
void StopAdvertising(absl::string_view service_id) override;
bool StartScanning(absl::string_view service_id,
const DiscoveredPeripheralCallback&
discovered_peripheral_callback) override;
void StopScanning(absl::string_view service_id) override;
bool StopAdvertising(const std::string& service_id) override;
bool StartScanning(
const std::string& service_id,
DiscoveredPeripheralCallback discovered_peripheral_callback) override;
bool StopScanning(const std::string& service_id) override;
bool StartAcceptingConnections(
absl::string_view service_id,
const AcceptedConnectionCallback& accepted_connection_callback) override;
void StopAcceptingConnections(const std::string& service_id) override;
const std::string& service_id,
AcceptedConnectionCallback accepted_connection_callback) override;
bool StopAcceptingConnections(const std::string& service_id) override;
std::unique_ptr<api::BleSocket> Connect(
api::BlePeripheral* ble_peripheral,
absl::string_view service_id) override;
api::BlePeripheral& ble_peripheral,
const std::string& service_id) override;
};
} // namespace chrome
......
......@@ -19,16 +19,6 @@ namespace {
const char kServiceName[] = "NearbySharing";
class FakeAcceptedConnectionCallback
: public BleMedium::AcceptedConnectionCallback {
public:
~FakeAcceptedConnectionCallback() override = default;
// BleMedium::AcceptedConnectionCallback:
void OnConnectionAccepted(std::unique_ptr<api::BleSocket> socket,
absl::string_view service_id) override {}
};
} // namespace
class BleMediumTest : public testing::Test {
......@@ -42,7 +32,6 @@ class BleMediumTest : public testing::Test {
protected:
std::unique_ptr<BleMedium> ble_medium_;
FakeAcceptedConnectionCallback fake_accepted_connection_callback_;
base::test::TaskEnvironment task_environment_;
};
......@@ -57,8 +46,8 @@ TEST_F(BleMediumTest, TestScanning) {
TEST_F(BleMediumTest, TestStartAcceptingConnections) {
// StartAcceptingConnections() should do nothing but still return true.
EXPECT_TRUE(ble_medium_->StartAcceptingConnections(
kServiceName, fake_accepted_connection_callback_));
EXPECT_TRUE(
ble_medium_->StartAcceptingConnections(kServiceName, /*callback=*/{}));
}
TEST_F(BleMediumTest, TestConnect) {
......@@ -66,7 +55,7 @@ TEST_F(BleMediumTest, TestConnect) {
BlePeripheral ble_peripheral(bluetooth_device);
// Connect() should do nothing and not return a valid api::BleSocket.
EXPECT_FALSE(ble_medium_->Connect(&ble_peripheral, kServiceName));
EXPECT_FALSE(ble_medium_->Connect(ble_peripheral, kServiceName));
}
} // namespace chrome
......
......@@ -8,13 +8,19 @@ namespace location {
namespace nearby {
namespace chrome {
BlePeripheral::BlePeripheral(api::BluetoothDevice& bluetooth_device)
: bluetooth_device_(bluetooth_device) {}
BlePeripheral::BlePeripheral(api::BluetoothDevice& bluetooth_device) {}
BlePeripheral::~BlePeripheral() = default;
api::BluetoothDevice& BlePeripheral::GetBluetoothDevice() {
return bluetooth_device_;
std::string BlePeripheral::GetName() const {
// TODO(hansberry): Implement.
return std::string();
}
ByteArray BlePeripheral::GetAdvertisementBytes(
const std::string& service_id) const {
// TODO(hansberry): Implement.
return ByteArray();
}
} // namespace chrome
......
......@@ -21,10 +21,8 @@ class BlePeripheral : public api::BlePeripheral {
BlePeripheral& operator=(const BlePeripheral&) = delete;
// api::BlePeripheral:
api::BluetoothDevice& GetBluetoothDevice() override;
private:
api::BluetoothDevice& bluetooth_device_;
std::string GetName() const override;
ByteArray GetAdvertisementBytes(const std::string& service_id) const override;
};
} // namespace chrome
......
......@@ -64,6 +64,11 @@ bool BluetoothAdapter::SetName(absl::string_view name) {
return call_success && set_name_success;
}
std::string BluetoothAdapter::GetMacAddress() const {
// TODO(hansberry): Implement.
return std::string();
}
} // namespace chrome
} // namespace nearby
} // namespace location
......@@ -32,6 +32,7 @@ class BluetoothAdapter : public api::BluetoothAdapter {
bool SetScanMode(ScanMode scan_mode) override;
std::string GetName() const override;
bool SetName(absl::string_view name) override;
std::string GetMacAddress() const override;
private:
// This reference is owned by the top-level Nearby Connections interface and
......
......@@ -111,6 +111,12 @@ BluetoothClassicMedium::ListenForService(const std::string& service_name,
return nullptr;
}
BluetoothDevice* BluetoothClassicMedium::FindRemoteDevice(
const std::string& mac_address) {
// TODO(hansberry): Implement.
return nullptr;
}
void BluetoothClassicMedium::PresentChanged(bool present) {
// TODO(hansberry): It is unclear to me how the API implementation can signal
// to Core that |present| has become unexpectedly false. Need to ask
......
......@@ -41,6 +41,7 @@ class BluetoothClassicMedium : public api::BluetoothClassicMedium,
std::unique_ptr<api::BluetoothServerSocket> ListenForService(
const std::string& service_name,
const std::string& service_uuid) override;
BluetoothDevice* FindRemoteDevice(const std::string& mac_address) override;
private:
// bluetooth::mojom::AdapterObserver:
......
......@@ -17,6 +17,11 @@ std::string BluetoothDevice::GetName() const {
return device_info_->name_for_display;
}
std::string BluetoothDevice::GetMacAddress() const {
// TODO(hansberry): Implement.
return std::string();
}
std::string BluetoothDevice::GetAddress() const {
return device_info_->address;
}
......
......@@ -25,6 +25,7 @@ class BluetoothDevice : public api::BluetoothDevice {
// api::BluetoothDevice:
std::string GetName() const override;
std::string GetMacAddress() const override;
std::string GetAddress() const;
void UpdateDeviceInfo(bluetooth::mojom::DeviceInfoPtr device_info);
......
......@@ -119,10 +119,12 @@ source_set("platform_v2_base") {
public_configs = [ ":nearby_include_config" ]
sources = [
"src/cpp/platform_v2/base/base64_utils.cc",
"src/cpp/platform_v2/base/bluetooth_utils.cc",
"src/cpp/platform_v2/base/prng.cc",
]
public = [
"src/cpp/platform_v2/base/base64_utils.h",
"src/cpp/platform_v2/base/bluetooth_utils.h",
"src/cpp/platform_v2/base/byte_array.h",
"src/cpp/platform_v2/base/callable.h",
"src/cpp/platform_v2/base/exception.h",
......@@ -213,10 +215,12 @@ source_set("platform_v2_public_types") {
source_set("platform_v2_public_comm") {
public_configs = [ ":nearby_include_config" ]
sources = [
"src/cpp/platform_v2/public/ble.cc",
"src/cpp/platform_v2/public/bluetooth_classic.cc",
"src/cpp/platform_v2/public/wifi_lan.cc",
]
public = [
"src/cpp/platform_v2/public/ble.h",
"src/cpp/platform_v2/public/bluetooth_adapter.h",
"src/cpp/platform_v2/public/bluetooth_classic.h",
"src/cpp/platform_v2/public/webrtc.h",
......@@ -250,6 +254,7 @@ source_set("core") {
sources = [ "src/cpp/core_v2/core.cc" ]
public = [ "src/cpp/core_v2/core.h" ]
public_deps = [
":connections_enums_proto",
":core_v2_internal",
":core_v2_types",
":platform_v2_public_comm",
......@@ -273,6 +278,7 @@ source_set("core_v2_types") {
"src/cpp/core_v2/strategy.h",
]
public_deps = [
":connections_enums_proto",
":platform_v2_base",
":platform_v2_public_comm",
":platform_v2_public_logging",
......@@ -291,6 +297,7 @@ source_set("core_v2_internal") {
"src/cpp/core_v2/internal/base_endpoint_channel.cc",
"src/cpp/core_v2/internal/base_pcp_handler.cc",
"src/cpp/core_v2/internal/ble_advertisement.cc",
"src/cpp/core_v2/internal/ble_endpoint_channel.cc",
"src/cpp/core_v2/internal/bluetooth_device_name.cc",
"src/cpp/core_v2/internal/bluetooth_endpoint_channel.cc",
"src/cpp/core_v2/internal/client_proxy.cc",
......@@ -316,6 +323,7 @@ source_set("core_v2_internal") {
"src/cpp/core_v2/internal/base_endpoint_channel.h",
"src/cpp/core_v2/internal/base_pcp_handler.h",
"src/cpp/core_v2/internal/ble_advertisement.h",
"src/cpp/core_v2/internal/ble_endpoint_channel.h",
"src/cpp/core_v2/internal/bluetooth_device_name.h",
"src/cpp/core_v2/internal/bluetooth_endpoint_channel.h",
"src/cpp/core_v2/internal/client_proxy.h",
......@@ -374,6 +382,7 @@ source_set("core_v2_internal_mediums") {
public_configs = [ ":nearby_include_config" ]
sources = [
"src/cpp/core_v2/internal/mediums/advertisement_read_result.cc",
"src/cpp/core_v2/internal/mediums/ble.cc",
"src/cpp/core_v2/internal/mediums/ble_advertisement.cc",
"src/cpp/core_v2/internal/mediums/ble_advertisement_header.cc",
"src/cpp/core_v2/internal/mediums/ble_packet.cc",
......@@ -387,6 +396,7 @@ source_set("core_v2_internal_mediums") {
]
public = [
"src/cpp/core_v2/internal/mediums/advertisement_read_result.h",
"src/cpp/core_v2/internal/mediums/ble.h",
"src/cpp/core_v2/internal/mediums/ble_advertisement.h",
"src/cpp/core_v2/internal/mediums/ble_advertisement_header.h",
"src/cpp/core_v2/internal/mediums/ble_packet.h",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment